ReactOS 0.4.15-dev-7924-g5949c20
NtQueryValueKey.c File Reference
#include "precomp.h"
#include <winreg.h>
Include dependency graph for NtQueryValueKey.c:

Go to the source code of this file.

Functions

 START_TEST (NtQueryValueKey)
 

Function Documentation

◆ START_TEST()

START_TEST ( NtQueryValueKey  )

Definition at line 11 of file NtQueryValueKey.c.

12{
15 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
20 ULONG InfoLength;
22 const WCHAR *StringData;
23 ULONG StringLength;
24
26 &KeyName,
28 NULL,
29 NULL);
33 if (!NT_SUCCESS(Status))
34 {
35 skip("Test key unavailable\n");
36 return;
37 }
38
39 /* Specify zero-size buffer, get the length */
40 ResultLength = 0x55555555;
42 &ValueName,
44 NULL,
45 0,
49 "Invalid result length %lu\n", ResultLength);
51 {
52 skip("Result length %lu too small\n", ResultLength);
53 goto Exit;
54 }
55 InfoLength = ResultLength;
56 Info = RtlAllocateHeap(RtlGetProcessHeap(),
57 0,
58 InfoLength + 4);
59 if (Info == NULL)
60 {
61 skip("Could not alloc %lu bytes\n", InfoLength);
62 goto Exit;
63 }
64
65 /* Successful call */
67 &ValueName,
69 Info,
70 InfoLength,
73 ok_int(ResultLength, InfoLength);
74
75 ok_int(Info->Type, REG_SZ);
76 StringLength = InfoLength - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, Data);
77 ok_int(Info->DataLength, StringLength);
78
79 StringData = (PWCHAR)Info->Data;
80 ok(Info->DataLength >= 5 * sizeof(WCHAR), "DataLength %lu is too small for path\n", Info->DataLength);
81 if (Info->DataLength >= 5 * sizeof(WCHAR))
82 {
83 trace("SystemRoot: %.*ls\n", (int)(Info->DataLength / sizeof(WCHAR) - 1), StringData);
84 ok(StringData[0] >= 'A' && StringData[0] <= 'Z', "Data[0] = %x\n", StringData[0]);
85 ok(StringData[1] == ':', "Data[1] = %x\n", StringData[1]);
86 ok(StringData[2] == '\\', "Data[2] = %x\n", StringData[2]);
87 ok(iswalnum(StringData[3]), "Data[3] = %x\n", StringData[3]);
88 ok(StringData[Info->DataLength / sizeof(WCHAR) - 1] == UNICODE_NULL,
89 "Data[%lu] = %x\n", Info->DataLength / sizeof(WCHAR) - 1, StringData[Info->DataLength / sizeof(WCHAR) - 1]);
90 }
91
92 /* If the buffer isn't 64 bit aligned, the data won't be, either */
93 InfoUnaligned = (PVOID)((PUCHAR)Info + 4);
95 &ValueName,
97 InfoUnaligned,
98 InfoLength,
101 ok_int(ResultLength, InfoLength);
102 ok_int(InfoUnaligned->Type, REG_SZ);
103 StringData = (PWCHAR)InfoUnaligned->Data;
104 ok(InfoUnaligned->DataLength >= 2 * sizeof(WCHAR), "DataLength %lu is too small for path\n", InfoUnaligned->DataLength);
105 if (InfoUnaligned->DataLength >= 2 * sizeof(WCHAR))
106 {
107 ok(StringData[1] == ':', "Data[1] = %x\n", StringData[1]);
108 }
109
110 RtlFreeHeap(RtlGetProcessHeap(), 0, Info);
111
112Exit:
115}
#define ok_hex(expression, result)
Definition: atltest.h:94
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define ok_int(expression, result)
Definition: atltest.h:134
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define iswalnum(_c)
Definition: ctype.h:671
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define REG_SZ
Definition: layer.c:22
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
@ KeyValuePartialInformationAlign64
Definition: reg.c:103
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
static void Exit(void)
Definition: sock.c:1330
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
void * PVOID
Definition: typedefs.h:50
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
__wchar_t WCHAR
Definition: xmlstorage.h:180