static DWORD ChangeWindowStyle(HWND32 hWnd32, DWORD dwNewStyle) { RECT rcNewNC; if ((hWnd32->dwStyle & (WS_BORDER|WS_DLGFRAME|WS_THICKFRAME)) != (dwNewStyle & (WS_BORDER|WS_DLGFRAME|WS_THICKFRAME))) { CalcNCDimensions(&rcNewNC,dwNewStyle, hWnd32->dwExStyle, hWnd32->wMenuHeight); ChangeNCDimensions(GETHWND16(hWnd32),&rcNewNC); } if ((hWnd32->dwStyle & WS_HSCROLL) != (dwNewStyle & WS_HSCROLL)) ShowScrollBar(GETHWND16(hWnd32),SB_HORZ, (dwNewStyle & WS_HSCROLL)?TRUE:FALSE); if ((hWnd32->dwStyle & WS_VSCROLL) != (dwNewStyle & WS_VSCROLL)) ShowScrollBar(GETHWND16(hWnd32),SB_VERT, (dwNewStyle & WS_VSCROLL)?TRUE:FALSE); return dwNewStyle; }
ULONG FASTCALL WU32GetNextDlgGroupItem(PVDMFRAME pFrame) { ULONG ul; register PGETNEXTDLGGROUPITEM16 parg16; GETARGPTR(pFrame, sizeof(GETNEXTDLGGROUPITEM16), parg16); ul = GETHWND16(GetNextDlgGroupItem(HWND32(parg16->f1), HWND32(parg16->f2), BOOL32(parg16->f3))); FREEARGPTR(parg16); RETURN(ul); }
DWORD ExtDevModeHandler(LPWOWFAXINFO lpfaxinfo) { LPWOWFAXINFO16 lpT16; LPSTR lpT; VPVOID vp; LOGDEBUG(0,("ExtDevModeHandler\n")); (LONG)lpfaxinfo->retvalue = -1; GETVDMPTR(lpfaxinfo->lpinfo16, sizeof(WOWFAXINFO16), lpT16); if (lpT16) { // assumption that 16bit data won't be larger than 32bit data. // this makes life easy in two ways; first we don't need to calculate // the exact size and secondly the 16bit pointers can be set to same // relative offsets as input(32 bit) pointers vp = malloc16(lpfaxinfo->cData); if (vp) { GETVDMPTR(vp, lpfaxinfo->cData, lpT); if (lpT) { lpT16->wCmd = lpfaxinfo->wCmd; lpT16->lpOut = (LPSTR)lpfaxinfo->lpOut; lpT16->lpIn = (LPSTR)lpfaxinfo->lpIn; lpT16->lpDriverName = (LPBYTE)vp + (DWORD)lpfaxinfo->lpDriverName; lpT16->lpPortName = (LPBYTE)vp + (DWORD)lpfaxinfo->lpPortName; WideCharToMultiByte(CP_ACP, 0, (PWSTR)((LPSTR)lpfaxinfo + (DWORD)lpfaxinfo->lpDriverName), lstrlenW((LPWSTR)((LPSTR)lpfaxinfo + (DWORD)lpfaxinfo->lpDriverName)) + 1, lpT + (DWORD)lpfaxinfo->lpDriverName, lstrlenW((LPWSTR)((LPSTR)lpfaxinfo + (DWORD)lpfaxinfo->lpDriverName)) + 1, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, (PWSTR)((LPSTR)lpfaxinfo + (DWORD)lpfaxinfo->lpPortName), lstrlenW((LPWSTR)((LPSTR)lpfaxinfo + (DWORD)lpfaxinfo->lpPortName)) + 1, lpT + (DWORD)lpfaxinfo->lpPortName, lstrlenW((LPWSTR)((LPSTR)lpfaxinfo + (DWORD)lpfaxinfo->lpPortName)) + 1, NULL, NULL); if (lpfaxinfo->lpIn) { lpT16->lpIn = (LPBYTE)vp + (DWORD)lpfaxinfo->lpIn; ConvertDevMode((PDEVMODE16)(lpT + (DWORD)lpfaxinfo->lpIn), (LPDEVMODEW)((LPSTR)lpfaxinfo + (DWORD)lpfaxinfo->lpIn), TRUE); } if (lpfaxinfo->lpOut) { lpT16->lpOut = (LPBYTE)vp + (DWORD)lpfaxinfo->lpOut; } lpT16->hwndui = GETHWND16(lpfaxinfo->hwndui); FREEVDMPTR(lpT); lpfaxinfo->retvalue = CallWindowProc( gfaxinfo.proc16, gfaxinfo.hwnd, lpfaxinfo->msg, lpfaxinfo->hdc, (LPARAM)lpfaxinfo->lpinfo16); if ((lpfaxinfo->wCmd == 0) && (lpfaxinfo->retvalue > 0)) { // the 16bit driver has returned 16bit struct size. change // the return value to correspond to the devmodew struct. // // since devmode16 (the 3.0 version) is smaller than devmode31 // the retvalue will take careof both win30/win31 devmode WOW32ASSERT(sizeof(DEVMODE16) < sizeof(DEVMODE31)); lpfaxinfo->retvalue += (sizeof(DEVMODEW) - sizeof(DEVMODE16)); } GETVDMPTR(vp, lpfaxinfo->cData, lpT); if ((lpfaxinfo->wCmd & DM_COPY) && lpfaxinfo->lpOut && (lpfaxinfo->retvalue == IDOK)) { ConvertDevMode((PDEVMODE16)(lpT + (DWORD)lpfaxinfo->lpOut), (LPDEVMODEW)((LPSTR)lpfaxinfo + (DWORD)lpfaxinfo->lpOut), FALSE); } } free16(vp); } } FREEVDMPTR(lpT16); return lpfaxinfo->retvalue; }
static HWND AddScrollbar(HWND32 hWnd32, BOOL bVert) { HWND hWndScroll; HWND32 hScroll32; CREATESTRUCT csScroll; RECT rcScroll; /* Create scrollbar window handle */ if (!(hScroll32 = CREATEHWIN(hWndScroll))) { return (HWND)0; } hScroll32->lpfnWndProc = ScrollInfo.lpfnWndProc; hScroll32->dwStyle = WS_CHILD | ((bVert)?SBS_VERT:SBS_HORZ) | SBS_SYSTEM; hScroll32->dwExStyle = 0; hScroll32->hWndParent = hScroll32->hWndOwner = GETHWND16(hWnd32); hScroll32->hInstance = hWnd32->hInstance; hScroll32->hTask = GetCurrentTask(); hScroll32->hWindowClass32 = hClassScroll32; hScroll32->cbWndExtra = ScrollInfo.cbWndExtra; hScroll32->lpWndExtra = WinMalloc(ScrollInfo.cbWndExtra); memset(hScroll32->lpWndExtra, '\0', ScrollInfo.cbWndExtra); /* fill CREATESTRUCT */ csScroll.lpCreateParams = NULL; csScroll.hInstance = hScroll32->hInstance; csScroll.hwndParent = hScroll32->hWndParent; csScroll.cx = 0; csScroll.cy = 0; csScroll.x = 0; csScroll.y = 0; csScroll.style = hScroll32->dwStyle; csScroll.lpszName = NULL; csScroll.lpszClass = TWIN_SYSSCROLLCLASS; csScroll.dwExStyle = hScroll32->dwExStyle; CalcSysScrollLocation(hWnd32, (WORD)(hWnd32->rWnd.right-hWnd32->rWnd.left), (WORD)(hWnd32->rWnd.bottom-hWnd32->rWnd.top), &rcScroll, bVert); csScroll.x = rcScroll.left; csScroll.y = rcScroll.top; csScroll.cx = rcScroll.right; csScroll.cy = rcScroll.bottom; if (bVert) hWnd32->hWndVTScroll = hWndScroll; else hWnd32->hWndHZScroll = hWndScroll; SendMessage(hWndScroll,WM_CREATE,0,(LPARAM)&csScroll); SetRectEmpty(&hScroll32->rcNC); hScroll32->wWidth = csScroll.cx; hScroll32->wHeight = csScroll.cy; SetRect(&hScroll32->rWnd, csScroll.x, csScroll.y, csScroll.x+csScroll.cx, csScroll.y+csScroll.cy); RELEASEWININFO(hScroll32); return hWndScroll; }
ULONG FASTCALL WU32DialogBoxParam(PVDMFRAME pFrame) { ULONG ul; DLGDATA DlgData; PVOID pDlg; DWORD cb, cb16; register PDIALOGBOXPARAM16 parg16; BYTE abT[1024]; GETARGPTR(pFrame, sizeof(DIALOGBOXPARAM16), parg16); DlgData.vpfnDlgProc = DWORD32(parg16->f4); DlgData.dwUserInitParam = DWORD32(parg16->f5); if (!(cb16 = parg16->f6)) { cb = ConvertDialog16(NULL, DWORD32(parg16->f2), 0, cb16); } else { // The idea is eliminate a call to ConverDialog16 // // the maximum size that 32bit dlgtemplate would be is twice // the 16bit dlgtemplate. // // this assumption is true cause - we convert most words to dwords // and ansi strings to unicode strings - since we know that a // DWORD is twice the sizeof a WORD a unicode character is 2bytes // therefore maxsize of dlgtemplate cannot exceed cb * 2. // // - nanduri cb = cb16 * max(sizeof(DWORD) / sizeof(WORD), sizeof(WCHAR)/sizeof(BYTE)); WOW32ASSERT(cb >= ConvertDialog16(NULL, DWORD32(parg16->f2), 0, cb16)); } pDlg = (cb > sizeof(abT)) ? malloc_w(cb) : (PVOID)abT; if (cb && pDlg) { cb = ConvertDialog16(pDlg, DWORD32(parg16->f2), cb, cb16); if (parg16->f7) { ul = GETINT16(DialogBoxIndirectParamAorW(HMODINST32(parg16->f1), pDlg, HWND32(parg16->f3), (DLGPROC)(DlgData.vpfnDlgProc ? W32DialogFunc: 0), (LPARAM) &DlgData, SCDLG_ANSI)); } else { ul = GETHWND16((pfnOut.pfnServerCreateDialog)(HMODINST32(parg16->f1), (LPDLGTEMPLATE)pDlg, cb, HWND32(parg16->f3), (DLGPROC)(DlgData.vpfnDlgProc ? W32DialogFunc: 0), (LPARAM) &DlgData, SCDLG_CLIENT | SCDLG_ANSI | SCDLG_NOREVALIDATE)); } if (pDlg != (PVOID)abT) { free_w (pDlg); } } // Invalidate SendDlgItemMessage cache hdlgSDIMCached = NULL ; FREEARGPTR(parg16); RETURN(ul); }
LONG W32DialogFunc(HWND hdlg, UINT uMsg, DWORD uParam, LPARAM lParam) { BOOL fSuccess; register PWW pww; WM32MSGPARAMEX wm32mpex; BOOL fMessageNeedsThunking; #ifdef WOWPROFILE // for MSG profiling only (debugger extension) extern INT fWMsgProfRT; DWORD dwTics; #endif // WOWPROFILE // If the app has GP Faulted we don't want to pass it any more input // This should be removed when USER32 does clean up on task death so // it doesn't call us - mattfe june 24 92 if (CURRENTPTD()->dwFlags & TDF_IGNOREINPUT) { LOGDEBUG(6,(" W32DialogFunc Ignoring Input Messsage %04X\n",uMsg)); WOW32ASSERTMSG(!gfIgnoreInputAssertGiven, "WCD32CommonDialogProc: TDF_IGNOREINPUT hack was used, shouldn't be, " "please email DaveHart with repro instructions. Hit 'g' to ignore this " "and suppress this assertion from now on.\n"); gfIgnoreInputAssertGiven = TRUE; goto SilentError; } if (!(pww = (PWW) GetWindowLong(hdlg, GWL_WOWWORDS))) { LOGDEBUG(LOG_ALWAYS,(" W32DialogFunc ERROR: cannot find alias for window %08lx\n", hdlg)); goto Error; } // If pww->vpfnDlgProc is NULL, then something is broken; we // certainly can't continue because we don't know what 16-bit func to call if (!pww->vpfnDlgProc) { LOGDEBUG(LOG_ALWAYS,(" W32DialogFunc ERROR: no window proc for message %04x Dlg = %08lx\n", uMsg, hdlg )); goto Error; } wm32mpex.Parm16.WndProc.hwnd = GETHWND16(hdlg); wm32mpex.Parm16.WndProc.wMsg = (WORD)uMsg; wm32mpex.Parm16.WndProc.wParam = (WORD)uParam; wm32mpex.Parm16.WndProc.lParam = (LONG)lParam; wm32mpex.Parm16.WndProc.hInst = 0; // Forces AX = SS on WndProc entry, // for Win 3.1 compatibility. fMessageNeedsThunking = (uMsg < 0x400) && (aw32Msg[uMsg].lpfnM32 != WM32NoThunking); if (fMessageNeedsThunking) { LOGDEBUG(3,("%04X (%s)\n", CURRENTPTD()->htask16, (aw32Msg[uMsg].lpszW32))); #ifdef WOWPROFILE // for MSG profiling only (debugger extension) dwTics = GetWOWTicDiff(0L); #endif // WOWPROFILE wm32mpex.fThunk = THUNKMSG; wm32mpex.hwnd = hdlg; wm32mpex.uMsg = uMsg; wm32mpex.uParam = uParam; wm32mpex.lParam = lParam; wm32mpex.pww = pww; wm32mpex.lpfnM32 = aw32Msg[uMsg].lpfnM32; if (!(wm32mpex.lpfnM32)(&wm32mpex)) { LOGDEBUG(LOG_ERROR,(" W32DialogFunc ERROR: cannot thunk 32-bit message %04x\n", uMsg)); goto Error; } #ifdef WOWPROFILE // for MSG profiling only (debugger extension) if( !fWMsgProfRT ) { // only if not round trip profiling aw32Msg[uMsg].cTics += GetWOWTicDiff(dwTics); } #endif // WOWPROFILE } else { LOGDEBUG(6,(" No Thunking was required for the 32-bit message %s(%04x)\n", (LPSZ)GetWMMsgName(uMsg), uMsg)); } BlockWOWIdle(FALSE); fSuccess = CallBack16(RET_WNDPROC, &wm32mpex.Parm16, pww->vpfnDlgProc, (PVPVOID)&wm32mpex.lReturn); BlockWOWIdle(TRUE); // the callback function of a dialog is of type FARPROC whose return value // is of type 'int'. Since dx:ax is copied into lReturn in the above // CallBack16 call, we need to zero out the hiword, otherwise we will be // returning an erroneous value. wm32mpex.lReturn = (LONG)((SHORT)(LOWORD(wm32mpex.lReturn))); if (fMessageNeedsThunking) { #ifdef WOWPROFILE // for MSG profiling only (debugger extension) if( !fWMsgProfRT ) { // only if not round trip profiling dwTics = GetWOWTicDiff(0L); } #endif // WOWPROFILE // // if you send a message to a dialog what gets returned // to the caller is the dlg's msgresult window long. // app dialog functions will call // SetWindowLong(hdlg, DWL_MSGRESULT, n); // during message processing so the right thing gets returned. // scottlu says we only need to do this for wm_gettext, it's // the only message whose result is an output count. // if (uMsg == WM_GETTEXT && wm32mpex.lReturn != 0) { wm32mpex.lReturn = GetWindowLong(hdlg, DWL_MSGRESULT); } wm32mpex.fThunk = UNTHUNKMSG; (wm32mpex.lpfnM32)(&wm32mpex); #ifdef WOWPROFILE // for MSG profiling only (debugger extension) aw32Msg[uMsg].cTics += GetWOWTicDiff(dwTics); aw32Msg[uMsg].cCalls++; // increment # times message passed #endif // WOWPROFILE } if (!fSuccess) goto Error; Done: return wm32mpex.lReturn; Error: LOGDEBUG(6,(" W32DialogFunc WARNING: cannot call back, using default message handling\n")); SilentError: wm32mpex.lReturn = 0; goto Done; }