// SPDX-License-Identifier: LGPL-2.1-or-later #include "../foreground_hooks.h" #include #include int main(void) { HANDLE process = GetCurrentProcess(); WCHAR image[32768]; DWORD length = 32768; assert(QueryFullProcessImageNameW(process, 0, image, &length)); WCHAR *name = image; for (DWORD index = 0; index < length; ++index) if (image[index] == L'\\' || image[index] == L'/') name = image + index + 1; static WineAccessHookExclusions empty; assert(wine_access_hooks_allowed(&empty, process)); assert(wine_access_hooks_allowed(&empty, NULL)); static WineAccessHookExclusions other; assert(wine_access_hook_exclusions_add(&other, L"Other Game.exe")); assert(wine_access_hooks_allowed(&other, process)); // With exclusions configured, an unidentifiable target fails closed. assert(!wine_access_hooks_allowed(&other, NULL)); static WineAccessHookExclusions own; assert(wine_access_hook_exclusions_add(&own, name)); assert(!wine_access_hooks_allowed(&own, process)); CharUpperBuffW(name, lstrlenW(name)); static WineAccessHookExclusions upper; assert(wine_access_hook_exclusions_add(&upper, name)); assert(!wine_access_hooks_allowed(&upper, process)); WCHAR listed[32768] = L"Other; Game.exe\n"; lstrcatW(listed, name); lstrcatW(listed, L"\nThird Game.exe"); static WineAccessHookExclusions multiple; assert(wine_access_hook_exclusions_parse(&multiple, listed) == 3); assert(wine_access_hook_exclusions_match(&multiple, L"Other; Game.exe")); assert(!wine_access_hooks_allowed(&multiple, process)); puts("PASS: hook exclusions check the actual process before attachment"); return 0; }