ReactOS  0.4.15-dev-3173-g40ee59d
NtCreateKey.c File Reference
#include "precomp.h"
Include dependency graph for NtCreateKey.c:

Go to the source code of this file.

Macros

#define VerifyAccess(h, e)   VerifyAccess_(h, e, __FILE__, __LINE__)
 
#define TestCreateOpen(d, ea, es)   TestCreateOpen_(d, ea, es, __FILE__, __LINE__)
 

Functions

static VOID VerifyAccess_ (_In_ HANDLE Handle, _In_ ACCESS_MASK ExpectedAccess, _In_ PCSTR File, _In_ INT Line)
 
static VOID TestCreateOpen_ (_In_ ACCESS_MASK DesiredAccess, _In_ ACCESS_MASK ExpectedAccess, _In_ NTSTATUS ExpectedStatus, _In_ PCSTR File, _In_ INT Line)
 
 START_TEST (NtCreateKey)
 

Macro Definition Documentation

◆ TestCreateOpen

#define TestCreateOpen (   d,
  ea,
  es 
)    TestCreateOpen_(d, ea, es, __FILE__, __LINE__)

Definition at line 95 of file NtCreateKey.c.

◆ VerifyAccess

#define VerifyAccess (   h,
  e 
)    VerifyAccess_(h, e, __FILE__, __LINE__)

Definition at line 32 of file NtCreateKey.c.

Function Documentation

◆ START_TEST()

START_TEST ( NtCreateKey  )

Definition at line 97 of file NtCreateKey.c.

98 {
102  TestCreateOpen(KEY_WOW64_32KEY | KEY_WOW64_64KEY, 0, STATUS_ACCESS_DENIED); // STATUS_INVALID_PARAMETER on Win7
106  TestCreateOpen(READ_CONTROL | KEY_WOW64_32KEY | KEY_WOW64_64KEY, READ_CONTROL, STATUS_SUCCESS); // STATUS_INVALID_PARAMETER on Win7
107 }
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
#define TestCreateOpen(d, ea, es)
Definition: NtCreateKey.c:95
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define READ_CONTROL
Definition: nt_native.h:58
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ TestCreateOpen_()

static VOID TestCreateOpen_ ( _In_ ACCESS_MASK  DesiredAccess,
_In_ ACCESS_MASK  ExpectedAccess,
_In_ NTSTATUS  ExpectedStatus,
_In_ PCSTR  File,
_In_ INT  Line 
)
static

Definition at line 36 of file NtCreateKey.c.

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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static VOID VerifyAccess_(_In_ HANDLE Handle, _In_ ACCESS_MASK ExpectedAccess, _In_ PCSTR File, _In_ INT Line)
Definition: NtCreateKey.c:12
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
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
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
Definition: ncftp.h:79
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
Definition: File.h:15
#define STATUS_SUCCESS
Definition: shellext.h:65
#define skip_(test, file, line,...)
Definition: kmt_test.h:222
#define ok_(x1, x2)
Definition: atltest.h:61
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

◆ VerifyAccess_()

static VOID VerifyAccess_ ( _In_ HANDLE  Handle,
_In_ ACCESS_MASK  ExpectedAccess,
_In_ PCSTR  File,
_In_ INT  Line 
)
static

Definition at line 12 of file NtCreateKey.c.

17 {
19  OBJECT_BASIC_INFORMATION BasicInfo;
20  ULONG Length;
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 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:24
NTSTATUS NtQueryObject(IN HANDLE Handle, IN OBJECT_INFO_CLASS ObjectInformationClass, OUT PVOID ObjectInformation, IN ULONG ObjectInformationLength, OUT PULONG ReturnLength)
Definition: ncftp.h:79
ACCESS_MASK GrantedAccess
Definition: winternl.h:1251
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned int ULONG
Definition: retypes.h:1
Definition: File.h:15
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ok_(x1, x2)
Definition: atltest.h:61

Referenced by TestCreateOpen_().