2 * Unit test suite for fault reporting in XP and above
4 * Copyright 2010 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/test.h"
33 static const char regpath_root
[] = "Software\\Microsoft\\PCHealth\\ErrorReporting";
34 static const char regpath_exclude
[] = "ExclusionList";
37 static BOOL
is_process_limited(void)
40 TOKEN_ELEVATION_TYPE type
= TokenElevationTypeDefault
;
43 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
44 GetTokenInformation(token
, TokenElevationType
, &type
, sizeof(type
), &size
);
47 return type
== TokenElevationTypeLimited
;
50 static BOOL
is_registry_virtualization_enabled(void)
53 DWORD enabled
= FALSE
;
56 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
57 GetTokenInformation(token
, TokenVirtualizationEnabled
, &enabled
, sizeof(enabled
), &size
);
66 static void test_AddERExcludedApplicationA(void)
74 lres
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, regpath_root
, &hroot
);
77 lres
= RegOpenKeyA(hroot
, regpath_exclude
, &hexclude
);
80 RegDeleteValueA(hexclude
, "winetest_faultrep.exe");
83 SetLastError(0xdeadbeef);
84 res
= AddERExcludedApplicationA(NULL
);
85 ok(!res
, "got %d and 0x%lx (expected FALSE)\n", res
, GetLastError());
87 SetLastError(0xdeadbeef);
88 res
= AddERExcludedApplicationA("");
89 ok(!res
, "got %d and 0x%lx (expected FALSE)\n", res
, GetLastError());
91 SetLastError(0xdeadbeef);
92 /* existence of the path doesn't matter this function succeeded */
93 res
= AddERExcludedApplicationA("winetest_faultrep.exe");
94 if (is_process_limited())
96 /* LastError is not set! */
97 ok(!res
|| broken(is_registry_virtualization_enabled()) /* win8 */,
98 "AddERExcludedApplicationA should have failed, got %d\n", res
);
102 ok(res
, "AddERExcludedApplicationA failed (le=0x%lx)\n", GetLastError());
104 /* add, when already present */
105 SetLastError(0xdeadbeef);
106 res
= AddERExcludedApplicationA("winetest_faultrep.exe");
107 ok(res
, "AddERExcludedApplicationA failed (le=0x%lx)\n", GetLastError());
111 RegDeleteValueA(hexclude
, "winetest_faultrep.exe");
113 RegCloseKey(hexclude
);
117 /* ########################### */
121 test_AddERExcludedApplicationA();