Preserve staged helper builds and exclude hooks before attachment

This commit is contained in:
Storm Dragon committed 2026-10-31 15:21:01 -04:00
1 parent 0db42de77e
commit 989ecb681d
12 files changed
+267 -38

No files matched your search

+29
View File
@@ -33,6 +33,7 @@
#include <deque>
#include <iterator>
#include <string>
#include <vector>
namespace {
// Read directly by readers without starting Wine or initializing a prefix.
@@ -1146,7 +1147,20 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
bool validEndpoint = true;
std::string readerPath, readerInterface;
bool dialogReaderEnabled = true, controllerEnabled = true;
// Winelib WCHAR is 16-bit; avoid the host libc's wide-string ABI.
std::vector<wchar_t> excludedHookPrograms;
bool validHookExclusions = true;
for (int index = 1; index < argumentCount; ++index) {
if (lstrcmpW(arguments[index], L"--exclude-hook-program") == 0) {
if (++index == argumentCount || !arguments[index][0]) { validHookExclusions = false; break; }
for (const wchar_t *letter = arguments[index]; *letter; ++letter)
if (*letter == L'\n' || *letter == L'\r' || *letter == L'/' || *letter == L'\\')
validHookExclusions = false;
excludedHookPrograms.insert(excludedHookPrograms.end(), arguments[index],
arguments[index] + lstrlenW(arguments[index]));
excludedHookPrograms.push_back(L'\n');
continue;
}
if (lstrcmpW(arguments[index], L"--no-dialog-reader") == 0) {
dialogReaderEnabled = false;
continue;
@@ -1178,6 +1192,21 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
else { validReader = false; break; }
}
LocalFree(arguments);
if (!validHookExclusions) {
std::fprintf(stderr, "wine-access: --exclude-hook-program requires an executable basename\n");
return 1;
}
// The companion inherits this private list. Set it before launching either
// hook host, and reject oversized lists instead of silently losing protection.
if (!excludedHookPrograms.empty()) excludedHookPrograms.push_back(0);
if (excludedHookPrograms.empty())
SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDED_HOOK_PROGRAMS", nullptr);
if (excludedHookPrograms.size() >= 32767 ||
(!excludedHookPrograms.empty() && !SetEnvironmentVariableW(
L"WINE_ACCESS_EXCLUDED_HOOK_PROGRAMS", excludedHookPrograms.data()))) {
std::fprintf(stderr, "wine-access: cannot configure hook exclusions\n");
return 1;
}
if (!validReader) {
std::fprintf(stderr, "wine-access: --reader requires cthulhu or orca\n");
return 1;