Master goodies.
This commit is contained in:
commit
b51a08e7cc
13 files changed
+244
-46
No files matched your search
@@ -122,6 +122,13 @@ if(BUILD_TESTING)
|
||||
else()
|
||||
set(fixture_compiler "${MINGW_C_COMPILER}")
|
||||
endif()
|
||||
set(exclusions_test "${CMAKE_CURRENT_BINARY_DIR}/hook-exclusions${arch}.exe")
|
||||
add_custom_command(OUTPUT "${exclusions_test}"
|
||||
COMMAND "${fixture_compiler}" -std=c11 -O2 -Wall -Wextra
|
||||
-o "${exclusions_test}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/hook_exclusions_test.c" -luser32
|
||||
DEPENDS tests/hook_exclusions_test.c foreground_hooks.h hook_exclusions.h bootstrapper_hook.h VERBATIM)
|
||||
add_custom_target(hook-exclusions${arch} ALL DEPENDS "${exclusions_test}")
|
||||
add_wine_test(hook-exclusions${arch} 35 wine "${exclusions_test}")
|
||||
set(hook_fixture "${CMAKE_CURRENT_BINARY_DIR}/hook-safety-fixture${arch}.exe")
|
||||
add_custom_command(OUTPUT "${hook_fixture}"
|
||||
COMMAND "${fixture_compiler}" -std=c11 -O2 -Wall -Wextra -Wl,--stack,1048576
|
||||
|
||||
@@ -361,22 +361,26 @@ What a supervisor must get right for Proton prefixes:
|
||||
The home directory is bound at the same path in both namespaces: a
|
||||
user-local installation under `~/.local/libexec` works as-is, and the
|
||||
Orca extension stages a copy of a system installation under
|
||||
`~/.local/state/orca-wine-access/helper/` for such prefixes.
|
||||
`~/.local/state/orca-wine-access/helper/<content-hash>/` for such prefixes.
|
||||
Each staged directory contains a complete helper set and is left unchanged
|
||||
while older helpers or application hooks may still use it.
|
||||
|
||||
The Orca extension in this repository implements all of this. Cthulhu's
|
||||
supervisor needs the equivalent loader resolution in Cthulhu itself; until
|
||||
then, Protontricks-launched applications do not get a Cthulhu helper. To
|
||||
start the helper manually for a running game, use its Proton build and
|
||||
prefix, for example:
|
||||
prefix. Install the complete helper set under the user-local path first.
|
||||
Set `gameEsync` and `gameFsync` to the running game process's `WINEESYNC`
|
||||
and `WINEFSYNC` values (use an empty value when absent), for example:
|
||||
|
||||
```sh
|
||||
WINEPREFIX="$HOME/.local/share/Steam/steamapps/compatdata/<appid>/pfx" \
|
||||
WINELOADER="$HOME/.local/share/Steam/steamapps/common/Proton 11.0/files/bin/wine" \
|
||||
WINEESYNC=1 WINEFSYNC=1 \
|
||||
/usr/libexec/wine-access/wine-access.exe
|
||||
WINEESYNC="$gameEsync" WINEFSYNC="$gameFsync" \
|
||||
"$HOME/.local/libexec/wine-access/wine-access.exe"
|
||||
```
|
||||
|
||||
(add the reader options from above for Orca). Flatpak builds of Steam or
|
||||
Add the reader options from above for Orca. Flatpak builds of Steam or
|
||||
Protontricks are not supported: their sandboxes hide both the host helper
|
||||
installation and the game processes from the reader.
|
||||
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@ static inline void wine_access_update_hooks(WineAccessForegroundHooks *hooks, BO
|
||||
BOOL known = process && IsWow64Process(process, &wow64);
|
||||
// An excluded program's thread never receives the hooks; its controller
|
||||
// speech does not need them and its anti-tamper code may object to them.
|
||||
BOOL excluded = process && wine_access_process_hook_excluded(hooks->exclusions, process);
|
||||
// With exclusions configured, an unidentifiable target is not hooked.
|
||||
BOOL excluded = !wine_access_hooks_allowed(hooks->exclusions, process);
|
||||
if (process) CloseHandle(process);
|
||||
if (!known || wow64 != target_wow64 || excluded) thread = 0;
|
||||
if (thread == hooks->thread) return;
|
||||
|
||||
@@ -78,3 +78,16 @@ static inline BOOL wine_access_process_hook_excluded(const WineAccessHookExclusi
|
||||
if (!QueryFullProcessImageNameW(process, 0, path, &length)) return FALSE;
|
||||
return wine_access_hook_exclusions_match(list, path);
|
||||
}
|
||||
|
||||
// Hook attachment fails closed, independently of the reader's slower /proc
|
||||
// discovery: with exclusions configured, a target whose image cannot be
|
||||
// identified is treated as excluded. Both hook hosts use this guard.
|
||||
static inline BOOL wine_access_hooks_allowed(const WineAccessHookExclusions *list,
|
||||
HANDLE process) {
|
||||
if (!list || !list->count) return TRUE;
|
||||
if (!process) return FALSE;
|
||||
WCHAR path[4096];
|
||||
DWORD length = ARRAYSIZE(path);
|
||||
if (!QueryFullProcessImageNameW(process, 0, path, &length)) return FALSE;
|
||||
return !wine_access_hook_exclusions_match(list, path);
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <deque>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
// Read directly by readers without starting Wine or initializing a prefix.
|
||||
@@ -1226,12 +1227,22 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
|
||||
// exclusions there (or clear any inherited list) so both hook hosts gate
|
||||
// the same programs. Readers communicate them by argument only.
|
||||
if (hookExclusions.count) {
|
||||
std::wstring joined;
|
||||
// Winelib WCHAR is 16-bit; std::wstring would call the host libc's
|
||||
// 32-bit wide-string routines. Join with the Windows APIs instead.
|
||||
std::size_t joinedLength = 0;
|
||||
for (int index = 0; index < hookExclusions.count; ++index)
|
||||
joinedLength += lstrlenW(hookExclusions.names[index]) + 1;
|
||||
std::vector<WCHAR> joined(joinedLength);
|
||||
joined[0] = 0;
|
||||
for (int index = 0; index < hookExclusions.count; ++index) {
|
||||
if (index) joined += L';';
|
||||
joined += hookExclusions.names[index];
|
||||
if (index) lstrcatW(joined.data(), L";");
|
||||
lstrcatW(joined.data(), hookExclusions.names[index]);
|
||||
}
|
||||
if (joined.size() >= 32767 ||
|
||||
!SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDE_HOOK_PROGRAMS", joined.data())) {
|
||||
std::fprintf(stderr, "wine-access: cannot configure hook exclusions\n");
|
||||
return 1;
|
||||
}
|
||||
SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDE_HOOK_PROGRAMS", joined.c_str());
|
||||
std::fprintf(stderr, "wine-access: hook exclusions for %d program(s)\n", hookExclusions.count);
|
||||
} else {
|
||||
SetEnvironmentVariableW(L"WINE_ACCESS_EXCLUDE_HOOK_PROGRAMS", nullptr);
|
||||
|
||||
+14
-6
@@ -95,7 +95,8 @@ with the program's own loader, display and bus, and
|
||||
loader is resolved to the game's real Proton `files/bin/wine` (Protontricks'
|
||||
proxy `WINELOADER` is bypassed), the game's `WINEESYNC`/`WINEFSYNC` are
|
||||
forwarded so the helper joins the running server, and the helper set is
|
||||
staged under the state directory because the container's wineserver cannot
|
||||
staged as complete sets in separate content-hash directories under the
|
||||
state directory because the container's wineserver cannot
|
||||
see a system `/usr/libexec` installation; see the main README's Steam
|
||||
section.
|
||||
|
||||
@@ -108,11 +109,18 @@ preferences offer controller-only mode: helpers run with
|
||||
`--no-dialog-reader`, injecting nothing and polling no controls, while
|
||||
NVDA/Tolk speech and braille keep working. Enable it for all
|
||||
applications there, or list executable names (e.g. `Diablo IV.exe`) to
|
||||
apply it per game. Listed programs are also passed to every helper as
|
||||
`--exclude-hook-program` arguments, so the helper itself never hooks or
|
||||
dialog-reads them even in the first passes before a prefix's helper has been
|
||||
restarted controller-only. Settings are read when a helper starts, so neither
|
||||
Orca nor the reader needs a restart; relaunch the game to switch modes.
|
||||
apply it per game. Every helper receives the full list at startup as
|
||||
`--exclude-hook-program` arguments; both native hook hosts check the target
|
||||
executable before attachment, including when a game starts after its
|
||||
launcher, and listed programs are never dialog-read either. The supervisor
|
||||
also switches the prefix's helper to controller-only when it discovers a
|
||||
listed game.
|
||||
|
||||
Settings apply to newly started helpers. After changing the list, close the
|
||||
affected Wine applications, restart Orca to replace existing helpers, and then
|
||||
relaunch the applications. Restarting only the helper cannot remove hook DLLs
|
||||
already pinned inside an application. Names are matched case-insensitively by
|
||||
executable basename; directory paths are not accepted.
|
||||
`WINE_ACCESS_NO_DIALOG_READER=1` in Orca's environment forces the same
|
||||
mode for every helper, for testing.
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"""Prefix discovery and helper supervision against a fake /proc."""
|
||||
|
||||
import os
|
||||
import mmap
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -116,13 +117,14 @@ class DiscoveryTests(unittest.TestCase):
|
||||
def test_controller_only_arguments_accepts_tuple(self):
|
||||
# GSettings layers may hand string arrays back as tuples.
|
||||
self.assertEqual(controller_only_arguments({"game.exe"}, ("Game.EXE",), False),
|
||||
["--no-dialog-reader"])
|
||||
["--exclude-hook-program", "game.exe", "--no-dialog-reader"])
|
||||
|
||||
def test_controller_only_arguments_matching(self):
|
||||
self.assertEqual(controller_only_arguments({"game.exe"}, [], False), [])
|
||||
self.assertEqual(controller_only_arguments({"game.exe"}, ["Game.EXE"], False),
|
||||
["--no-dialog-reader"])
|
||||
self.assertEqual(controller_only_arguments({"other.exe"}, ["game.exe"], False), [])
|
||||
["--exclude-hook-program", "game.exe", "--no-dialog-reader"])
|
||||
self.assertEqual(controller_only_arguments({"other.exe"}, ["game.exe"], False),
|
||||
["--exclude-hook-program", "game.exe"])
|
||||
self.assertEqual(controller_only_arguments(set(), [], True),
|
||||
["--no-dialog-reader"])
|
||||
|
||||
@@ -326,6 +328,7 @@ class SupervisionTests(unittest.TestCase):
|
||||
self.assertEqual(helper.env["WINEFSYNC"], "1")
|
||||
|
||||
def test_steam_game_helper_uses_host_bus_not_container_proxy(self):
|
||||
self.make_helper()
|
||||
wine, preloader = self.fake.proton()
|
||||
self.fake.remove(20)
|
||||
self.fake.add_path(24, preloader, {
|
||||
@@ -366,20 +369,58 @@ class SupervisionTests(unittest.TestCase):
|
||||
}, r"S:\games\game.exe")
|
||||
self.manager.poll()
|
||||
self.assertEqual(len(self.spawned), 1)
|
||||
staged = self.fake.root / "logs" / "helper" / "wine-access.exe"
|
||||
self.assertEqual(self.spawned[0].command[0], str(staged))
|
||||
staged = Path(self.spawned[0].command[0])
|
||||
self.assertEqual(staged.parent.parent, self.fake.root / "logs" / "helper")
|
||||
self.assertEqual((staged.parent / "wine-access.exe.so").read_text(),
|
||||
"content of wine-access.exe.so")
|
||||
self.assertEqual((staged.parent / "wine-access-menu.dll").read_text(),
|
||||
"content of wine-access-menu.dll")
|
||||
|
||||
def make_helper(self):
|
||||
origin = self.fake.root / "installed"
|
||||
origin.mkdir()
|
||||
for name in ("wine-access.exe", "wine-access.exe.so", *manager_module.HELPER_SIBLINGS):
|
||||
(origin / name).write_bytes(b"old-build-content")
|
||||
(origin / name).chmod(0o755)
|
||||
self.manager.helper = str(origin / "wine-access.exe")
|
||||
return origin
|
||||
|
||||
def test_staging_update_preserves_running_mapping_and_complete_old_set(self):
|
||||
origin = self.make_helper()
|
||||
source = {"PRESSURE_VESSEL_RUNTIME": "steamrt4"}
|
||||
old = Path(self.manager._helper_for(source))
|
||||
self.assertEqual(self.manager._helper_for(source), str(old))
|
||||
with (old.parent / "wine-access.exe.so").open("rb") as file:
|
||||
with mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) as mapping:
|
||||
for path in origin.iterdir():
|
||||
path.write_bytes(b"NEW-build-content")
|
||||
new = Path(self.manager._helper_for(source))
|
||||
self.assertNotEqual(old.parent, new.parent)
|
||||
self.assertEqual(mapping[:], b"old-build-content")
|
||||
for path in new.parent.iterdir():
|
||||
self.assertEqual(path.read_bytes(), b"NEW-build-content")
|
||||
for path in old.parent.iterdir():
|
||||
self.assertEqual(path.read_bytes(), b"old-build-content")
|
||||
|
||||
def test_missing_helper_sibling_prevents_spawn_and_backs_off(self):
|
||||
origin = self.make_helper()
|
||||
self.manager._helper_for({"PRESSURE_VESSEL_RUNTIME": "steamrt4"})
|
||||
(origin / "wine-access-menu32.dll").unlink()
|
||||
self.fake.remove(20)
|
||||
self.fake.add(20, "wine", {"WINEPREFIX": "/p/game", "DISPLAY": ":7",
|
||||
"PRESSURE_VESSEL_RUNTIME": "steamrt4"})
|
||||
self.manager.poll()
|
||||
self.assertEqual(self.spawned, [])
|
||||
self.assertGreater(self.manager.prefixes[self.prefix].next_start, self.now)
|
||||
|
||||
def test_listed_program_starts_controller_only_helper(self):
|
||||
self.manager.arguments_for = (
|
||||
lambda programs: controller_only_arguments(programs, ["App.EXE"]))
|
||||
self.manager.poll()
|
||||
self.assertEqual(len(self.spawned), 1)
|
||||
self.assertEqual(self.spawned[0].command,
|
||||
["/helper.exe", "--reader", "orca", "--no-dialog-reader"])
|
||||
["/helper.exe", "--reader", "orca", "--exclude-hook-program",
|
||||
"app.exe", "--no-dialog-reader"])
|
||||
|
||||
def test_listed_program_appearing_later_restarts_controller_only(self):
|
||||
# A loader process can be discovered before the game itself, so a
|
||||
@@ -390,6 +431,8 @@ class SupervisionTests(unittest.TestCase):
|
||||
self.manager.poll()
|
||||
self.assertEqual(len(self.spawned), 1)
|
||||
self.assertNotIn("--no-dialog-reader", self.spawned[0].command)
|
||||
self.assertEqual(self.spawned[0].command[-2:],
|
||||
["--exclude-hook-program", "game.exe"])
|
||||
self.fake.add(26, "wine", {"WINEPREFIX": "/p/game", "DISPLAY": ":7"},
|
||||
r"S:\games\Game.exe")
|
||||
self.manager.poll()
|
||||
|
||||
@@ -17,7 +17,7 @@ from orca.extension import Extension
|
||||
from orca.extension_preferences import ExtensionPreference
|
||||
|
||||
from .manager import (HelperManager, controller_only_arguments,
|
||||
excluded_hook_arguments, extra_helper_arguments)
|
||||
extra_helper_arguments)
|
||||
from .presenter import WineEvent, WineEventPresenter
|
||||
from .review import DialogReader, gio_capture
|
||||
from .service import INTERFACE, OBJECT_PATH, WineAccessInterface
|
||||
@@ -68,7 +68,8 @@ class WineAccess(Extension):
|
||||
"Controller-only helpers serve NVDA/Tolk speech without "
|
||||
"injecting hooks or reading standard controls. Use it for "
|
||||
"games whose anti-tamper code objects to injected hooks. "
|
||||
"Changes apply the next time a helper starts."),
|
||||
"Changes apply to new helpers. Close Wine applications and restart Orca "
|
||||
"before relaunching them to apply a changed list."),
|
||||
]
|
||||
|
||||
def _helper_arguments(self, programs: set[str]) -> list[str]:
|
||||
@@ -76,8 +77,7 @@ class WineAccess(Extension):
|
||||
|
||||
always = self.settings.get("controller-only", False)
|
||||
listed = self.settings.get("controller-only-programs", [])
|
||||
return [*excluded_hook_arguments(listed),
|
||||
*controller_only_arguments(programs, listed, always is True)]
|
||||
return controller_only_arguments(programs, listed, always is True)
|
||||
|
||||
# Extension lifecycle
|
||||
|
||||
|
||||
+37
-17
@@ -16,6 +16,7 @@ from pathlib import Path
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
from typing import Callable
|
||||
|
||||
@@ -98,10 +99,15 @@ def controller_only_arguments(programs: set[str], listed,
|
||||
"""
|
||||
|
||||
names = {name.lower() for name in listed
|
||||
if isinstance(name, str)} if isinstance(listed, (list, tuple)) else set()
|
||||
if isinstance(name, str) and name and not any(
|
||||
char in name for char in "\n\r\0/\\")
|
||||
} if isinstance(listed, (list, tuple)) else set()
|
||||
# Every helper must know the exclusions before a game exists in /proc.
|
||||
# The native hosts check these names before injecting either hook.
|
||||
arguments = excluded_hook_arguments(listed)
|
||||
if always or programs & names:
|
||||
return ["--no-dialog-reader"]
|
||||
return []
|
||||
arguments.append("--no-dialog-reader")
|
||||
return arguments
|
||||
|
||||
|
||||
def excluded_hook_arguments(listed) -> list[str]:
|
||||
@@ -390,22 +396,36 @@ class HelperManager:
|
||||
if "PRESSURE_VESSEL_RUNTIME" not in source:
|
||||
return self.helper
|
||||
origin = Path(self.helper)
|
||||
stage = self.log_directory / "helper"
|
||||
try:
|
||||
stage.mkdir(parents=True, exist_ok=True)
|
||||
names = [origin.name, origin.name + ".so", *HELPER_SIBLINGS]
|
||||
for name in names:
|
||||
source_file = origin.parent / name
|
||||
target = stage / name
|
||||
if not source_file.is_file():
|
||||
continue
|
||||
if target.is_file() and target.read_bytes() == source_file.read_bytes():
|
||||
continue
|
||||
shutil.copy2(source_file, target)
|
||||
# Read the complete set before publishing anything. Missing files are
|
||||
# a failed start, never a reason to reuse stale staged siblings.
|
||||
contents = {name: (origin.parent / name).read_bytes() for name in names}
|
||||
digest = hashlib.sha256()
|
||||
for name, data in contents.items():
|
||||
digest.update(name.encode() + b"\0")
|
||||
digest.update(len(data).to_bytes(8, "big"))
|
||||
digest.update(data)
|
||||
stageRoot = self.log_directory / "helper"
|
||||
stageRoot.mkdir(parents=True, exist_ok=True)
|
||||
stage = stageRoot / digest.hexdigest()
|
||||
if not stage.exists():
|
||||
with tempfile.TemporaryDirectory(prefix=".stage-", dir=stageRoot) as temporary:
|
||||
pending = Path(temporary) / "complete"
|
||||
pending.mkdir()
|
||||
for name, data in contents.items():
|
||||
target = pending / name
|
||||
target.write_bytes(data)
|
||||
target.chmod(0o755 if os.access(origin.parent / name, os.X_OK) else 0o644)
|
||||
try:
|
||||
pending.rename(stage)
|
||||
except OSError:
|
||||
return self.helper
|
||||
staged = stage / origin.name
|
||||
return str(staged) if staged.is_file() else self.helper
|
||||
# Another supervisor may have published the identical set.
|
||||
if not stage.is_dir():
|
||||
raise
|
||||
for name, data in contents.items():
|
||||
if (stage / name).read_bytes() != data:
|
||||
raise OSError("Incomplete or modified staged Wine Access helper")
|
||||
return str(stage / origin.name)
|
||||
|
||||
def _command(self, source: dict[str, str], programs: set[str]) -> list[str]:
|
||||
return [self._helper_for(source), *self.reader_arguments,
|
||||
|
||||
@@ -829,3 +829,39 @@ D-Bus events do not establish audible speech or physical Braille acceptance.
|
||||
If the helper reports that the reader service is unavailable, verify its
|
||||
session bus matches Cthulhu's, even when the application was launched from a
|
||||
different bus. The reader's helper launcher owns that environment policy.
|
||||
|
||||
## Proton staging and pre-attachment exclusions
|
||||
|
||||
Run `python3 -m unittest discover -s orca/tests -p 'test_*.py'` for manager,
|
||||
installed-Orca lifecycle, and existing presentation/review checks. Manager
|
||||
regressions cover complete staged sets, preservation of an older memory-mapped
|
||||
sidecar across an update, missing-file startup failure/backoff, and passing
|
||||
exclusions to a launcher helper before a listed game is discovered.
|
||||
|
||||
Build normally, then run `xvfb-run -a ctest --test-dir build --output-on-failure`.
|
||||
The hook-exclusions32/64 fixtures exercise actual process-image lookup,
|
||||
case-insensitive basename matching, multiple entries, and refusal when a
|
||||
configured target cannot be identified. These check the shared guard used by
|
||||
both native hook hosts; they do not establish anti-tamper compatibility.
|
||||
|
||||
Run the actual attachment checks sequentially on a private display:
|
||||
|
||||
```sh
|
||||
xvfb-run -a python3 tests/menu_integration.py --build-dir build --fixture hooks --exclude-hooks
|
||||
xvfb-run -a python3 tests/menu_integration.py --build-dir build --fixture hooks --exclude-hooks --32-bit
|
||||
```
|
||||
|
||||
These start a full helper before an excluded executable, exercise foreground
|
||||
switches, and assert that neither native hook DLL is loaded into that process.
|
||||
The executable name contains a space and differs in case from the exclusion.
|
||||
Run the same checks without `--exclude-hooks` to verify normal attachment.
|
||||
|
||||
For live acceptance, configure an exclusion before starting helpers, launch a
|
||||
game through its launcher, and verify that its process never loads either
|
||||
Wine Access hook DLL while NVDA/Tolk announcements continue. Check both
|
||||
architectures where available. Also test two Proton prefixes across a helper
|
||||
upgrade: the earlier process must retain its original files while the later
|
||||
one uses a separate complete set. Check ordinary Wine menus, editor navigation,
|
||||
password exclusion, speech and Braille separately. After changing exclusions,
|
||||
close affected applications and restart Orca before relaunching them; pinned
|
||||
DLLs cannot be removed by a helper restart.
|
||||
@@ -0,0 +1,38 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
#include "../foreground_hooks.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;";
|
||||
lstrcatW(listed, name);
|
||||
lstrcatW(listed, L";Third Game.exe");
|
||||
static WineAccessHookExclusions multiple;
|
||||
assert(wine_access_hook_exclusions_parse(&multiple, listed) == 3);
|
||||
assert(!wine_access_hooks_allowed(&multiple, process));
|
||||
puts("PASS: hook exclusions check the actual process before attachment");
|
||||
return 0;
|
||||
}
|
||||
@@ -72,6 +72,9 @@ int main(void) {
|
||||
pump(600);
|
||||
BOOL restored = GetForegroundWindow() == window && attached_on_focus(window);
|
||||
BOOL detached = !SendMessageW(worker_window, WM_APP, 0, 0);
|
||||
BOOL excluded = GetEnvironmentVariableA("WINE_ACCESS_EXPECT_NO_HOOKS", NULL, 0) != 0;
|
||||
BOOL loaded = GetModuleHandleW(L"wine-access-menu.dll") != NULL ||
|
||||
GetModuleHandleW(L"wine-access-menu32.dll") != NULL;
|
||||
printf("hook scope: initial=%d background=%d switched=%d old-thread=%d restored=%d detached=%d\n",
|
||||
first, background, switched, old_thread, restored, detached);
|
||||
PostMessageW(worker_window, WM_CLOSE, 0, 0);
|
||||
@@ -79,5 +82,9 @@ int main(void) {
|
||||
CloseHandle(thread);
|
||||
CloseHandle(ready);
|
||||
DestroyWindow(window);
|
||||
if (excluded) {
|
||||
printf("excluded process: hook DLL loaded=%d\n", loaded);
|
||||
return !first && !background && !switched && !old_thread && !restored && detached && !loaded ? 0 : 5;
|
||||
}
|
||||
return first && !background && switched && !old_thread && restored && detached ? 0 : 4;
|
||||
}
|
||||
@@ -26,8 +26,11 @@ parser.add_argument("--goldwave-exe", type=Path)
|
||||
parser.add_argument("--32-bit", dest="is32Bit", action="store_true")
|
||||
parser.add_argument("--late-helper", action="store_true")
|
||||
parser.add_argument("--restart-helper", action="store_true")
|
||||
parser.add_argument("--exclude-hooks", action="store_true")
|
||||
add_test_options(parser)
|
||||
args = parser.parse_args()
|
||||
if args.exclude_hooks and args.fixture != "hooks":
|
||||
parser.error("--exclude-hooks requires --fixture hooks")
|
||||
if args.is32Bit and args.fixture not in ("menu", "edit", "hooks", "winforms", "list", "listbox", "delphi", "controls", "foobar-controls", "bootstrapper"):
|
||||
parser.error("32-bit checks currently require --fixture menu, edit, hooks, winforms, list, listbox, delphi, controls or bootstrapper")
|
||||
if (args.late_helper or args.restart_helper) and args.fixture not in ("edit", "winforms", "scintilla"):
|
||||
@@ -47,13 +50,16 @@ if not args.session:
|
||||
*(["--goldwave-exe", str(args.goldwave_exe.resolve())] if args.goldwave_exe else []),
|
||||
*(["--32-bit"] if args.is32Bit else []),
|
||||
*(["--late-helper"] if args.late_helper else []),
|
||||
*(["--restart-helper"] if args.restart_helper else [])], build, "menu_integration",
|
||||
*(["--restart-helper"] if args.restart_helper else []),
|
||||
*(["--exclude-hooks"] if args.exclude_hooks else [])], build, "menu_integration",
|
||||
keep=args.keep, keepOnFailure=args.keepOnFailure))
|
||||
|
||||
busName = "org.gnome.Orca1.Service" if args.reader == "orca" else "org.stormux.Cthulhu1.Service"
|
||||
interface = busName.rsplit(".", 1)[0] + ".WineAccess" if args.extension_endpoint else busName
|
||||
object_path = "/" + busName.replace(".", "/") + ("/WineAccess" if args.extension_endpoint else "")
|
||||
readerArguments = ["--reader", args.reader] if args.reader else []
|
||||
if args.exclude_hooks:
|
||||
readerArguments += ["--exclude-hook-program", "EXCLUDED GAME.EXE"]
|
||||
if args.extension_endpoint:
|
||||
readerArguments += ["--reader-path", object_path, "--reader-interface", interface]
|
||||
xml = '<node><interface name="' + interface + '"><method name="PresentAccessibleEvent">'
|
||||
@@ -103,7 +109,10 @@ with wine_test_directory(prefix="wine-access-menus-") as temporary:
|
||||
"x" * 1100000 + "\r\n" + "x" * 1022 + "😀tail").encode("utf-8"))
|
||||
env["WINE_ACCESS_NOTEPADPP_EXE"] = "Z:" + str(appDir / args.notepadpp_exe.name).replace("/", "\\")
|
||||
env["WINE_ACCESS_SCINTILLA_DOCUMENT"] = "Z:" + str(document).replace("/", "\\")
|
||||
fixture = Path(temporary) / ("foobar2000.exe" if args.fixture == "foobar-controls" else "menu-fixture.exe")
|
||||
fixture = Path(temporary) / ("Excluded Game.exe" if args.exclude_hooks else
|
||||
"foobar2000.exe" if args.fixture == "foobar-controls" else "menu-fixture.exe")
|
||||
if args.exclude_hooks:
|
||||
env["WINE_ACCESS_EXPECT_NO_HOOKS"] = "1"
|
||||
compiler = "i686-w64-mingw32-gcc" if args.is32Bit or args.fixture == "goldwave" else "x86_64-w64-mingw32-gcc"
|
||||
sourceName = "edit" if args.fixture == "winforms" else "controls" if args.fixture == "foobar-controls" else args.fixture
|
||||
if args.fixture == "delphi":
|
||||
@@ -158,7 +167,8 @@ with wine_test_directory(prefix="wine-access-menus-") as temporary:
|
||||
pass
|
||||
time.sleep(0.01)
|
||||
if args.fixture == "hooks":
|
||||
print("PASS: hooks follow only the foreground UI thread, detach and reattach")
|
||||
print("PASS: excluded process never loads hook DLLs" if args.exclude_hooks else
|
||||
"PASS: hooks follow only the foreground UI thread, detach and reattach")
|
||||
sys.exit(0)
|
||||
focused = None
|
||||
for event in events:
|
||||
|
||||
Reference in new issue
Block a user