/*********************************************************************** * CallMsgFilter32 (USER.823) */ BOOL16 WINAPI CallMsgFilter32_16( MSG32_16 *lpmsg16_32, INT16 code, BOOL16 wHaveParamHigh ) { MSG msg32; BOOL16 ret; if (GetSysModalWindow16()) return FALSE; msg32.hwnd = WIN_Handle32( lpmsg16_32->msg.hwnd ); msg32.message = lpmsg16_32->msg.message; msg32.lParam = lpmsg16_32->msg.lParam; msg32.time = lpmsg16_32->msg.time; msg32.pt.x = lpmsg16_32->msg.pt.x; msg32.pt.y = lpmsg16_32->msg.pt.y; if (wHaveParamHigh) msg32.wParam = MAKELONG(lpmsg16_32->msg.wParam, lpmsg16_32->wParamHigh); else msg32.wParam = lpmsg16_32->msg.wParam; ret = (BOOL16)CallMsgFilterA(&msg32, code); lpmsg16_32->msg.hwnd = HWND_16( msg32.hwnd ); lpmsg16_32->msg.message = msg32.message; lpmsg16_32->msg.wParam = LOWORD(msg32.wParam); lpmsg16_32->msg.lParam = msg32.lParam; lpmsg16_32->msg.time = msg32.time; lpmsg16_32->msg.pt.x = msg32.pt.x; lpmsg16_32->msg.pt.y = msg32.pt.y; if (wHaveParamHigh) lpmsg16_32->wParamHigh = HIWORD(msg32.wParam); return ret; }
/*********************************************************************** * SetSystemTimer (USER.11) */ UINT16 WINAPI SetSystemTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout, TIMERPROC16 proc ) { TRACE("%04x %d %d %08lx\n", hwnd, id, timeout, (LONG)proc ); return TIMER_SetTimer( WIN_Handle32(hwnd), id, timeout, (WNDPROC16)proc, WIN_PROC_16, TRUE ); }
/*********************************************************************** * map_msg_16_to_32 */ static inline void map_msg_16_to_32( const MSG16 *msg16, MSG *msg32 ) { msg32->hwnd = WIN_Handle32(msg16->hwnd); msg32->message = msg16->message; msg32->wParam = msg16->wParam; msg32->lParam = msg16->lParam; msg32->time = msg16->time; msg32->pt.x = msg16->pt.x; msg32->pt.y = msg16->pt.y; }
/*********************************************************************** * EnableCommNotification (USER.245) */ BOOL16 WINAPI EnableCommNotification16( INT16 cid, HWND16 hwnd, INT16 cbWriteNotify, INT16 cbOutQueue ) { struct DosDeviceStruct *ptr; TRACE("(%d, %x, %d, %d)\n", cid, hwnd, cbWriteNotify, cbOutQueue); if ((ptr = GetDeviceStruct(cid)) == NULL) { FIXME("no handle for cid = %0x!\n",cid); return -1; } ptr->wnd = WIN_Handle32( hwnd ); ptr->n_read = cbWriteNotify; ptr->n_write = cbOutQueue; return TRUE; }
/*********************************************************************** * CallNextHookEx (USER.293) */ LRESULT WINAPI CallNextHookEx16( HHOOK hhook, INT16 code, WPARAM16 wparam, LPARAM lparam ) { struct hook16_queue_info *info; LRESULT ret = 0; if (!(info = get_user_thread_info()->hook16_info)) return 0; switch (info->id) { case WH_MSGFILTER: { MSG16 *msg16 = MapSL(lparam); MSG msg32; map_msg_16_to_32( msg16, &msg32 ); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&msg32 ); break; } case WH_GETMESSAGE: { MSG16 *msg16 = MapSL(lparam); MSG msg32; map_msg_16_to_32( msg16, &msg32 ); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&msg32 ); map_msg_32_to_16( &msg32, msg16 ); break; } case WH_CALLWNDPROC: { CWPSTRUCT16 *cwp16 = MapSL(lparam); LRESULT result; struct wndproc_hook_params params; params.hhook = hhook; params.code = code; params.wparam = wparam; ret = WINPROC_CallProc16To32A( wndproc_hook_callback, cwp16->hwnd, cwp16->message, cwp16->wParam, cwp16->lParam, &result, ¶ms ); break; } case WH_CBT: switch (code) { case HCBT_CREATEWND: { CBT_CREATEWNDA cbtcw32; CREATESTRUCTA cs32; CBT_CREATEWND16 *cbtcw16 = MapSL(lparam); CREATESTRUCT16 *cs16 = MapSL( (SEGPTR)cbtcw16->lpcs ); cbtcw32.lpcs = &cs32; cbtcw32.hwndInsertAfter = WIN_Handle32( cbtcw16->hwndInsertAfter ); cs32.lpCreateParams = (LPVOID)cs16->lpCreateParams; cs32.hInstance = HINSTANCE_32(cs16->hInstance); cs32.hMenu = HMENU_32(cs16->hMenu); cs32.hwndParent = WIN_Handle32(cs16->hwndParent); cs32.cy = cs16->cy; cs32.cx = cs16->cx; cs32.y = cs16->y; cs32.x = cs16->x; cs32.style = cs16->style; cs32.lpszName = MapSL( cs16->lpszName ); cs32.lpszClass = MapSL( cs16->lpszClass ); cs32.dwExStyle = cs16->dwExStyle; ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&cbtcw32 ); cbtcw16->hwndInsertAfter = HWND_16( cbtcw32.hwndInsertAfter ); break; } case HCBT_ACTIVATE: { CBTACTIVATESTRUCT16 *cas16 = MapSL(lparam); CBTACTIVATESTRUCT cas32; cas32.fMouse = cas16->fMouse; cas32.hWndActive = WIN_Handle32(cas16->hWndActive); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&cas32 ); break; } case HCBT_CLICKSKIPPED: { MOUSEHOOKSTRUCT16 *ms16 = MapSL(lparam); MOUSEHOOKSTRUCT ms32; ms32.pt.x = ms16->pt.x; ms32.pt.y = ms16->pt.y; /* wHitTestCode may be negative, so convince compiler to do correct sign extension. Yay. :| */ ms32.wHitTestCode = (INT)(INT16)ms16->wHitTestCode; ms32.dwExtraInfo = ms16->dwExtraInfo; ms32.hwnd = WIN_Handle32( ms16->hwnd ); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&ms32 ); break; } case HCBT_MOVESIZE: { RECT16 *rect16 = MapSL(lparam); RECT rect32; rect32.left = rect16->left; rect32.top = rect16->top; rect32.right = rect16->right; rect32.bottom = rect16->bottom; ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&rect32 ); break; } } break; case WH_MOUSE: { MOUSEHOOKSTRUCT16 *ms16 = MapSL(lparam); MOUSEHOOKSTRUCT ms32; ms32.pt.x = ms16->pt.x; ms32.pt.y = ms16->pt.y; /* wHitTestCode may be negative, so convince compiler to do correct sign extension. Yay. :| */ ms32.wHitTestCode = (INT)((INT16)ms16->wHitTestCode); ms32.dwExtraInfo = ms16->dwExtraInfo; ms32.hwnd = WIN_Handle32(ms16->hwnd); ret = CallNextHookEx( hhook, code, wparam, (LPARAM)&ms32 ); break; } case WH_SHELL: case WH_KEYBOARD: ret = CallNextHookEx( hhook, code, wparam, lparam ); break; case WH_HARDWARE: case WH_FOREGROUNDIDLE: case WH_CALLWNDPROCRET: case WH_SYSMSGFILTER: case WH_JOURNALRECORD: case WH_JOURNALPLAYBACK: default: FIXME("\t[%i] 16to32 translation unimplemented\n", info->id); ret = CallNextHookEx( hhook, code, wparam, lparam ); break; } return ret; }
/*********************************************************************** * call_WH_CBT */ static LRESULT CALLBACK call_WH_CBT( INT code, WPARAM wp, LPARAM lp ) { LRESULT ret = 0; switch (code) { case HCBT_CREATEWND: { CBT_CREATEWNDA *cbtcw32 = (CBT_CREATEWNDA *)lp; CBT_CREATEWND16 cbtcw16; CREATESTRUCT16 cs16; cs16.lpCreateParams = (SEGPTR)cbtcw32->lpcs->lpCreateParams; cs16.hInstance = HINSTANCE_16(cbtcw32->lpcs->hInstance); cs16.hMenu = HMENU_16(cbtcw32->lpcs->hMenu); cs16.hwndParent = HWND_16(cbtcw32->lpcs->hwndParent); cs16.cy = cbtcw32->lpcs->cy; cs16.cx = cbtcw32->lpcs->cx; cs16.y = cbtcw32->lpcs->y; cs16.x = cbtcw32->lpcs->x; cs16.style = cbtcw32->lpcs->style; cs16.lpszName = MapLS( cbtcw32->lpcs->lpszName ); cs16.lpszClass = MapLS( cbtcw32->lpcs->lpszClass ); cs16.dwExStyle = cbtcw32->lpcs->dwExStyle; cbtcw16.lpcs = (CREATESTRUCT16 *)MapLS( &cs16 ); cbtcw16.hwndInsertAfter = HWND_16( cbtcw32->hwndInsertAfter ); lp = MapLS( &cbtcw16 ); ret = call_hook_16( WH_CBT, code, wp, lp ); UnMapLS( cs16.lpszName ); UnMapLS( cs16.lpszClass ); cbtcw32->hwndInsertAfter = WIN_Handle32( cbtcw16.hwndInsertAfter ); UnMapLS( (SEGPTR)cbtcw16.lpcs ); UnMapLS( lp ); break; } case HCBT_ACTIVATE: { CBTACTIVATESTRUCT *cas32 = (CBTACTIVATESTRUCT *)lp; CBTACTIVATESTRUCT16 cas16; cas16.fMouse = cas32->fMouse; cas16.hWndActive = HWND_16( cas32->hWndActive ); lp = MapLS( &cas16 ); ret = call_hook_16( WH_CBT, code, wp, lp ); UnMapLS( lp ); break; } case HCBT_CLICKSKIPPED: { MOUSEHOOKSTRUCT *ms32 = (MOUSEHOOKSTRUCT *)lp; MOUSEHOOKSTRUCT16 ms16; ms16.pt.x = ms32->pt.x; ms16.pt.y = ms32->pt.y; ms16.hwnd = HWND_16( ms32->hwnd ); ms16.wHitTestCode = ms32->wHitTestCode; ms16.dwExtraInfo = ms32->dwExtraInfo; lp = MapLS( &ms16 ); ret = call_hook_16( WH_CBT, code, wp, lp ); UnMapLS( lp ); break; } case HCBT_MOVESIZE: { RECT *rect32 = (RECT *)lp; RECT16 rect16; rect16.left = rect32->left; rect16.top = rect32->top; rect16.right = rect32->right; rect16.bottom = rect32->bottom; lp = MapLS( &rect16 ); ret = call_hook_16( WH_CBT, code, wp, lp ); UnMapLS( lp ); break; } } return ret; }