Author: jgardou
Date: Tue Sep 30 22:05:50 2014
New Revision: 64427
URL: 
http://svn.reactos.org/svn/reactos?rev=64427&view=rev
Log:
[ADVAPI32]
 - Centralize RegDeleteKey[Ex]{A,W} implementation into RegDeleteKeyExW
 - Update the HKCR wrapper accordingly.
CORE-8582
Modified:
    trunk/reactos/dll/win32/advapi32/reg/hkcr.c
    trunk/reactos/dll/win32/advapi32/reg/reg.c
    trunk/reactos/dll/win32/advapi32/reg/reg.h
Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/hkc…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] Tue Sep 30 22:05:50 2014
@@ -272,7 +272,9 @@
 WINAPI
 DeleteHKCRKey(
     _In_ HKEY hKey,
-    _In_ LPCWSTR lpSubKey)
+    _In_ LPCWSTR lpSubKey,
+    _In_ REGSAM RegSam,
+    _In_ DWORD Reserved)
 {
     HKEY QueriedKey;
     LONG ErrorCode;
@@ -287,7 +289,7 @@
     if (ErrorCode == ERROR_FILE_NOT_FOUND)
     {
         /* The key doesn't exist on HKCU side, no chance for a subkey */
-        return RegDeleteKeyW(hKey, lpSubKey);
+        return RegDeleteKeyExW(hKey, lpSubKey, RegSam, Reserved);
     }
     if (ErrorCode != ERROR_SUCCESS)
@@ -296,7 +298,7 @@
         return ErrorCode;
     }
-    ErrorCode = RegDeleteKeyW(QueriedKey, lpSubKey);
+    ErrorCode = RegDeleteKeyExW(QueriedKey, lpSubKey, RegSam, Reserved);
     /* Close it if we must */
     if (QueriedKey != hKey)
@@ -317,7 +319,7 @@
         return ErrorCode;
     }
