mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 11:23:38 +00:00
wow64win: Convert parameters in place in wow64_NtUserCallWindowsHook.
This commit is contained in:
parent
2149bdfda7
commit
8f168ea69b
|
@ -488,6 +488,8 @@ static void createstruct_64to32( const CREATESTRUCTW *from, CREATESTRUCT32 *to )
|
||||||
cs.y = from->y;
|
cs.y = from->y;
|
||||||
cs.x = from->x;
|
cs.x = from->x;
|
||||||
cs.style = from->style;
|
cs.style = from->style;
|
||||||
|
cs.lpszName = PtrToUlong( from->lpszName );
|
||||||
|
cs.lpszClass = PtrToUlong( from->lpszClass );
|
||||||
cs.dwExStyle = from->dwExStyle;
|
cs.dwExStyle = from->dwExStyle;
|
||||||
memcpy( to, &cs, sizeof(cs) );
|
memcpy( to, &cs, sizeof(cs) );
|
||||||
}
|
}
|
||||||
|
@ -633,11 +635,11 @@ static NTSTATUS WINAPI wow64_NtUserCallWinProc( void *arg, ULONG size )
|
||||||
return NtCallbackReturn( &result, sizeof(result), status );
|
return NtCallbackReturn( &result, sizeof(result), status );
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT hook_lparam_64to32( struct win_hook_params *params, const void *lp, void *lp32 )
|
static UINT hook_lparam_64to32( int id, int code, const void *lp, size_t size, void *lp32 )
|
||||||
{
|
{
|
||||||
if (!params->lparam_size) return 0;
|
if (!size) return 0;
|
||||||
|
|
||||||
switch (params->id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case WH_SYSMSGFILTER:
|
case WH_SYSMSGFILTER:
|
||||||
case WH_MSGFILTER:
|
case WH_MSGFILTER:
|
||||||
|
@ -646,28 +648,27 @@ static UINT hook_lparam_64to32( struct win_hook_params *params, const void *lp,
|
||||||
return sizeof(MSG32);
|
return sizeof(MSG32);
|
||||||
|
|
||||||
case WH_CBT:
|
case WH_CBT:
|
||||||
switch (params->code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case HCBT_CREATEWND:
|
case HCBT_CREATEWND:
|
||||||
if (lp)
|
|
||||||
{
|
{
|
||||||
const CREATESTRUCTW *cs = lp;
|
const CREATESTRUCTW *cs64 = lp;
|
||||||
CREATESTRUCT32 *cs32 = lp32;
|
CREATESTRUCT32 *cs32 = lp32;
|
||||||
createstruct_64to32( cs, cs32 );
|
createstruct_64to32( cs64, cs32 );
|
||||||
cs32->lpszName = PtrToUlong( cs->lpszName );
|
size -= sizeof(*cs64);
|
||||||
cs32->lpszClass = PtrToUlong( cs->lpszClass );
|
if (size) memmove( cs32 + 1, cs64 + 1, size );
|
||||||
|
return sizeof(*cs32) + size;
|
||||||
}
|
}
|
||||||
return sizeof(CREATESTRUCT32);
|
|
||||||
|
|
||||||
case HCBT_ACTIVATE:
|
case HCBT_ACTIVATE:
|
||||||
if (lp)
|
|
||||||
{
|
{
|
||||||
const CBTACTIVATESTRUCT *cbt = lp;
|
const CBTACTIVATESTRUCT *cbt = lp;
|
||||||
CBTACTIVATESTRUCT32 *cbt32 = lp32;
|
CBTACTIVATESTRUCT32 cbt32;
|
||||||
cbt32->fMouse = cbt->fMouse;
|
cbt32.fMouse = cbt->fMouse;
|
||||||
cbt32->hWndActive = HandleToUlong( cbt->hWndActive );
|
cbt32.hWndActive = HandleToUlong( cbt->hWndActive );
|
||||||
|
memcpy( lp32, &cbt32, sizeof(cbt32) );
|
||||||
|
return sizeof(cbt32);
|
||||||
}
|
}
|
||||||
return sizeof(CBTACTIVATESTRUCT32);
|
|
||||||
|
|
||||||
case HCBT_CLICKSKIPPED:
|
case HCBT_CLICKSKIPPED:
|
||||||
mousehookstruct_64to32( lp, lp32 );
|
mousehookstruct_64to32( lp, lp32 );
|
||||||
|
@ -676,120 +677,122 @@ static UINT hook_lparam_64to32( struct win_hook_params *params, const void *lp,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WH_CALLWNDPROC:
|
case WH_CALLWNDPROC:
|
||||||
if (lp)
|
|
||||||
{
|
{
|
||||||
const CWPSTRUCT *cwp = lp;
|
const CWPSTRUCT *cwp = lp;
|
||||||
CWPSTRUCT32 *cwp32 = lp32;
|
CWPSTRUCT32 cwp32;
|
||||||
cwp32->lParam = cwp->lParam;
|
cwp32.lParam = cwp->lParam;
|
||||||
cwp32->wParam = cwp->wParam;
|
cwp32.wParam = cwp->wParam;
|
||||||
cwp32->message = cwp->message;
|
cwp32.message = cwp->message;
|
||||||
cwp32->hwnd = HandleToUlong( cwp->hwnd );
|
cwp32.hwnd = HandleToUlong( cwp->hwnd );
|
||||||
|
memcpy( lp32, &cwp32, sizeof(cwp32) );
|
||||||
|
return sizeof(cwp32);
|
||||||
}
|
}
|
||||||
return sizeof(CWPSTRUCT32);
|
|
||||||
|
|
||||||
case WH_CALLWNDPROCRET:
|
case WH_CALLWNDPROCRET:
|
||||||
if (lp)
|
|
||||||
{
|
{
|
||||||
const CWPRETSTRUCT *cwpret = lp;
|
const CWPRETSTRUCT *cwpret = lp;
|
||||||
CWPRETSTRUCT32 *cwpret32 = lp32;
|
CWPRETSTRUCT32 cwpret32;
|
||||||
cwpret32->lResult = cwpret->lResult;
|
cwpret32.lResult = cwpret->lResult;
|
||||||
cwpret32->lParam = cwpret->lParam;
|
cwpret32.lParam = cwpret->lParam;
|
||||||
cwpret32->wParam = cwpret->wParam;
|
cwpret32.wParam = cwpret->wParam;
|
||||||
cwpret32->message = cwpret->message;
|
cwpret32.message = cwpret->message;
|
||||||
cwpret32->hwnd = HandleToUlong( cwpret->hwnd );
|
cwpret32.hwnd = HandleToUlong( cwpret->hwnd );
|
||||||
|
memcpy( lp32, &cwpret32, sizeof(cwpret32) );
|
||||||
|
return sizeof(cwpret32);
|
||||||
}
|
}
|
||||||
return sizeof(CWPRETSTRUCT32);
|
|
||||||
|
|
||||||
case WH_MOUSE:
|
case WH_MOUSE:
|
||||||
mousehookstruct_64to32( lp, lp32 );
|
mousehookstruct_64to32( lp, lp32 );
|
||||||
return sizeof(MOUSEHOOKSTRUCTEX32);
|
return sizeof(MOUSEHOOKSTRUCTEX32);
|
||||||
|
|
||||||
case WH_MOUSE_LL:
|
case WH_MOUSE_LL:
|
||||||
if (lp)
|
|
||||||
{
|
{
|
||||||
const MSLLHOOKSTRUCT *hook = lp;
|
const MSLLHOOKSTRUCT *hook = lp;
|
||||||
MSLLHOOKSTRUCT32 *hook32 = lp32;
|
MSLLHOOKSTRUCT32 hook32;
|
||||||
hook32->pt = hook->pt;
|
hook32.pt = hook->pt;
|
||||||
hook32->mouseData = hook->mouseData;
|
hook32.mouseData = hook->mouseData;
|
||||||
hook32->flags = hook->flags;
|
hook32.flags = hook->flags;
|
||||||
hook32->time = hook->time;
|
hook32.time = hook->time;
|
||||||
hook32->dwExtraInfo = hook->dwExtraInfo;
|
hook32.dwExtraInfo = hook->dwExtraInfo;
|
||||||
|
memcpy( lp32, &hook32, sizeof(hook32) );
|
||||||
|
return sizeof(hook32);
|
||||||
}
|
}
|
||||||
return sizeof(MSLLHOOKSTRUCT32);
|
|
||||||
|
|
||||||
case WH_KEYBOARD_LL:
|
case WH_KEYBOARD_LL:
|
||||||
if (lp)
|
|
||||||
{
|
{
|
||||||
const KBDLLHOOKSTRUCT *hook = lp;
|
const KBDLLHOOKSTRUCT *hook = lp;
|
||||||
KBDLLHOOKSTRUCT32 *hook32 = lp32;
|
KBDLLHOOKSTRUCT32 hook32;
|
||||||
hook32->vkCode = hook->vkCode;
|
hook32.vkCode = hook->vkCode;
|
||||||
hook32->scanCode = hook->scanCode;
|
hook32.scanCode = hook->scanCode;
|
||||||
hook32->flags = hook->flags;
|
hook32.flags = hook->flags;
|
||||||
hook32->time = hook->time;
|
hook32.time = hook->time;
|
||||||
hook32->dwExtraInfo = hook->dwExtraInfo;
|
hook32.dwExtraInfo = hook->dwExtraInfo;
|
||||||
|
memcpy( lp32, &hook32, sizeof(hook32) );
|
||||||
|
return sizeof(hook32);
|
||||||
}
|
}
|
||||||
return sizeof(KBDLLHOOKSTRUCT32);
|
|
||||||
|
|
||||||
case WH_JOURNALRECORD:
|
case WH_JOURNALRECORD:
|
||||||
if (lp)
|
|
||||||
{
|
{
|
||||||
const EVENTMSG *event = lp;
|
const EVENTMSG *event = lp;
|
||||||
EVENTMSG32 *event32 = lp32;
|
EVENTMSG32 event32;
|
||||||
|
|
||||||
event32->message = event->message;
|
event32.message = event->message;
|
||||||
event32->paramL = event->paramL;
|
event32.paramL = event->paramL;
|
||||||
event32->paramH = event->paramH;
|
event32.paramH = event->paramH;
|
||||||
event32->time = event->time;
|
event32.time = event->time;
|
||||||
event32->hwnd = HandleToUlong( event->hwnd );
|
event32.hwnd = HandleToUlong( event->hwnd );
|
||||||
|
memcpy( lp32, &event32, sizeof(event32) );
|
||||||
|
return sizeof(event32);
|
||||||
}
|
}
|
||||||
return sizeof(EVENTMSG32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lp) memcpy( lp32, lp, params->lparam_size );
|
memmove( lp32, lp, size );
|
||||||
return params->lparam_size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS WINAPI wow64_NtUserCallWindowsHook( void *arg, ULONG size )
|
static NTSTATUS WINAPI wow64_NtUserCallWindowsHook( void *arg, ULONG size )
|
||||||
{
|
{
|
||||||
struct win_hook_params *params = arg;
|
struct win_hook_params *params = arg;
|
||||||
struct win_hook_params32 *params32;
|
struct win_hook_params32 params32;
|
||||||
UINT lparam32_size = 0, module_size, size32;
|
UINT lparam64_size, module_size;
|
||||||
void *ret_ptr;
|
void *ret_ptr;
|
||||||
ULONG ret_len;
|
ULONG ret_len;
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
|
|
||||||
lparam32_size = hook_lparam_64to32( params, NULL, NULL );
|
|
||||||
module_size = size - params->lparam_size - sizeof(*params);
|
module_size = size - params->lparam_size - sizeof(*params);
|
||||||
|
lparam64_size = params->lparam_size;
|
||||||
|
|
||||||
size32 = sizeof(*params32) + lparam32_size + module_size;
|
params32.proc = PtrToUlong( params->proc );
|
||||||
if (!(params32 = Wow64AllocateTemp( size32 ))) return 0;
|
params32.handle = HandleToUlong( params->handle );
|
||||||
params32->proc = (UINT_PTR)params->proc;
|
params32.pid = params->pid;
|
||||||
params32->handle = HandleToUlong( params->handle );
|
params32.tid = params->tid;
|
||||||
params32->pid = params->pid;
|
params32.id = params->id;
|
||||||
params32->tid = params->tid;
|
params32.code = params->code;
|
||||||
params32->id = params->id;
|
params32.wparam = params->wparam;
|
||||||
params32->code = params->code;
|
params32.lparam = lparam64_size ? 0 : params->lparam;
|
||||||
params32->wparam = params->wparam;
|
params32.prev_unicode = params->prev_unicode;
|
||||||
params32->lparam = params->lparam_size ? 0 : params->lparam;
|
params32.next_unicode = params->next_unicode;
|
||||||
params32->lparam_size = lparam32_size;
|
params32.lparam_size = hook_lparam_64to32( params32.id, params32.code, params + 1,
|
||||||
params32->prev_unicode = params->prev_unicode;
|
lparam64_size, (char *)arg + sizeof(params32) );
|
||||||
params32->next_unicode = params->next_unicode;
|
memcpy( arg, ¶ms32, sizeof(params32) );
|
||||||
if (lparam32_size) hook_lparam_64to32( params, params + 1, params32 + 1 );
|
|
||||||
if (module_size)
|
if (module_size)
|
||||||
memcpy( (char *)(params32 + 1) + params32->lparam_size,
|
memmove( (char *)arg + sizeof(params32) + params32.lparam_size,
|
||||||
(const char *)params + size - module_size, module_size );
|
(const char *)arg + size - module_size, module_size );
|
||||||
|
|
||||||
ret = Wow64KiUserCallbackDispatcher( NtUserCallWindowsHook, params32, size32, &ret_ptr, &ret_len );
|
ret = Wow64KiUserCallbackDispatcher( NtUserCallWindowsHook, arg,
|
||||||
|
sizeof(params32) + params32.lparam_size + module_size,
|
||||||
|
&ret_ptr, &ret_len );
|
||||||
|
|
||||||
switch (params->id)
|
switch (params32.id)
|
||||||
{
|
{
|
||||||
case WH_SYSMSGFILTER:
|
case WH_SYSMSGFILTER:
|
||||||
case WH_MSGFILTER:
|
case WH_MSGFILTER:
|
||||||
case WH_GETMESSAGE:
|
case WH_GETMESSAGE:
|
||||||
if (params->lparam_size == sizeof(MSG))
|
if (ret_len == sizeof(MSG32))
|
||||||
{
|
{
|
||||||
msg_32to64( (MSG *)(params + 1), (const MSG32 *)(params32 + 1) );
|
MSG msg;
|
||||||
return NtCallbackReturn( params + 1, params->lparam_size, ret );
|
msg_32to64( &msg, ret_ptr );
|
||||||
|
return NtCallbackReturn( &msg, sizeof(msg), ret );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2907,7 +2910,16 @@ static LRESULT message_call_32to64( HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
||||||
|
|
||||||
createstruct_32to64( cs32, &cs );
|
createstruct_32to64( cs32, &cs );
|
||||||
ret = NtUserMessageCall( hwnd, msg, wparam, (LPARAM)&cs, result_info, type, ansi );
|
ret = NtUserMessageCall( hwnd, msg, wparam, (LPARAM)&cs, result_info, type, ansi );
|
||||||
createstruct_64to32( &cs, cs32 );
|
cs32->lpCreateParams = PtrToUlong( cs.lpCreateParams );
|
||||||
|
cs32->hInstance = PtrToUlong( cs.hInstance );
|
||||||
|
cs32->hMenu = HandleToLong( cs.hMenu );
|
||||||
|
cs32->hwndParent = HandleToLong( cs.hwndParent );
|
||||||
|
cs32->cy = cs.cy;
|
||||||
|
cs32->cx = cs.cx;
|
||||||
|
cs32->y = cs.y;
|
||||||
|
cs32->x = cs.x;
|
||||||
|
cs32->style = cs.style;
|
||||||
|
cs32->dwExStyle = cs.dwExStyle;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue