ReactOS 0.4.15-dev-8119-g4fb2fdb
NtQueryOpenSubKeys.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Tests for the NtQueryOpenSubKeys API
5 * COPYRIGHT: Copyright 2023 George Bișoc <george.bisoc@reactos.org>
6 */
7
8#include "precomp.h"
9
11{
14 ULONG Subkeys;
15 UNICODE_STRING RegistryKey = RTL_CONSTANT_STRING(L"\\Registry");
16 UNICODE_STRING SystemKey = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM");
17 UNICODE_STRING SoftwareKey = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SOFTWARE");
18 UNICODE_STRING DefaultUserKey = RTL_CONSTANT_STRING(L"\\Registry\\User\\.DEFAULT");
19
20 /* We give no object attributes and no return variable */
23
24 /* Build a key path to the main registry tree */
26 &RegistryKey,
28 NULL,
29 NULL);
30
31 /* We give object attributes but no return variable */
34
35 /*
36 * We give no object attributes but return variable.
37 *
38 * NOTE: Windows 10 and Server 2003 return different kinds of status
39 * codes. In Server 2003 it returns STATUS_ACCESS_VIOLATION because
40 * this function implements more probe checks against the object
41 * attributes parameter (namely the path name of the object) so it
42 * fails earlier. In Windows 10 instead the function only probes the
43 * memory address of the object attributes so that it resides in the boundary
44 * of the UM memory range so the function lets this NULL parameter
45 * slide through until ObOpenObjectByName hits this parameter as being
46 * NULL and returns STATUS_INVALID_PARAMETER. Currently ReactOS follows
47 * the behavior of Windows 10.
48 */
49 Status = NtQueryOpenSubKeys(NULL, &Subkeys);
51 "STATUS_ACCESS_VIOLATION or STATUS_INVALID_PARAMETER expected, got 0x%lx\n", Status);
52
53 /* Garbage return variable, this function doesn't check for alignment */
56
57 /* Return the open subkeys of this key now */
60
61 trace("\\Registry has %lu opened subkeys\n", Subkeys);
62
63 /* Build a key path to the SYSTEM key */
65 &SystemKey,
67 NULL,
68 NULL);
69
70 /* Return the open subkeys of this key now */
73
74 trace("\\Registry\\Machine\\SYSTEM has %lu opened subkeys\n", Subkeys);
75
76 /* Build a key path to the SYSTEM key */
78 &SoftwareKey,
80 NULL,
81 NULL);
82
83 /* Return the open subkeys of this key now */
86
87 trace("\\Registry\\Machine\\SOFTWARE has %lu opened subkeys\n", Subkeys);
88
89 /* Build a key path to the default user key */
91 &DefaultUserKey,
93 NULL,
94 NULL);
95
96 /* Return the open subkeys of this key now */
99
100 trace("\\Registry\\User\\.DEFAULT has %lu opened subkeys\n", Subkeys);
101}
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSTATUS NTAPI NtQueryOpenSubKeys(IN POBJECT_ATTRIBUTES TargetKey, OUT PULONG HandleCount)
Definition: ntapi.c:1489
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135