diff --git a/dll/win32/userenv/CMakeLists.txt b/dll/win32/userenv/CMakeLists.txt index 28b272697b5..8e372f16001 100644 --- a/dll/win32/userenv/CMakeLists.txt +++ b/dll/win32/userenv/CMakeLists.txt @@ -24,6 +24,6 @@ add_library(userenv MODULE set_module_type(userenv win32dll) target_link_libraries(userenv uuid) -add_importlibs(userenv advapi32 user32 msvcrt kernel32 ntdll) +add_importlibs(userenv advapi32 advapi32_vista user32 msvcrt kernel32 ntdll) add_pch(userenv precomp.h "${PCH_SKIP_SOURCE}") add_cd_file(TARGET userenv DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/userenv/registry.c b/dll/win32/userenv/registry.c index a7fc4fee49c..326832a1164 100644 --- a/dll/win32/userenv/registry.c +++ b/dll/win32/userenv/registry.c @@ -29,6 +29,8 @@ #define NDEBUG #include +LSTATUS WINAPI RegCopyTreeW(_In_ HKEY, _In_opt_ LPCWSTR, _In_ HKEY); + /* FUNCTIONS ***************************************************************/ static @@ -38,7 +40,6 @@ CopyKey(HKEY hDstKey, { LONG Error; -#if (_WIN32_WINNT >= 0x0600) Error = RegCopyTreeW(hSrcKey, NULL, hDstKey); @@ -49,229 +50,6 @@ CopyKey(HKEY hDstKey, } return TRUE; - -#else - FILETIME LastWrite; - DWORD dwSubKeys; - DWORD dwValues; - DWORD dwType; - DWORD dwMaxSubKeyNameLength; - DWORD dwSubKeyNameLength; - DWORD dwMaxValueNameLength; - DWORD dwValueNameLength; - DWORD dwMaxValueLength; - DWORD dwValueLength; - DWORD dwDisposition; - DWORD i; - LPWSTR lpNameBuffer; - LPBYTE lpDataBuffer; - HKEY hDstSubKey; - HKEY hSrcSubKey; - - DPRINT ("CopyKey() called\n"); - - Error = RegQueryInfoKey(hSrcKey, - NULL, - NULL, - NULL, - &dwSubKeys, - &dwMaxSubKeyNameLength, - NULL, - &dwValues, - &dwMaxValueNameLength, - &dwMaxValueLength, - NULL, - NULL); - if (Error != ERROR_SUCCESS) - { - DPRINT1("RegQueryInfoKey() failed (Error %lu)\n", Error); - SetLastError((DWORD)Error); - return FALSE; - } - - dwMaxSubKeyNameLength++; - dwMaxValueNameLength++; - - DPRINT("dwSubKeys %lu\n", dwSubKeys); - DPRINT("dwMaxSubKeyNameLength %lu\n", dwMaxSubKeyNameLength); - DPRINT("dwValues %lu\n", dwValues); - DPRINT("dwMaxValueNameLength %lu\n", dwMaxValueNameLength); - DPRINT("dwMaxValueLength %lu\n", dwMaxValueLength); - - /* Copy subkeys */ - if (dwSubKeys != 0) - { - lpNameBuffer = HeapAlloc(GetProcessHeap(), - 0, - dwMaxSubKeyNameLength * sizeof(WCHAR)); - if (lpNameBuffer == NULL) - { - DPRINT1("Buffer allocation failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - for (i = 0; i < dwSubKeys; i++) - { - dwSubKeyNameLength = dwMaxSubKeyNameLength; - Error = RegEnumKeyExW(hSrcKey, - i, - lpNameBuffer, - &dwSubKeyNameLength, - NULL, - NULL, - NULL, - &LastWrite); - if (Error != ERROR_SUCCESS) - { - DPRINT1("Subkey enumeration failed (Error %lu)\n", Error); - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - - Error = RegCreateKeyExW(hDstKey, - lpNameBuffer, - 0, - NULL, - REG_OPTION_NON_VOLATILE, - KEY_WRITE, - NULL, - &hDstSubKey, - &dwDisposition); - if (Error != ERROR_SUCCESS) - { - DPRINT1("Subkey creation failed (Error %lu)\n", Error); - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - - Error = RegOpenKeyExW(hSrcKey, - lpNameBuffer, - 0, - KEY_READ, - &hSrcSubKey); - if (Error != ERROR_SUCCESS) - { - DPRINT1("Error: %lu\n", Error); - RegCloseKey(hDstSubKey); - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - - if (!CopyKey(hDstSubKey, - hSrcSubKey)) - { - DPRINT1("Error: %lu\n", GetLastError()); - RegCloseKey (hSrcSubKey); - RegCloseKey (hDstSubKey); - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - return FALSE; - } - - RegCloseKey(hSrcSubKey); - RegCloseKey(hDstSubKey); - } - - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - } - - /* Copy values */ - if (dwValues != 0) - { - lpNameBuffer = HeapAlloc(GetProcessHeap(), - 0, - dwMaxValueNameLength * sizeof(WCHAR)); - if (lpNameBuffer == NULL) - { - DPRINT1("Buffer allocation failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - lpDataBuffer = HeapAlloc(GetProcessHeap(), - 0, - dwMaxValueLength); - if (lpDataBuffer == NULL) - { - DPRINT1("Buffer allocation failed\n"); - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - for (i = 0; i < dwValues; i++) - { - dwValueNameLength = dwMaxValueNameLength; - dwValueLength = dwMaxValueLength; - Error = RegEnumValueW(hSrcKey, - i, - lpNameBuffer, - &dwValueNameLength, - NULL, - &dwType, - lpDataBuffer, - &dwValueLength); - if (Error != ERROR_SUCCESS) - { - DPRINT1("Error: %lu\n", Error); - HeapFree(GetProcessHeap(), - 0, - lpDataBuffer); - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - - Error = RegSetValueExW(hDstKey, - lpNameBuffer, - 0, - dwType, - lpDataBuffer, - dwValueLength); - if (Error != ERROR_SUCCESS) - { - DPRINT1("Error: %lu\n", Error); - HeapFree(GetProcessHeap(), - 0, - lpDataBuffer); - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - SetLastError((DWORD)Error); - return FALSE; - } - } - - HeapFree(GetProcessHeap(), - 0, - lpDataBuffer); - - HeapFree(GetProcessHeap(), - 0, - lpNameBuffer); - } - - DPRINT("CopyKey() done\n"); - - return TRUE; -#endif }