mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:23:03 +00:00
[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. ;-) svn path=/trunk/; revision=64394
This commit is contained in:
parent
40cf5d521c
commit
ea57e45a4b
4 changed files with 104 additions and 2 deletions
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS api tests
|
* PROJECT: ReactOS api tests
|
||||||
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||||
* PURPOSE: Test for CreateService
|
* PURPOSE: Test for the HKEY_CLASSES_ROOT key
|
||||||
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
* PROGRAMMER: Jérôme Gardou <jerome.gardou@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <apitest.h>
|
#include <apitest.h>
|
||||||
|
|
|
@ -10,6 +10,7 @@ list(APPEND SOURCE
|
||||||
NtMapViewOfSection.c
|
NtMapViewOfSection.c
|
||||||
NtMutant.c
|
NtMutant.c
|
||||||
NtProtectVirtualMemory.c
|
NtProtectVirtualMemory.c
|
||||||
|
NtQueryKey.c
|
||||||
NtQuerySystemEnvironmentValue.c
|
NtQuerySystemEnvironmentValue.c
|
||||||
NtQueryVolumeInformationFile.c
|
NtQueryVolumeInformationFile.c
|
||||||
NtSaveKey.c
|
NtSaveKey.c
|
||||||
|
|
99
rostests/apitests/ntdll/NtQueryKey.c
Normal file
99
rostests/apitests/ntdll/NtQueryKey.c
Normal file
|
@ -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();
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ extern void func_NtFreeVirtualMemory(void);
|
||||||
extern void func_NtMapViewOfSection(void);
|
extern void func_NtMapViewOfSection(void);
|
||||||
extern void func_NtMutant(void);
|
extern void func_NtMutant(void);
|
||||||
extern void func_NtProtectVirtualMemory(void);
|
extern void func_NtProtectVirtualMemory(void);
|
||||||
|
extern void func_NtQueryKey(void);
|
||||||
extern void func_NtQuerySystemEnvironmentValue(void);
|
extern void func_NtQuerySystemEnvironmentValue(void);
|
||||||
extern void func_NtQueryVolumeInformationFile(void);
|
extern void func_NtQueryVolumeInformationFile(void);
|
||||||
extern void func_NtSaveKey(void);
|
extern void func_NtSaveKey(void);
|
||||||
|
@ -44,6 +45,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "NtMapViewOfSection", func_NtMapViewOfSection },
|
{ "NtMapViewOfSection", func_NtMapViewOfSection },
|
||||||
{ "NtMutant", func_NtMutant },
|
{ "NtMutant", func_NtMutant },
|
||||||
{ "NtProtectVirtualMemory", func_NtProtectVirtualMemory },
|
{ "NtProtectVirtualMemory", func_NtProtectVirtualMemory },
|
||||||
|
{ "NtQueryKey", func_NtQueryKey },
|
||||||
{ "NtQuerySystemEnvironmentValue", func_NtQuerySystemEnvironmentValue },
|
{ "NtQuerySystemEnvironmentValue", func_NtQuerySystemEnvironmentValue },
|
||||||
{ "NtQueryVolumeInformationFile", func_NtQueryVolumeInformationFile },
|
{ "NtQueryVolumeInformationFile", func_NtQueryVolumeInformationFile },
|
||||||
{ "NtSaveKey", func_NtSaveKey},
|
{ "NtSaveKey", func_NtSaveKey},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue