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

This commit is contained in:
Alexandre Julliard 2007-08-22 11:59:21 +02:00
parent 1bc72fb6da
commit 04a9f93f62
2 changed files with 18 additions and 4 deletions

View File

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

View File

@ -419,8 +419,18 @@ DECL_HANDLER(set_hook)
global = 1;
}
else
{
/* 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;
}