-    ErrorCode = RegDeleteKeyW(QueriedKey, lpSubKey);
+    ErrorCode = RegDeleteKeyExW(QueriedKey, lpSubKey, RegSam, Reserved);
     /* Close it if we must */
     if (QueriedKey != hKey)
Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/reg.c  [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/reg.c  [iso-8859-1] Tue Sep 30 22:05:50 2014
@@ -1181,16 +1181,50 @@
  *
  * @implemented
  */
-LONG WINAPI
-RegDeleteKeyA(HKEY hKey,
-              LPCSTR lpSubKey)
+LONG
+WINAPI
+RegDeleteKeyA(
+    _In_ HKEY hKey,
+    _In_ LPCSTR lpSubKey)
+{
+    return RegDeleteKeyExA(hKey, lpSubKey, 0, 0);
+}
+
+
+/************************************************************************
+ *  RegDeleteKeyW
+ *
+ * @implemented
+ */
+LONG
+WINAPI
+RegDeleteKeyW(
+    _In_ HKEY hKey,
+    _In_ LPCWSTR lpSubKey)
+{
+    return RegDeleteKeyExW(hKey, lpSubKey, 0, 0);
+}
+
+
+/************************************************************************
+ *  RegDeleteKeyExA
+ *
+ * @implemented
+ */
+LONG
+WINAPI
+RegDeleteKeyExA(
+    _In_ HKEY hKey,
+    _In_ LPCSTR lpSubKey,
+    _In_ REGSAM samDesired,
+    _In_ DWORD Reserved)
 {
     LONG ErrorCode;
     UNICODE_STRING SubKeyName;
     RtlCreateUnicodeStringFromAsciiz(&SubKeyName, (LPSTR)lpSubKey);
-    ErrorCode = RegDeleteKeyW(hKey, SubKeyName.Buffer);
+    ErrorCode = RegDeleteKeyExW(hKey, SubKeyName.Buffer, samDesired, Reserved);
     RtlFreeUnicodeString(&SubKeyName);
@@ -1199,13 +1233,17 @@
 /************************************************************************
- *  RegDeleteKeyW
- *
- * @implemented
- */
-LONG WINAPI
-RegDeleteKeyW(HKEY hKey,
-              LPCWSTR lpSubKey)
+ *  RegDeleteKeyExW
+ *
+ * @implemented
+ */
+LONG
+WINAPI
+RegDeleteKeyExW(
+    _In_ HKEY hKey,
+    _In_ LPCWSTR lpSubKey,
+    _In_ REGSAM samDesired,
+    _In_ DWORD Reserved)
 {
     OBJECT_ATTRIBUTES ObjectAttributes;
     UNICODE_STRING SubKeyName;
@@ -1228,139 +1266,7 @@
     }
     if (IsHKCRKey(ParentKey))
-        return DeleteHKCRKey(ParentKey, lpSubKey);
-
-    RtlInitUnicodeString(&SubKeyName,
-                         (LPWSTR)lpSubKey);
-    InitializeObjectAttributes(&ObjectAttributes,
-                               &SubKeyName,
-                               OBJ_CASE_INSENSITIVE,
-                               ParentKey,
-                               NULL);
-    Status = NtOpenKey(&TargetKey,
-                       DELETE,
-                       &ObjectAttributes);
-    if (!NT_SUCCESS(Status))
-    {
-        goto Cleanup;
-    }
-
-    Status = NtDeleteKey(TargetKey);
-    NtClose(TargetKey);
-
-Cleanup:
-    ClosePredefKey(ParentKey);
-
-    if (!NT_SUCCESS(Status))
-    {
-        return RtlNtStatusToDosError(Status);
-    }
-
-    return ERROR_SUCCESS;
-}
-
-
-/************************************************************************
- *  RegDeleteKeyExA
- *
- * @implemented
- */
-LONG
-WINAPI
-RegDeleteKeyExA(HKEY hKey,
-                LPCSTR lpSubKey,
-                REGSAM samDesired,
-                DWORD Reserved)
-{
-    OBJECT_ATTRIBUTES ObjectAttributes;
-    UNICODE_STRING SubKeyName;
-    HANDLE ParentKey;
-    HANDLE TargetKey;
-    NTSTATUS Status;
-
-    /* Make sure we got a subkey */
-    if (!lpSubKey)
-    {
-        /* Fail */
-        return ERROR_INVALID_PARAMETER;
-    }
-
-    Status = MapDefaultKey(&ParentKey,
-                           hKey);
-    if (!NT_SUCCESS(Status))
-    {
-        return RtlNtStatusToDosError(Status);
-    }
-
-    if (samDesired & KEY_WOW64_32KEY)
-        ERR("Wow64 not yet supported!\n");
-
-    if (samDesired & KEY_WOW64_64KEY)
-        ERR("Wow64 not yet supported!\n");
-
-    RtlCreateUnicodeStringFromAsciiz(&SubKeyName,
-                                     (LPSTR)lpSubKey);
-    InitializeObjectAttributes(&ObjectAttributes,
-                               &SubKeyName,
-                               OBJ_CASE_INSENSITIVE,
-                               ParentKey,
-                               NULL);
-
-    Status = NtOpenKey(&TargetKey,
-                       DELETE,
-                       &ObjectAttributes);
-    RtlFreeUnicodeString(&SubKeyName);
-    if (!NT_SUCCESS(Status))
-    {
-        goto Cleanup;
-    }
-
-    Status = NtDeleteKey(TargetKey);
-    NtClose (TargetKey);
-
-Cleanup:
-    ClosePredefKey(ParentKey);
-
-    if (!NT_SUCCESS(Status))
-    {
-        return RtlNtStatusToDosError(Status);
-    }
-
-    return ERROR_SUCCESS;
-}
-
-
-/************************************************************************
- *  RegDeleteKeyExW
- *
- * @implemented
- */
-LONG
-WINAPI
-RegDeleteKeyExW(HKEY hKey,
-                LPCWSTR lpSubKey,
-                REGSAM samDesired,
-                DWORD Reserved)
-{
-    OBJECT_ATTRIBUTES ObjectAttributes;
-    UNICODE_STRING SubKeyName;
-    HANDLE ParentKey;
-    HANDLE TargetKey;
-    NTSTATUS Status;
-
-    /* Make sure we got a subkey */
-    if (!lpSubKey)
-    {
-        /* Fail */
-        return ERROR_INVALID_PARAMETER;
-    }
-
-    Status = MapDefaultKey(&ParentKey,
-                           hKey);
-    if (!NT_SUCCESS(Status))
-    {
-        return RtlNtStatusToDosError(Status);
-    }
+        return DeleteHKCRKey(ParentKey, lpSubKey, samDesired, Reserved);
     if (samDesired & KEY_WOW64_32KEY)
         ERR("Wow64 not yet supported!\n");
Modified: trunk/reactos/dll/win32/advapi32/reg/reg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/reg.h  [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/reg.h  [iso-8859-1] Tue Sep 30 22:05:50 2014
@@ -35,5 +35,7 @@
 WINAPI
 DeleteHKCRKey(
     _In_ HKEY hKey,
-    _In_ LPCWSTR lpSubKey);
+    _In_ LPCWSTR lpSubKey,
+    _In_ REGSAM RegSam,
+    _In_ DWORD Reserved);