void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch) { int i,r; if (dlsch) { for (i=0;i<dlsch->Mdlharq;i++) { if (dlsch->harq_processes[i]) { if (dlsch->harq_processes[i]->b) { free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES); dlsch->harq_processes[i]->b = NULL; } if (dlsch->harq_processes[i]->c) { for (r=0;r<MAX_NUM_DLSCH_SEGMENTS;r++) { free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); dlsch->harq_processes[i]->c[r] = NULL; } } for (r=0;r<MAX_NUM_DLSCH_SEGMENTS;r++) if (dlsch->harq_processes[i]->d[r]) { free16(dlsch->harq_processes[i]->d[r],((3*8*6144)+12+96)*sizeof(short)); dlsch->harq_processes[i]->d[r] = NULL; } free16(dlsch->harq_processes[i],sizeof(LTE_DL_UE_HARQ_t)); dlsch->harq_processes[i] = NULL; } } free16(dlsch,sizeof(LTE_UE_DLSCH_t)); dlsch = NULL; } }
void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { int i; int r; if (dlsch) { #ifdef DEBUG_DLSCH_FREE msg("Freeing dlsch %p\n",dlsch); #endif for (i=0; i<dlsch->Mdlharq; i++) { #ifdef DEBUG_DLSCH_FREE msg("Freeing dlsch process %d\n",i); #endif if (dlsch->harq_processes[i]) { #ifdef DEBUG_DLSCH_FREE msg("Freeing dlsch process %d (%p)\n",i,dlsch->harq_processes[i]); #endif if (dlsch->harq_processes[i]->b) { free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES); dlsch->harq_processes[i]->b = NULL; #ifdef DEBUG_DLSCH_FREE msg("Freeing dlsch process %d b (%p)\n",i,dlsch->harq_processes[i]->b); #endif } #ifdef DEBUG_DLSCH_FREE msg("Freeing dlsch process %d c (%p)\n",i,dlsch->harq_processes[i]->c); #endif for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) { #ifdef DEBUG_DLSCH_FREE msg("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]); #endif if (dlsch->harq_processes[i]->c[r]) { free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768); dlsch->harq_processes[i]->c[r] = NULL; } if (dlsch->harq_processes[i]->d[r]) { free16(dlsch->harq_processes[i]->d[r],(96+12+3+(3*6144))); dlsch->harq_processes[i]->d[r] = NULL; } } free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t)); dlsch->harq_processes[i] = NULL; } } free16(dlsch,sizeof(LTE_eNB_DLSCH_t)); dlsch = NULL; } }
void free_ul_ref_sigs(void){ unsigned int u,v,Msc_RS; for (Msc_RS=2;Msc_RS<33;Msc_RS++) { for (u=0;u<30;u++) { for (v=0;v<2;v++) { if (ul_ref_sigs[u][v][Msc_RS]) free16(ul_ref_sigs[u][v][Msc_RS],2*sizeof(int16_t)*dftsizes[Msc_RS]); if (ul_ref_sigs_rx[u][v][Msc_RS]) free16(ul_ref_sigs_rx[u][v][Msc_RS],4*sizeof(int16_t)*dftsizes[Msc_RS]); } } } }
BOOL FASTCALL WM32CBAddString (LPWM32MSGPARAMEX lpwm32mpex) { PWW pww; if ( lpwm32mpex->fThunk ) { if (!(pww = lpwm32mpex->pww)) { if (pww = FindPWW (lpwm32mpex->hwnd, WOWCLASS_UNKNOWN)) lpwm32mpex->pww = pww; else return FALSE; } lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - CB_GETEDITSEL)); // // Determine if this combobox has string pointers or handles passed // in with CB_ADDSTRING messages. Normal comboboxes have string // pointers passed. Owner-draw comboboxes that don't have the // CBS_HASSTRINGS style bit set have handles passed in. These handles // are simply passed back to the owner at paint time. If the // CBS_HASSTRINGS style bit is set, strings are used instead of // handles as the "cookie" which is passed back to the application // at paint time. // // We treat lpwm32mpex->dwParam as a BOOL indicating this combobox // takes handles instead of strings. // lpwm32mpex->dwParam = (pww->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) && !(pww->dwStyle & CBS_HASSTRINGS); if ( !lpwm32mpex->dwParam ) { // if strings are used if (lpwm32mpex->lParam) { INT cb; cb = strlen((LPSZ)lpwm32mpex->lParam)+1; lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; putstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, cb); } } } else { if ( !lpwm32mpex->dwParam ) { // if strings are used if (lpwm32mpex->Parm16.WndProc.lParam) { getstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, -1); free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } } } LOGDEBUG(3,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg)); return(TRUE); }
BOOL FASTCALL WM32LBDir (LPWM32MSGPARAMEX lpwm32mpex) { INT cb; VPVOID vp; if (lpwm32mpex->fThunk) { lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1)); if (lpwm32mpex->lParam) { cb = strlen((LPSTR)lpwm32mpex->lParam)+1; if (!(vp = malloc16(cb))) { LOGDEBUG(0,(" WOW32.DLL : WM32LBDir() :: Could not allocate memory for string, ChandanC\n")); WOW32ASSERT(vp); return FALSE; } putstr16(vp, (LPSTR) lpwm32mpex->lParam, cb); lpwm32mpex->Parm16.WndProc.lParam = vp; } } else { if (lpwm32mpex->Parm16.WndProc.lParam) { free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } } return(TRUE); }
BOOL FASTCALL WM32EMGetLine (LPWM32MSGPARAMEX lpwm32mpex) { if ( lpwm32mpex->fThunk ) { lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL)); if (lpwm32mpex->lParam) { INT cb; PBYTE lp; // the first WORD is what USER uses. cb = *(UNALIGNED WORD *)(lpwm32mpex->lParam); lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; ALLOCVDMPTR(lpwm32mpex->Parm16.WndProc.lParam,2,lp); *((UNALIGNED WORD *)lp) = cb; FLUSHVDMPTR(lpwm32mpex->Parm16.WndProc.lParam,2,lp); /* first 2 bytes modified */ } } else { if (lpwm32mpex->Parm16.WndProc.lParam) { PBYTE lp; GETMISCPTR(lpwm32mpex->Parm16.WndProc.lParam,lp); RtlCopyMemory((PBYTE)lpwm32mpex->lParam,lp,lpwm32mpex->lReturn); FREEVDMPTR(lp); free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } } LOGDEBUG(3,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg)); return (TRUE); }
BOOL FASTCALL WM32CBDir (LPWM32MSGPARAMEX lpwm32mpex) { if (lpwm32mpex->fThunk) { lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - CB_GETEDITSEL)); if (lpwm32mpex->lParam) { INT cb; if (W32CheckThunkParamFlag()) { LONG lParam = (LONG)GetParam16(lpwm32mpex->lParam); if (lParam) { lpwm32mpex->Parm16.WndProc.lParam = lParam; return (TRUE); } } cb = strlen((LPSZ)lpwm32mpex->lParam)+1; lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; putstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, cb); } } else { if (W32CheckThunkParamFlag()) { if (DeleteParamMap(lpwm32mpex->Parm16.WndProc.lParam, PARAM_16, NULL)) { return TRUE; } } if (lpwm32mpex->Parm16.WndProc.lParam) free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } return(TRUE); }
BOOL FASTCALL WM32EMReplaceSel (LPWM32MSGPARAMEX lpwm32mpex) { if ( lpwm32mpex->fThunk ) { lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL)); if (lpwm32mpex->lParam) { INT cb; cb = strlen((LPSZ)lpwm32mpex->lParam)+1; // winworks2.0a requires DS based string pointers for this message if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_DSBASEDSTRINGPOINTERS) { lpwm32mpex->Parm16.WndProc.lParam = stackalloc16(cb); } else { lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb); } if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; putstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, cb); } } else { if (lpwm32mpex->Parm16.WndProc.lParam) { if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_DSBASEDSTRINGPOINTERS) { stackfree16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } else { free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } } } return (TRUE); }
BOOL FASTCALL WM32LBAddString (LPWM32MSGPARAMEX lpwm32mpex) { PWW pww; if ( lpwm32mpex->fThunk ) { if (!(pww = lpwm32mpex->pww)) { if (pww = FindPWW (lpwm32mpex->hwnd, WOWCLASS_UNKNOWN)) lpwm32mpex->pww = pww; else return FALSE; } lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1)); // // Determine if this listbox has string pointers or handles passed // in with LB_ADDSTRING messages. Owner-draw listboxes that don't // have the LBS_HASSTRINGS style bit set have handles passed in. // These handles are simply passed back to the owner at paint time. // If the LBS_HASSTRINGS style bit is set, strings are used instead of // handles as the "cookie" which is passed back to the application // at paint time. // // We treat lpwm32mpex->dwParam as a BOOL indicating this listbox // takes handles instead of strings. // lpwm32mpex->dwParam = (pww->dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) && !(pww->dwStyle & LBS_HASSTRINGS); if ( !lpwm32mpex->dwParam ) { // if this listbox takes strings if (lpwm32mpex->lParam) { INT cb; cb = strlen((LPSZ)lpwm32mpex->lParam)+1; lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; putstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, cb); } } } else { if ( !lpwm32mpex->dwParam ) { // if this listbox takes strings if (lpwm32mpex->Parm16.WndProc.lParam) { getstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, -1); free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } } } return(TRUE); }
BOOL FASTCALL WM32EMGetRect (LPWM32MSGPARAMEX lpwm32mpex) { if ( lpwm32mpex->fThunk ) { lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - EM_GETSEL)); lpwm32mpex->Parm16.WndProc.lParam = malloc16(sizeof(RECT16)); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; } else { GETRECT16( lpwm32mpex->Parm16.WndProc.lParam, (LPRECT)lpwm32mpex->lParam ); if (lpwm32mpex->Parm16.WndProc.lParam) free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } return (TRUE); }
BOOL FASTCALL WM32LBSetTabStops (LPWM32MSGPARAMEX lpwm32mpex) { if ( lpwm32mpex->fThunk ) { lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1)); if (lpwm32mpex->uParam != 0) { lpwm32mpex->Parm16.WndProc.lParam = malloc16(lpwm32mpex->uParam * sizeof(WORD)); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; putintarray16((VPRECT16)lpwm32mpex->Parm16.WndProc.lParam, (INT)lpwm32mpex->uParam, (LPINT)lpwm32mpex->lParam); } } else { if (lpwm32mpex->Parm16.WndProc.lParam) free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } return(TRUE); }
BOOL FASTCALL WM32LBGetItemRect (LPWM32MSGPARAMEX lpwm32mpex) { if ( lpwm32mpex->fThunk ) { lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1)); lpwm32mpex->Parm16.WndProc.lParam = malloc16(sizeof(RECT16)); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; } else { GETRECT16( lpwm32mpex->Parm16.WndProc.lParam, (LPRECT)lpwm32mpex->lParam ); if (lpwm32mpex->Parm16.WndProc.lParam) free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } LOGDEBUG(3,(" Window %08lX is receiving Control Message %s(%08x)\n", lpwm32mpex->hwnd, (LPSZ)GetWMMsgName(lpwm32mpex->uMsg), lpwm32mpex->uMsg)); return(TRUE); }
BOOL FASTCALL WM32LBGetSelItems (LPWM32MSGPARAMEX lpwm32mpex) { if ( lpwm32mpex->fThunk ) { lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1)); if (lpwm32mpex->lParam) { INT cb; cb = lpwm32mpex->uParam * sizeof(WORD); lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; } } else { getintarray16((VPRECT16)lpwm32mpex->Parm16.WndProc.lParam, (INT)lpwm32mpex->uParam, (LPINT)lpwm32mpex->lParam); if (lpwm32mpex->Parm16.WndProc.lParam) free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } return(TRUE); }
BOOL FASTCALL WM32LBGetText (LPWM32MSGPARAMEX lpwm32mpex) { PWW pww; if ( lpwm32mpex->fThunk ) { INT cb; if (!(pww = lpwm32mpex->pww)) { if (pww = FindPWW (lpwm32mpex->hwnd, WOWCLASS_UNKNOWN)) lpwm32mpex->pww = pww; else return FALSE; } lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - LB_ADDSTRING + 1)); // // Determine if this listbox has string pointers or handles passed // in with LB_ADDSTRING messages. Owner-draw listboxes that don't // have the LBS_HASSTRINGS style bit set have handles passed in. // These handles are simply passed back to the owner at paint time. // If the LBS_HASSTRINGS style bit is set, strings are used instead of // handles as the "cookie" which is passed back to the application // at paint time. // // We treat lpwm32mpex->dwParam as a BOOL indicating this listbox // takes handles instead of strings. // lpwm32mpex->dwParam = (pww->dwStyle & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) && !(pww->dwStyle & LBS_HASSTRINGS); if (lpwm32mpex->dwParam) { // if this listbox takes handles cb = 4; } else { cb = SendMessage(lpwm32mpex->hwnd, LB_GETTEXTLEN, lpwm32mpex->uParam, 0); // Check for LB_ERR (which is -1) on the above SendMessage(). // When cb is equal to LB_ERR make the size as SIZE_BOGUS (256 bytes), // and allocate a buffer just in case if the app diddles the lParam. // We will free the buffer while unthunking the message (LB_GETTEXT). // This fix makes the app MCAD happy. // ChandanC 4-21-93. if (cb == LB_ERR) { cb = SIZE_BOGUS; } else { // // Add one for NULL character. // cb = cb + 1; } } if (lpwm32mpex->lParam) { BYTE *lpT; lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; // The reason for this code to be here is that sometimes thunks // are executed on a buffer that has not been initialized, e.g. // if the hooks are installed by a wow app. That means we will // alloc 16-bit buffer while thunking (boils down to uninitialized // data buffer and will try to copy the buffer back while unthunking // overwriting the stack sometimes (as user allocates temp bufs from // the stack). This code initializes data so problem is avoided // App: Grammatik/Windows v6.0 -- VadimB GETVDMPTR((lpwm32mpex->Parm16.WndProc.lParam), sizeof(BYTE), lpT); *lpT = 0; FREEVDMPTR(lpT); } } else { if ((lpwm32mpex->lReturn != LB_ERR) && lpwm32mpex->lParam && lpwm32mpex->Parm16.WndProc.lParam) { if (lpwm32mpex->dwParam) { // if this listbox takes handles UNALIGNED DWORD *lpT; GETVDMPTR((lpwm32mpex->Parm16.WndProc.lParam), sizeof(DWORD), lpT); *(UNALIGNED DWORD *)lpwm32mpex->lParam = *lpT; FREEVDMPTR(lpT); } else { getstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, -1); } } if (lpwm32mpex->Parm16.WndProc.lParam) { free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } } return(TRUE); }
BOOL FASTCALL WM32CBGetLBText (LPWM32MSGPARAMEX lpwm32mpex) { PWW pww; if ( lpwm32mpex->fThunk ) { INT cb; if (!(pww = lpwm32mpex->pww)) { if (pww = FindPWW (lpwm32mpex->hwnd, WOWCLASS_UNKNOWN)) lpwm32mpex->pww = pww; else return FALSE; } lpwm32mpex->Parm16.WndProc.wMsg = (WORD) (WM_USER + (lpwm32mpex->uMsg - CB_GETEDITSEL)); // // Determine if this combobox has string pointers or handles passed // in with CB_ADDSTRING messages. Normal comboboxes have string // pointers passed. Owner-draw comboboxes that don't have the // CBS_HASSTRINGS style bit set have handles passed in. These handles // are simply passed back to the owner at paint time. If the // CBS_HASSTRINGS style bit is set, strings are used instead of // handles as the "cookie" which is passed back to the application // at paint time. // // We treat lpwm32mpex->dwParam as a BOOL indicating this combobox // takes handles instead of strings. // lpwm32mpex->dwParam = (pww->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) && !(pww->dwStyle & CBS_HASSTRINGS); // // Determine the size of the buffer to allocate on the 16-bit side // to receive the text. // if (lpwm32mpex->dwParam) { // if handles are used cb = 4; } else { cb = SendMessage(lpwm32mpex->hwnd, CB_GETLBTEXTLEN, lpwm32mpex->uParam, 0); if (cb == CB_ERR) { // // lpwm32mpex->dwTmp[0] is initialized to 0 so that nothing // gets copied to the buffer by getstr16() while unthunking // this message. // // bug # 24415, ChandanC // cb = SIZE_BOGUS; lpwm32mpex->dwTmp[0] = 0; } else { // // Add one for NULL character. // cb = cb + 1; (INT) lpwm32mpex->dwTmp[0] = (INT) -1; } } if (lpwm32mpex->lParam) { BYTE *lpT; // See comment on similar code below lpwm32mpex->Parm16.WndProc.lParam = malloc16(cb); if (!(lpwm32mpex->Parm16.WndProc.lParam)) return FALSE; GETVDMPTR((lpwm32mpex->Parm16.WndProc.lParam), sizeof(BYTE), lpT); *lpT = 0; FREEVDMPTR(lpT); } } else { if (lpwm32mpex->lParam && lpwm32mpex->Parm16.WndProc.lParam) { if (lpwm32mpex->dwParam) { // if handles are used UNALIGNED DWORD *lpT; GETVDMPTR((lpwm32mpex->Parm16.WndProc.lParam), sizeof(DWORD), lpT); *(UNALIGNED DWORD *)lpwm32mpex->lParam = *lpT; FREEVDMPTR(lpT); } else { getstr16((VPSZ)lpwm32mpex->Parm16.WndProc.lParam, (LPSZ)lpwm32mpex->lParam, (INT) lpwm32mpex->dwTmp[0]); } free16((VPVOID) lpwm32mpex->Parm16.WndProc.lParam); } } return(TRUE); }
ULONG WOW32FaxHandler(UINT iFun, LPSTR lpIn) { LPWOWFAXINFO lpT = (LPWOWFAXINFO)lpIn; LPWOWFAXINFO16 lpT16; HWND hwnd = gfaxinfo.hwnd; LPBYTE lpData; VPVOID vp; #ifdef DEBUG int DebugStringIndex = iFun - (WM_USER+0x100+1); if ((DebugStringIndex >= WM_DDRV_FIRST) && (DebugStringIndex <= WM_DDRV_LAST) ) { LOGDEBUG(0,("WOW32FaxHandler, %s, 0x%lX\n", (LPSTR)szWmDdrvDebugStrings[DebugStringIndex], (LPSTR) lpIn)); } #endif switch (iFun) { case WM_DDRV_SUBCLASS: // // Subclass the window - This is so that we get a chance to // transform the 32bit data to 16bit data and vice versa. A // NULL HWND, passed in lpIn, indicates don't subclass. // if (gfaxinfo.hwnd = (HWND)lpIn) { gfaxinfo.proc16 = (WNDPROC)SetWindowLong((HWND)lpIn, GWL_WNDPROC, (DWORD)WowFaxWndProc); gfaxinfo.tid = GetWindowThreadProcessId((HWND)lpIn, NULL); } WOW32ASSERT(sizeof(DEVMODE16) + 4 == sizeof(DEVMODE31)); // // Read in the SupFaxDrv name list from the registry. // SupFaxDrv = GetSupportedFaxDrivers(&uNumSupFaxDrv); break; case WM_DDRV_ENABLE: // Enable the driver: // . first intialize the 16bit faxinfo datastruct // . then inform the driver (dll name) to be loaded // // format of ddrv_message: // wParam = hdc (just a unique id) // lparam = 16bit faxinfo struct with relevant data // Must call 'callwindowproc' not 'sendmessage' because // WowFaxWndProc is a subclass of the 16-bit FaxWndProc. // WOW32ASSERT(lpT->lpinfo16 == (LPSTR)NULL); lpT->lpinfo16 = (LPSTR)CallWindowProc( gfaxinfo.proc16, hwnd, WM_DDRV_INITFAXINFO16, lpT->hdc, (LPARAM)0); if (lpT->lpinfo16) { vp = malloc16(lpT->cData); GETVDMPTR(vp, lpT->cData, lpData); if (lpData == 0) { break; } GETVDMPTR(lpT->lpinfo16, sizeof(WOWFAXINFO16), lpT16); if (lpT16) { if (lstrlenW(lpT->szDeviceName) < sizeof(lpT16->szDeviceName)) { WideCharToMultiByte(CP_ACP, 0, lpT->szDeviceName, lstrlenW(lpT->szDeviceName) + 1, lpT16->szDeviceName, sizeof(lpT16->szDeviceName), NULL, NULL); lpT16->lpDriverName = lpT->lpDriverName; if (lpT->lpDriverName) { lpT16->lpDriverName = (LPBYTE)vp + (DWORD)lpT->lpDriverName; WideCharToMultiByte(CP_ACP, 0, (PWSTR)((LPSTR)lpT + (DWORD)lpT->lpDriverName), lstrlenW((LPWSTR)((LPSTR)lpT + (DWORD)lpT->lpDriverName)) + 1, lpData + (DWORD)lpT->lpDriverName, lstrlenW((LPWSTR)((LPSTR)lpT + (DWORD)lpT->lpDriverName)) + 1, NULL, NULL); } lpT16->lpPortName = lpT->lpPortName; if (lpT->lpPortName) { lpT16->lpPortName = (LPBYTE)vp + (DWORD)lpT->lpPortName; WideCharToMultiByte(CP_ACP, 0, (PWSTR)((LPSTR)lpT + (DWORD)lpT->lpPortName), lstrlenW((LPWSTR)((LPSTR)lpT + (DWORD)lpT->lpPortName)) + 1, lpData + (DWORD)lpT->lpPortName, lstrlenW((LPWSTR)((LPSTR)lpT + (DWORD)lpT->lpPortName)) + 1, NULL, NULL); } lpT16->lpIn = lpT->lpIn; if (lpT->lpIn) { lpT16->lpIn = (LPBYTE)vp + (DWORD)lpT->lpIn; ConvertDevMode((PDEVMODE16)(lpData + (DWORD)lpT->lpIn), (LPDEVMODEW)((LPSTR)lpT + (DWORD)lpT->lpIn), TRUE); } WOW32ASSERT((sizeof(GDIINFO16) + sizeof(POINT16)) <= sizeof(GDIINFO)); lpT16->lpOut = (LPBYTE)vp + (DWORD)lpT->lpOut; FREEVDMPTR(lpData); FREEVDMPTR(lpT16); lpT->retvalue = CallWindowProc( gfaxinfo.proc16, hwnd, lpT->msg, lpT->hdc, (LPARAM)lpT->lpinfo16); if (lpT->retvalue) { GETVDMPTR(vp, lpT->cData, lpData); ConvertGdiInfo((LPGDIINFO16)(lpData + (DWORD)lpT->lpOut), (PGDIINFO)((LPSTR)lpT + (DWORD)lpT->lpOut), FALSE); } } } free16(vp); } break; case WM_DDRV_ESCAPE: GETVDMPTR(lpT->lpinfo16, sizeof(WOWFAXINFO16), lpT16); if (lpT16) { lpT16->wCmd = lpT->wCmd; } FREEVDMPTR(lpT16); lpT->retvalue = CallWindowProc( gfaxinfo.proc16, hwnd, lpT->msg, lpT->hdc, (LPARAM)lpT->lpinfo16); break; case WM_DDRV_PRINTPAGE: // // set the global variable. When the 16bit driver calls DMBitBlt we // get the bitmap info from here. Since WOW is single threaded we // won't receive another printpage msg before we return from here. // // All pointers in the faxinfo structure are actually // 'offsets from the start of the mapfile' to relevant data. // glpfaxinfoCur = lpT; lpT->lpbits = (LPBYTE)lpT + (DWORD)lpT->lpbits; // fall through; case WM_DDRV_STARTDOC: case WM_DDRV_ENDDOC: lpT->retvalue = CallWindowProc( gfaxinfo.proc16, hwnd, lpT->msg, lpT->hdc, (LPARAM)lpT->lpinfo16); break; case WM_DDRV_DISABLE: CallWindowProc( gfaxinfo.proc16, hwnd, lpT->msg, lpT->hdc, (LPARAM)lpT->lpinfo16); lpT->retvalue = TRUE; break; case WM_DDRV_EXTDMODE: case WM_DDRV_DEVCAPS: WOW32ASSERT(lpT->lpinfo16 == (LPSTR)NULL); lpT->lpinfo16 = (LPSTR)CallWindowProc( gfaxinfo.proc16, hwnd, WM_DDRV_INITFAXINFO16, lpT->hdc, (LPARAM)0); if (lpT->lpinfo16) { vp = malloc16(lpT->cData); GETVDMPTR(vp, lpT->cData, lpData); if (lpData == 0) { break; } GETVDMPTR(lpT->lpinfo16, sizeof(WOWFAXINFO16), lpT16); if (lpT16) { if (lstrlenW(lpT->szDeviceName) < sizeof(lpT16->szDeviceName)) { WideCharToMultiByte(CP_ACP, 0, lpT->szDeviceName, lstrlenW(lpT->szDeviceName) + 1, lpT16->szDeviceName, sizeof(lpT16->szDeviceName), NULL, NULL); lpT16->lpDriverName = lpT->lpDriverName; if (lpT->lpDriverName) { lpT16->lpDriverName = (LPBYTE)vp + (DWORD)lpT->lpDriverName; WideCharToMultiByte(CP_ACP, 0, (PWSTR)((LPSTR)lpT + (DWORD)lpT->lpDriverName), lstrlenW((LPWSTR)((LPSTR)lpT + (DWORD)lpT->lpDriverName)) + 1, lpData + (DWORD)lpT->lpDriverName, lstrlenW((LPWSTR)((LPSTR)lpT + (DWORD)lpT->lpDriverName)) + 1, NULL, NULL); } FREEVDMPTR(lpData); FREEVDMPTR(lpT16); lpT->retvalue = CallWindowProc( gfaxinfo.proc16, hwnd, WM_DDRV_LOAD, lpT->hdc, (LPARAM)lpT->lpinfo16); if (lpT->retvalue) { lpT->retvalue = (iFun == WM_DDRV_DEVCAPS) ? DeviceCapsHandler(lpT) : ExtDevModeHandler(lpT) ; } CallWindowProc( gfaxinfo.proc16, hwnd, WM_DDRV_UNLOAD, lpT->hdc, (LPARAM)lpT->lpinfo16); } } free16(vp); } break; } return TRUE; }
DWORD DeviceCapsHandler(LPWOWFAXINFO lpfaxinfo) { LPWOWFAXINFO16 lpWFI16; LPSTR lpSrc; LPBYTE lpDest; INT i; DWORD cbData16; // Size of data items. UINT cbUni; LOGDEBUG(0,("DeviceCapsHandler, lpfaxinfo: %X, wCmd: %X\n", lpfaxinfo, lpfaxinfo->wCmd)); GETVDMPTR(lpfaxinfo->lpinfo16, sizeof(WOWFAXINFO16), lpWFI16); // Get the number of data items with a call to the 16-bit printer driver. lpWFI16->lpDriverName = 0; lpWFI16->lpPortName = 0; lpWFI16->wCmd = lpfaxinfo->wCmd; lpWFI16->cData = 0; lpWFI16->lpOut = 0; lpfaxinfo->cData = 0; lpfaxinfo->retvalue = CallWindowProc(gfaxinfo.proc16, gfaxinfo.hwnd, lpfaxinfo->msg, lpfaxinfo->hdc, (LPARAM)lpfaxinfo->lpinfo16); cbData16 = gDC_ListItemSize[lpfaxinfo->wCmd]; if (lpfaxinfo->lpOut && cbData16 && lpfaxinfo->retvalue) { // We need to allocate and copy for this query lpWFI16->cData = cbData16 * lpfaxinfo->retvalue; // assert the size of output buffer - and set it the actual data size switch (lpfaxinfo->wCmd) { case DC_BINNAMES: case DC_PAPERNAMES: // These fields need extra room for ANSI to UNICODE conversion. WOW32ASSERT((lpfaxinfo->cData - (DWORD)lpfaxinfo->lpOut) >= lpWFI16->cData * sizeof(WCHAR)); lpfaxinfo->cData = lpWFI16->cData * sizeof(WCHAR); break; default: WOW32ASSERT((lpfaxinfo->cData - (DWORD)lpfaxinfo->lpOut) >= lpWFI16->cData); lpfaxinfo->cData = lpWFI16->cData; break; } if ((lpWFI16->lpOut = (LPSTR)malloc16(lpWFI16->cData)) == NULL) { lpfaxinfo->retvalue = 0; goto LeaveDeviceCapsHandler; } // Get the list data with a call to the 16-bit printer driver. lpfaxinfo->retvalue = CallWindowProc(gfaxinfo.proc16, gfaxinfo.hwnd, lpfaxinfo->msg, lpfaxinfo->hdc, (LPARAM)lpfaxinfo->lpinfo16); GETVDMPTR(lpWFI16->lpOut, 0, lpSrc); lpDest = (LPBYTE)lpfaxinfo + (DWORD)lpfaxinfo->lpOut; switch (lpfaxinfo->wCmd) { case DC_BINNAMES: case DC_PAPERNAMES: for (i = 0; i < (INT)lpfaxinfo->retvalue; i++) { RtlMultiByteToUnicodeN((LPWSTR)lpDest, cbData16 * sizeof(WCHAR), (PULONG)&cbUni, (LPBYTE)lpSrc, cbData16); lpDest += cbData16 * sizeof(WCHAR); lpSrc += cbData16; } break; default: RtlCopyMemory(lpDest, lpSrc, lpWFI16->cData); break; } free16((VPVOID)lpWFI16->lpOut); FREEVDMPTR(lpSrc); } LeaveDeviceCapsHandler: FREEVDMPTR(lpWFI16); return lpfaxinfo->retvalue; }
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; }