ReactOS 0.4.15-dev-7674-gc0b4db1
NtDeleteKey.c File Reference
#include "precomp.h"
Include dependency graph for NtDeleteKey.c:

Go to the source code of this file.

Functions

static NTSTATUS CreateRegistryKeyHandle (PHANDLE KeyHandle, ACCESS_MASK AccessMask, PWCHAR RegistryPath)
 
 START_TEST (NtDeleteKey)
 

Function Documentation

◆ CreateRegistryKeyHandle()

static NTSTATUS CreateRegistryKeyHandle ( PHANDLE  KeyHandle,
ACCESS_MASK  AccessMask,
PWCHAR  RegistryPath 
)
static

Definition at line 11 of file NtDeleteKey.c.

14{
17
20 &KeyName,
22 NULL,
23 NULL);
24
26}
#define NULL
Definition: types.h:112
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
_In_ ACCESS_MASK AccessMask
Definition: exfuncs.h:186
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
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
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( NtDeleteKey  )

Definition at line 28 of file NtDeleteKey.c.

29{
31 HANDLE ParentKey, ChildKey, PetKey;
32 WCHAR Buffer[sizeof("\\Registry\\Machine\\Software\\RosTests\\Child\\Pet") + 5];
33 ULONG i;
34
35 /* Create a registry key */
36 Status = CreateRegistryKeyHandle(&ParentKey, KEY_READ | DELETE, L"\\Registry\\Machine\\Software\\RosTests");
38
39 /* Create a children registry key */
40 Status = CreateRegistryKeyHandle(&ChildKey, KEY_READ | DELETE, L"\\Registry\\Machine\\Software\\RosTests\\Child");
42
43 /* Try deleting the parent one */
46
47 /* See what happens with Child one */
48 Status = NtDeleteKey(ChildKey);
50
51 /* Retry with parent one */
54
55 /* re-retry */
58
59 /* Close everything */
60 NtClose(ChildKey);
62
63 /* Same, but this time close the child handle before trying to delete the parent */
64 /* Create a registry key */
65 Status = CreateRegistryKeyHandle(&ParentKey, KEY_READ | DELETE, L"\\Registry\\Machine\\Software\\RosTests");
67
68 /* Create a children registry key */
69 Status = CreateRegistryKeyHandle(&ChildKey, KEY_READ, L"\\Registry\\Machine\\Software\\RosTests\\Child");
71
72 /* Close the Child */
73 NtClose(ChildKey);
74
75 /* Try deleting the parent one */
78
79 /* See what happens with Child one */
80 Status = CreateRegistryKeyHandle(&ChildKey, DELETE, L"\\Registry\\Machine\\Software\\RosTests\\Child");
82 Status = NtDeleteKey(ChildKey);
84
85 /* Retry with parent one */
88
89 /* Close everything */
90 NtClose(ChildKey);
92
93 /* Stress test key creation */
94 Status = CreateRegistryKeyHandle(&ParentKey, KEY_READ | DELETE, L"\\Registry\\Machine\\Software\\RosTests");
95
96 for (i = 0; i <= 9999; i++) {
97 swprintf(Buffer, L"\\Registry\\Machine\\Software\\RosTests\\Child%04d", i);
99 NtClose(ChildKey);
100
101 swprintf(Buffer, L"\\Registry\\Machine\\Software\\RosTests\\Child%04d\\Pet", i);
103 NtClose(PetKey);
104 }
106
107 /* Test hive rerooting */
108 Status = CreateRegistryKeyHandle(&PetKey, DELETE, L"\\Registry\\Machine\\Software\\RosTests\\Child5000\\Pet");
110 Status = NtDeleteKey(PetKey);
112
113 NtClose(PetKey);
114
115 Status = CreateRegistryKeyHandle(&ChildKey, DELETE, L"\\Registry\\Machine\\Software\\RosTests\\Child5000");
117 Status = NtDeleteKey(ChildKey);
119
120 /* Test mass key deletion */
121 for (i = 0; i <= 9999; i++) {
122 if (i != 5000) {
123 swprintf(Buffer, L"\\Registry\\Machine\\Software\\RosTests\\Child%04d\\Pet", i);
125 Status = NtDeleteKey(PetKey);
126 NtClose(PetKey);
127
128 swprintf(Buffer, L"\\Registry\\Machine\\Software\\RosTests\\Child%04d", i);
130 Status = NtDeleteKey(ChildKey);
131 NtClose(ChildKey);
132 }
133 }
135
138
139 /* Close ParentKey */
141}
static NTSTATUS CreateRegistryKeyHandle(PHANDLE KeyHandle, ACCESS_MASK AccessMask, PWCHAR RegistryPath)
Definition: NtDeleteKey.c:11
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define swprintf
Definition: precomp.h:40
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define KEY_READ
Definition: nt_native.h:1023
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define DELETE
Definition: nt_native.h:57
NTSTATUS NTAPI NtDeleteKey(IN HANDLE KeyHandle)
Definition: ntapi.c:408
#define L(x)
Definition: ntvdm.h:50
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69
__wchar_t WCHAR
Definition: xmlstorage.h:180