Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/faultrep/tests/faultrep.c | 62 ++++------------------------------ 1 file changed, 6 insertions(+), 56 deletions(-)
diff --git a/dlls/faultrep/tests/faultrep.c b/dlls/faultrep/tests/faultrep.c index d0b30f70cf1..30664bd29be 100644 --- a/dlls/faultrep/tests/faultrep.c +++ b/dlls/faultrep/tests/faultrep.c @@ -36,65 +36,15 @@ static const char regpath_exclude[] = "ExclusionList";
static BOOL is_process_limited(void) { - static BOOL (WINAPI *pCheckTokenMembership)(HANDLE,PSID,PBOOL) = NULL; - static BOOL (WINAPI *pOpenProcessToken)(HANDLE, DWORD, PHANDLE) = NULL; - SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; - PSID Group; - BOOL IsInGroup; HANDLE token; + TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault; + DWORD size;
- if (!pOpenProcessToken) - { - HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll"); - pOpenProcessToken = (void*)GetProcAddress(hadvapi32, "OpenProcessToken"); - pCheckTokenMembership = (void*)GetProcAddress(hadvapi32, "CheckTokenMembership"); - if (!pCheckTokenMembership || !pOpenProcessToken) - { - /* Win9x (power to the masses) or NT4 (no way to know) */ - trace("missing pOpenProcessToken or CheckTokenMembership\n"); - return FALSE; - } - } - - if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, &Group) || - !pCheckTokenMembership(NULL, Group, &IsInGroup)) - { - trace("Could not check if the current user is an administrator\n"); - return FALSE; - } - FreeSid(Group); - if (!IsInGroup) - { - if (!AllocateAndInitializeSid(&NtAuthority, 2, - SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_POWER_USERS, - 0, 0, 0, 0, 0, 0, &Group) || - !pCheckTokenMembership(NULL, Group, &IsInGroup)) - { - trace("Could not check if the current user is a power user\n"); - return FALSE; - } - FreeSid(Group); - if (!IsInGroup) - { - /* Only administrators and power users can be powerful */ - return TRUE; - } - } + OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token); + GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size); + CloseHandle(token);
- if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) - { - BOOL ret; - TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault; - DWORD size; - - ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size); - CloseHandle(token); - return (ret && type == TokenElevationTypeLimited); - } - return FALSE; + return type == TokenElevationTypeLimited; }
If registry virtualization is enabled, AddERExcludedApplicationA succeeds on Windows 8 even if the user does not really have permission to write to HKLM\Software. The behind-the-scenes writes to HLKM\Software are treated like any other writes: They are silently redirected to HKCU\Software\Classes\VirtualStore\Machine\Software. Since AddERExcludedApplicationA still fails even with registry virtualization enabled on Vista, 7, and 10, Windows 8's behavior is clearly broken.
Fixes a testbot failure on 32-bit Windows 8 with a non-elevated administrator account.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/faultrep/tests/faultrep.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/faultrep/tests/faultrep.c b/dlls/faultrep/tests/faultrep.c index 30664bd29be..c71db80cdbb 100644 --- a/dlls/faultrep/tests/faultrep.c +++ b/dlls/faultrep/tests/faultrep.c @@ -47,6 +47,19 @@ static BOOL is_process_limited(void) return type == TokenElevationTypeLimited; }
+static BOOL is_registry_virtualization_enabled(void) +{ + HANDLE token; + DWORD enabled = FALSE; + DWORD size; + + OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token); + GetTokenInformation(token, TokenVirtualizationEnabled, &enabled, sizeof(enabled), &size); + CloseHandle(token); + + return enabled; +} +
/* ###### */
@@ -86,7 +99,8 @@ static void test_AddERExcludedApplicationA(void) if (is_process_limited()) { /* LastError is not set! */ - ok(!res, "AddERExcludedApplicationA should have failed got %d\n", res); + ok(!res || broken(is_registry_virtualization_enabled()) /* win8 */, + "AddERExcludedApplicationA should have failed, got %d\n", res); } else {
Why are we dropping them?
On Sun, Jan 2, 2022 at 12:44 AM Damjan Jovanovic damjan.jov@gmail.com wrote:
Why are we dropping them?
The Windows 2000 virtual machine was removed from the testbot years ago. It's a lot of work for practically no benefit to make sure that the tests keep passing on old and broken versions of Windows, especially when we can't use the testbot to test them. Besides, since I was adding new code here, I preferred to delete the old workarounds rather than add even more of them for the new code.
Of course, if someone else has a better explanation, feel free to chime in ;-)
-Alex