// 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; SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDED_HOOK_PROGRAMS", NULL); assert(wine_access_hooks_allowed(process)); assert(SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDED_HOOK_PROGRAMS", L"Other Game.exe\n")); assert(wine_access_hooks_allowed(process)); assert(!wine_access_hooks_allowed(NULL)); assert(SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDED_HOOK_PROGRAMS", name)); assert(!wine_access_hooks_allowed(process)); CharUpperBuffW(name, lstrlenW(name)); assert(SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDED_HOOK_PROGRAMS", name)); assert(!wine_access_hooks_allowed(process)); WCHAR listed[32768] = L"Other Game.exe\n"; lstrcatW(listed, name); lstrcatW(listed, L"\nThird Game.exe\n"); assert(SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDED_HOOK_PROGRAMS", listed)); assert(!wine_access_hooks_allowed(process)); SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDED_HOOK_PROGRAMS", NULL); puts("PASS: hook exclusions check the actual process before attachment"); return 0; }