From 90a91712765a87817153d594ae713010ef727d87 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 14 Dec 2023 20:01:40 +0200 Subject: [PATCH] [ADVAPI32_VISTA] Use RegDeleteTree from reg.c --- dll/win32/advapi32/reg/reg.c | 2 + dll/win32/advapi32_vista/CMakeLists.txt | 1 - dll/win32/advapi32_vista/RegDeleteTree.c | 102 ----------------------- 3 files changed, 2 insertions(+), 103 deletions(-) delete mode 100644 dll/win32/advapi32_vista/RegDeleteTree.c diff --git a/dll/win32/advapi32/reg/reg.c b/dll/win32/advapi32/reg/reg.c index 1488fb9bf9f..8ca0927d678 100644 --- a/dll/win32/advapi32/reg/reg.c +++ b/dll/win32/advapi32/reg/reg.c @@ -1737,6 +1737,7 @@ Cleanup: } #endif +#endif // _ADVAPI32_VISTA_ /************************************************************************ * RegDeleteTreeW @@ -1859,6 +1860,7 @@ RegDeleteTreeA(IN HKEY hKey, return Ret; } +#ifndef _ADVAPI32_VISTA_ /************************************************************************ * RegDisableReflectionKey diff --git a/dll/win32/advapi32_vista/CMakeLists.txt b/dll/win32/advapi32_vista/CMakeLists.txt index 4890d0ed0bc..4cb29d3844f 100644 --- a/dll/win32/advapi32_vista/CMakeLists.txt +++ b/dll/win32/advapi32_vista/CMakeLists.txt @@ -13,7 +13,6 @@ include_directories( list(APPEND SOURCE DllMain.c ../advapi32/reg/reg.c - RegDeleteTree.c RegSetKeyValue.c RegLoadMUIString.c ${CMAKE_CURRENT_BINARY_DIR}/advapi32_vista.def) diff --git a/dll/win32/advapi32_vista/RegDeleteTree.c b/dll/win32/advapi32_vista/RegDeleteTree.c deleted file mode 100644 index 0a9f6192fb7..00000000000 --- a/dll/win32/advapi32_vista/RegDeleteTree.c +++ /dev/null @@ -1,102 +0,0 @@ - -#include "advapi32_vista.h" - -/* heap allocation helpers */ -static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1); -static inline void *heap_alloc( size_t len ) -{ - return HeapAlloc( GetProcessHeap(), 0, len ); -} - -static inline BOOL heap_free( void *mem ) -{ - return HeapFree( GetProcessHeap(), 0, mem ); -} - -/* Taken from Wine advapi32/registry.c */ - -/****************************************************************************** - * RegDeleteTreeW [ADVAPI32.@] - * - */ -LSTATUS WINAPI RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey) -{ - LONG ret; - DWORD dwMaxSubkeyLen, dwMaxValueLen; - DWORD dwMaxLen, dwSize; - WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf; - HKEY hSubKey = hKey; - - if(lpszSubKey) - { - ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey); - if (ret) return ret; - } - - /* Get highest length for keys, values */ - ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL, - &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL); - if (ret) goto cleanup; - - dwMaxSubkeyLen++; - dwMaxValueLen++; - dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen); - if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR)) - { - /* Name too big: alloc a buffer for it */ - if (!(lpszName = heap_alloc( dwMaxLen*sizeof(WCHAR)))) - { - ret = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - } - - - /* Recursively delete all the subkeys */ - while (TRUE) - { - dwSize = dwMaxLen; - if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL, - NULL, NULL, NULL)) break; - - ret = RegDeleteTreeW(hSubKey, lpszName); - if (ret) goto cleanup; - } - - if (lpszSubKey) - ret = RegDeleteKeyW(hKey, lpszSubKey); - else - while (TRUE) - { - dwSize = dwMaxLen; - if (RegEnumValueW(hKey, 0, lpszName, &dwSize, - NULL, NULL, NULL, NULL)) break; - - ret = RegDeleteValueW(hKey, lpszName); - if (ret) goto cleanup; - } - -cleanup: - /* Free buffer if allocated */ - if (lpszName != szNameBuf) - heap_free( lpszName); - if(lpszSubKey) - RegCloseKey(hSubKey); - return ret; -} - -/****************************************************************************** - * RegDeleteTreeA [ADVAPI32.@] - * - */ -LSTATUS WINAPI RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey) -{ - LONG ret; - UNICODE_STRING lpszSubKeyW; - - if (lpszSubKey) RtlCreateUnicodeStringFromAsciiz( &lpszSubKeyW, lpszSubKey); - else lpszSubKeyW.Buffer = NULL; - ret = RegDeleteTreeW( hKey, lpszSubKeyW.Buffer); - RtlFreeUnicodeString( &lpszSubKeyW ); - return ret; -}