From 8d862306eff3672afd748e6791a6a9246f8064b3 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Thu, 25 Aug 2005 12:25:11 +0000 Subject: [PATCH] added stubs for RegDeleteTreeA/W() and RegCopyTreeA/W() svn path=/trunk/; revision=17535 --- reactos/lib/advapi32/advapi32.def | 4 + reactos/lib/advapi32/reg/reg.c | 196 +++++++++++++++++++++++++++++- 2 files changed, 199 insertions(+), 1 deletion(-) diff --git a/reactos/lib/advapi32/advapi32.def b/reactos/lib/advapi32/advapi32.def index 8f3817ea19d..55757f2097c 100644 --- a/reactos/lib/advapi32/advapi32.def +++ b/reactos/lib/advapi32/advapi32.def @@ -467,6 +467,8 @@ ReadEventLogW@28 RegCloseKey@4 RegConnectRegistryA@12 RegConnectRegistryW@12 +RegCopyTreeA@12 +RegCopyTreeW@12 RegCreateKeyA@12 RegCreateKeyExA@36 RegCreateKeyExW@36 @@ -475,6 +477,8 @@ RegDeleteKeyA@8 RegDeleteKeyW@8 RegDeleteKeyValueA@12 RegDeleteKeyValueW@12 +RegDeleteTreeA@8 +RegDeleteTreeW@8 RegDeleteValueA@8 RegDeleteValueW@8 ;RegDisablePredefinedCache diff --git a/reactos/lib/advapi32/reg/reg.c b/reactos/lib/advapi32/reg/reg.c index 540e990fd78..2faaf7a66fa 100644 --- a/reactos/lib/advapi32/reg/reg.c +++ b/reactos/lib/advapi32/reg/reg.c @@ -297,6 +297,108 @@ RegConnectRegistryA (LPCSTR lpMachineName, } +/************************************************************************ + * RegCopyTreeW + * + * @unimplemented + */ +LONG STDCALL +RegCopyTreeW(IN HKEY hKeySrc, + IN LPCWSTR lpSubKey OPTIONAL, + IN HKEY hKeyDest) +{ + HANDLE DestKeyHandle, KeyHandle, SubKeyHandle = NULL; + NTSTATUS Status; + + Status = MapDefaultKey(&KeyHandle, + hKeySrc); + if (!NT_SUCCESS(Status)) + { + return RtlNtStatusToDosError(Status); + } + + Status = MapDefaultKey(&DestKeyHandle, + hKeyDest); + if (!NT_SUCCESS(Status)) + { + return RtlNtStatusToDosError(Status); + } + + if (lpSubKey != NULL) + { + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING SubKeyName; + + RtlInitUnicodeString(&SubKeyName, + (LPWSTR)lpSubKey); + + InitializeObjectAttributes(&ObjectAttributes, + &SubKeyName, + OBJ_CASE_INSENSITIVE, + KeyHandle, + NULL); + + Status = NtOpenKey(&SubKeyHandle, + KEY_READ, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + return RtlNtStatusToDosError(Status); + } + } + + /* FIXME - copy all keys and values recursively */ + Status = STATUS_NOT_IMPLEMENTED; + + if (SubKeyHandle != NULL) + { + NtClose(SubKeyHandle); + } + + if (!NT_SUCCESS(Status)) + { + return RtlNtStatusToDosError(Status); + } + + return ERROR_SUCCESS; +} + + +/************************************************************************ + * RegCopyTreeA + * + * @implemented + */ +LONG STDCALL +RegCopyTreeA(IN HKEY hKeySrc, + IN LPCSTR lpSubKey OPTIONAL, + IN HKEY hKeyDest) +{ + UNICODE_STRING SubKeyName; + LONG Ret; + + if (lpSubKey != NULL) + { + if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName, + (LPSTR)lpSubKey)) + { + return ERROR_NOT_ENOUGH_MEMORY; + } + } + else + RtlInitUnicodeString(&SubKeyName, + NULL); + + Ret = RegCopyTreeW(hKeySrc, + SubKeyName.Buffer, + hKeyDest); + + RtlFreeUnicodeString(&SubKeyName); + + return Ret; +} + + /************************************************************************ * RegConnectRegistryW * @@ -802,6 +904,98 @@ RegDeleteKeyValueA(IN HKEY hKey, } +/************************************************************************ + * RegDeleteTreeW + * + * @unimplemented + */ +LONG STDCALL +RegDeleteTreeW(IN HKEY hKey, + IN LPCWSTR lpSubKey OPTIONAL) +{ + HANDLE KeyHandle, SubKeyHandle = NULL; + NTSTATUS Status; + + Status = MapDefaultKey(&KeyHandle, + hKey); + if (!NT_SUCCESS(Status)) + { + return RtlNtStatusToDosError(Status); + } + + if (lpSubKey != NULL) + { + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING SubKeyName; + + RtlInitUnicodeString(&SubKeyName, + (LPWSTR)lpSubKey); + + InitializeObjectAttributes(&ObjectAttributes, + &SubKeyName, + OBJ_CASE_INSENSITIVE, + KeyHandle, + NULL); + + Status = NtOpenKey(&SubKeyHandle, + KEY_READ, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + return RtlNtStatusToDosError(Status); + } + } + + /* FIXME - delete all keys recursively */ + Status = STATUS_NOT_IMPLEMENTED; + + if (SubKeyHandle != NULL) + { + NtClose(SubKeyHandle); + } + + if (!NT_SUCCESS(Status)) + { + return RtlNtStatusToDosError(Status); + } + + return ERROR_SUCCESS; +} + + +/************************************************************************ + * RegDeleteTreeA + * + * @implemented + */ +LONG STDCALL +RegDeleteTreeA(IN HKEY hKey, + IN LPCSTR lpSubKey OPTIONAL) +{ + UNICODE_STRING SubKeyName; + LONG Ret; + + if (lpSubKey != NULL) + { + if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName, + (LPSTR)lpSubKey)) + { + return ERROR_NOT_ENOUGH_MEMORY; + } + } + else + RtlInitUnicodeString(&SubKeyName, + NULL); + + Ret = RegDeleteTreeW(hKey, + SubKeyName.Buffer); + + RtlFreeUnicodeString(&SubKeyName); + + return Ret; +} + + /************************************************************************ * RegSetKeyValueW * @@ -897,7 +1091,7 @@ RegSetKeyValueA(IN HKEY hKey, if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName, (LPSTR)lpSubKey)) { - return RtlNtStatusToDosError(Status); + return ERROR_NOT_ENOUGH_MEMORY; } InitializeObjectAttributes(&ObjectAttributes,