Commit 77fcaa4b authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Fix SHCopyKey to treat string parameter correctly as source path

instead of destination path.
parent 1e365f77
......@@ -2183,7 +2183,7 @@ HKEY WINAPI SHRegDuplicateHKey(HKEY hKey)
*
* PARAMS
* hKeySrc [I] Source key to copy from
* lpszSubKey [I] Sub key under hKeyDst, or NULL to use hKeyDst directly
* lpszSrcSubKey [I] Sub key under hKeySrc, or NULL to use hKeySrc directly
* hKeyDst [I] Destination key
* dwReserved [I] Reserved, must be 0
*
......@@ -2196,16 +2196,16 @@ HKEY WINAPI SHRegDuplicateHKey(HKEY hKey)
* (It will loop until out of stack, or the registry is full). This
* bug is present in Win32 also.
*/
DWORD WINAPI SHCopyKeyA(HKEY hKeySrc, LPCSTR lpszSubKey, HKEY hKeyDst, DWORD dwReserved)
DWORD WINAPI SHCopyKeyA(HKEY hKeySrc, LPCSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved)
{
WCHAR szSubKeyW[MAX_PATH];
TRACE("(hkey=%p,%s,%p08x,%ld)\n", hKeySrc, debugstr_a(lpszSubKey), hKeyDst, dwReserved);
TRACE("(hkey=%p,%s,%p08x,%ld)\n", hKeySrc, debugstr_a(lpszSrcSubKey), hKeyDst, dwReserved);
if (lpszSubKey)
MultiByteToWideChar(0, 0, lpszSubKey, -1, szSubKeyW, MAX_PATH);
if (lpszSrcSubKey)
MultiByteToWideChar(0, 0, lpszSrcSubKey, -1, szSubKeyW, MAX_PATH);
return SHCopyKeyW(hKeySrc, lpszSubKey ? szSubKeyW : NULL, hKeyDst, dwReserved);
return SHCopyKeyW(hKeySrc, lpszSrcSubKey ? szSubKeyW : NULL, hKeyDst, dwReserved);
}
/*************************************************************************
......@@ -2213,7 +2213,7 @@ DWORD WINAPI SHCopyKeyA(HKEY hKeySrc, LPCSTR lpszSubKey, HKEY hKeyDst, DWORD dwR
*
* See SHCopyKeyA.
*/
DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSubKey, HKEY hKeyDst, DWORD dwReserved)
DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved)
{
DWORD dwKeyCount = 0, dwValueCount = 0, dwMaxKeyLen = 0;
DWORD dwMaxValueLen = 0, dwMaxDataLen = 0, i;
......@@ -2222,18 +2222,18 @@ DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSubKey, HKEY hKeyDst, DWORD dw
WCHAR szName[MAX_PATH], *lpszName = szName;
DWORD dwRet = S_OK;
TRACE("hkey=%p,%s,%p08x,%ld)\n", hKeySrc, debugstr_w(lpszSubKey), hKeyDst, dwReserved);
TRACE("hkey=%p,%s,%p08x,%ld)\n", hKeySrc, debugstr_w(lpszSrcSubKey), hKeyDst, dwReserved);
if(!hKeyDst || !hKeySrc)
dwRet = ERROR_INVALID_PARAMETER;
else
{
/* Open destination key */
if(lpszSubKey)
dwRet = RegOpenKeyExW(hKeyDst, lpszSubKey, 0, KEY_ALL_ACCESS, &hKeyDst);
/* Open source key */
if(lpszSrcSubKey)
dwRet = RegOpenKeyExW(hKeySrc, lpszSrcSubKey, 0, KEY_ALL_ACCESS, &hKeySrc);
if(dwRet)
hKeyDst = 0; /* Don't close this key since we didn't open it */
hKeyDst = NULL; /* Don't close this key since we didn't open it */
else
{
/* Get details about sub keys and values */
......@@ -2303,7 +2303,7 @@ DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSubKey, HKEY hKeyDst, DWORD dw
if (lpBuff != buff)
HeapFree(GetProcessHeap(), 0, lpBuff);
if (lpszSubKey && hKeyDst)
if (lpszSrcSubKey && hKeyDst)
RegCloseKey(hKeyDst);
return dwRet;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment