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.
This commit is contained in:
Zhiyi Zhang 2023-10-25 15:20:32 -05:00 committed by Alexandre Julliard
parent 6dfeab55bd
commit e1259ff91a
2 changed files with 5 additions and 3 deletions

View file

@ -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

View file

@ -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)
{