ReactOS  0.4.14-dev-614-gbfd8a84
HKEY_CLASSES_ROOT.c File Reference
#include "precomp.h"
#include <ndk/cmfuncs.h>
Include dependency graph for HKEY_CLASSES_ROOT.c:

Go to the source code of this file.

Macros

#define IS_HKCR(hk)   (((UINT_PTR)hk & 3) == 2)
 
#define ok_key_deleted(hKey)   _test_key_deleted(hKey, TRUE, __LINE__)
 
#define ok_key_not_deleted(hKey)   _test_key_deleted(hKey, FALSE, __LINE__)
 
#define ok_key_name(hKey, Prefix, Name)   _test_key_name(hKey, Prefix, Name, __LINE__)
 

Functions

static LONG DeleteSubKey (HKEY hKey, LPWSTR Root, LPWSTR SubKey)
 
static void GetKeyName (HKEY hKey, PUNICODE_STRING KeyName)
 
static void _test_key_deleted (HKEY hKey, BOOL Deleted, ULONG LineNumber)
 
static void _test_key_name (HKEY hKey, PUNICODE_STRING Prefix, LPCWSTR Name, ULONG LineNumber)
 
static void Test_CreateOpenKey (void)
 
static void Test_DuplicateHandle (void)
 
 START_TEST (HKEY_CLASSES_ROOT)
 

Variables

static UNICODE_STRING HKLM_ClassesPath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\Classes")
 
static UNICODE_STRING HKCU_ClassesPath
 

Macro Definition Documentation

◆ IS_HKCR

#define IS_HKCR (   hk)    (((UINT_PTR)hk & 3) == 2)

Definition at line 12 of file HKEY_CLASSES_ROOT.c.

◆ ok_key_deleted

#define ok_key_deleted (   hKey)    _test_key_deleted(hKey, TRUE, __LINE__)

Definition at line 76 of file HKEY_CLASSES_ROOT.c.

◆ ok_key_name

#define ok_key_name (   hKey,
  Prefix,
  Name 
)    _test_key_name(hKey, Prefix, Name, __LINE__)

Definition at line 102 of file HKEY_CLASSES_ROOT.c.

◆ ok_key_not_deleted

#define ok_key_not_deleted (   hKey)    _test_key_deleted(hKey, FALSE, __LINE__)

Definition at line 77 of file HKEY_CLASSES_ROOT.c.

Function Documentation

◆ _test_key_deleted()

static void _test_key_deleted ( HKEY  hKey,
BOOL  Deleted,
ULONG  LineNumber 
)
static

Definition at line 68 of file HKEY_CLASSES_ROOT.c.

