Merged from branch deedra after conflict fixes.
This commit is contained in:
commit
2dfd5b200a
15 files changed
+494
-152
No files matched your search
+11
-3
@@ -15,7 +15,7 @@ find_program(MINGW32_C_COMPILER i686-w64-mingw32-gcc REQUIRED)
|
|||||||
# GLib dependencies. Keep it alongside the Winelib helper.
|
# GLib dependencies. Keep it alongside the Winelib helper.
|
||||||
set(menu_hook "${CMAKE_CURRENT_BINARY_DIR}/wine-access-menu.dll")
|
set(menu_hook "${CMAKE_CURRENT_BINARY_DIR}/wine-access-menu.dll")
|
||||||
add_custom_command(OUTPUT "${menu_hook}"
|
add_custom_command(OUTPUT "${menu_hook}"
|
||||||
COMMAND "${MINGW_C_COMPILER}" -std=c11 -O2 -Wall -Wextra -shared
|
COMMAND "${MINGW_C_COMPILER}" -std=c11 -O2 -g -fno-omit-frame-pointer -Wall -Wextra -shared
|
||||||
-static-libgcc -o "${menu_hook}" "${CMAKE_CURRENT_SOURCE_DIR}/menu_hook.c"
|
-static-libgcc -o "${menu_hook}" "${CMAKE_CURRENT_SOURCE_DIR}/menu_hook.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/edit_hook.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/edit_hook.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/scintilla_hook.c" -luser32 -lcomctl32 -lgdi32
|
"${CMAKE_CURRENT_SOURCE_DIR}/scintilla_hook.c" -luser32 -lcomctl32 -lgdi32
|
||||||
@@ -28,7 +28,7 @@ add_custom_target(wine-access-menu ALL DEPENDS "${menu_hook}")
|
|||||||
set(menu_hook32 "${CMAKE_CURRENT_BINARY_DIR}/wine-access-menu32.dll")
|
set(menu_hook32 "${CMAKE_CURRENT_BINARY_DIR}/wine-access-menu32.dll")
|
||||||
set(menu_host32 "${CMAKE_CURRENT_BINARY_DIR}/wine-access-menu-host32.exe")
|
set(menu_host32 "${CMAKE_CURRENT_BINARY_DIR}/wine-access-menu-host32.exe")
|
||||||
add_custom_command(OUTPUT "${menu_hook32}" "${menu_host32}"
|
add_custom_command(OUTPUT "${menu_hook32}" "${menu_host32}"
|
||||||
COMMAND "${MINGW32_C_COMPILER}" -std=c11 -O2 -Wall -Wextra -shared
|
COMMAND "${MINGW32_C_COMPILER}" -std=c11 -O2 -g -fno-omit-frame-pointer -Wall -Wextra -shared
|
||||||
-static-libgcc -Wl,--kill-at -o "${menu_hook32}"
|
-static-libgcc -Wl,--kill-at -o "${menu_hook32}"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/menu_hook.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/menu_hook.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/edit_hook.c" -luser32 -lcomctl32
|
"${CMAKE_CURRENT_SOURCE_DIR}/edit_hook.c" -luser32 -lcomctl32
|
||||||
@@ -37,7 +37,7 @@ add_custom_command(OUTPUT "${menu_hook32}" "${menu_host32}"
|
|||||||
COMMAND "${MINGW32_C_COMPILER}" -std=c11 -O2 -Wall -Wextra -mwindows
|
COMMAND "${MINGW32_C_COMPILER}" -std=c11 -O2 -Wall -Wextra -mwindows
|
||||||
-static-libgcc -o "${menu_host32}"
|
-static-libgcc -o "${menu_host32}"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/menu_host32.c" -luser32
|
"${CMAKE_CURRENT_SOURCE_DIR}/menu_host32.c" -luser32
|
||||||
DEPENDS menu_hook.c menu_bridge.h notification_hook.c notification_hook.h bootstrapper_hook.c bootstrapper_hook.h menu_host32.c edit_hook.c edit_hook.h control_class.h
|
DEPENDS menu_hook.c menu_bridge.h notification_hook.c notification_hook.h bootstrapper_hook.c bootstrapper_hook.h menu_host32.c foreground_hooks.h edit_hook.c edit_hook.h control_class.h
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
add_custom_target(wine-access-menu32 ALL DEPENDS "${menu_hook32}" "${menu_host32}")
|
add_custom_target(wine-access-menu32 ALL DEPENDS "${menu_hook32}" "${menu_host32}")
|
||||||
|
|
||||||
@@ -112,6 +112,12 @@ if(BUILD_TESTING)
|
|||||||
else()
|
else()
|
||||||
set(fixture_compiler "${MINGW_C_COMPILER}")
|
set(fixture_compiler "${MINGW_C_COMPILER}")
|
||||||
endif()
|
endif()
|
||||||
|
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
|
||||||
|
-o "${hook_fixture}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/hook_safety_fixture.c" -luser32 -lcomctl32
|
||||||
|
DEPENDS tests/hook_safety_fixture.c edit_hook.h VERBATIM)
|
||||||
|
add_custom_target(hook-safety-fixture${arch} ALL DEPENDS "${hook_fixture}")
|
||||||
set(review_fixture "${CMAKE_CURRENT_BINARY_DIR}/review-fixture${arch}.exe")
|
set(review_fixture "${CMAKE_CURRENT_BINARY_DIR}/review-fixture${arch}.exe")
|
||||||
add_custom_command(OUTPUT "${review_fixture}"
|
add_custom_command(OUTPUT "${review_fixture}"
|
||||||
COMMAND "${fixture_compiler}" -std=c11 -Wall -Wextra -mwindows
|
COMMAND "${fixture_compiler}" -std=c11 -Wall -Wextra -mwindows
|
||||||
@@ -122,6 +128,8 @@ if(BUILD_TESTING)
|
|||||||
add_wine_test(review-capture${arch} 35
|
add_wine_test(review-capture${arch} 35
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/review-capture-test.exe" --fixture "${review_fixture}")
|
"${CMAKE_CURRENT_BINARY_DIR}/review-capture-test.exe" --fixture "${review_fixture}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
add_wine_test(hook-safety 100 python3
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/tests/hook_safety_test.py" "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Winegcc emits a launcher and a Winelib sidecar. CMake's normal target
|
# Winegcc emits a launcher and a Winelib sidecar. CMake's normal target
|
||||||
|
|||||||
@@ -139,9 +139,11 @@ record; replacing files on disk does not update the running process.
|
|||||||
Ordinary startup writes `wine-access: identity` and `wine-access: ready` JSON
|
Ordinary startup writes `wine-access: identity` and `wine-access: ready` JSON
|
||||||
records to stderr. Identity is emitted even when later startup fails. The ready
|
records to stderr. Identity is emitted even when later startup fails. The ready
|
||||||
record means initialization reached the message loop; inspect its individual
|
record means initialization reached the message loop; inspect its individual
|
||||||
booleans for unavailable components. Hook handles and `host32_started` report
|
booleans for unavailable components. `menu_hook_available` and
|
||||||
installation/launch success, not attachment to a particular application or
|
`input_hook_available` report whether the native callbacks loaded. `menu_hook`
|
||||||
confirmation that the companion installed its hooks. Failures retain concise
|
and `input_hook` report foreground hook installation at startup; they may be
|
||||||
|
false until a matching foreground application appears. `host32_started` reports
|
||||||
|
companion launch, not confirmation that it attached its hooks. Failures retain concise
|
||||||
`wine-access:` diagnostics without accessible event text or password values.
|
`wine-access:` diagnostics without accessible event text or password values.
|
||||||
Reader replies that merely filter duplicate/unwanted events are not errors.
|
Reader replies that merely filter duplicate/unwanted events are not errors.
|
||||||
|
|
||||||
@@ -291,10 +293,11 @@ shortcuts, submenu roles, and checked/unavailable states to the helper. The
|
|||||||
helper queues these messages before forwarding them over D-Bus, suppresses
|
helper queues these messages before forwarding them over D-Bus, suppresses
|
||||||
repeated selections, and restores standard-control focus reporting when menus
|
repeated selections, and restores standard-control focus reporting when menus
|
||||||
close. The hooks apply to the helper's Wine desktop and prefix and are removed
|
close. The hooks apply to the helper's Wine desktop and prefix and are removed
|
||||||
on normal shutdown. The 32-bit host attaches to the foreground 32-bit UI thread
|
on normal shutdown. Each host attaches both hooks only to the foreground UI
|
||||||
so Wine's global hook chain cannot interfere with 64-bit menus. It exits when the helper dies or its bridge
|
thread of the matching architecture, releasing them when focus moves away.
|
||||||
window closes. Menu and editor hooks are disabled by `--no-dialog-reader`. The
|
This avoids synchronous cross-architecture traffic through Wine's global hook
|
||||||
32-bit companion attaches both hooks to the same foreground UI thread.
|
chain. The 32-bit host exits when the helper dies or its bridge window closes.
|
||||||
|
Menu and editor hooks are disabled by `--no-dialog-reader`.
|
||||||
|
|
||||||
Focused combo boxes are checked every 100 ms to recover value changes that
|
Focused combo boxes are checked every 100 ms to recover value changes that
|
||||||
Wine does not report through WinEvents. The combo's internal list events use
|
Wine does not report through WinEvents. The combo's internal list events use
|
||||||
|
|||||||
+11
-2
@@ -19,7 +19,7 @@ static void read_toggle(IRawElementProviderSimple *root) {
|
|||||||
IRawElementProviderSimple *provider = NULL;
|
IRawElementProviderSimple *provider = NULL;
|
||||||
IUnknown *pattern = NULL;
|
IUnknown *pattern = NULL;
|
||||||
IToggleProvider *toggle = NULL;
|
IToggleProvider *toggle = NULL;
|
||||||
VARIANT type = {0}, name = {0};
|
VARIANT type = {0}, name = {0}, enabled = {0}, password = {0};
|
||||||
enum ToggleState state;
|
enum ToggleState state;
|
||||||
if (FAILED(IRawElementProviderSimple_QueryInterface(root, &IID_IRawElementProviderFragmentRoot,
|
if (FAILED(IRawElementProviderSimple_QueryInterface(root, &IID_IRawElementProviderFragmentRoot,
|
||||||
(void **)&fragmentRoot)) || !fragmentRoot) goto done;
|
(void **)&fragmentRoot)) || !fragmentRoot) goto done;
|
||||||
@@ -36,8 +36,16 @@ static void read_toggle(IRawElementProviderSimple *root) {
|
|||||||
name.vt != VT_BSTR || !name.bstrVal || GetForegroundWindow() != queryWindow) goto done;
|
name.vt != VT_BSTR || !name.bstrVal || GetForegroundWindow() != queryWindow) goto done;
|
||||||
WineAccessBootstrapperState event = {0};
|
WineAccessBootstrapperState event = {0};
|
||||||
event.owner = (ULONGLONG)(UINT_PTR)queryWindow;
|
event.owner = (ULONGLONG)(UINT_PTR)queryWindow;
|
||||||
event.tick = GetTickCount64();
|
|
||||||
event.state = state;
|
event.state = state;
|
||||||
|
// Copy all checkbox state on this UI thread. Mixing a newer Toggle value
|
||||||
|
// with flags from the asynchronous UIA worker can announce a false change.
|
||||||
|
if (SUCCEEDED(IRawElementProviderSimple_GetPropertyValue(provider, UIA_IsEnabledPropertyId, &enabled)) &&
|
||||||
|
enabled.vt == VT_BOOL && enabled.boolVal == VARIANT_FALSE)
|
||||||
|
event.flags |= WINE_ACCESS_BOOTSTRAPPER_DISABLED;
|
||||||
|
if (SUCCEEDED(IRawElementProviderSimple_GetPropertyValue(provider, UIA_IsPasswordPropertyId, &password)) &&
|
||||||
|
password.vt == VT_BOOL && password.boolVal == VARIANT_TRUE)
|
||||||
|
event.flags |= WINE_ACCESS_BOOTSTRAPPER_PASSWORD;
|
||||||
|
event.tick = GetTickCount64();
|
||||||
UINT length = SysStringLen(name.bstrVal);
|
UINT length = SysStringLen(name.bstrVal);
|
||||||
if (length >= ARRAYSIZE(event.name)) goto done;
|
if (length >= ARRAYSIZE(event.name)) goto done;
|
||||||
memcpy(event.name, name.bstrVal, length * sizeof(WCHAR));
|
memcpy(event.name, name.bstrVal, length * sizeof(WCHAR));
|
||||||
@@ -47,6 +55,7 @@ static void read_toggle(IRawElementProviderSimple *root) {
|
|||||||
SMTO_ABORTIFHUNG | SMTO_BLOCK, 50, &result);
|
SMTO_ABORTIFHUNG | SMTO_BLOCK, 50, &result);
|
||||||
done:
|
done:
|
||||||
VariantClear(&type); VariantClear(&name);
|
VariantClear(&type); VariantClear(&name);
|
||||||
|
VariantClear(&enabled); VariantClear(&password);
|
||||||
if (toggle) IToggleProvider_Release(toggle);
|
if (toggle) IToggleProvider_Release(toggle);
|
||||||
if (pattern) IUnknown_Release(pattern);
|
if (pattern) IUnknown_Release(pattern);
|
||||||
if (provider) IRawElementProviderSimple_Release(provider);
|
if (provider) IRawElementProviderSimple_Release(provider);
|
||||||
|
|||||||
+37
-13
@@ -81,17 +81,10 @@ static void notify_text(HWND window, UINT kind, const WCHAR *text, DWORD start,
|
|||||||
wine_access_notify_text(window, kind, text, start, end, 0);
|
wine_access_notify_text(window, kind, text, start, end, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK edit_proc(HWND window, UINT message, WPARAM wp, LPARAM lp,
|
// Keep the text buffers off the stack when forwarding ignored or reentrant
|
||||||
UINT_PTR id, DWORD_PTR reference) {
|
// messages. Inlining this handler would put them back in every subclass call.
|
||||||
EditState *state = (EditState *)reference;
|
static __attribute__((noinline)) LRESULT handle_edit(HWND window, UINT message,
|
||||||
if (message == WM_NCDESTROY) {
|
WPARAM wp, LPARAM lp, EditState *state) {
|
||||||
RemoveWindowSubclass(window, edit_proc, id);
|
|
||||||
RemovePropW(window, EDIT_STATE_PROPERTY);
|
|
||||||
state->destroyed = TRUE;
|
|
||||||
if (!state->busy) { free(state->text); free(state); }
|
|
||||||
return DefSubclassProc(window, message, wp, lp);
|
|
||||||
}
|
|
||||||
if (state->busy) return DefSubclassProc(window, message, wp, lp);
|
|
||||||
BOOL navigation = message == WM_KEYDOWN &&
|
BOOL navigation = message == WM_KEYDOWN &&
|
||||||
(wp == VK_LEFT || wp == VK_RIGHT || wp == VK_UP || wp == VK_DOWN ||
|
(wp == VK_LEFT || wp == VK_RIGHT || wp == VK_UP || wp == VK_DOWN ||
|
||||||
wp == VK_HOME || wp == VK_END || wp == VK_PRIOR || wp == VK_NEXT);
|
wp == VK_HOME || wp == VK_END || wp == VK_PRIOR || wp == VK_NEXT);
|
||||||
@@ -113,8 +106,6 @@ static LRESULT CALLBACK edit_proc(HWND window, UINT message, WPARAM wp, LPARAM l
|
|||||||
if (navigation || focus || message == WM_KILLFOCUS || remote_replacement)
|
if (navigation || focus || message == WM_KILLFOCUS || remote_replacement)
|
||||||
state->history_key = state->history_replaced = FALSE;
|
state->history_key = state->history_replaced = FALSE;
|
||||||
BOOL history_replacement = message == WM_SETTEXT && state->history_key;
|
BOOL history_replacement = message == WM_SETTEXT && state->history_key;
|
||||||
if (!navigation && !changing && !focus && !selected && message != EM_SETPASSWORDCHAR)
|
|
||||||
return DefSubclassProc(window, message, wp, lp);
|
|
||||||
|
|
||||||
state->busy = TRUE;
|
state->busy = TRUE;
|
||||||
WCHAR pending_high = state->pending_high;
|
WCHAR pending_high = state->pending_high;
|
||||||
@@ -249,6 +240,39 @@ static LRESULT CALLBACK edit_proc(HWND window, UINT message, WPARAM wp, LPARAM l
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK edit_proc(HWND window, UINT message, WPARAM wp, LPARAM lp,
|
||||||
|
UINT_PTR id, DWORD_PTR reference) {
|
||||||
|
EditState *state = (EditState *)reference;
|
||||||
|
if (message == WM_NCDESTROY) {
|
||||||
|
RemoveWindowSubclass(window, edit_proc, id);
|
||||||
|
RemovePropW(window, EDIT_STATE_PROPERTY);
|
||||||
|
state->destroyed = TRUE;
|
||||||
|
if (!state->busy) { free(state->text); free(state); }
|
||||||
|
return DefSubclassProc(window, message, wp, lp);
|
||||||
|
}
|
||||||
|
if (state->busy) return DefSubclassProc(window, message, wp, lp);
|
||||||
|
if (message == WM_KILLFOCUS)
|
||||||
|
state->history_key = state->history_replaced = FALSE;
|
||||||
|
BOOL relevant = FALSE;
|
||||||
|
switch (message) {
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
relevant = wp == VK_LEFT || wp == VK_RIGHT || wp == VK_UP || wp == VK_DOWN ||
|
||||||
|
wp == VK_HOME || wp == VK_END || wp == VK_PRIOR || wp == VK_NEXT || wp == VK_DELETE;
|
||||||
|
break;
|
||||||
|
case WM_CHAR: case WM_PASTE: case WM_CUT: case WM_CLEAR:
|
||||||
|
case WM_UNDO: case EM_UNDO: case EM_REPLACESEL: case WM_SETTEXT:
|
||||||
|
case EM_SETHANDLE: case EM_FMTLINES: case WM_SETFOCUS: case EM_SETSEL:
|
||||||
|
case EM_SETPASSWORDCHAR:
|
||||||
|
relevant = TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
relevant = message == RegisterWindowMessageW(EDIT_FOCUS_MESSAGE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!relevant) return DefSubclassProc(window, message, wp, lp);
|
||||||
|
return handle_edit(window, message, wp, lp, state);
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL watch_edit(HWND window, EditState **edit_state) {
|
static BOOL watch_edit(HWND window, EditState **edit_state) {
|
||||||
if (edit_state) *edit_state = NULL;
|
if (edit_state) *edit_state = NULL;
|
||||||
WCHAR class_name[64];
|
WCHAR class_name[64];
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
#pragma once
|
||||||
|
#include <windows.h>
|
||||||
|
#include "bootstrapper_hook.h"
|
||||||
|
|
||||||
|
typedef struct WineAccessForegroundHooks {
|
||||||
|
HMODULE module;
|
||||||
|
HOOKPROC menu_callback, input_callback;
|
||||||
|
HHOOK menu, input;
|
||||||
|
DWORD thread;
|
||||||
|
} WineAccessForegroundHooks;
|
||||||
|
|
||||||
|
static inline void wine_access_release_hooks(WineAccessForegroundHooks *hooks) {
|
||||||
|
if (hooks->menu) UnhookWindowsHookEx(hooks->menu);
|
||||||
|
if (hooks->input) UnhookWindowsHookEx(hooks->input);
|
||||||
|
hooks->menu = hooks->input = NULL;
|
||||||
|
hooks->thread = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Global hooks cross the 32/64-bit boundary through the installing thread.
|
||||||
|
// Avoid that synchronous traffic and hook only the matching foreground UI
|
||||||
|
// thread. Both hosts use the same detach/retry rules.
|
||||||
|
static inline void wine_access_update_hooks(WineAccessForegroundHooks *hooks, BOOL target_wow64) {
|
||||||
|
DWORD pid = 0;
|
||||||
|
DWORD thread = GetWindowThreadProcessId(GetForegroundWindow(), &pid);
|
||||||
|
HANDLE process = pid ? OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid) : NULL;
|
||||||
|
BOOL wow64 = FALSE;
|
||||||
|
BOOL known = process && IsWow64Process(process, &wow64);
|
||||||
|
if (process) CloseHandle(process);
|
||||||
|
if (!known || wow64 != target_wow64) thread = 0;
|
||||||
|
if (thread == hooks->thread) return;
|
||||||
|
wine_access_release_hooks(hooks);
|
||||||
|
if (!thread || !hooks->menu_callback || !hooks->input_callback) return;
|
||||||
|
hooks->menu = SetWindowsHookExW(WH_CALLWNDPROC, hooks->menu_callback, hooks->module, thread);
|
||||||
|
hooks->input = SetWindowsHookExW(WH_GETMESSAGE, hooks->input_callback, hooks->module, thread);
|
||||||
|
if (hooks->menu && hooks->input) {
|
||||||
|
hooks->thread = thread;
|
||||||
|
HWND foreground = GetForegroundWindow();
|
||||||
|
WCHAR className[128];
|
||||||
|
if (GetWindowThreadProcessId(foreground, NULL) == thread &&
|
||||||
|
GetClassNameW(foreground, className, ARRAYSIZE(className)) &&
|
||||||
|
!lstrcmpW(className, L"Blizzard Bootstrapper")) {
|
||||||
|
// A query may have arrived while detached. Reestablish readiness on
|
||||||
|
// every attachment, including return from another application.
|
||||||
|
RemovePropW(foreground, BOOTSTRAPPER_STATE_READY);
|
||||||
|
RemovePropW(foreground, BOOTSTRAPPER_STATE_PENDING);
|
||||||
|
PostMessageW(foreground, WM_NULL, 0, 0);
|
||||||
|
}
|
||||||
|
} else wine_access_release_hooks(hooks); // Retry both on the next foreground poll.
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "native_items.h"
|
#include "native_items.h"
|
||||||
#include "review_service.h"
|
#include "review_service.h"
|
||||||
#include "foreground_focus.h"
|
#include "foreground_focus.h"
|
||||||
|
#include "foreground_hooks.h"
|
||||||
#include "reader_endpoint.h"
|
#include "reader_endpoint.h"
|
||||||
#include "msaa_events.h"
|
#include "msaa_events.h"
|
||||||
#include "reader_events.h"
|
#include "reader_events.h"
|
||||||
@@ -529,8 +530,6 @@ void poll_control_focus(bool refresh = false) {
|
|||||||
DWORD process = 0;
|
DWORD process = 0;
|
||||||
const DWORD thread = GetWindowThreadProcessId(bootstrapper, &process);
|
const DWORD thread = GetWindowThreadProcessId(bootstrapper, &process);
|
||||||
if (thread == result.thread && process == result.process) {
|
if (thread == result.thread && process == result.process) {
|
||||||
const std::string key = result.identity + "\n" + result.name + "\n" +
|
|
||||||
result.role + "\n" + result.value + "\n" + result.states;
|
|
||||||
ControlDescription control;
|
ControlDescription control;
|
||||||
control.name = result.name; control.role = result.role;
|
control.name = result.name; control.role = result.role;
|
||||||
control.value = result.value; control.states = result.states;
|
control.value = result.value; control.states = result.states;
|
||||||
@@ -540,11 +539,12 @@ void poll_control_focus(bool refresh = false) {
|
|||||||
to_utf8(bootstrapperState.name) == control.name) {
|
to_utf8(bootstrapperState.name) == control.name) {
|
||||||
control.states = bootstrapperState.state == 0 ? "not checked" :
|
control.states = bootstrapperState.state == 0 ? "not checked" :
|
||||||
bootstrapperState.state == 1 ? "checked" : "half checked";
|
bootstrapperState.state == 1 ? "checked" : "half checked";
|
||||||
for (const char *flag : {"password", "unavailable"}) {
|
if (bootstrapperState.flags & WINE_ACCESS_BOOTSTRAPPER_PASSWORD) control.states += ", password";
|
||||||
if (result.states.find(flag) != std::string::npos) control.states += std::string(", ") + flag;
|
if (bootstrapperState.flags & WINE_ACCESS_BOOTSTRAPPER_DISABLED) control.states += ", unavailable";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const std::string presentation = key + "\n" + control.states;
|
// Deduplicate the actual presentation, not superseded UIA state flags.
|
||||||
|
const std::string presentation = result.identity + "\n" + control.name + "\n" +
|
||||||
|
control.role + "\n" + control.value + "\n" + control.states;
|
||||||
const bool focusChanged = result.identity != lastBootstrapperIdentity;
|
const bool focusChanged = result.identity != lastBootstrapperIdentity;
|
||||||
if (presentation != lastBootstrapperPresentation &&
|
if (presentation != lastBootstrapperPresentation &&
|
||||||
present_accessible_event(source_id(bootstrapper, "bootstrapper-uia") + result.identity,
|
present_accessible_event(source_id(bootstrapper, "bootstrapper-uia") + result.identity,
|
||||||
@@ -1264,8 +1264,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
|
|||||||
std::fprintf(stderr, "wine-access: controller endpoint unavailable\n");
|
std::fprintf(stderr, "wine-access: controller endpoint unavailable\n");
|
||||||
|
|
||||||
HWINEVENTHOOK hook = nullptr;
|
HWINEVENTHOOK hook = nullptr;
|
||||||
HHOOK menuHook = nullptr;
|
WineAccessForegroundHooks foregroundHooks{};
|
||||||
HHOOK inputHook = nullptr;
|
|
||||||
HMODULE menuModule = nullptr;
|
HMODULE menuModule = nullptr;
|
||||||
HWND menuBridge = nullptr;
|
HWND menuBridge = nullptr;
|
||||||
HANDLE menuHost32 = nullptr;
|
HANDLE menuHost32 = nullptr;
|
||||||
@@ -1289,20 +1288,18 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
|
|||||||
} else if ((menuModule = load_menu_hook()) == nullptr) {
|
} else if ((menuModule = load_menu_hook()) == nullptr) {
|
||||||
menuHookError = inputHookError = GetLastError();
|
menuHookError = inputHookError = GetLastError();
|
||||||
} else {
|
} else {
|
||||||
const auto callback = std::bit_cast<HOOKPROC>(GetProcAddress(menuModule, "WineAccessMenuHook"));
|
foregroundHooks.module = menuModule;
|
||||||
if (callback != nullptr)
|
foregroundHooks.menu_callback = std::bit_cast<HOOKPROC>(GetProcAddress(menuModule, "WineAccessMenuHook"));
|
||||||
menuHook = SetWindowsHookExW(WH_CALLWNDPROC, callback, menuModule, 0);
|
if (!foregroundHooks.menu_callback) menuHookError = GetLastError();
|
||||||
if (menuHook == nullptr) menuHookError = GetLastError();
|
foregroundHooks.input_callback = std::bit_cast<HOOKPROC>(GetProcAddress(menuModule, "WineAccessInputHook"));
|
||||||
const auto inputCallback = std::bit_cast<HOOKPROC>(GetProcAddress(menuModule, "WineAccessInputHook"));
|
if (!foregroundHooks.input_callback) inputHookError = GetLastError();
|
||||||
if (inputCallback != nullptr)
|
editReaderActive = foregroundHooks.menu_callback && foregroundHooks.input_callback;
|
||||||
inputHook = SetWindowsHookExW(WH_GETMESSAGE, inputCallback, menuModule, 0);
|
wine_access_update_hooks(&foregroundHooks, FALSE);
|
||||||
if (inputHook == nullptr) inputHookError = GetLastError();
|
|
||||||
editReaderActive = menuHook != nullptr && inputHook != nullptr;
|
|
||||||
}
|
}
|
||||||
if (menuHook == nullptr)
|
if (menuHookError)
|
||||||
std::fprintf(stderr, "wine-access: native menu hook unavailable (error %lu)\n",
|
std::fprintf(stderr, "wine-access: native menu hook unavailable (error %lu)\n",
|
||||||
static_cast<unsigned long>(menuHookError));
|
static_cast<unsigned long>(menuHookError));
|
||||||
if (inputHook == nullptr)
|
if (inputHookError)
|
||||||
std::fprintf(stderr, "wine-access: native input hook unavailable (error %lu)\n",
|
std::fprintf(stderr, "wine-access: native input hook unavailable (error %lu)\n",
|
||||||
static_cast<unsigned long>(inputHookError));
|
static_cast<unsigned long>(inputHookError));
|
||||||
if (menuBridge != nullptr) {
|
if (menuBridge != nullptr) {
|
||||||
@@ -1310,6 +1307,9 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
|
|||||||
if (menuHost32 == nullptr)
|
if (menuHost32 == nullptr)
|
||||||
std::fprintf(stderr, "wine-access: 32-bit menu host unavailable (error %lu)\n",
|
std::fprintf(stderr, "wine-access: 32-bit menu host unavailable (error %lu)\n",
|
||||||
static_cast<unsigned long>(GetLastError()));
|
static_cast<unsigned long>(GetLastError()));
|
||||||
|
// Existing subclasses keep working after foreground hooks move away,
|
||||||
|
// including those attached by the 32-bit host.
|
||||||
|
editReaderActive = editReaderActive || menuHost32 != nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MSG message{};
|
MSG message{};
|
||||||
@@ -1320,15 +1320,19 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
|
|||||||
std::fprintf(stderr, "wine-access: bootstrapper UIA worker unavailable\n");
|
std::fprintf(stderr, "wine-access: bootstrapper UIA worker unavailable\n");
|
||||||
if (dialogReaderEnabled && !listTimer)
|
if (dialogReaderEnabled && !listTimer)
|
||||||
std::fprintf(stderr, "wine-access: control polling timer unavailable\n");
|
std::fprintf(stderr, "wine-access: control polling timer unavailable\n");
|
||||||
// Initialization status is distinct from process creation. Hook handles and
|
// Callback availability is distinct from foreground attachment. There may
|
||||||
// a started host do not prove attachment to a particular application.
|
// be no matching application when this startup snapshot is emitted.
|
||||||
std::fprintf(stderr, "wine-access: ready {\"reader\":\"%s\",\"controls_enabled\":%s,"
|
std::fprintf(stderr, "wine-access: ready {\"reader\":\"%s\",\"controls_enabled\":%s,"
|
||||||
"\"controller\":%s,\"review\":%s,\"msaa_worker\":%s,\"win_events\":%s,"
|
"\"controller\":%s,\"review\":%s,\"msaa_worker\":%s,\"win_events\":%s,"
|
||||||
"\"menu_hook\":%s,\"input_hook\":%s,\"host32_started\":%s,\"control_poll\":%s}\n",
|
"\"menu_hook\":%s,\"input_hook\":%s,"
|
||||||
|
"\"menu_hook_available\":%s,\"input_hook_available\":%s,"
|
||||||
|
"\"host32_started\":%s,\"control_poll\":%s}\n",
|
||||||
readerEndpoint.busName, dialogReaderEnabled ? "true" : "false",
|
readerEndpoint.busName, dialogReaderEnabled ? "true" : "false",
|
||||||
controllerActive ? "true" : "false", reviewActive ? "true" : "false",
|
controllerActive ? "true" : "false", reviewActive ? "true" : "false",
|
||||||
msaaActive ? "true" : "false", hook ? "true" : "false",
|
msaaActive ? "true" : "false", hook ? "true" : "false",
|
||||||
menuHook ? "true" : "false", inputHook ? "true" : "false",
|
foregroundHooks.menu ? "true" : "false", foregroundHooks.input ? "true" : "false",
|
||||||
|
foregroundHooks.menu_callback ? "true" : "false",
|
||||||
|
foregroundHooks.input_callback ? "true" : "false",
|
||||||
menuHost32 ? "true" : "false", listTimer ? "true" : "false");
|
menuHost32 ? "true" : "false", listTimer ? "true" : "false");
|
||||||
while (GetMessageW(&message, nullptr, 0, 0) > 0) {
|
while (GetMessageW(&message, nullptr, 0, 0) > 0) {
|
||||||
if (listTimer && message.message == WM_TIMER && message.hwnd == nullptr &&
|
if (listTimer && message.message == WM_TIMER && message.hwnd == nullptr &&
|
||||||
@@ -1342,6 +1346,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
|
|||||||
if (current_msaa_source(source)) present_standard_focus(source.window);
|
if (current_msaa_source(source)) present_standard_focus(source.window);
|
||||||
}
|
}
|
||||||
restore_virtual_desktop_focus();
|
restore_virtual_desktop_focus();
|
||||||
|
wine_access_update_hooks(&foregroundHooks, FALSE);
|
||||||
poll_control_focus();
|
poll_control_focus();
|
||||||
reviewService.focus_changed(reviewIdentities.observe_foreground());
|
reviewService.focus_changed(reviewIdentities.observe_foreground());
|
||||||
continue;
|
continue;
|
||||||
@@ -1356,15 +1361,12 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) {
|
|||||||
reviewService.stop();
|
reviewService.stop();
|
||||||
if (hook != nullptr)
|
if (hook != nullptr)
|
||||||
UnhookWinEvent(hook);
|
UnhookWinEvent(hook);
|
||||||
if (menuHook != nullptr)
|
wine_access_release_hooks(&foregroundHooks);
|
||||||
UnhookWindowsHookEx(menuHook);
|
|
||||||
if (inputHook != nullptr)
|
|
||||||
UnhookWindowsHookEx(inputHook);
|
|
||||||
if (menuBridge != nullptr)
|
if (menuBridge != nullptr)
|
||||||
DestroyWindow(menuBridge);
|
DestroyWindow(menuBridge);
|
||||||
if (menuHost32 != nullptr) {
|
if (menuHost32 != nullptr) {
|
||||||
// Destroying the bridge ends the host's loop. Parent-process death also
|
// Destroying the bridge ends the host's loop. Parent-process death also
|
||||||
// stops it, so a reader crash cannot leave an orphaned global menu hook.
|
// stops it, so a reader crash cannot leave an orphaned foreground hook.
|
||||||
if (WaitForSingleObject(menuHost32, 1000) == WAIT_TIMEOUT) {
|
if (WaitForSingleObject(menuHost32, 1000) == WAIT_TIMEOUT) {
|
||||||
TerminateProcess(menuHost32, 0);
|
TerminateProcess(menuHost32, 0);
|
||||||
WaitForSingleObject(menuHost32, 1000);
|
WaitForSingleObject(menuHost32, 1000);
|
||||||
|
|||||||
+4
-2
@@ -21,12 +21,14 @@
|
|||||||
#define WINE_ACCESS_TEXT_SCINTILLA 1
|
#define WINE_ACCESS_TEXT_SCINTILLA 1
|
||||||
#define WINE_ACCESS_TEXT_READONLY 2
|
#define WINE_ACCESS_TEXT_READONLY 2
|
||||||
#define WINE_ACCESS_NOTIFICATION_TAG 0x57414e31
|
#define WINE_ACCESS_NOTIFICATION_TAG 0x57414e31
|
||||||
#define WINE_ACCESS_BOOTSTRAPPER_TAG 0x57414231
|
#define WINE_ACCESS_BOOTSTRAPPER_TAG 0x57414232
|
||||||
|
#define WINE_ACCESS_BOOTSTRAPPER_DISABLED 1
|
||||||
|
#define WINE_ACCESS_BOOTSTRAPPER_PASSWORD 2
|
||||||
|
|
||||||
typedef struct WineAccessBootstrapperState {
|
typedef struct WineAccessBootstrapperState {
|
||||||
ULONGLONG owner;
|
ULONGLONG owner;
|
||||||
ULONGLONG tick;
|
ULONGLONG tick;
|
||||||
UINT state;
|
UINT state, flags;
|
||||||
WCHAR name[1024];
|
WCHAR name[1024];
|
||||||
} WineAccessBootstrapperState;
|
} WineAccessBootstrapperState;
|
||||||
|
|
||||||
|
|||||||
+49
-44
@@ -15,6 +15,53 @@ static void menu_text(WCHAR *output, UINT capacity, const WCHAR *input) {
|
|||||||
output[used] = 0;
|
output[used] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep menu payloads off the forwarding callback's stack, including in
|
||||||
|
// optimized builds. Most application messages do not need menu inspection.
|
||||||
|
static __attribute__((noinline)) void handle_menu(const CWPSTRUCT *message) {
|
||||||
|
HWND bridge = FindWindowW(WINE_ACCESS_MENU_CLASS, NULL);
|
||||||
|
HWND owner = GetAncestor(message->hwnd, GA_ROOT);
|
||||||
|
BOOL closed = message->message == WM_EXITMENULOOP ||
|
||||||
|
(!message->lParam && HIWORD(message->wParam) == 0xffff);
|
||||||
|
if (bridge && (closed || owner == GetAncestor(GetForegroundWindow(), GA_ROOT))) {
|
||||||
|
WineAccessMenuEvent event = {0};
|
||||||
|
UINT flags = HIWORD(message->wParam);
|
||||||
|
HMENU menu = (HMENU)message->lParam;
|
||||||
|
event.owner = (ULONGLONG)(UINT_PTR)owner;
|
||||||
|
event.menu = (ULONGLONG)(UINT_PTR)menu;
|
||||||
|
event.item = LOWORD(message->wParam);
|
||||||
|
if (closed) {
|
||||||
|
event.flags = WINE_ACCESS_MENU_CLOSED;
|
||||||
|
} else {
|
||||||
|
WCHAR text[640] = {0};
|
||||||
|
MENUITEMINFOW info = {0};
|
||||||
|
info.cbSize = sizeof(info);
|
||||||
|
info.fMask = MIIM_STRING | MIIM_STATE | MIIM_FTYPE | MIIM_SUBMENU;
|
||||||
|
info.dwTypeData = text;
|
||||||
|
info.cch = sizeof(text) / sizeof(text[0]);
|
||||||
|
if (!GetMenuItemInfoW(menu, event.item, (flags & MF_POPUP) != 0, &info) ||
|
||||||
|
(info.fType & MFT_SEPARATOR))
|
||||||
|
return;
|
||||||
|
menu_text(event.name, 512, text);
|
||||||
|
for (UINT i = 0; text[i]; ++i) {
|
||||||
|
if (text[i] == '\t') {
|
||||||
|
lstrcpynW(event.shortcut, text + i + 1, 128);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!event.name[0]) return;
|
||||||
|
if (info.hSubMenu) event.flags |= WINE_ACCESS_MENU_SUBMENU;
|
||||||
|
if (info.fState & MFS_CHECKED) event.flags |= WINE_ACCESS_MENU_CHECKED;
|
||||||
|
if (info.fState & MFS_DISABLED) event.flags |= WINE_ACCESS_MENU_DISABLED;
|
||||||
|
GetWindowTextW(owner, event.title, 256);
|
||||||
|
}
|
||||||
|
COPYDATASTRUCT data = {WINE_ACCESS_MENU_TAG, sizeof(event), &event};
|
||||||
|
DWORD_PTR result;
|
||||||
|
// The bridge only queues the payload; speech never runs in this hook.
|
||||||
|
SendMessageTimeoutW(bridge, WM_COPYDATA, (WPARAM)message->hwnd,
|
||||||
|
(LPARAM)&data, SMTO_ABORTIFHUNG | SMTO_BLOCK, 50, &result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This runs in the application's process: Wine does not expose another
|
// This runs in the application's process: Wine does not expose another
|
||||||
// process's HMENU contents to the standalone reader.
|
// process's HMENU contents to the standalone reader.
|
||||||
__declspec(dllexport) LRESULT CALLBACK WineAccessMenuHook(int code, WPARAM wp,
|
__declspec(dllexport) LRESULT CALLBACK WineAccessMenuHook(int code, WPARAM wp,
|
||||||
@@ -23,50 +70,8 @@ __declspec(dllexport) LRESULT CALLBACK WineAccessMenuHook(int code, WPARAM wp,
|
|||||||
wine_access_watch_notifications();
|
wine_access_watch_notifications();
|
||||||
const CWPSTRUCT *message = (const CWPSTRUCT *)lp;
|
const CWPSTRUCT *message = (const CWPSTRUCT *)lp;
|
||||||
if (message->message == WM_SETFOCUS) wine_access_watch_edit(message->hwnd);
|
if (message->message == WM_SETFOCUS) wine_access_watch_edit(message->hwnd);
|
||||||
if (message->message == WM_MENUSELECT || message->message == WM_EXITMENULOOP) {
|
if (message->message == WM_MENUSELECT || message->message == WM_EXITMENULOOP)
|
||||||
HWND bridge = FindWindowW(WINE_ACCESS_MENU_CLASS, NULL);
|
handle_menu(message);
|
||||||
HWND owner = GetAncestor(message->hwnd, GA_ROOT);
|
|
||||||
BOOL closed = message->message == WM_EXITMENULOOP ||
|
|
||||||
(!message->lParam && HIWORD(message->wParam) == 0xffff);
|
|
||||||
if (bridge && (closed || owner == GetAncestor(GetForegroundWindow(), GA_ROOT))) {
|
|
||||||
WineAccessMenuEvent event = {0};
|
|
||||||
UINT flags = HIWORD(message->wParam);
|
|
||||||
HMENU menu = (HMENU)message->lParam;
|
|
||||||
event.owner = (ULONGLONG)(UINT_PTR)owner;
|
|
||||||
event.menu = (ULONGLONG)(UINT_PTR)menu;
|
|
||||||
event.item = LOWORD(message->wParam);
|
|
||||||
if (closed) {
|
|
||||||
event.flags = WINE_ACCESS_MENU_CLOSED;
|
|
||||||
} else {
|
|
||||||
WCHAR text[640] = {0};
|
|
||||||
MENUITEMINFOW info = {0};
|
|
||||||
info.cbSize = sizeof(info);
|
|
||||||
info.fMask = MIIM_STRING | MIIM_STATE | MIIM_FTYPE | MIIM_SUBMENU;
|
|
||||||
info.dwTypeData = text;
|
|
||||||
info.cch = sizeof(text) / sizeof(text[0]);
|
|
||||||
if (!GetMenuItemInfoW(menu, event.item, (flags & MF_POPUP) != 0, &info) ||
|
|
||||||
(info.fType & MFT_SEPARATOR))
|
|
||||||
return CallNextHookEx(NULL, code, wp, lp);
|
|
||||||
menu_text(event.name, 512, text);
|
|
||||||
for (UINT i = 0; text[i]; ++i) {
|
|
||||||
if (text[i] == '\t') {
|
|
||||||
lstrcpynW(event.shortcut, text + i + 1, 128);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!event.name[0]) return CallNextHookEx(NULL, code, wp, lp);
|
|
||||||
if (info.hSubMenu) event.flags |= WINE_ACCESS_MENU_SUBMENU;
|
|
||||||
if (info.fState & MFS_CHECKED) event.flags |= WINE_ACCESS_MENU_CHECKED;
|
|
||||||
if (info.fState & MFS_DISABLED) event.flags |= WINE_ACCESS_MENU_DISABLED;
|
|
||||||
GetWindowTextW(owner, event.title, 256);
|
|
||||||
}
|
|
||||||
COPYDATASTRUCT data = {WINE_ACCESS_MENU_TAG, sizeof(event), &event};
|
|
||||||
DWORD_PTR result;
|
|
||||||
// The bridge only queues the payload; speech never runs in this hook.
|
|
||||||
SendMessageTimeoutW(bridge, WM_COPYDATA, (WPARAM)message->hwnd,
|
|
||||||
(LPARAM)&data, SMTO_ABORTIFHUNG | SMTO_BLOCK, 50, &result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return CallNextHookEx(NULL, code, wp, lp);
|
return CallNextHookEx(NULL, code, wp, lp);
|
||||||
}
|
}
|
||||||
+4
-45
@@ -1,19 +1,9 @@
|
|||||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
#include "menu_bridge.h"
|
#include "menu_bridge.h"
|
||||||
#include "bootstrapper_hook.h"
|
#include "foreground_hooks.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static DWORD foreground_thread32(void) {
|
|
||||||
DWORD pid = 0;
|
|
||||||
DWORD thread = GetWindowThreadProcessId(GetForegroundWindow(), &pid);
|
|
||||||
HANDLE process = pid ? OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid) : NULL;
|
|
||||||
BOOL wow64 = FALSE;
|
|
||||||
BOOL known = process && IsWow64Process(process, &wow64);
|
|
||||||
if (process) CloseHandle(process);
|
|
||||||
return known && wow64 ? thread : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook DLLs must match the application's architecture. This small PE host
|
// Hook DLLs must match the application's architecture. This small PE host
|
||||||
// supplies 32-bit menu/editor hooks without requiring 32-bit Linux GLib/Winelib.
|
// supplies 32-bit menu/editor hooks without requiring 32-bit Linux GLib/Winelib.
|
||||||
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show) {
|
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show) {
|
||||||
@@ -41,42 +31,12 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show)
|
|||||||
HMODULE module = LoadLibraryW(path);
|
HMODULE module = LoadLibraryW(path);
|
||||||
HOOKPROC callback = module ? (HOOKPROC)GetProcAddress(module, "WineAccessMenuHook") : NULL;
|
HOOKPROC callback = module ? (HOOKPROC)GetProcAddress(module, "WineAccessMenuHook") : NULL;
|
||||||
HOOKPROC inputCallback = module ? (HOOKPROC)GetProcAddress(module, "WineAccessInputHook") : NULL;
|
HOOKPROC inputCallback = module ? (HOOKPROC)GetProcAddress(module, "WineAccessInputHook") : NULL;
|
||||||
HHOOK hook = NULL;
|
WineAccessForegroundHooks hooks = {module, callback, inputCallback, NULL, NULL, 0};
|
||||||
HHOOK inputHook = NULL;
|
|
||||||
DWORD hookedThread = 0;
|
|
||||||
if (!callback || !inputCallback)
|
if (!callback || !inputCallback)
|
||||||
fprintf(stderr, "wine-access: 32-bit menu/editor hooks unavailable (error %lu)\n", GetLastError());
|
fprintf(stderr, "wine-access: 32-bit menu/editor hooks unavailable (error %lu)\n", GetLastError());
|
||||||
if (callback && inputCallback) {
|
if (callback && inputCallback) {
|
||||||
while (IsWindow(bridge)) {
|
while (IsWindow(bridge)) {
|
||||||
// Wine's mixed-architecture global hook chain can suppress the 64-bit
|
wine_access_update_hooks(&hooks, TRUE);
|
||||||
// hook. Attach only to the foreground 32-bit UI thread, and release it
|
|
||||||
// when focus moves elsewhere. The 64-bit helper keeps its global hook.
|
|
||||||
DWORD thread = foreground_thread32();
|
|
||||||
if (thread != hookedThread) {
|
|
||||||
if (hook) UnhookWindowsHookEx(hook);
|
|
||||||
if (inputHook) UnhookWindowsHookEx(inputHook);
|
|
||||||
hook = thread ? SetWindowsHookExW(WH_CALLWNDPROC, callback, module, thread) : NULL;
|
|
||||||
inputHook = thread ? SetWindowsHookExW(WH_GETMESSAGE, inputCallback, module, thread) : NULL;
|
|
||||||
hookedThread = hook && inputHook ? thread : 0;
|
|
||||||
if (!hookedThread) {
|
|
||||||
if (hook) UnhookWindowsHookEx(hook);
|
|
||||||
if (inputHook) UnhookWindowsHookEx(inputHook);
|
|
||||||
hook = inputHook = NULL;
|
|
||||||
} else {
|
|
||||||
HWND foreground = GetForegroundWindow();
|
|
||||||
WCHAR className[128];
|
|
||||||
if (GetWindowThreadProcessId(foreground, NULL) == hookedThread &&
|
|
||||||
GetClassNameW(foreground, className, ARRAYSIZE(className)) &&
|
|
||||||
!lstrcmpW(className, L"Blizzard Bootstrapper")) {
|
|
||||||
// A query can have passed through while this thread's hook was
|
|
||||||
// detached. Reestablish readiness on every attachment, including
|
|
||||||
// return from another workspace/application.
|
|
||||||
RemovePropW(foreground, BOOTSTRAPPER_STATE_READY);
|
|
||||||
RemovePropW(foreground, BOOTSTRAPPER_STATE_PENDING);
|
|
||||||
PostMessageW(foreground, WM_NULL, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DWORD result = MsgWaitForMultipleObjects(1, &parent, FALSE, 100, QS_ALLINPUT);
|
DWORD result = MsgWaitForMultipleObjects(1, &parent, FALSE, 100, QS_ALLINPUT);
|
||||||
if (result == WAIT_OBJECT_0 || result == WAIT_FAILED) break;
|
if (result == WAIT_OBJECT_0 || result == WAIT_FAILED) break;
|
||||||
MSG message;
|
MSG message;
|
||||||
@@ -85,8 +45,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show)
|
|||||||
DispatchMessageW(&message);
|
DispatchMessageW(&message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hook) UnhookWindowsHookEx(hook);
|
wine_access_release_hooks(&hooks);
|
||||||
if (inputHook) UnhookWindowsHookEx(inputHook);
|
|
||||||
}
|
}
|
||||||
if (module) FreeLibrary(module);
|
if (module) FreeLibrary(module);
|
||||||
CloseHandle(parent);
|
CloseHandle(parent);
|
||||||
|
|||||||
+33
-1
@@ -56,6 +56,8 @@ and exclusion of protected or unknown-protection values before querying them.
|
|||||||
The real native input hook also reads a Toggle provider whose state is absent
|
The real native input hook also reads a Toggle provider whose state is absent
|
||||||
from the provider's simple properties. It checks unchecked, checked and mixed
|
from the provider's simple properties. It checks unchecked, checked and mixed
|
||||||
states, changes without focus movement, focus return and background exclusion.
|
states, changes without focus movement, focus return and background exclusion.
|
||||||
|
Toggle and enabled/protected flags are copied together on the UI thread, so
|
||||||
|
asynchronous UIA replies cannot combine old flags with a newer Toggle value.
|
||||||
The fixture fails if the helper invokes Toggle rather than reading its state.
|
The fixture fails if the helper invokes Toggle rather than reading its state.
|
||||||
The test does not use the real installer or send speech to the running reader.
|
The test does not use the real installer or send speech to the running reader.
|
||||||
|
|
||||||
@@ -113,6 +115,36 @@ in Arcadelux, verify the introduction and repeated Up/Down menu announcements,
|
|||||||
including switching away and back. Also check existing NVDA/Tolk speech and
|
including switching away and back. Also check existing NVDA/Tolk speech and
|
||||||
ordinary Wine menus and Edit controls before submitting the change.
|
ordinary Wine menus and Edit controls before submitting the change.
|
||||||
|
|
||||||
|
## Native hook scope and stack use
|
||||||
|
|
||||||
|
Run sequentially after building:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
xvfb-run -a ctest --test-dir build -R hook-safety --output-on-failure
|
||||||
|
xvfb-run -a python3 tests/menu_integration.py --build-dir build --fixture hooks
|
||||||
|
xvfb-run -a python3 tests/menu_integration.py --build-dir build --fixture hooks --32-bit
|
||||||
|
```
|
||||||
|
|
||||||
|
The hook-safety test loads both actual DLLs in a disposable Wine prefix. It
|
||||||
|
compares nested ANSI Edit calls with a minimal comctl32 subclass, checks the
|
||||||
|
busy reentrant path and menu-hook forwarding stack, and exercises application
|
||||||
|
subclasses installed before and after attachment, A/W text queries, typing and
|
||||||
|
destruction during a text change. The scope fixture switches between UI threads
|
||||||
|
and checks that only the foreground thread acquires new Edit subclasses.
|
||||||
|
|
||||||
|
The original 32-bit callbacks fail the stack budget; the original global 64-bit
|
||||||
|
hooks fail the background-thread check. These reproduce specific defects,
|
||||||
|
without proving they caused the live MUSHclient stack overflow. Hook DLLs keep
|
||||||
|
debug symbols and frame pointers to improve subsequent native stack captures.
|
||||||
|
|
||||||
|
Also run the existing menu and editor tests for both architectures, including
|
||||||
|
`--late-helper --restart-helper`, the 32-bit list fixture and the reader timeout
|
||||||
|
test. For live acceptance, check MUSHclient typing, command history, incoming
|
||||||
|
plugin speech, menu return and switching between Wine and Linux applications.
|
||||||
|
Check Notepad, password exclusion and speech/braille separately. Loaded Edit
|
||||||
|
subclasses pin the DLL, so testing an installed replacement requires restarting
|
||||||
|
the affected Wine application as well as the helper.
|
||||||
|
|
||||||
## Reader reply stalls
|
## Reader reply stalls
|
||||||
|
|
||||||
Run sequentially on a private X display:
|
Run sequentially on a private X display:
|
||||||
@@ -314,7 +346,7 @@ MinGW's x86_64 and i686 C compilers, PyGObject, and `dbus-run-session`.
|
|||||||
|
|
||||||
The test creates a temporary Wine prefix and a private D-Bus service. Its
|
The test creates a temporary Wine prefix and a private D-Bus service. Its
|
||||||
64-bit PE application exercises the separately running Winelib helper's
|
64-bit PE application exercises the separately running Winelib helper's
|
||||||
global menu hook, rather than calling helper functions inside the fixture.
|
foreground menu hook, rather than calling helper functions inside the fixture.
|
||||||
The test processes carry the managed-helper marker so the running Cthulhu
|
The test processes carry the managed-helper marker so the running Cthulhu
|
||||||
supervisor does not start an additional helper in the test prefix.
|
supervisor does not start an additional helper in the test prefix.
|
||||||
|
|
||||||
|
|||||||
@@ -93,8 +93,14 @@ with wine_test_directory(prefix="wine-access-diagnostics-") as temporary:
|
|||||||
for field in ("controls_enabled", "review", "msaa_worker", "win_events", "control_poll"):
|
for field in ("controls_enabled", "review", "msaa_worker", "win_events", "control_poll"):
|
||||||
assert ready[field], (field, ready)
|
assert ready[field], (field, ready)
|
||||||
assert not ready["controller"]
|
assert not ready["controller"]
|
||||||
for field in ("menu_hook", "input_hook", "host32_started"):
|
for field in ("menu_hook_available", "input_hook_available", "host32_started"):
|
||||||
assert ready[field] == (not missingHooks), (field, ready)
|
assert ready[field] == (not missingHooks), (field, ready)
|
||||||
|
# Hooks attach only to a matching foreground UI thread, which
|
||||||
|
# need not exist in this startup-only fixture.
|
||||||
|
for field in ("menu_hook", "input_hook"):
|
||||||
|
assert isinstance(ready[field], bool), (field, ready)
|
||||||
|
if missingHooks:
|
||||||
|
assert not ready[field], (field, ready)
|
||||||
if missingHooks:
|
if missingHooks:
|
||||||
assert "native menu hook unavailable" in logPath.read_text()
|
assert "native menu hook unavailable" in logPath.read_text()
|
||||||
assert "32-bit menu host unavailable" in logPath.read_text()
|
assert "32-bit menu host unavailable" in logPath.read_text()
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
#include <windows.h>
|
||||||
|
#include <commctrl.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "../edit_hook.h"
|
||||||
|
|
||||||
|
#define PROBE_MESSAGE (WM_APP + 10)
|
||||||
|
#define PROBE_DEPTH 16
|
||||||
|
static WNDPROC original, outer_original;
|
||||||
|
static uintptr_t deepest, hook_stack;
|
||||||
|
static BOOL nested, destroy_on_set;
|
||||||
|
static unsigned calls;
|
||||||
|
|
||||||
|
static LRESULT CALLBACK passthrough(HWND window, UINT message, WPARAM wp, LPARAM lp,
|
||||||
|
UINT_PTR id, DWORD_PTR reference) {
|
||||||
|
(void)id; (void)reference;
|
||||||
|
return DefSubclassProc(window, message, wp, lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK application_proc(HWND window, UINT message, WPARAM wp, LPARAM lp) {
|
||||||
|
volatile char marker = 0;
|
||||||
|
++calls;
|
||||||
|
if (message == PROBE_MESSAGE) {
|
||||||
|
if (wp) return SendMessageA(window, PROBE_MESSAGE, wp - 1, 0);
|
||||||
|
deepest = (uintptr_t)▮
|
||||||
|
return 123;
|
||||||
|
}
|
||||||
|
if (message == WM_SETTEXT && nested) {
|
||||||
|
char text[64];
|
||||||
|
GetWindowTextA(window, text, sizeof(text));
|
||||||
|
SendMessageA(window, PROBE_MESSAGE, PROBE_DEPTH, 0);
|
||||||
|
}
|
||||||
|
if (message == WM_SETTEXT && destroy_on_set) {
|
||||||
|
DestroyWindow(window);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return CallWindowProcA(original, window, message, wp, lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK outer_proc(HWND window, UINT message, WPARAM wp, LPARAM lp) {
|
||||||
|
return CallWindowProcA(outer_original, window, message, wp, lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK observer(int code, WPARAM wp, LPARAM lp) {
|
||||||
|
volatile char marker = 0;
|
||||||
|
if (code >= 0 && ((CWPSTRUCT *)lp)->message == PROBE_MESSAGE)
|
||||||
|
hook_stack = (uintptr_t)▮
|
||||||
|
return CallNextHookEx(NULL, code, wp, lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uintptr_t probe(HWND window, BOOL busy) {
|
||||||
|
volatile char marker = 0;
|
||||||
|
nested = busy;
|
||||||
|
if (busy) SetWindowTextA(window, "replacement");
|
||||||
|
else if (SendMessageA(window, PROBE_MESSAGE, PROBE_DEPTH, 0) != 123) ExitProcess(2);
|
||||||
|
nested = FALSE;
|
||||||
|
return (uintptr_t)&marker - deepest;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if (argc != 2) return 2;
|
||||||
|
HMODULE module = LoadLibraryA(argv[1]);
|
||||||
|
HOOKPROC callback = module ? (HOOKPROC)GetProcAddress(module, "WineAccessMenuHook") : NULL;
|
||||||
|
if (!callback) return 3;
|
||||||
|
HWND window = CreateWindowA("Edit", "initial", WS_POPUP | ES_MULTILINE,
|
||||||
|
0, 0, 200, 100, NULL, NULL, GetModuleHandleW(NULL), NULL);
|
||||||
|
if (!window || IsWindowUnicode(window)) return 4;
|
||||||
|
original = (WNDPROC)SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)application_proc);
|
||||||
|
// Include comctl32's subclass dispatch in both measurements so the budget
|
||||||
|
// measures our callback rather than Wine's architecture-specific thunks.
|
||||||
|
if (!SetWindowSubclass(window, passthrough, 1, 0)) return 4;
|
||||||
|
uintptr_t baseline = probe(window, FALSE);
|
||||||
|
uintptr_t busy_baseline = probe(window, TRUE);
|
||||||
|
RemoveWindowSubclass(window, passthrough, 1);
|
||||||
|
// Attach through the real DLL's focus path, after the application's ANSI
|
||||||
|
// subclass. This also exercises Wine's A/W procedure conversion.
|
||||||
|
CWPSTRUCT focus = {0, 0, WM_SETFOCUS, window};
|
||||||
|
callback(HC_ACTION, 0, (LPARAM)&focus);
|
||||||
|
if (!GetPropW(window, EDIT_STATE_PROPERTY)) return 5;
|
||||||
|
uintptr_t hooked = probe(window, FALSE);
|
||||||
|
uintptr_t busy_hooked = probe(window, TRUE);
|
||||||
|
printf("edit stack: baseline=%llu hooked=%llu busy-baseline=%llu busy-hooked=%llu\n",
|
||||||
|
(unsigned long long)baseline, (unsigned long long)hooked,
|
||||||
|
(unsigned long long)busy_baseline, (unsigned long long)busy_hooked);
|
||||||
|
// Allow comctl32 and A/W thunk overhead, but not a 4 KiB buffer frame on
|
||||||
|
// every ignored or reentrant message. This compares the same call chain.
|
||||||
|
BOOL stack_ok = hooked < baseline + PROBE_DEPTH * 2048 &&
|
||||||
|
busy_hooked < busy_baseline + PROBE_DEPTH * 2048 + 8192;
|
||||||
|
|
||||||
|
outer_original = (WNDPROC)SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)outer_proc);
|
||||||
|
SetWindowTextA(window, "ANSI replacement");
|
||||||
|
SendMessageA(window, EM_SETSEL, 16, 16);
|
||||||
|
SendMessageA(window, WM_CHAR, '!', 1);
|
||||||
|
char text[64];
|
||||||
|
WCHAR wide[64];
|
||||||
|
GetWindowTextA(window, text, sizeof(text));
|
||||||
|
GetWindowTextW(window, wide, 64);
|
||||||
|
if (strcmp(text, "ANSI replacement!") || lstrcmpW(wide, L"ANSI replacement!") || !calls)
|
||||||
|
return 6;
|
||||||
|
// Destroy while the accessibility callback is busy; it must defer freeing
|
||||||
|
// its state until the application's callback has returned.
|
||||||
|
destroy_on_set = TRUE;
|
||||||
|
SetWindowTextA(window, "destroy");
|
||||||
|
if (IsWindow(window)) return 7;
|
||||||
|
|
||||||
|
window = CreateWindowA("Static", "", WS_POPUP, 0, 0, 10, 10,
|
||||||
|
NULL, NULL, GetModuleHandleW(NULL), NULL);
|
||||||
|
HHOOK measure = SetWindowsHookExW(WH_CALLWNDPROC, observer, NULL, GetCurrentThreadId());
|
||||||
|
if (!window || !measure) return 8;
|
||||||
|
SendMessageW(window, PROBE_MESSAGE, 0, 0);
|
||||||
|
uintptr_t unhooked_stack = hook_stack;
|
||||||
|
HHOOK hook = SetWindowsHookExW(WH_CALLWNDPROC, callback, module, GetCurrentThreadId());
|
||||||
|
if (!hook) return 9;
|
||||||
|
SendMessageW(window, PROBE_MESSAGE, 0, 0);
|
||||||
|
uintptr_t overhead = unhooked_stack - hook_stack;
|
||||||
|
printf("menu forwarding stack overhead: %llu\n", (unsigned long long)overhead);
|
||||||
|
UnhookWindowsHookEx(hook);
|
||||||
|
UnhookWindowsHookEx(measure);
|
||||||
|
DestroyWindow(window);
|
||||||
|
if (!stack_ok || overhead >= 2048) return 10;
|
||||||
|
puts("PASS: bounded forwarding stack, ANSI subclass chaining, nested queries and destruction");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
"""Exercise real PE callbacks in an isolated Wine prefix (both architectures)."""
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from wine_test_environment import wine_test_directory
|
||||||
|
|
||||||
|
build = Path(sys.argv[1]).resolve()
|
||||||
|
with wine_test_directory(prefix="wine-access-hook-safety-") as temporary:
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update(WINEPREFIX=str(Path(temporary) / "prefix"), WINEDEBUG="-all",
|
||||||
|
WINEDLLOVERRIDES="mscoree,mshtml=", CTHULHU_WINE_ACCESS_MANAGED="1")
|
||||||
|
try:
|
||||||
|
subprocess.run(["wineboot", "-u"], env=env, check=True, timeout=45)
|
||||||
|
failed = False
|
||||||
|
for arch in (32, 64):
|
||||||
|
dll = build / ("wine-access-menu32.dll" if arch == 32 else "wine-access-menu.dll")
|
||||||
|
result = subprocess.run(["wine", str(build / f"hook-safety-fixture{arch}.exe"),
|
||||||
|
"Z:" + str(dll).replace("/", "\\")],
|
||||||
|
env=env, timeout=20)
|
||||||
|
print(f"{arch}-bit hook safety: exit {result.returncode}", flush=True)
|
||||||
|
failed |= result.returncode != 0
|
||||||
|
sys.exit(1 if failed else 0)
|
||||||
|
finally:
|
||||||
|
subprocess.run(["wineserver", "-k"], env=env, timeout=5)
|
||||||
|
subprocess.run(["wineserver", "-w"], env=env, timeout=5)
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "../edit_hook.h"
|
||||||
|
|
||||||
|
static HWND worker_window;
|
||||||
|
static HANDLE ready;
|
||||||
|
|
||||||
|
static void pump(DWORD milliseconds) {
|
||||||
|
DWORD end = GetTickCount() + milliseconds;
|
||||||
|
do {
|
||||||
|
MSG message;
|
||||||
|
while (PeekMessageW(&message, NULL, 0, 0, PM_REMOVE)) {
|
||||||
|
TranslateMessage(&message);
|
||||||
|
DispatchMessageW(&message);
|
||||||
|
}
|
||||||
|
Sleep(10);
|
||||||
|
} while ((LONG)(end - GetTickCount()) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL attached_on_focus(HWND parent) {
|
||||||
|
HWND edit = CreateWindowA("Edit", "ANSI background probe", WS_CHILD,
|
||||||
|
0, 0, 100, 30, parent, NULL, GetModuleHandleW(NULL), NULL);
|
||||||
|
if (!edit) ExitProcess(2);
|
||||||
|
// A background application can send focus messages of its own. It must
|
||||||
|
// not acquire new accessibility subclasses through a desktop-wide hook.
|
||||||
|
SendMessageW(edit, WM_SETFOCUS, 0, 0);
|
||||||
|
BOOL attached = GetPropW(edit, EDIT_STATE_PROPERTY) != NULL;
|
||||||
|
DestroyWindow(edit);
|
||||||
|
return attached;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wp, LPARAM lp) {
|
||||||
|
if (message == WM_APP) return attached_on_focus(window);
|
||||||
|
if (message == WM_CLOSE) { DestroyWindow(window); PostQuitMessage(0); return 0; }
|
||||||
|
return DefWindowProcW(window, message, wp, lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI worker(void *unused) {
|
||||||
|
(void)unused;
|
||||||
|
worker_window = CreateWindowW(L"WineAccessHookScope", L"Other UI thread", WS_OVERLAPPEDWINDOW,
|
||||||
|
300, 0, 200, 120, NULL, NULL, GetModuleHandleW(NULL), NULL);
|
||||||
|
SetEvent(ready);
|
||||||
|
MSG message;
|
||||||
|
while (GetMessageW(&message, NULL, 0, 0) > 0) DispatchMessageW(&message);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
WNDCLASSW cls = {0};
|
||||||
|
cls.lpfnWndProc = window_proc;
|
||||||
|
cls.hInstance = GetModuleHandleW(NULL);
|
||||||
|
cls.lpszClassName = L"WineAccessHookScope";
|
||||||
|
if (!RegisterClassW(&cls)) return 2;
|
||||||
|
HWND window = CreateWindowW(cls.lpszClassName, L"Hook scope fixture", WS_OVERLAPPEDWINDOW,
|
||||||
|
0, 0, 200, 120, NULL, NULL, cls.hInstance, NULL);
|
||||||
|
ready = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
|
HANDLE thread = CreateThread(NULL, 0, worker, NULL, 0, NULL);
|
||||||
|
if (!window || !ready || !thread || WaitForSingleObject(ready, 3000) != WAIT_OBJECT_0 ||
|
||||||
|
!worker_window) return 3;
|
||||||
|
ShowWindow(window, SW_SHOW);
|
||||||
|
SetForegroundWindow(window);
|
||||||
|
pump(600);
|
||||||
|
BOOL first = GetForegroundWindow() == window && attached_on_focus(window);
|
||||||
|
BOOL background = SendMessageW(worker_window, WM_APP, 0, 0);
|
||||||
|
ShowWindow(worker_window, SW_SHOW);
|
||||||
|
SetForegroundWindow(worker_window);
|
||||||
|
pump(600);
|
||||||
|
BOOL switched = GetForegroundWindow() == worker_window && SendMessageW(worker_window, WM_APP, 0, 0);
|
||||||
|
BOOL old_thread = attached_on_focus(window);
|
||||||
|
SetForegroundWindow(window);
|
||||||
|
pump(600);
|
||||||
|
BOOL restored = GetForegroundWindow() == window && attached_on_focus(window);
|
||||||
|
BOOL detached = !SendMessageW(worker_window, WM_APP, 0, 0);
|
||||||
|
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);
|
||||||
|
WaitForSingleObject(thread, 3000);
|
||||||
|
CloseHandle(thread);
|
||||||
|
CloseHandle(ready);
|
||||||
|
DestroyWindow(window);
|
||||||
|
return first && !background && switched && !old_thread && restored && detached ? 0 : 4;
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ parser.add_argument("--build-dir", default="build")
|
|||||||
parser.add_argument("--session", action="store_true")
|
parser.add_argument("--session", action="store_true")
|
||||||
parser.add_argument("--reader", choices=("cthulhu", "orca"))
|
parser.add_argument("--reader", choices=("cthulhu", "orca"))
|
||||||
parser.add_argument("--extension-endpoint", action="store_true")
|
parser.add_argument("--extension-endpoint", action="store_true")
|
||||||
parser.add_argument("--fixture", choices=("menu", "edit", "notepad", "list", "listbox", "delphi", "winforms", "controls", "scintilla", "goldwave", "bootstrapper"), default="menu")
|
parser.add_argument("--fixture", choices=("menu", "edit", "hooks", "notepad", "list", "listbox", "delphi", "winforms", "controls", "scintilla", "goldwave", "bootstrapper"), default="menu")
|
||||||
parser.add_argument("--notepadpp-exe", type=Path)
|
parser.add_argument("--notepadpp-exe", type=Path)
|
||||||
parser.add_argument("--goldwave-exe", type=Path)
|
parser.add_argument("--goldwave-exe", type=Path)
|
||||||
parser.add_argument("--32-bit", dest="is32Bit", action="store_true")
|
parser.add_argument("--32-bit", dest="is32Bit", action="store_true")
|
||||||
@@ -28,8 +28,8 @@ parser.add_argument("--late-helper", action="store_true")
|
|||||||
parser.add_argument("--restart-helper", action="store_true")
|
parser.add_argument("--restart-helper", action="store_true")
|
||||||
add_test_options(parser)
|
add_test_options(parser)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.is32Bit and args.fixture not in ("menu", "edit", "winforms", "list", "listbox", "delphi", "controls", "bootstrapper"):
|
if args.is32Bit and args.fixture not in ("menu", "edit", "hooks", "winforms", "list", "listbox", "delphi", "controls", "bootstrapper"):
|
||||||
parser.error("32-bit checks currently require --fixture menu, edit, winforms, list, listbox, delphi, controls or 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"):
|
if (args.late_helper or args.restart_helper) and args.fixture not in ("edit", "winforms", "scintilla"):
|
||||||
parser.error("helper lifecycle checks require --fixture edit, winforms or scintilla")
|
parser.error("helper lifecycle checks require --fixture edit, winforms or scintilla")
|
||||||
if args.fixture == "scintilla" and (not args.notepadpp_exe or not args.notepadpp_exe.is_file()):
|
if args.fixture == "scintilla" and (not args.notepadpp_exe or not args.notepadpp_exe.is_file()):
|
||||||
@@ -157,6 +157,9 @@ with wine_test_directory(prefix="wine-access-menus-") as temporary:
|
|||||||
while GLib.MainContext.default().iteration(False):
|
while GLib.MainContext.default().iteration(False):
|
||||||
pass
|
pass
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
if args.fixture == "hooks":
|
||||||
|
print("PASS: hooks follow only the foreground UI thread, detach and reattach")
|
||||||
|
sys.exit(0)
|
||||||
focused = None
|
focused = None
|
||||||
for event in events:
|
for event in events:
|
||||||
if event[1] == "focus":
|
if event[1] == "focus":
|
||||||
@@ -169,14 +172,18 @@ with wine_test_directory(prefix="wine-access-menus-") as temporary:
|
|||||||
uiaEvents = [e for e in events if ":bootstrapper-uia:" in e[0]]
|
uiaEvents = [e for e in events if ":bootstrapper-uia:" in e[0]]
|
||||||
for event in uiaEvents:
|
for event in uiaEvents:
|
||||||
print(event[1:9])
|
print(event[1:9])
|
||||||
|
def has_toggle_state(event):
|
||||||
|
return bool({"checked", "not checked", "half checked"}.intersection(event[5].split(", ")))
|
||||||
|
|
||||||
# Focus can arrive before the native hook's state reply. It must
|
# Focus can arrive before the native hook's state reply. It must
|
||||||
# then be followed by a known state for that same focused source.
|
# then be followed by a known state for that same focused source.
|
||||||
|
# An unavailable flag alone does not include the Toggle value.
|
||||||
for index, event in enumerate(uiaEvents):
|
for index, event in enumerate(uiaEvents):
|
||||||
if event[3] == "check box" and not event[5]:
|
if event[3] == "check box" and not has_toggle_state(event):
|
||||||
assert event[1] == "focus", f"lost a previously known checkbox state: {event!r}"
|
assert event[1] == "focus", f"lost a previously known checkbox state: {event!r}"
|
||||||
assert index + 1 < len(uiaEvents) and uiaEvents[index + 1][0] == event[0] and uiaEvents[index + 1][5], \
|
assert index + 1 < len(uiaEvents) and uiaEvents[index + 1][0] == event[0] and has_toggle_state(uiaEvents[index + 1]), \
|
||||||
f"checkbox state never arrived after focus: {uiaEvents[index:]!r}"
|
f"checkbox state never arrived after focus: {uiaEvents[index:]!r}"
|
||||||
knownEvents = [e for e in uiaEvents if e[3] != "check box" or e[5]]
|
knownEvents = [e for e in uiaEvents if e[3] != "check box" or has_toggle_state(e)]
|
||||||
assert [e[2:5] for e in knownEvents] == [
|
assert [e[2:5] for e in knownEvents] == [
|
||||||
("Select a Language", "combo box", "English (United States)"),
|
("Select a Language", "combo box", "English (United States)"),
|
||||||
("Select a Language", "combo box", "French"),
|
("Select a Language", "combo box", "French"),
|
||||||
|
|||||||
Reference in new issue
Block a user