faultrep/tests: Fix a test failure when the user has limited access rights.

This commit is contained in:
Detlef Riekenberg 2013-08-02 06:01:59 +02:00 committed by Alexandre Julliard
parent b9b6b0585f
commit c1f9129d7b
2 changed files with 11 additions and 7 deletions

View File

@ -53,14 +53,13 @@ static const WCHAR SZ_EXCLUSIONLIST_KEY[] = {
* Wine doesn't use this data but stores it in the registry (in the same place * Wine doesn't use this data but stores it in the registry (in the same place
* as Windows would) in case it will be useful in a future version * as Windows would) in case it will be useful in a future version
* *
* According to MSDN this function should succeed even if the user has no write
* access to HKLM. This probably means that there is no error checking.
*/ */
BOOL WINAPI AddERExcludedApplicationW(LPCWSTR lpAppFileName) BOOL WINAPI AddERExcludedApplicationW(LPCWSTR lpAppFileName)
{ {
WCHAR *bslash; WCHAR *bslash;
DWORD value = 1; DWORD value = 1;
HKEY hkey; HKEY hkey;
LONG res;
TRACE("(%s)\n", wine_dbgstr_w(lpAppFileName)); TRACE("(%s)\n", wine_dbgstr_w(lpAppFileName));
bslash = strrchrW(lpAppFileName, '\\'); bslash = strrchrW(lpAppFileName, '\\');
@ -72,13 +71,14 @@ BOOL WINAPI AddERExcludedApplicationW(LPCWSTR lpAppFileName)
return FALSE; return FALSE;
} }
if (!RegCreateKeyW(HKEY_LOCAL_MACHINE, SZ_EXCLUSIONLIST_KEY, &hkey)) res = RegCreateKeyW(HKEY_LOCAL_MACHINE, SZ_EXCLUSIONLIST_KEY, &hkey);
if (!res)
{ {
RegSetValueExW(hkey, lpAppFileName, 0, REG_DWORD, (LPBYTE)&value, sizeof(value)); RegSetValueExW(hkey, lpAppFileName, 0, REG_DWORD, (LPBYTE)&value, sizeof(value));
RegCloseKey(hkey); RegCloseKey(hkey);
} }
return TRUE; return !res;
} }
/************************************************************************* /*************************************************************************

View File

@ -43,7 +43,12 @@ static void test_AddERExcludedApplicationA(void)
HKEY hexclude = 0; HKEY hexclude = 0;
/* clean state */ /* clean state */
lres = RegOpenKeyExA(HKEY_LOCAL_MACHINE, regpath_root, 0, KEY_WRITE, &hroot); lres = RegCreateKeyA(HKEY_LOCAL_MACHINE, regpath_root, &hroot);
if (lres == ERROR_ACCESS_DENIED)
{
skip("Not enough access rights\n");
return;
}
if (!lres) if (!lres)
lres = RegOpenKeyA(hroot, regpath_exclude, &hexclude); lres = RegOpenKeyA(hroot, regpath_exclude, &hexclude);
@ -61,8 +66,7 @@ static void test_AddERExcludedApplicationA(void)
ok(!res, "got %d and 0x%x (expected FALSE)\n", res, GetLastError()); ok(!res, "got %d and 0x%x (expected FALSE)\n", res, GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
/* access rights to HKLM or existence of the path doesn't matter /* existence of the path doesn't matter this function succeeded */
this function succeeded */
res = AddERExcludedApplicationA("winetest_faultrep.exe"); res = AddERExcludedApplicationA("winetest_faultrep.exe");
ok(res, "got %d and 0x%x (expected TRUE)\n", res, GetLastError()); ok(res, "got %d and 0x%x (expected TRUE)\n", res, GetLastError());