69 {
71  if (Deleted)
72  ok_(__FILE__, LineNumber)(ErrorCode == ERROR_KEY_DELETED, "\n");
73  else
74  ok_(__FILE__, LineNumber)(ErrorCode == ERROR_SUCCESS, "\n");
75 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_KEY_DELETED
Definition: winerror.h:597
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3686
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1212
#define ok_(x1, x2)
Definition: atltest.h:61

◆ _test_key_name()

static void _test_key_name ( HKEY  hKey,
PUNICODE_STRING  Prefix,
LPCWSTR  Name,
ULONG  LineNumber 
)
static

Definition at line 79 of file HKEY_CLASSES_ROOT.c.

80 {
81  UNICODE_STRING ExpectedName, KeyName;
82  WCHAR Buffer[1024];
83 
84  ExpectedName.Length = 0;
85  ExpectedName.MaximumLength = sizeof(Buffer);
86  ExpectedName.Buffer = Buffer;
87 
88  RtlAppendUnicodeStringToString(&ExpectedName, Prefix);
89  RtlAppendUnicodeToString(&ExpectedName, L"\\");
90  RtlAppendUnicodeToString(&ExpectedName, Name);
91 
92  GetKeyName(hKey, &KeyName);
93 
94  ok_(__FILE__, LineNumber)(RtlCompareUnicodeString(&KeyName, &ExpectedName, TRUE) == 0,
95  "Key name is %.*S, expected %.*S\n",
96  KeyName.Length, KeyName.Buffer,
97  ExpectedName.Length, ExpectedName.Buffer);
98 
100 }
static void GetKeyName(HKEY hKey, PUNICODE_STRING KeyName)
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
_In_ __drv_aliasesMem PSTRING Prefix
Definition: rtlfuncs.h:1631
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: bufpool.h:45
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static const WCHAR L[]
Definition: oid.c:1250
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1212
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define ok_(x1, x2)
Definition: atltest.h:61

◆ DeleteSubKey()

static LONG DeleteSubKey ( HKEY  hKey,
LPWSTR  Root,
LPWSTR  SubKey 
)
static

Definition at line 20 of file HKEY_CLASSES_ROOT.c.

21 {
22  HKEY RootKey;
24 
26  hKey,
27  Root,
28  0,
30  &RootKey);
32  ErrorCode = RegDeleteKeyW(RootKey, SubKey);
34 
35  return ErrorCode;
36 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
static PMEMKEY RootKey
Definition: registry.c:55
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
root entry for file system trees
Definition: entries.h:148
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define ok_dec(expression, result)
Definition: atltest.h:101

Referenced by Test_CreateOpenKey().

◆ GetKeyName()

static void GetKeyName ( HKEY  hKey,
PUNICODE_STRING  KeyName 
)
static

Definition at line 40 of file HKEY_CLASSES_ROOT.c.

41 {
42  UNICODE_STRING InfoName;
43  PKEY_NAME_INFORMATION NameInformation;
44  ULONG InfoLength;
46 
47  /* Get info length */
48  InfoLength = 0;
49  Status = NtQueryKey(hKey, KeyNameInformation, NULL, 0, &InfoLength);
51 
52  /* Get it for real */
53  NameInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, InfoLength);
54  ok(NameInformation != NULL, "\n");
55 
56  Status = NtQueryKey(hKey, KeyNameInformation, NameInformation, InfoLength, &InfoLength);
58 
59  InfoName.Buffer = NameInformation->Name;
60  InfoName.Length = NameInformation->NameLength;
61  InfoName.MaximumLength = InfoName.Length;
62 
64 
65  RtlFreeHeap(RtlGetProcessHeap(), 0, NameInformation);
66 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
NTSTATUS NTAPI NtQueryKey(IN HANDLE KeyHandle, IN KEY_INFORMATION_CLASS KeyInformationClass, OUT PVOID KeyInformation, IN ULONG Length, OUT PULONG ResultLength)
Definition: ntapi.c:632
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
Status
Definition: gdiplustypes.h:24
#define ok(value,...)
Definition: atltest.h:57
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by _test_key_name(), and START_TEST().

◆ START_TEST()

START_TEST ( HKEY_CLASSES_ROOT  )

Definition at line 607 of file HKEY_CLASSES_ROOT.c.

608 {
609  HKEY UserKey;
610  LONG ErrorCode;
611 
612  /* Get HKCU real key name */
615  L"Software\\Classes",
616  0,
617  KEY_READ,
618  &UserKey);
620  GetKeyName(UserKey, &HKCU_ClassesPath);
621  RegCloseKey(UserKey);
622 
625 }
static void GetKeyName(HKEY hKey, PUNICODE_STRING KeyName)
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static void Test_CreateOpenKey(void)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
static UNICODE_STRING HKCU_ClassesPath
static void Test_DuplicateHandle(void)
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define ok_dec(expression, result)
Definition: atltest.h:101

◆ Test_CreateOpenKey()

static void Test_CreateOpenKey ( void  )
static

Definition at line 106 of file HKEY_CLASSES_ROOT.c.

107 {
108  HKEY MachineKey, MachineSubKey;
109  HKEY UserKey, UserSubKey;
110  HKEY ClassesRootKey, ClassesRootSubKey;
113 
114  /* First create a subkey in HKLM */
117  L"Software\\Classes\\Apitest_HKLM",
118  0,
119  NULL,
120  0,
122  NULL,
123  &MachineKey,
124  NULL);
125 
127  {
128  win_skip("Please run those tests with Administrator rights\n");
129  return;
130  }
131 
133  ok(!IS_HKCR(MachineKey), "\n");
134 
135  /* Open it in HKCR */
138  L"Apitest_HKLM",
139  0,
141  &ClassesRootKey);
143  ok(IS_HKCR(ClassesRootKey), "\n");
144  ok_key_name(ClassesRootKey, &HKLM_ClassesPath, L"Apitest_HKLM");
145 
146  /* Try opening it in HKCU */
147  UserKey = (HKEY)(ULONG_PTR)0xCAFEF00DCAFEF00DULL;
150  L"Software\\Classes\\Apitest_HKLM",
151  0,
153  &UserKey);
155  ok_hdl(UserKey, NULL);
156 
157  /* Cleanup */
158  RegCloseKey(ClassesRootKey);
159  RegCloseKey(MachineKey);
160  ErrorCode = DeleteSubKey(HKEY_LOCAL_MACHINE, L"Software\\Classes", L"Apitest_HKLM");
162 
163  /* Try creating in HKCR */
166  L"Apitest_HKCR",
167  0,
168  NULL,
169  0,
171  NULL,
172  &ClassesRootKey,
173  NULL);
175  ok(IS_HKCR(ClassesRootKey), "\n");
176  ok_key_name(ClassesRootKey, &HKLM_ClassesPath, L"Apitest_HKCR");
177 
178  /* It should be present in HKLM */
181  L"Software\\Classes\\Apitest_HKCR",
182  0,
184  &MachineKey);
186  ok(!IS_HKCR(MachineKey), "\n");
187 
188  /* But not in HKCU */
189  UserKey = (HKEY)(ULONG_PTR)0xCAFEF00DCAFEF00DULL;
192  L"Software\\Classes\\Apitest_HKCR",
193  0,
195  &UserKey);
197  ok_hdl(UserKey, NULL);
198 
199  /* This must delete the one in HKLM */
200  ErrorCode = RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Apitest_HKCR");
202  ok_key_deleted(ClassesRootKey);
203  ok_key_deleted(MachineKey);
204  RegCloseKey(ClassesRootKey);
205  RegCloseKey(MachineKey);
206 
207  /* Test that it is really not present anymore */
208  MachineKey = (HKEY)(ULONG_PTR)0xCAFEF00DCAFEF00DULL;
211  L"Software\\Classes\\Apitest_HKCR",
212  0,
214  &MachineKey);
216  ok_hdl(MachineKey, NULL);
217 
218  /* Try creating in HKCU */
221  L"Software\\Classes\\Apitest_HKCU",
222  0,
223  NULL,
224  0,
226  NULL,
227  &UserKey,
228  NULL);
230  ok(!IS_HKCR(UserKey), "\n");
231 
232  /* Try opening it in HKCR */
235  L"Apitest_HKCU",
236  0,
238  &ClassesRootKey);
240  ok(IS_HKCR(ClassesRootKey), "\n");
241  ok_key_name(ClassesRootKey, &HKCU_ClassesPath, L"Apitest_HKCU");
242 
243  /* And in HKLM */
246  L"Software\\Classes\\Apitest_HKCU",
247  0,
249  &MachineKey);
251  ok_hdl(MachineKey, NULL);
252 
253  ErrorCode = RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Apitest_HKCU");
255  ok_key_deleted(ClassesRootKey);
256  ok_key_deleted(UserKey);
257  RegCloseKey(ClassesRootKey);
258  RegCloseKey(UserKey);
259 
260  /* Test that it is really not present anymore */
261  UserKey = (HKEY)(ULONG_PTR)0xCAFEF00DCAFEF00DULL;
264  L"Software\\Classes\\Apitest_HKCU",
265  0,
267  &UserKey);
269  ok_hdl(UserKey, NULL);
270 
271  /* Try creating in both HKLM and HKCU */
274  L"Software\\Classes\\Apitest_HKLM_HKCU",
275  0,
276  NULL,
277  0,
279  NULL,
280  &UserKey,
281  NULL);
283  ok(!IS_HKCR(UserKey), "\n");
284 
287  L"Software\\Classes\\Apitest_HKLM_HKCU",
288  0,
289  NULL,
290  0,
292  NULL,
293  &MachineKey,
294  NULL);
296  ok(!IS_HKCR(MachineKey), "\n");
297 
298  /* Open it in HKCR */
301  L"Apitest_HKLM_HKCU",
302  0,
304  &ClassesRootKey);
306  ok(IS_HKCR(ClassesRootKey), "\n");
307  /* Verify it has opened the HKCU one */
308  ok_key_name(ClassesRootKey, &HKCU_ClassesPath, L"Apitest_HKLM_HKCU");
309 
310  /* Try the same thing, but this time with RegCreateKeyEx API */
311  RegCloseKey(ClassesRootKey);
314  L"Apitest_HKLM_HKCU",
315  0,
316  NULL,
317  0,
319  NULL,
320  &ClassesRootKey,
321  &Disposition);
323  ok(IS_HKCR(ClassesRootKey), "\n");
324  /* Verify it has opened the HKCU one */
325  ok_key_name(ClassesRootKey, &HKCU_ClassesPath, L"Apitest_HKLM_HKCU");
327 
328  /* Deleting it from HKCR first deletes the one in HKCU */
329  ErrorCode = RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Apitest_HKLM_HKCU");
331  ok_key_deleted(UserKey);
332  ok_key_deleted(ClassesRootKey);
333  ok_key_not_deleted(MachineKey);
334 
335  RegCloseKey(UserKey);
336  RegCloseKey(ClassesRootKey);
337 
338  /* This deletes it from HKLM this time */
339  ErrorCode = RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Apitest_HKLM_HKCU");
341  ok_key_deleted(MachineKey);
342  RegCloseKey(MachineKey);
343 
344  /* See what happens with subkeys */
347  L"Software\\Classes\\Apitest_HKLM",
348  0,
349  NULL,
350  0,
352  NULL,
353  &MachineKey,
354  NULL);
356  ok(!IS_HKCR(MachineKey), "\n");
357 
358  /* Open it in HKCR */
361  L"Apitest_HKLM",
362  0,
364  &ClassesRootKey);
366  ok(IS_HKCR(ClassesRootKey), "\n");
367  ok_key_name(ClassesRootKey, &HKLM_ClassesPath, L"Apitest_HKLM");
368 
369  /* Create a corresponding subkey in HKCU */
372  L"Software\\Classes\\Apitest_HKLM\\HKCU_Subkey",
373  0,
374  NULL,
375  0,
377  NULL,
378  &UserSubKey,
379  NULL);
381  ok(!IS_HKCR(UserSubKey), "\n");
382 
383  /* Open it as an HKCR subkey */
385  ClassesRootKey,
386  L"HKCU_Subkey",
387  0,
389  &ClassesRootSubKey);
391  ok(IS_HKCR(ClassesRootSubKey), "\n");
392  ok_key_name(ClassesRootSubKey, &HKCU_ClassesPath, L"Apitest_HKLM\\HKCU_Subkey");
393 
394  /* Try the same thing, but this time with RegCreateKeyEx API */
395  RegCloseKey(ClassesRootSubKey);
397  ClassesRootKey,
398  L"HKCU_Subkey",
399  0,
400  NULL,
401  0,
403  NULL,
404  &ClassesRootSubKey,
405  &Disposition);
407  ok(IS_HKCR(ClassesRootSubKey), "\n");
408  /* Verify it has opened the HKCU one */
409  ok_key_name(ClassesRootSubKey, &HKCU_ClassesPath, L"Apitest_HKLM\\HKCU_Subkey");
411 
412  /* This one now exists */
415  L"Software\\Classes\\Apitest_HKLM",
416  0,
418  &UserKey);
420  ok(!IS_HKCR(UserKey), "\n");
421 
422  /* Delete */
423  ErrorCode = RegDeleteKeyW(UserKey, L"HKCU_Subkey");
425  ok_key_deleted(UserSubKey);
426  ok_key_deleted(ClassesRootSubKey);
427  RegCloseKey(UserSubKey);
428  RegCloseKey(ClassesRootSubKey);
429 
430  /* See what this deletes */
431  RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Apitest_HKLM");
432  ok_key_deleted(UserKey);
433  RegCloseKey(UserKey);
434  ok_key_not_deleted(ClassesRootKey);
435  ok_key_not_deleted(MachineKey);
436 
437  /* Once again */
438  RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Apitest_HKLM");
439  ok_key_deleted(ClassesRootKey);
440  ok_key_deleted(MachineKey);
441  RegCloseKey(ClassesRootKey);
442  RegCloseKey(MachineKey);
443 
444  /* Same, but with HKCU first */
447  L"Software\\Classes\\Apitest_HKCU",
448  0,
449  NULL,
450  0,
452  NULL,
453  &UserKey,
454  NULL);
456  ok(!IS_HKCR(UserKey), "\n");
457 
458  /* Open it in HKCR */
461  L"Apitest_HKCU",
462  0,
464  &ClassesRootKey);
466  ok(IS_HKCR(ClassesRootKey), "\n");
467  ok_key_name(ClassesRootKey, &HKCU_ClassesPath, L"Apitest_HKCU");
468 
469  /* Try creating a subkey with this HKCR handle, which points to a subkey in HKCU. */
471  ClassesRootKey,
472  L"HKCR_Subkey",
473  0,
474  NULL,
475  0,
477  NULL,
478  &ClassesRootSubKey,
479  NULL);
481  ok(IS_HKCR(ClassesRootSubKey), "\n");
482  /* It is in fact created in HKLM */
483  ok_key_name(ClassesRootSubKey, &HKLM_ClassesPath, L"Apitest_HKCU\\HKCR_Subkey");
484  /* Let's see if we can delete it */
485  RegDeleteKeyW(ClassesRootKey, L"HKCR_Subkey");
486  ok_key_deleted(ClassesRootSubKey);
487  RegCloseKey(ClassesRootSubKey);
488 
489  /* Create a corresponding subkey in HKLM */
492  L"Software\\Classes\\Apitest_HKCU\\HKLM_Subkey",
493  0,
494  NULL,
495  0,
497  NULL,
498  &MachineSubKey,
499  NULL);
501  ok(!IS_HKCR(MachineSubKey), "\n");
502 
503  /* Open it from the HKCR handle (which is still pointing to HKCU) */
504  ok_key_name(ClassesRootKey, &HKCU_ClassesPath, L"Apitest_HKCU");
506  ClassesRootKey,
507  L"HKLM_Subkey",
508  0,
510  &ClassesRootSubKey);
512  ok(IS_HKCR(ClassesRootSubKey), "\n");
513  ok_key_name(ClassesRootSubKey, &HKLM_ClassesPath, L"Apitest_HKCU\\HKLM_Subkey");
514 
515  /* This one now exists */
518  L"Software\\Classes\\Apitest_HKCU",
519  0,
521  &MachineKey);
523  ok(!IS_HKCR(MachineKey), "\n");
524 
525  /* Delete this subkey */
526  ErrorCode = RegDeleteKeyW(MachineKey, L"HKLM_Subkey");
528  ok_key_deleted(MachineSubKey);
529  ok_key_deleted(ClassesRootSubKey);
530 
531  /* Create another subkey, this time from HKCU */
534  L"Software\\Classes\\Apitest_HKCU\\HKCU_Subkey",
535  0,
536  NULL,
537  0,
539  NULL,
540  &UserSubKey,
541  NULL);
543  ok(!IS_HKCR(UserSubKey), "\n");
544 
545  /* And try creating it again as a subkey of this HKCR handle (which points to HKCU). */
546  ok_key_name(ClassesRootKey, &HKCU_ClassesPath, L"Apitest_HKCU");
548  ClassesRootKey,
549  L"HKCU_Subkey",
550  0,
551  NULL,
552  0,
554  NULL,
555  &ClassesRootSubKey,
556  &Disposition);
558  ok(IS_HKCR(ClassesRootSubKey), "\n");
559  /* This time the one in HKCU is opened */
560  ok_key_name(ClassesRootSubKey, &HKCU_ClassesPath, L"Apitest_HKCU\\HKCU_Subkey");
562  /* Let's see if we can delete it */
563  RegDeleteKeyW(ClassesRootKey, L"HKCU_Subkey");
564  ok_key_deleted(ClassesRootSubKey);
565  RegCloseKey(ClassesRootSubKey);
566  ok_key_deleted(UserSubKey);
567  RegCloseKey(UserSubKey);
568 
569  RegCloseKey(MachineSubKey);
570  RegCloseKey(ClassesRootSubKey);
571 
572  /* See what this deletes */
573  RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Apitest_HKCU");
574  ok_key_deleted(UserKey);
575  RegCloseKey(UserKey);
576  ok_key_deleted(ClassesRootKey);
577  RegCloseKey(UserKey);
578  ok_key_not_deleted(MachineKey);
579 
580  /* Once again */
581  RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Apitest_HKCU");
582  ok_key_deleted(MachineKey);
583  RegCloseKey(MachineKey);
584 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
static UNICODE_STRING HKLM_ClassesPath
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
static LONG DeleteSubKey(HKEY hKey, LPWSTR Root, LPWSTR SubKey)
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
#define ok_hdl
Definition: atltest.h:136
#define ok_hex(expression, result)
Definition: atltest.h:94
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
uint32_t ULONG_PTR
Definition: typedefs.h:63
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
static UNICODE_STRING HKCU_ClassesPath
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define ULL(a, b)
Definition: format_msg.c:27
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ok_key_deleted(hKey)
static const WCHAR L[]
Definition: oid.c:1250
#define ok_key_not_deleted(hKey)
#define ok_key_name(hKey, Prefix, Name)
#define ok(value,...)
Definition: atltest.h:57
HANDLE HKEY
Definition: registry.h:24
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define IS_HKCR(hk)
#define ok_dec(expression, result)
Definition: atltest.h:101
#define win_skip
Definition: test.h:150
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by START_TEST().

◆ Test_DuplicateHandle()

static void Test_DuplicateHandle ( void  )
static

Definition at line 588 of file HKEY_CLASSES_ROOT.c.

589 {
590  HKEY KeyHandle, DupHandle;
592  BOOL Duplicated;
593 
596  ok(IS_HKCR(KeyHandle), "\n");
597 
599  ok(Duplicated, "\n");
600  ok(DupHandle != NULL, "\n");
601  ok(!IS_HKCR(DupHandle), "\n");
602 
604  RegCloseKey(DupHandle);
605 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
#define DUPLICATE_SAME_ACCESS
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define ok(value,...)
Definition: atltest.h:57
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define IS_HKCR(hk)
#define ok_dec(expression, result)
Definition: atltest.h:101
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149

Referenced by START_TEST().

Variable Documentation

◆ HKCU_ClassesPath

UNICODE_STRING HKCU_ClassesPath
static

Definition at line 16 of file HKEY_CLASSES_ROOT.c.

Referenced by START_TEST(), and Test_CreateOpenKey().

◆ HKLM_ClassesPath

UNICODE_STRING HKLM_ClassesPath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\Classes")
static

Definition at line 15 of file HKEY_CLASSES_ROOT.c.

Referenced by Test_CreateOpenKey().