Commit 04a9f93f authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Thread-local hooks need a module if they don't belong to the current process.

parent 1bc72fb6
......@@ -144,7 +144,6 @@ static HHOOK set_windows_hook( INT id, HOOKPROC proc, HINSTANCE inst, DWORD tid,
return 0;
}
/* FIXME: what if the tid belongs to another process? */
if (tid) /* thread-local hook */
{
if (id == WH_JOURNALRECORD ||
......@@ -157,18 +156,23 @@ static HHOOK set_windows_hook( INT id, HOOKPROC proc, HINSTANCE inst, DWORD tid,
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
inst = 0;
}
else /* system-global hook */
{
if (id == WH_KEYBOARD_LL || id == WH_MOUSE_LL) inst = 0;
else if (!inst || !(len = GetModuleFileNameW( inst, module, MAX_PATH )) || len >= MAX_PATH)
else if (!inst)
{
SetLastError( ERROR_HOOK_NEEDS_HMOD );
return 0;
}
}
if (inst && (!(len = GetModuleFileNameW( inst, module, MAX_PATH )) || len >= MAX_PATH))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
SERVER_START_REQ( set_hook )
{
req->id = id;
......
......@@ -420,7 +420,17 @@ DECL_HANDLER(set_hook)
}
else
{
module = NULL;
/* module is optional only if hook is in current process */
if (!module_size)
{
module = NULL;
if (thread->process != current->process)
{
set_error( STATUS_INVALID_PARAMETER );
goto done;
}
}
else if (!(module = memdup( get_req_data(), module_size ))) goto done;
global = 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment