From 89722b00b4ddc3dac847670d941cde070a4d773f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Tue, 30 Sep 2014 22:05:50 +0000 Subject: [PATCH] [ADVAPI32] - Centralize RegDeleteKey[Ex]{A,W} implementation into RegDeleteKeyExW - Update the HKCR wrapper accordingly. CORE-8582 svn path=/trunk/; revision=64427 --- reactos/dll/win32/advapi32/reg/hkcr.c | 10 +- reactos/dll/win32/advapi32/reg/reg.c | 204 +++++++------------------- reactos/dll/win32/advapi32/reg/reg.h | 4 +- 3 files changed, 64 insertions(+), 154 deletions(-) diff --git a/reactos/dll/win32/advapi32/reg/hkcr.c b/reactos/dll/win32/advapi32/reg/hkcr.c index 5180f4546ff..32b12d699a1 100644 --- a/reactos/dll/win32/advapi32/reg/hkcr.c +++ b/reactos/dll/win32/advapi32/reg/hkcr.c @@ -272,7 +272,9 @@ LONG 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 @@ DeleteHKCRKey( 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 @@ DeleteHKCRKey( return ErrorCode; } - ErrorCode = RegDeleteKeyW(QueriedKey, lpSubKey); + ErrorCode = RegDeleteKeyExW(QueriedKey, lpSubKey, RegSam, Reserved); /* Close it if we must */ if (QueriedKey != hKey) @@ -317,7 +319,7 @@ DeleteHKCRKey( return ErrorCode; } - ErrorCode = RegDeleteKeyW(QueriedKey, lpSubKey); + ErrorCode = RegDeleteKeyExW(QueriedKey, lpSubKey, RegSam, Reserved); /* Close it if we must */ if (QueriedKey != hKey) diff --git a/reactos/dll/win32/advapi32/reg/reg.c b/reactos/dll/win32/advapi32/reg/reg.c index b68337da82d..3ac7545ac69 100644 --- a/reactos/dll/win32/advapi32/reg/reg.c +++ b/reactos/dll/win32/advapi32/reg/reg.c @@ -1181,20 +1181,13 @@ RegCreateKeyW(HKEY hKey, * * @implemented */ -LONG WINAPI -RegDeleteKeyA(HKEY hKey, - LPCSTR lpSubKey) +LONG +WINAPI +RegDeleteKeyA( + _In_ HKEY hKey, + _In_ LPCSTR lpSubKey) { - LONG ErrorCode; - UNICODE_STRING SubKeyName; - - RtlCreateUnicodeStringFromAsciiz(&SubKeyName, (LPSTR)lpSubKey); - - ErrorCode = RegDeleteKeyW(hKey, SubKeyName.Buffer); - - RtlFreeUnicodeString(&SubKeyName); - - return ErrorCode; + return RegDeleteKeyExA(hKey, lpSubKey, 0, 0); } @@ -1203,9 +1196,54 @@ RegDeleteKeyA(HKEY hKey, * * @implemented */ -LONG WINAPI -RegDeleteKeyW(HKEY hKey, - LPCWSTR lpSubKey) +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 = RegDeleteKeyExW(hKey, SubKeyName.Buffer, samDesired, Reserved); + + RtlFreeUnicodeString(&SubKeyName); + + return ErrorCode; +} + + +/************************************************************************ + * 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 @@ RegDeleteKeyW(HKEY hKey, } 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"); diff --git a/reactos/dll/win32/advapi32/reg/reg.h b/reactos/dll/win32/advapi32/reg/reg.h index 5d0bc25ff0c..25f72432803 100644 --- a/reactos/dll/win32/advapi32/reg/reg.h +++ b/reactos/dll/win32/advapi32/reg/reg.h @@ -35,5 +35,7 @@ LONG WINAPI DeleteHKCRKey( _In_ HKEY hKey, - _In_ LPCWSTR lpSubKey); + _In_ LPCWSTR lpSubKey, + _In_ REGSAM RegSam, + _In_ DWORD Reserved);