Module: wine Branch: master Commit: e1259ff91a40d7d97fa730235e2b7737b229f708 URL: https://gitlab.winehq.org/wine/wine/-/commit/e1259ff91a40d7d97fa730235e2b773...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Wed Oct 25 15:20:32 2023 -0500
win32u: Return ERROR_ACCESS_DENIED for WH_JOURNALRECORD and WH_JOURNALPLAYBACK.
On > XP, settings WH_JOURNALRECORD or WH_JOURNALPLAYBACK hooks report ERROR_ACCESS_DENIED according to tests, even with administrator rights. PCSE_TERM depends on this to not crash. MSDN also says that journaling hooks APIs are unsupported starting in Windows 11. Reject journalling hooks unconditionally here because they have been broken for a long time.
---
dlls/user32/tests/msg.c | 3 --- dlls/win32u/hook.c | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index f95e1603e65..90abf9b83a1 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -12271,7 +12271,6 @@ static void test_set_hook(void) SetLastError(0xdeadbeef); hhook = SetWindowsHookExA(WH_JOURNALRECORD, cbt_hook_proc, 0, 0); ok(!hhook, "global hook requires hModule != 0\n"); - todo_wine ok(GetLastError() == ERROR_ACCESS_DENIED, "unexpected error %ld\n", GetLastError());
SetLastError(0xdeadbeef); @@ -12297,9 +12296,7 @@ static void test_set_hook(void) error = GetLastError(); if (i == WH_JOURNALRECORD || i == WH_JOURNALPLAYBACK) { - todo_wine ok(!hhook, "SetWinEventHook succeeded.\n"); - todo_wine ok(error == ERROR_ACCESS_DENIED, "Got unexpected error %ld.\n", GetLastError()); } else diff --git a/dlls/win32u/hook.c b/dlls/win32u/hook.c index 3cd6b1ee1a2..e9b3ae7d70d 100644 --- a/dlls/win32u/hook.c +++ b/dlls/win32u/hook.c @@ -97,6 +97,11 @@ HHOOK WINAPI NtUserSetWindowsHookEx( HINSTANCE inst, UNICODE_STRING *module, DWO } else /* system-global hook */ { + if (id == WH_JOURNALRECORD || id == WH_JOURNALPLAYBACK) + { + RtlSetLastWin32Error( ERROR_ACCESS_DENIED ); + return 0; + } if (id == WH_KEYBOARD_LL || id == WH_MOUSE_LL) inst = 0; else if (!inst) {