00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <odin.h>
00019 #include <odinwrap.h>
00020 #include <os2sel.h>
00021
00022 #include <os2win.h>
00023 #include <misc.h>
00024 #include <win32wbase.h>
00025 #include <win.h>
00026 #include <heapstring.h>
00027 #include <handlemanager.h>
00028 #include "oslibutil.h"
00029 #include "oslibwin.h"
00030 #include "oslibmsg.h"
00031 #include "hook.h"
00032
00033 #define DBG_LOCALLOG DBG_windowmsg
00034 #include "dbglocal.h"
00035
00036 ODINDEBUGCHANNEL(USER32-WINDOWMSG)
00037
00038
00039
00040
00041 VOID WIN32API PostQuitMessage( int nExitCode)
00042 {
00043 dprintf(("USER32: PostQuitMessage\n"));
00044 OSLibWinPostQuitMessage(nExitCode);
00045 }
00046
00047
00048 LONG WIN32API DispatchMessageA(const MSG * msg)
00049 {
00050 dprintf2(("DispatchMessageA %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
00051 return OSLibWinDispatchMsg((MSG *)msg);
00052 }
00053
00054
00055 LONG WIN32API DispatchMessageW( const MSG * msg)
00056 {
00057 dprintf2(("DispatchMessageW %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
00058 return OSLibWinDispatchMsg((MSG *)msg, TRUE);
00059 }
00060
00061
00062 BOOL WIN32API TranslateMessage(const MSG *msg)
00063 {
00064
00065 if ( (msg->message < WM_KEYDOWN) ||
00066 (msg->message > WM_SYSKEYUP)||
00067 (msg->message == WM_CHAR) ||
00068 (msg->message == WM_DEADCHAR) )
00069 {
00070 SetLastError(ERROR_INVALID_PARAMETER);
00071 return FALSE;
00072 }
00073
00074
00075
00076
00077 return OSLibWinTranslateMessage((MSG *)msg);
00078 }
00079
00080
00081 BOOL WIN32API GetMessageA( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax)
00082 {
00083 BOOL ret;
00084
00085 dprintf2(("GetMessageA %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax));
00086 ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax);
00087 if(ret) dprintf2(("GetMessageA %x %x %x %x", hwnd, pMsg->message, pMsg->wParam, pMsg->lParam));
00088 HOOK_CallHooksA(WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)pMsg);
00089 return ret;
00090 }
00091
00092
00093 BOOL WIN32API GetMessageW( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax)
00094 {
00095 BOOL ret;
00096
00097 dprintf2(("GetMessageW %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax));
00098 ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, TRUE);
00099 HOOK_CallHooksW(WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)pMsg);
00100 return ret;
00101 }
00102
00103
00104 BOOL WIN32API PeekMessageA(LPMSG msg, HWND hwndOwner, UINT uMsgFilterMin,
00105 UINT uMsgFilterMax, UINT fuRemoveMsg)
00106 {
00107 BOOL fFoundMsg;
00108
00109 dprintf2(("PeekMessageA %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg));
00110 fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax,
00111 fuRemoveMsg, FALSE);
00112 if(fFoundMsg) {
00113 dprintf2(("PeekMessageA %x %d-%d %d found message %x %d %x %x", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, msg->hwnd, msg->message, msg->wParam, msg->lParam));
00114 HOOK_CallHooksA(WH_GETMESSAGE, HC_ACTION, fuRemoveMsg & PM_REMOVE, (LPARAM)msg );
00115 if (msg->message == WM_QUIT && (fuRemoveMsg & PM_REMOVE)) {
00116
00117 }
00118 }
00119 return fFoundMsg;
00120 }
00121
00122
00123 BOOL WIN32API PeekMessageW(LPMSG msg, HWND hwndOwner, UINT uMsgFilterMin,
00124 UINT uMsgFilterMax, UINT fuRemoveMsg)
00125 {
00126 BOOL fFoundMsg;
00127
00128 dprintf2(("PeekMessageW %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg));
00129 fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax,
00130 fuRemoveMsg, TRUE);
00131 if(fFoundMsg) {
00132 dprintf2(("PeekMessageW %x %d-%d %d found message %x %d %x %x", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, msg->hwnd, msg->message, msg->wParam, msg->lParam));
00133 HOOK_CallHooksW(WH_GETMESSAGE, HC_ACTION, fuRemoveMsg & PM_REMOVE, (LPARAM)msg );
00134 if (msg->message == WM_QUIT && (fuRemoveMsg & (PM_REMOVE))) {
00135
00136 }
00137 }
00138 return fFoundMsg;
00139 }
00140
00141
00142
00143 LONG WIN32API GetMessageExtraInfo()
00144 {
00145 dprintf(("USER32: GetMessageExtraInfo %x", GetThreadMessageExtraInfo()));
00146 return GetThreadMessageExtraInfo();
00147 }
00148
00149
00150 LPARAM WIN32API SetMessageExtraInfo(LPARAM lParam)
00151 {
00152 dprintf(("USER32: SetMessageExtraInfo %x", lParam));
00153 return SetThreadMessageExtraInfo(lParam);
00154 }
00155
00156
00157 DWORD WIN32API GetMessagePos(void)
00158 {
00159 DWORD pos;
00160
00161 pos = OSLibWinGetMessagePos();
00162 dprintf(("USER32: GetMessagePos -> (%d,%d)", HIWORD(pos), LOWORD(pos)));
00163 return pos;
00164 }
00165
00166
00167 LONG WIN32API GetMessageTime(void)
00168 {
00169 dprintf(("USER32: GetMessageTime"));
00170 return OSLibWinGetMessageTime();
00171 }
00172
00173
00174 LRESULT WIN32API SendMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00175 {
00176 Win32BaseWindow *window;
00177 LRESULT result;
00178
00179 if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
00180 {
00181 Win32BaseWindow::BroadcastMessageA(BROADCAST_SEND, msg, wParam, lParam);
00182 return TRUE;
00183 }
00184
00185 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
00186 if(!window) {
00187 dprintf(("SendMessageA, %x %x %x window %x not found", msg, wParam, lParam, hwnd));
00188 return 0;
00189 }
00190 result = window->SendMessageA(msg, wParam, lParam);
00191 RELEASE_WNDOBJ(window);
00192 return result;
00193 }
00194
00195
00196 LRESULT WIN32API SendMessageW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00197 {
00198 Win32BaseWindow *window;
00199 LRESULT result;
00200
00201 if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
00202 {
00203 Win32BaseWindow::BroadcastMessageW(BROADCAST_SEND, msg, wParam, lParam);
00204 return TRUE;
00205 }
00206
00207 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
00208 if(!window) {
00209 dprintf(("SendMessageW, window %x not found", hwnd));
00210 return 0;
00211 }
00212 result = window->SendMessageW(msg, wParam, lParam);
00213 RELEASE_WNDOBJ(window);
00214 return result;
00215 }
00216
00217
00218 BOOL WIN32API PostMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00219 {
00220 Win32BaseWindow *window;
00221 HWND hwndOS2;
00222
00223 if (hwnd == HWND_BROADCAST)
00224 {
00225 Win32BaseWindow::BroadcastMessageA(BROADCAST_POST, msg, wParam, lParam);
00226 return TRUE;
00227 }
00228
00229 if(hwnd == NULL)
00230 return PostThreadMessageA(GetCurrentThreadId(), msg, wParam, lParam);
00231
00232 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
00233 if(!window) {
00234 dprintf(("PostMessageA, window %x not found", hwnd));
00235 return FALSE;
00236 }
00237 hwndOS2 = window->getOS2WindowHandle();
00238 RELEASE_WNDOBJ(window);
00239 dprintf(("PostMessageA, %x %x %x %x", hwnd, msg, wParam, lParam));
00240 return OSLibPostMessage(hwndOS2, msg, wParam, lParam, FALSE);
00241 }
00242
00243
00244 BOOL WIN32API PostMessageW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00245 {
00246 Win32BaseWindow *window;
00247 HWND hwndOS2;
00248
00249 if (hwnd == HWND_BROADCAST)
00250 {
00251 Win32BaseWindow::BroadcastMessageW(BROADCAST_POST, msg, wParam, lParam);
00252 return TRUE;
00253 }
00254
00255 if(hwnd == NULL)
00256 return PostThreadMessageW(GetCurrentThreadId(), msg, wParam, lParam);
00257
00258 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
00259 if(!window) {
00260 dprintf(("PostMessageW, window %x not found", hwnd));
00261 return FALSE;
00262 }
00263 hwndOS2 = window->getOS2WindowHandle();
00264 RELEASE_WNDOBJ(window);
00265 dprintf(("PostMessageW, %x %x %x %x", hwnd, msg, wParam, lParam));
00266 return OSLibPostMessage(hwndOS2, msg, wParam, lParam, TRUE);
00267 }
00268
00269
00270 BOOL WIN32API PostThreadMessageA( DWORD threadid, UINT msg, WPARAM wParam, LPARAM lParam)
00271 {
00272 return OSLibPostThreadMessage(threadid, msg, wParam, lParam, FALSE);
00273 }
00274
00275
00276 BOOL WIN32API PostThreadMessageW( DWORD threadid, UINT msg, WPARAM wParam, LPARAM lParam)
00277 {
00278 return OSLibPostThreadMessage(threadid, msg, wParam, lParam, TRUE);
00279 }
00280
00281
00282 BOOL WIN32API WaitMessage(void)
00283 {
00284 dprintf2(("USER32: WaitMessage"));
00285 return OSLibWinWaitMessage();
00286 }
00287
00288
00289 BOOL WIN32API InSendMessage(void)
00290 {
00291 dprintf(("USER32: InSendMessage"));
00292 return OSLibWinInSendMessage();
00293 }
00294
00295
00296 BOOL WIN32API ReplyMessage(LRESULT result)
00297 {
00298 dprintf(("USER32: ReplyMessage %x", result));
00299 return OSLibWinReplyMessage(result);
00300 }
00301
00302
00303 UINT WIN32API RegisterWindowMessageA(LPCSTR lpString)
00304 {
00305 UINT rc;
00306
00307 rc = GlobalAddAtomA(lpString);
00308 dprintf(("USER32: RegisterWindowMessageA %s returned %X\n", lpString, rc));
00309 return(rc);
00310 }
00311
00312
00313 UINT WIN32API RegisterWindowMessageW( LPCWSTR lpString)
00314 {
00315 dprintf(("USER32: RegisterWindowMessageW\n"));
00316 return GlobalAddAtomW(lpString);
00317 }
00318
00319
00320
00321 BOOL WIN32API SetMessageQueue(int cMessagesMax)
00322 {
00323 dprintf(("USER32: SetMessageQueue\n"));
00324 return(TRUE);
00325 }
00326
00327
00328 LRESULT WIN32API SendMessageTimeoutA(HWND hwnd, UINT Msg, WPARAM wParam,
00329 LPARAM lParam, UINT fuFlags, UINT uTimeOut,
00330 LPDWORD lpdwResult)
00331 {
00332 dprintf(("USER32: SendMessageTimeoutA, partially implemented\n"));
00333
00334 *lpdwResult = SendMessageA(hwnd, Msg, wParam, lParam);
00335 return(TRUE);
00336 }
00337
00338
00339 LRESULT WIN32API SendMessageTimeoutW(HWND hwnd, UINT Msg, WPARAM wParam,
00340 LPARAM lParam, UINT fuFlags, UINT uTimeOut,
00341 LPDWORD lpdwResult)
00342 {
00343 dprintf(("USER32: SendMessageTimeoutW, partially implemented\n"));
00344 return(SendMessageTimeoutA(hwnd, Msg, wParam, lParam, fuFlags, uTimeOut, lpdwResult));
00345 }
00346
00347
00348 BOOL WIN32API SendNotifyMessageA(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
00349 {
00350 dprintf(("USER32: SendNotifyMessageA, not completely implemented\n"));
00351 return(SendMessageA(hwnd, Msg, wParam, lParam));
00352 }
00353
00354
00355 BOOL WIN32API SendNotifyMessageW(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
00356 {
00357 dprintf(("USER32: SendNotifyMessageW, not completely implemented\n"));
00358 return(SendMessageA(hwnd, Msg, wParam, lParam));
00359 }
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384 BOOL WIN32API SendMessageCallbackA(HWND hWnd,
00385 UINT uMsg,
00386 WPARAM wParam,
00387 LPARAM lParam,
00388 SENDASYNCPROC lpResultCallBack,
00389 DWORD dwData)
00390 {
00391 dprintf(("USER32:SendMessageCallBackA (%08xh,%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n",
00392 hWnd,
00393 uMsg,
00394 wParam,
00395 lParam,
00396 lpResultCallBack,
00397 dwData));
00398
00399 return (FALSE);
00400 }
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 BOOL WIN32API SendMessageCallbackW(HWND hWnd,
00428 UINT uMsg,
00429 WPARAM wParam,
00430 LPARAM lParam,
00431 SENDASYNCPROC lpResultCallBack,
00432 DWORD dwData)
00433 {
00434 dprintf(("USER32:SendMessageCallBackW (%08xh,%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n",
00435 hWnd,
00436 uMsg,
00437 wParam,
00438 lParam,
00439 lpResultCallBack,
00440 dwData));
00441
00442 return (FALSE);
00443 }
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465 long WIN32API BroadcastSystemMessage(DWORD dwFlags,
00466 LPDWORD lpdwRecipients,
00467 UINT uiMessage,
00468 WPARAM wParam,
00469 LPARAM lParam)
00470 {
00471 dprintf(("USER32:BroadcastSystemMessage(%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n",
00472 dwFlags,
00473 lpdwRecipients,
00474 uiMessage,
00475 wParam,
00476 lParam));
00477
00478 return (-1);
00479 }
00480
00481
00482
00483
00484
00485
00486
00487 BOOL WINPROC_TestCBForStr ( HWND hwnd )
00488 {
00489 BOOL retvalue;
00490 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
00491 retvalue = ( !(LOWORD(dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
00492 (LOWORD(dwStyle) & CBS_HASSTRINGS) );
00493 return retvalue;
00494 }
00495
00496
00497
00498
00499
00500 BOOL WINPROC_TestLBForStr ( HWND hwnd )
00501 {
00502 BOOL retvalue;
00503 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
00504 retvalue = ( !(LOWORD(dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
00505 (LOWORD(dwStyle) & LBS_HASSTRINGS) );
00506 return retvalue;
00507 }
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523 INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam )
00524 {
00525 switch(msg)
00526 {
00527 case WM_GETTEXT:
00528 {
00529 LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
00530 wParam * sizeof(WCHAR) + sizeof(LPARAM) );
00531 if (!ptr) return -1;
00532 *ptr++ = *plparam;
00533 *plparam = (LPARAM)ptr;
00534 }
00535 return 1;
00536
00537 case WM_SETTEXT:
00538 case WM_WININICHANGE:
00539 case CB_DIR:
00540 case LB_DIR:
00541 case LB_ADDFILE:
00542 #ifndef __WIN32OS2__
00543 case CB_FINDSTRING:
00544 case CB_FINDSTRINGEXACT:
00545 case CB_SELECTSTRING:
00546 case LB_FINDSTRING:
00547 case LB_SELECTSTRING:
00548 #endif
00549 case EM_REPLACESEL:
00550 *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
00551 return (*plparam ? 1 : -1);
00552
00553 case WM_NCCREATE:
00554 case WM_CREATE:
00555 {
00556 CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0,
00557 sizeof(*cs) );
00558 if (!cs) return -1;
00559 *cs = *(CREATESTRUCTW *)*plparam;
00560 if (HIWORD(cs->lpszName))
00561 cs->lpszName = HEAP_strdupAtoW( GetProcessHeap(), 0,
00562 (LPCSTR)cs->lpszName );
00563 if (HIWORD(cs->lpszClass))
00564 cs->lpszClass = HEAP_strdupAtoW( GetProcessHeap(), 0,
00565 (LPCSTR)cs->lpszClass );
00566 *plparam = (LPARAM)cs;
00567 }
00568 return 1;
00569 case WM_MDICREATE:
00570 {
00571 MDICREATESTRUCTW *cs =
00572 (MDICREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) );
00573 if (!cs) return -1;
00574 *cs = *(MDICREATESTRUCTW *)*plparam;
00575 if (HIWORD(cs->szClass))
00576 cs->szClass = HEAP_strdupAtoW( GetProcessHeap(), 0,
00577 (LPCSTR)cs->szClass );
00578 if (HIWORD(cs->szTitle))
00579 cs->szTitle = HEAP_strdupAtoW( GetProcessHeap(), 0,
00580 (LPCSTR)cs->szTitle );
00581 *plparam = (LPARAM)cs;
00582 }
00583 return 1;
00584
00585
00586 case LB_ADDSTRING:
00587 #ifdef __WIN32OS2__
00588 case LB_FINDSTRING:
00589 case LB_FINDSTRINGEXACT:
00590 case LB_SELECTSTRING:
00591 #endif
00592 case LB_INSERTSTRING:
00593 if ( WINPROC_TestLBForStr( hwnd ))
00594 *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
00595 return (*plparam ? 1 : -1);
00596
00597 case LB_GETTEXT:
00598 { if ( WINPROC_TestLBForStr( hwnd ))
00599 { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
00600 if (!ptr) return -1;
00601 *ptr++ = *plparam;
00602 *plparam = (LPARAM)ptr;
00603 }
00604 }
00605 return 1;
00606
00607
00608 case CB_ADDSTRING:
00609 #ifdef __WIN32OS2__
00610 case CB_FINDSTRING:
00611 case CB_FINDSTRINGEXACT:
00612 case CB_SELECTSTRING:
00613 #endif
00614 case CB_INSERTSTRING:
00615 if ( WINPROC_TestCBForStr( hwnd ))
00616 *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
00617 return (*plparam ? 1 : -1);
00618
00619 case CB_GETLBTEXT:
00620 { if ( WINPROC_TestCBForStr( hwnd ))
00621 { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
00622 if (!ptr) return -1;
00623 *ptr++ = *plparam;
00624 *plparam = (LPARAM)ptr;
00625 }
00626 }
00627 return 1;
00628
00629
00630 case EM_GETLINE:
00631 { WORD len = (WORD)*plparam;
00632 LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
00633 if (!ptr) return -1;
00634 *ptr++ = *plparam;
00635 *((WORD *) ptr) = len;
00636 *plparam = (LPARAM)ptr;
00637 }
00638 return 1;
00639
00640 case WM_ASKCBFORMATNAME:
00641 case WM_DEVMODECHANGE:
00642 case WM_PAINTCLIPBOARD:
00643 case WM_SIZECLIPBOARD:
00644 case EM_SETPASSWORDCHAR:
00645
00646 return -1;
00647 default:
00648 return 0;
00649 }
00650 }
00651
00652
00653
00654
00655
00656
00657
00658 void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
00659 {
00660 switch(msg)
00661 {
00662 case WM_GETTEXT:
00663 {
00664 LPARAM *ptr = (LPARAM *)lParam - 1;
00665 lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam );
00666 HeapFree( GetProcessHeap(), 0, ptr );
00667 }
00668 break;
00669
00670 case WM_NCCREATE:
00671 case WM_CREATE:
00672 {
00673 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
00674 if (HIWORD(cs->lpszName))
00675 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName );
00676 if (HIWORD(cs->lpszClass))
00677 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass );
00678 HeapFree( GetProcessHeap(), 0, cs );
00679 }
00680 break;
00681
00682 case WM_MDICREATE:
00683 {
00684 MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
00685 if (HIWORD(cs->szTitle))
00686 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle );
00687 if (HIWORD(cs->szClass))
00688 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass );
00689 HeapFree( GetProcessHeap(), 0, cs );
00690 }
00691 break;
00692
00693 case WM_SETTEXT:
00694 case WM_WININICHANGE:
00695 case CB_DIR:
00696 case LB_DIR:
00697 case LB_ADDFILE:
00698 #ifndef __WIN32OS2__
00699 case CB_FINDSTRING:
00700 case CB_FINDSTRINGEXACT:
00701 case CB_SELECTSTRING:
00702 case LB_FINDSTRING:
00703 case LB_SELECTSTRING:
00704 #endif
00705 case EM_REPLACESEL:
00706 HeapFree( GetProcessHeap(), 0, (void *)lParam );
00707 break;
00708
00709
00710 case LB_ADDSTRING:
00711 #ifdef __WIN32OS2__
00712 case LB_FINDSTRING:
00713 case LB_FINDSTRINGEXACT:
00714 case LB_SELECTSTRING:
00715 #endif
00716 case LB_INSERTSTRING:
00717 if ( WINPROC_TestLBForStr( hwnd ))
00718 HeapFree( GetProcessHeap(), 0, (void *)lParam );
00719 break;
00720
00721 case LB_GETTEXT:
00722 { if ( WINPROC_TestLBForStr( hwnd ))
00723 { LPARAM *ptr = (LPARAM *)lParam - 1;
00724 lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
00725 HeapFree( GetProcessHeap(), 0, ptr );
00726 }
00727 }
00728 break;
00729
00730
00731 case CB_ADDSTRING:
00732 #ifdef __WIN32OS2__
00733 case CB_FINDSTRING:
00734 case CB_FINDSTRINGEXACT:
00735 case CB_SELECTSTRING:
00736 #endif
00737 case CB_INSERTSTRING:
00738 if ( WINPROC_TestCBForStr( hwnd ))
00739 HeapFree( GetProcessHeap(), 0, (void *)lParam );
00740 break;
00741
00742 case CB_GETLBTEXT:
00743 { if ( WINPROC_TestCBForStr( hwnd ))
00744 { LPARAM *ptr = (LPARAM *)lParam - 1;
00745 lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
00746 HeapFree( GetProcessHeap(), 0, ptr );
00747 }
00748 }
00749 break;
00750
00751
00752 case EM_GETLINE:
00753 { LPARAM * ptr = (LPARAM *)lParam - 1;
00754 WORD len = *(WORD *) lParam;
00755 lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len );
00756 HeapFree( GetProcessHeap(), 0, ptr );
00757 }
00758 break;
00759 }
00760 }
00761
00762
00763
00764
00765
00766
00767
00768
00769 INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam)
00770 { switch(msg)
00771 {
00772 case WM_GETTEXT:
00773 {
00774 LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
00775 wParam + sizeof(LPARAM) );
00776 if (!ptr) return -1;
00777 *ptr++ = *plparam;
00778 *plparam = (LPARAM)ptr;
00779 }
00780 return 1;
00781
00782 case WM_SETTEXT:
00783 case WM_WININICHANGE:
00784 case CB_DIR:
00785 case LB_DIR:
00786 case LB_ADDFILE:
00787 #ifndef __WIN32OS2__
00788 case CB_FINDSTRING:
00789 case CB_FINDSTRINGEXACT:
00790 case CB_SELECTSTRING:
00791 case LB_FINDSTRING:
00792 case LB_SELECTSTRING:
00793 #endif
00794 case EM_REPLACESEL:
00795 *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
00796 return (*plparam ? 1 : -1);
00797
00798 case WM_NCCREATE:
00799 case WM_CREATE:
00800 {
00801 CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0,
00802 sizeof(*cs) );
00803 if (!cs) return -1;
00804 *cs = *(CREATESTRUCTA *)*plparam;
00805 if (HIWORD(cs->lpszName))
00806 cs->lpszName = HEAP_strdupWtoA( GetProcessHeap(), 0,
00807 (LPCWSTR)cs->lpszName );
00808 if (HIWORD(cs->lpszClass))
00809 cs->lpszClass = HEAP_strdupWtoA( GetProcessHeap(), 0,
00810 (LPCWSTR)cs->lpszClass);
00811 *plparam = (LPARAM)cs;
00812 }
00813 return 1;
00814 case WM_MDICREATE:
00815 {
00816 MDICREATESTRUCTA *cs =
00817 (MDICREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) );
00818
00819 if (!cs) return -1;
00820 *cs = *(MDICREATESTRUCTA *)*plparam;
00821 if (HIWORD(cs->szTitle))
00822 cs->szTitle = HEAP_strdupWtoA( GetProcessHeap(), 0,
00823 (LPCWSTR)cs->szTitle );
00824 if (HIWORD(cs->szClass))
00825 cs->szClass = HEAP_strdupWtoA( GetProcessHeap(), 0,
00826 (LPCWSTR)cs->szClass );
00827 *plparam = (LPARAM)cs;
00828 }
00829 return 1;
00830
00831
00832 case LB_ADDSTRING:
00833 #ifdef __WIN32OS2__
00834 case LB_FINDSTRING:
00835 case LB_FINDSTRINGEXACT:
00836 case LB_SELECTSTRING:
00837 #endif
00838 case LB_INSERTSTRING:
00839 if ( WINPROC_TestLBForStr( hwnd ))
00840 *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
00841 return (*plparam ? 1 : -1);
00842
00843 case LB_GETTEXT:
00844 { if ( WINPROC_TestLBForStr( hwnd ))
00845 { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
00846 if (!ptr) return -1;
00847 *ptr++ = *plparam;
00848 *plparam = (LPARAM)ptr;
00849 }
00850 }
00851 return 1;
00852
00853
00854 case CB_ADDSTRING:
00855 #ifdef __WIN32OS2__
00856 case CB_FINDSTRING:
00857 case CB_FINDSTRINGEXACT:
00858 case CB_SELECTSTRING:
00859 #endif
00860 case CB_INSERTSTRING:
00861 if ( WINPROC_TestCBForStr( hwnd ))
00862 *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
00863 return (*plparam ? 1 : -1);
00864
00865 case CB_GETLBTEXT:
00866 { if ( WINPROC_TestCBForStr( hwnd ))
00867 { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
00868 if (!ptr) return -1;
00869 *ptr++ = *plparam;
00870 *plparam = (LPARAM)ptr;
00871 }
00872 }
00873 return 1;
00874
00875
00876 case EM_GETLINE:
00877 { WORD len = (WORD)*plparam;
00878 LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
00879 if (!ptr) return -1;
00880 *ptr++ = *plparam;
00881 *((WORD *) ptr) = len;
00882 *plparam = (LPARAM)ptr;
00883 }
00884 return 1;
00885
00886 case WM_ASKCBFORMATNAME:
00887 case WM_DEVMODECHANGE:
00888 case WM_PAINTCLIPBOARD:
00889 case WM_SIZECLIPBOARD:
00890 case EM_SETPASSWORDCHAR:
00891
00892 return -1;
00893 default:
00894 return 0;
00895 }
00896 }
00897
00898
00899
00900
00901
00902
00903
00904 void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
00905 {
00906 switch(msg)
00907 {
00908 case WM_GETTEXT:
00909 {
00910 LPARAM *ptr = (LPARAM *)lParam - 1;
00911 lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam );
00912 HeapFree( GetProcessHeap(), 0, ptr );
00913 }
00914 break;
00915
00916 case WM_SETTEXT:
00917 case WM_WININICHANGE:
00918 case CB_DIR:
00919 case LB_DIR:
00920 case LB_ADDFILE:
00921 #ifndef __WIN32OS2__
00922 case CB_FINDSTRING:
00923 case CB_FINDSTRINGEXACT:
00924 case CB_SELECTSTRING:
00925 case LB_FINDSTRING:
00926 case LB_SELECTSTRING:
00927 #endif
00928 case EM_REPLACESEL:
00929 HeapFree( GetProcessHeap(), 0, (void *)lParam );
00930 break;
00931
00932 case WM_NCCREATE:
00933 case WM_CREATE:
00934 {
00935 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
00936 if (HIWORD(cs->lpszName))
00937 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName );
00938 if (HIWORD(cs->lpszClass))
00939 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass );
00940 HeapFree( GetProcessHeap(), 0, cs );
00941 }
00942 break;
00943
00944 case WM_MDICREATE:
00945 {
00946 MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
00947 if (HIWORD(cs->szTitle))
00948 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle );
00949 if (HIWORD(cs->szClass))
00950 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass );
00951 HeapFree( GetProcessHeap(), 0, cs );
00952 }
00953 break;
00954
00955
00956 case LB_ADDSTRING:
00957 #ifdef __WIN32OS2__
00958 case LB_FINDSTRING:
00959 case LB_FINDSTRINGEXACT:
00960 case LB_SELECTSTRING:
00961 #endif
00962 case LB_INSERTSTRING:
00963 if ( WINPROC_TestLBForStr( hwnd ))
00964 HeapFree( GetProcessHeap(), 0, (void *)lParam );
00965 break;
00966
00967 case LB_GETTEXT:
00968 { if ( WINPROC_TestLBForStr( hwnd ))
00969 { LPARAM *ptr = (LPARAM *)lParam - 1;
00970 lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
00971 HeapFree(GetProcessHeap(), 0, ptr );
00972 }
00973 }
00974 break;
00975
00976
00977 case CB_ADDSTRING:
00978 #ifdef __WIN32OS2__
00979 case CB_FINDSTRING:
00980 case CB_FINDSTRINGEXACT:
00981 case CB_SELECTSTRING:
00982 #endif
00983 case CB_INSERTSTRING:
00984 if ( WINPROC_TestCBForStr( hwnd ))
00985 HeapFree( GetProcessHeap(), 0, (void *)lParam );
00986 break;
00987
00988 case CB_GETLBTEXT:
00989 { if ( WINPROC_TestCBForStr( hwnd ))
00990 { LPARAM *ptr = (LPARAM *)lParam - 1;
00991 lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
00992 HeapFree( GetProcessHeap(), 0, ptr );
00993 }
00994 }
00995 break;
00996
00997
00998 case EM_GETLINE:
00999 { LPARAM * ptr = (LPARAM *)lParam - 1;
01000 WORD len = *(WORD *)ptr;
01001 lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
01002 HeapFree( GetProcessHeap(), 0, ptr );
01003 }
01004 break;
01005 }
01006 }
01007
01008
01009
01010
01011
01012
01013 LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd,
01014 UINT msg, WPARAM wParam,
01015 LPARAM lParam )
01016 {
01017 LRESULT result;
01018
01019 if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0;
01020 result = func( hwnd, msg, wParam, lParam );
01021 WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
01022 return result;
01023 }
01024
01025
01026
01027
01028
01029
01030 LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd,
01031 UINT msg, WPARAM wParam,
01032 LPARAM lParam )
01033 {
01034 LRESULT result;
01035
01036 if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0;
01037
01038 result = func( hwnd, msg, wParam, lParam );
01039 WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
01040 return result;
01041 }
01042
01043
01044
01045
01046
01047
01048 DWORD WIN32API GetQueueStatus( UINT flags)
01049 {
01050 DWORD queueStatus;
01051
01052 queueStatus = OSLibWinQueryQueueStatus();
01053 queueStatus = MAKELONG(queueStatus, queueStatus);
01054
01055 dprintf(("USER32: GetQueueStatus %x returned %x", flags, queueStatus & MAKELONG(flags, flags)));
01056
01057 return queueStatus & MAKELONG(flags, flags);
01058 }
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073 BOOL WIN32API GetInputState(VOID)
01074 {
01075 DWORD queueStatus;
01076 BOOL rc;
01077
01078 queueStatus = OSLibWinQueryQueueStatus();
01079
01080 rc = (queueStatus & (QS_KEY | QS_MOUSEBUTTON)) ? TRUE : FALSE;
01081 dprintf(("USER32:GetInputState() returned %d", rc));
01082 return rc;
01083 }
01084
01085
01086
01087 DWORD WIN32API MsgWaitForMultipleObjects(DWORD nCount, LPHANDLE pHandles, BOOL fWaitAll,
01088 DWORD dwMilliseconds, DWORD dwWakeMask)
01089 {
01090 DWORD curtime, endtime, ret;
01091 MSG msg;
01092
01093 dprintf(("MsgWaitForMultipleObjects %x %x %d %d %x", nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask));
01094
01095 if (nCount == 0)
01096 {
01097 if(dwMilliseconds == 0) {
01098 if(GetQueueStatus(dwWakeMask) == 0) {
01099 return WAIT_TIMEOUT;
01100 }
01101 return WAIT_OBJECT_0;
01102 }
01103
01104
01105
01106 curtime = GetCurrentTime();
01107 endtime = curtime + dwMilliseconds;
01108 while(curtime < endtime || dwMilliseconds == INFINITE) {
01109 if(OSLibWinWaitMessage() == FALSE) {
01110 dprintf(("OSLibWinWaitMessage returned FALSE!"));
01111 return WAIT_ABANDONED;
01112 }
01113 if(GetQueueStatus(dwWakeMask) != 0) {
01114 return WAIT_OBJECT_0;
01115 }
01116
01117
01118 if(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
01119 {
01120 if (msg.message == WM_QUIT) {
01121 dprintf(("ERROR: MsgWaitForMultipleObjects call abandoned because WM_QUIT msg was received!!"));
01122 return WAIT_ABANDONED;
01123 }
01124
01125
01126 DispatchMessageA(&msg);
01127 }
01128 curtime = GetCurrentTime();
01129 }
01130 return WAIT_TIMEOUT;
01131 }
01132
01133 ret = HMMsgWaitForMultipleObjects(nCount,pHandles,fWaitAll,dwMilliseconds,dwWakeMask);
01134 return ret;
01135 }