ReactOS 0.4.15-dev-8339-g4028de8
NtCreateKey.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for NtCreateKey
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include "precomp.h"
9
10static
11VOID
14 _In_ ACCESS_MASK ExpectedAccess,
17{
21
24 &BasicInfo,
25 sizeof(BasicInfo),
26 &Length);
27 ok_(File, Line)(Status == STATUS_SUCCESS, "NtQueryObject returned 0x%lx\n", Status);
28 ok_(File, Line)(BasicInfo.GrantedAccess == ExpectedAccess,
29 "GrantedAccess is 0x%lx, expected 0x%lx\n",
30 BasicInfo.GrantedAccess, ExpectedAccess);
31}
32#define VerifyAccess(h, e) VerifyAccess_(h, e, __FILE__, __LINE__)
33
34static
35VOID
38 _In_ ACCESS_MASK ExpectedAccess,
39 _In_ NTSTATUS ExpectedStatus,
42{
45 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software");
47
49 &KeyName,
51 NULL,
52 NULL);
56 0,
57 NULL,
59 NULL);
60 ok_(File, Line)(Status == ExpectedStatus,
61 "NtCreateKey returned 0x%lx, expected 0x%lx\n",
62 Status, ExpectedStatus);
63 if (NT_SUCCESS(Status))
64 {
65 VerifyAccess_(KeyHandle, ExpectedAccess, File, Line);
68 "NtClose from NtCreateKey returned 0x%lx\n",
69 Status);
70 }
71 else if (NT_SUCCESS(ExpectedStatus))
72 {
73 skip_(File, Line)("NtCreateKey failed, skipping\n");
74 }
75
79 ok_(File, Line)(Status == ExpectedStatus,
80 "NtOpenKey returned 0x%lx, expected 0x%lx\n",
81 Status, ExpectedStatus);
82 if (NT_SUCCESS(Status))
83 {
84 VerifyAccess_(KeyHandle, ExpectedAccess, File, Line);
87 "NtClose from NtOpenKey returned 0x%lx\n",
88 Status);
89 }
90 else if (NT_SUCCESS(ExpectedStatus))
91 {
92 skip_(File, Line)("NtOpenKey failed, skipping\n");
93 }
94}
95#define TestCreateOpen(d, ea, es) TestCreateOpen_(d, ea, es, __FILE__, __LINE__)
96
98{
102 TestCreateOpen(KEY_WOW64_32KEY | KEY_WOW64_64KEY, 0, STATUS_ACCESS_DENIED); // STATUS_INVALID_PARAMETER on Win7
107}
@ ObjectBasicInformation
Definition: DriverTester.h:54
NTSTATUS NtQueryObject(IN HANDLE Handle, IN OBJECT_INFO_CLASS ObjectInformationClass, OUT PVOID ObjectInformation, IN ULONG ObjectInformationLength, OUT PULONG ReturnLength)
#define TestCreateOpen(d, ea, es)
Definition: NtCreateKey.c:95
static VOID VerifyAccess_(_In_ HANDLE Handle, _In_ ACCESS_MASK ExpectedAccess, _In_ PCSTR File, _In_ INT Line)
Definition: NtCreateKey.c:12
static VOID TestCreateOpen_(_In_ ACCESS_MASK DesiredAccess, _In_ ACCESS_MASK ExpectedAccess, _In_ NTSTATUS ExpectedStatus, _In_ PCSTR File, _In_ INT Line)
Definition: NtCreateKey.c:36
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
LONG NTSTATUS
Definition: precomp.h:26
Definition: File.h:16
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define skip_(test, file, line,...)
Definition: kmt_test.h:224
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define _In_
Definition: ms_sal.h:308
_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
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define READ_CONTROL
Definition: nt_native.h:58
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ncftp.h:79
ACCESS_MASK GrantedAccess
Definition: winternl.h:1251
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46