Author: jgardou Date: Mon Sep 29 16:21:53 2014 New Revision: 64394
URL: http://svn.reactos.org/svn/reactos?rev=64394&view=rev Log: [NTDLL_APITEST] - Add tests for NtQueryKey(KeyNameInformation) [ADVAPI32_APITEST] - Don't be so generous and claim back my code. @Thomas: If you ever find out how buggy it is, feel free to claim it back. ;-)
Added: trunk/rostests/apitests/ntdll/NtQueryKey.c (with props) Modified: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/testlist.c
Modified: trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/HKEY_CLA... ============================================================================== --- trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/HKEY_CLASSES_ROOT.c [iso-8859-1] Mon Sep 29 16:21:53 2014 @@ -1,8 +1,8 @@ /* * PROJECT: ReactOS api tests * LICENSE: GPLv2+ - See COPYING in the top level directory - * PURPOSE: Test for CreateService - * PROGRAMMER: Thomas Faber thomas.faber@reactos.org + * PURPOSE: Test for the HKEY_CLASSES_ROOT key + * PROGRAMMER: Jérôme Gardou jerome.gardou@reactos.org */
#include <apitest.h>
Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists.... ============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Mon Sep 29 16:21:53 2014 @@ -10,6 +10,7 @@ NtMapViewOfSection.c NtMutant.c NtProtectVirtualMemory.c + NtQueryKey.c NtQuerySystemEnvironmentValue.c NtQueryVolumeInformationFile.c NtSaveKey.c
Added: trunk/rostests/apitests/ntdll/NtQueryKey.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtQueryKey.... ============================================================================== --- trunk/rostests/apitests/ntdll/NtQueryKey.c (added) +++ trunk/rostests/apitests/ntdll/NtQueryKey.c [iso-8859-1] Mon Sep 29 16:21:53 2014 @@ -0,0 +1,99 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Tests for the NtQueryKey API + * PROGRAMMER: Jérôme Gardou jerome.gardou@reactos.org + */ + +#include <apitest.h> + +#define WIN32_NO_STATUS +#include <ndk/rtlfuncs.h> +#include <ndk/cmfuncs.h> +#include <ndk/cmtypes.h> +#include <ndk/obfuncs.h> + +static +void +Test_KeyNameInformation(void) +{ + UNICODE_STRING HKLM_Name = RTL_CONSTANT_STRING(L"\Registry\Machine"); + UNICODE_STRING HKLM_Software_Name = RTL_CONSTANT_STRING(L"\Registry\Machine\Software"); + UNICODE_STRING Software_Name = RTL_CONSTANT_STRING(L"Software"); + UNICODE_STRING InfoName; + HANDLE HKLM_Key, HKLM_Software_Key; + PKEY_NAME_INFORMATION NameInformation; + ULONG InfoLength; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status; + + /* Open the HKCU key */ + InitializeObjectAttributes(&ObjectAttributes, + &HKLM_Name, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenKey(&HKLM_Key, KEY_READ, &ObjectAttributes); + ok_ntstatus(Status, STATUS_SUCCESS); + + /* Get the name info length */ + InfoLength = 0; + Status = NtQueryKey(HKLM_Key, KeyNameInformation, NULL, 0, &InfoLength); + ok_ntstatus(Status, STATUS_BUFFER_TOO_SMALL); + ok_size_t(InfoLength, FIELD_OFFSET(KEY_NAME_INFORMATION, Name[HKLM_Name.Length/sizeof(WCHAR)])); + + /* Get it for real */ + NameInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, InfoLength); + ok(NameInformation != NULL, "\n"); + + Status = NtQueryKey(HKLM_Key, KeyNameInformation, NameInformation, InfoLength, &InfoLength); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_size_t(InfoLength, FIELD_OFFSET(KEY_NAME_INFORMATION, Name[HKLM_Name.Length/sizeof(WCHAR)])); + ok_size_t(NameInformation->NameLength, HKLM_Name.Length); + + RtlInitUnicodeString(&InfoName, NameInformation->Name); + InfoName.Length = NameInformation->NameLength; + ok(RtlCompareUnicodeString(&InfoName, &HKLM_Name, TRUE) == 0, "%.*S\n", + InfoName.Length, InfoName.Buffer); + + RtlFreeHeap(RtlGetProcessHeap(), 0, NameInformation); + + /* Open one subkey */ + InitializeObjectAttributes(&ObjectAttributes, + &Software_Name, + OBJ_CASE_INSENSITIVE, + HKLM_Key, + NULL); + Status = NtOpenKey(&HKLM_Software_Key, KEY_READ, &ObjectAttributes); + ok_ntstatus(Status, STATUS_SUCCESS); + + /* Get the name info length */ + InfoLength = 0; + Status = NtQueryKey(HKLM_Software_Key, KeyNameInformation, NULL, 0, &InfoLength); + ok_ntstatus(Status, STATUS_BUFFER_TOO_SMALL); + ok_size_t(InfoLength, FIELD_OFFSET(KEY_NAME_INFORMATION, Name[HKLM_Software_Name.Length/sizeof(WCHAR)])); + + /* Get it for real */ + NameInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, InfoLength); + ok(NameInformation != NULL, "\n"); + + Status = NtQueryKey(HKLM_Software_Key, KeyNameInformation, NameInformation, InfoLength, &InfoLength); + ok_ntstatus(Status, STATUS_SUCCESS); + ok_size_t(InfoLength, FIELD_OFFSET(KEY_NAME_INFORMATION, Name[HKLM_Software_Name.Length/sizeof(WCHAR)])); + ok_size_t(NameInformation->NameLength, HKLM_Software_Name.Length); + + RtlInitUnicodeString(&InfoName, NameInformation->Name); + InfoName.Length = NameInformation->NameLength; + ok(RtlCompareUnicodeString(&InfoName, &HKLM_Software_Name, TRUE) == 0, "%.*S\n", + InfoName.Length, InfoName.Buffer); + + RtlFreeHeap(RtlGetProcessHeap(), 0, NameInformation); + + NtClose(HKLM_Software_Key); + NtClose(HKLM_Key); +} + +START_TEST(NtQueryKey) +{ + Test_KeyNameInformation(); +}
Propchange: trunk/rostests/apitests/ntdll/NtQueryKey.c ------------------------------------------------------------------------------ charset = UTF-8
Propchange: trunk/rostests/apitests/ntdll/NtQueryKey.c ------------------------------------------------------------------------------ svn:eol-style = native
Propchange: trunk/rostests/apitests/ntdll/NtQueryKey.c ------------------------------------------------------------------------------ svn:mime-type = text/plain
Modified: trunk/rostests/apitests/ntdll/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c?... ============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Mon Sep 29 16:21:53 2014 @@ -13,6 +13,7 @@ extern void func_NtMapViewOfSection(void); extern void func_NtMutant(void); extern void func_NtProtectVirtualMemory(void); +extern void func_NtQueryKey(void); extern void func_NtQuerySystemEnvironmentValue(void); extern void func_NtQueryVolumeInformationFile(void); extern void func_NtSaveKey(void); @@ -44,6 +45,7 @@ { "NtMapViewOfSection", func_NtMapViewOfSection }, { "NtMutant", func_NtMutant }, { "NtProtectVirtualMemory", func_NtProtectVirtualMemory }, + { "NtQueryKey", func_NtQueryKey }, { "NtQuerySystemEnvironmentValue", func_NtQuerySystemEnvironmentValue }, { "NtQueryVolumeInformationFile", func_NtQueryVolumeInformationFile }, { "NtSaveKey", func_NtSaveKey},