shlwapi: Reject NULL key on SHRegCloseUSKey with tests.
This commit is contained in:
parent
519ad57cb5
commit
ffb4d15117
|
@ -193,6 +193,9 @@ LONG WINAPI SHRegCloseUSKey(
|
||||||
LPSHUSKEY hKey = hUSKey;
|
LPSHUSKEY hKey = hUSKey;
|
||||||
LONG ret = ERROR_SUCCESS;
|
LONG ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
if (!hKey)
|
||||||
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (hKey->HKCUkey)
|
if (hKey->HKCUkey)
|
||||||
ret = RegCloseKey(hKey->HKCUkey);
|
ret = RegCloseKey(hKey->HKCUkey);
|
||||||
if (hKey->HKCUstart && hKey->HKCUstart != HKEY_CURRENT_USER)
|
if (hKey->HKCUstart && hKey->HKCUstart != HKEY_CURRENT_USER)
|
||||||
|
|
|
@ -38,6 +38,8 @@ static DWORD (WINAPI *pSHCopyKeyA)(HKEY,LPCSTR,HKEY,DWORD);
|
||||||
static DWORD (WINAPI *pSHRegGetPathA)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD);
|
static DWORD (WINAPI *pSHRegGetPathA)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD);
|
||||||
static LSTATUS (WINAPI *pSHRegGetValueA)(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD);
|
static LSTATUS (WINAPI *pSHRegGetValueA)(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD);
|
||||||
static LSTATUS (WINAPI *pSHRegCreateUSKeyW)(LPCWSTR,REGSAM,HUSKEY,PHUSKEY,DWORD);
|
static LSTATUS (WINAPI *pSHRegCreateUSKeyW)(LPCWSTR,REGSAM,HUSKEY,PHUSKEY,DWORD);
|
||||||
|
static LSTATUS (WINAPI *pSHRegOpenUSKeyW)(LPCWSTR,REGSAM,HUSKEY,PHUSKEY,BOOL);
|
||||||
|
static LSTATUS (WINAPI *pSHRegCloseUSKey)(HUSKEY);
|
||||||
|
|
||||||
static const char sTestpath1[] = "%LONGSYSTEMVAR%\\subdir1";
|
static const char sTestpath1[] = "%LONGSYSTEMVAR%\\subdir1";
|
||||||
static const char sTestpath2[] = "%FOO%\\subdir1";
|
static const char sTestpath2[] = "%FOO%\\subdir1";
|
||||||
|
@ -458,6 +460,35 @@ static void test_SHRegCreateUSKeyW(void)
|
||||||
ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
|
ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_SHRegCloseUSKey(void)
|
||||||
|
{
|
||||||
|
static const WCHAR localW[] = {'S','o','f','t','w','a','r','e',0};
|
||||||
|
LONG ret;
|
||||||
|
HUSKEY key;
|
||||||
|
|
||||||
|
if (!pSHRegOpenUSKeyW || !pSHRegCloseUSKey)
|
||||||
|
{
|
||||||
|
win_skip("SHRegOpenUSKeyW or SHRegCloseUSKey not available\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = pSHRegCloseUSKey(NULL);
|
||||||
|
ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
|
||||||
|
|
||||||
|
ret = pSHRegOpenUSKeyW(localW, KEY_ALL_ACCESS, NULL, &key, FALSE);
|
||||||
|
ok(ret == ERROR_SUCCESS, "got %d\n", ret);
|
||||||
|
|
||||||
|
ret = pSHRegCloseUSKey(key);
|
||||||
|
ok(ret == ERROR_SUCCESS, "got %d\n", ret);
|
||||||
|
|
||||||
|
/* Test with limited rights, specially without KEY_SET_VALUE */
|
||||||
|
ret = pSHRegOpenUSKeyW(localW, KEY_QUERY_VALUE, NULL, &key, FALSE);
|
||||||
|
ok(ret == ERROR_SUCCESS, "got %d\n", ret);
|
||||||
|
|
||||||
|
ret = pSHRegCloseUSKey(key);
|
||||||
|
ok(ret == ERROR_SUCCESS, "got %d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(shreg)
|
START_TEST(shreg)
|
||||||
{
|
{
|
||||||
HKEY hkey = create_test_entries();
|
HKEY hkey = create_test_entries();
|
||||||
|
@ -476,6 +507,8 @@ START_TEST(shreg)
|
||||||
pSHRegGetPathA = (void*)GetProcAddress(hshlwapi,"SHRegGetPathA");
|
pSHRegGetPathA = (void*)GetProcAddress(hshlwapi,"SHRegGetPathA");
|
||||||
pSHRegGetValueA = (void*)GetProcAddress(hshlwapi,"SHRegGetValueA");
|
pSHRegGetValueA = (void*)GetProcAddress(hshlwapi,"SHRegGetValueA");
|
||||||
pSHRegCreateUSKeyW = (void*)GetProcAddress(hshlwapi, "SHRegCreateUSKeyW");
|
pSHRegCreateUSKeyW = (void*)GetProcAddress(hshlwapi, "SHRegCreateUSKeyW");
|
||||||
|
pSHRegOpenUSKeyW = (void*)GetProcAddress(hshlwapi, "SHRegOpenUSKeyW");
|
||||||
|
pSHRegCloseUSKey = (void*)GetProcAddress(hshlwapi, "SHRegCloseUSKey");
|
||||||
|
|
||||||
test_SHGetValue();
|
test_SHGetValue();
|
||||||
test_SHRegGetValue();
|
test_SHRegGetValue();
|
||||||
|
@ -484,6 +517,7 @@ START_TEST(shreg)
|
||||||
test_SHCopyKey();
|
test_SHCopyKey();
|
||||||
test_SHDeleteKey();
|
test_SHDeleteKey();
|
||||||
test_SHRegCreateUSKeyW();
|
test_SHRegCreateUSKeyW();
|
||||||
|
test_SHRegCloseUSKey();
|
||||||
|
|
||||||
delete_key( hkey, "Software\\Wine", "Test" );
|
delete_key( hkey, "Software\\Wine", "Test" );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue