HMONITOR MonitorFromWindow( IN HWND hwnd, IN DWORD dwFlags) { PMONITOR pMonitor; PWND pwnd; if (dwFlags > MONITOR_DEFAULTTONEAREST) { RIPERR1(ERROR_INVALID_FLAGS, RIP_WARNING, "Invalid flags to MonitorFromWindow, %x", dwFlags); return NULL; } if (hwnd) { pwnd = ValidateHwnd(hwnd); if (!pwnd) { return NULL; } } else { pwnd = NULL; } pMonitor = _MonitorFromWindow(pwnd, dwFlags); try { return PtoH(pMonitor); } except(W32ExceptionHandler(TRUE, RIP_WARNING)) { return NULL; } }
void xxxSetTrayWindow(PDESKTOP pdesk, PWND pwnd) { HWND hwnd; if (pwnd != STW_SAME) { hwnd = PtoH(pwnd); Lock(&(pdesk->spwndTray), pwnd); } else { pwnd = pdesk->spwndTray; hwnd = PtoH(pwnd); } if ( FPostTray(pdesk)) PostShellHookMessages(pdesk->cFullScreen ? HSHELL_RUDEAPPACTIVATED : HSHELL_WINDOWACTIVATED, hwnd); if ( FCallHookTray() ) xxxCallHook(HSHELL_WINDOWACTIVATED, (WPARAM) hwnd, (pdesk->cFullScreen ? 1 : 0), WH_SHELL); }
HCURSOR _CreateEmptyCursorObject( BOOL fPublic) { PCURSOR pcurT; /* * Create the cursor object. */ pcurT = (PCURSOR)HMAllocObject(fPublic ? NULL : PtiCurrent(), NULL, TYPE_CURSOR, max(sizeof(CURSOR), sizeof(ACON))); return (HCURSOR)PtoH(pcurT); }
/***************************************************************************\ * xxxMessageEvent * * Description: Called when a hooked DDE message is sent or posted. flags * specifies the applicable MF_ flag. This is called in the server side * context of the sender or poster which may or may not be a DDEML process. * pdmhd contains DDE data extracted and copied from the client side. * * History: * 12-1-91 sanfords Created. \***************************************************************************/ VOID xxxMessageEvent( PWND pwndTo, UINT message, WPARAM wParam, LPARAM lParam, DWORD flag, PDDEML_MSG_HOOK_DATA pdmhd) { PEVENT_PACKET pep; PWND pwndFrom; TL tlpep; PTHREADINFO pti; CheckCritIn(); pep = (PEVENT_PACKET)UserAllocPoolWithQuota(sizeof(EVENT_PACKET) - sizeof(DWORD) + sizeof(MONMSGSTRUCT), TAG_DDE8); if (pep == NULL) { return; } pep->EventType = flag; pep->fSense = TRUE; pep->cbEventData = sizeof(MONMSGSTRUCT); #define pmsgs ((MONMSGSTRUCT *)&pep->Data) pmsgs->cb = sizeof(MONMSGSTRUCT); pmsgs->hwndTo = PtoH(pwndTo); pmsgs->dwTime = NtGetTickCount(); pwndFrom = RevalidateHwnd((HWND)wParam); if (pwndFrom != NULL) { pmsgs->hTask = GETPTI(pwndFrom)->pEThread->Cid.UniqueThread; } else { pmsgs->hTask = 0; } pmsgs->wMsg = message; pmsgs->wParam = wParam; pmsgs->lParam = lParam; if (pdmhd != NULL) { pmsgs->dmhd = *pdmhd; } #undef pmsgs pti = PtiCurrent(); ThreadLockPool(pti, pep, &tlpep); xxxCsEvent(pep, sizeof(MONMSGSTRUCT)); ThreadUnlockAndFreePool(pti, &tlpep); }
HMONITOR MonitorFromRect( IN LPCRECT lprc, IN DWORD dwFlags) { PMONITOR pMonitor; if (dwFlags > MONITOR_DEFAULTTONEAREST) { RIPERR1(ERROR_INVALID_FLAGS, RIP_WARNING, "Invalid flags to MonitorFromRect, %x", dwFlags); return NULL; } pMonitor = _MonitorFromRect(lprc, dwFlags); try { return PtoH(pMonitor); } except(W32ExceptionHandler(TRUE, RIP_WARNING)) { return NULL; } }
ULONG_PTR _GetClassData( PCLS pcls, PWND pwnd, // used for transition to kernel-mode for GCL_WNDPROC int index, BOOL bAnsi) { KERNEL_ULONG_PTR dwData; DWORD dwCPDType = 0; index -= INDEX_OFFSET; if (index < 0) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE, ""); return 0; } UserAssert(index >= 0); UserAssert(index < sizeof(afClassDWord)); UserAssert(sizeof(afClassDWord) == sizeof(aiClassOffset)); if (afClassDWord[index] == sizeof(DWORD)) { dwData = *(DWORD *)(((BYTE *)pcls) + aiClassOffset[index]); } else if (afClassDWord[index] == sizeof(KERNEL_ULONG_PTR)) { dwData = *(KERNEL_ULONG_PTR *)(((BYTE *)pcls) + aiClassOffset[index]); } else { dwData = (DWORD)*(WORD *)(((BYTE *)pcls) + aiClassOffset[index]); } index += INDEX_OFFSET; /* * If we're returning an icon or cursor handle, do the reverse * mapping here. */ switch(index) { case GCLP_MENUNAME: if (IS_PTR(pcls->lpszMenuName)) { /* * The Menu Name is a real string: return the client-side address. * (If the class was registered by another app this returns an * address in that app's addr. space, but it's the best we can do) */ dwData = bAnsi ? (ULONG_PTR)pcls->lpszClientAnsiMenuName : (ULONG_PTR)pcls->lpszClientUnicodeMenuName; } break; case GCLP_HICON: case GCLP_HCURSOR: case GCLP_HICONSM: /* * We have to go to the kernel to convert the pcursor to a handle because * cursors are allocated out of POOL, which is not accessable from the client. */ if (dwData) { dwData = NtUserCallHwndParam(PtoH(pwnd), index, SFI_GETCLASSICOCUR); } break; case GCLP_WNDPROC: { /* * Always return the client wndproc in case this is a server * window class. */ if (pcls->CSF_flags & CSF_SERVERSIDEPROC) { dwData = MapServerToClientPfn(dwData, bAnsi); } else { KERNEL_ULONG_PTR dwT = dwData; dwData = MapClientNeuterToClientPfn(pcls, dwT, bAnsi); /* * If the client mapping didn't change the window proc then see if * we need a callproc handle. */ if (dwData == dwT) { /* * Need to return a CallProc handle if there is an Ansi/Unicode mismatch */ if (bAnsi != !!(pcls->CSF_flags & CSF_ANSIPROC)) { dwCPDType |= bAnsi ? CPD_ANSI_TO_UNICODE : CPD_UNICODE_TO_ANSI; } } } if (dwCPDType) { ULONG_PTR dwCPD; dwCPD = GetCPD(pwnd, dwCPDType | CPD_WNDTOCLS, KERNEL_ULONG_PTR_TO_ULONG_PTR(dwData)); if (dwCPD) { dwData = dwCPD; } else { RIPMSG0(RIP_WARNING, "GetClassLong unable to alloc CPD returning handle\n"); } } } break; case GCL_CBCLSEXTRA: if ((pcls->CSF_flags & CSF_WOWCLASS) && (pcls->CSF_flags & CSF_WOWEXTRA)) { /* * The 16-bit app changed its Extra bytes value. Return the changed * value. FritzS */ return PWCFromPCLS(pcls)->iClsExtra; } else return pcls->cbclsExtra; break; /* * WOW uses a pointer straight into the class structure. */ case GCLP_WOWWORDS: if (pcls->CSF_flags & CSF_WOWCLASS) { return ((ULONG_PTR)PWCFromPCLS(pcls)); } else return 0; case GCL_STYLE: dwData &= CS_VALID; break; } return KERNEL_ULONG_PTR_TO_ULONG_PTR(dwData); }
/***************************************************************************\ * xxxCsEvent * * Description: * Handles broadcasting of all types of DDEML events. * * History: * 11-1-91 sanfords Created. * 10-28-97 FritzS added cbEventData as a passed-in parameter. This was done because the EVENT_PACKET may be client-side and we capture the count to keep a hostile app from changing the size after data probing. \***************************************************************************/ DWORD xxxCsEvent( PEVENT_PACKET pep, WORD cbEventData) { PSVR_INSTANCE_INFO psiiT; PEVENT_PACKET pep2; HWND *ahwndEvent = NULL; PWND pwnd; int cHwndAllocated, i, cTargets; TL tlpwnd; TL tlpep2; TL tlahwndEvent; ULONG cbEventPacket; PTHREADINFO pti = PtiCurrent(); CheckCritIn(); /* * Copy pep info to a server side stable area */ cbEventPacket = cbEventData + sizeof(EVENT_PACKET) - sizeof(DWORD); pep2 = (PEVENT_PACKET)UserAllocPoolWithQuota(cbEventPacket, TAG_DDE5); if (pep2 == NULL) { return DMLERR_MEMORY_ERROR; } try { RtlCopyMemory((LPSTR)pep2, (LPSTR)pep, cbEventPacket); } except (W32ExceptionHandler(FALSE, RIP_WARNING)) { UserFreePool(pep2); return DMLERR_INVALIDPARAMETER; } pep2->cbEventData = cbEventData; cTargets = 0; cHwndAllocated = 0; for (psiiT = psiiList; psiiT != NULL; psiiT = psiiT->next) { // // Don't bother with event windows for instances who's flags // indicate they're not interrested in the event. // if (((psiiT->afCmd & pep2->EventType) && !pep2->fSense) || (!(psiiT->afCmd & pep2->EventType) && pep2->fSense)) { continue; } if (cTargets >= cHwndAllocated) { if (ahwndEvent == NULL) { cHwndAllocated = 8; ahwndEvent = (HWND *)UserAllocPoolWithQuota( sizeof(HWND) * cHwndAllocated, TAG_DDE6); } else { DWORD dwSize = cHwndAllocated * sizeof(HWND); HWND *ahwndEventT = ahwndEvent; cHwndAllocated += 8; ahwndEvent = (HWND *)UserReAllocPoolWithQuota(ahwndEvent, dwSize, sizeof(HWND) * cHwndAllocated, TAG_DDE7); if (ahwndEvent == NULL) { UserFreePool(ahwndEventT); } } if (ahwndEvent == NULL) { UserFreePool(pep2); return DMLERR_MEMORY_ERROR; } } ahwndEvent[cTargets++] = PtoH(psiiT->spwndEvent); } ThreadLockPool(pti, pep2, &tlpep2); if (ahwndEvent != NULL) { ThreadLockPool(pti, ahwndEvent, &tlahwndEvent); for (i = 0; i < cTargets; i++) { /* * We need to change contexts for the callback */ pwnd = ValidateHwnd(ahwndEvent[i]); if (pwnd != NULL) { ThreadLockAlwaysWithPti(pti, pwnd, &tlpwnd); xxxSendMessage(pwnd, WM_DDEMLEVENT, 0, (LPARAM)pep2); ThreadUnlock(&tlpwnd); } } ThreadUnlockAndFreePool(pti, &tlahwndEvent); } ThreadUnlockAndFreePool(pti, &tlpep2); return DMLERR_NO_ERROR; }
BOOL xxxMNStartState( PPOPUPMENU ppopupmenu, int mn) { PWND pwndMenu; PMENUSTATE pMenuState; TL tlpwndMenu; TL tlpmenu; UserAssert(IsRootPopupMenu(ppopupmenu)); if (ppopupmenu->fDestroyed) { return FALSE; } pwndMenu = ppopupmenu->spwndNotify; ThreadLock(pwndMenu, &tlpwndMenu); pMenuState = GetpMenuState(pwndMenu); if (pMenuState == NULL) { RIPMSG0(RIP_ERROR, "xxxMNStartState: pMenuState == NULL"); return FALSE; } pMenuState->mnFocus = mn; pMenuState->fMenuStarted = TRUE; pMenuState->fButtonDown = FALSE; /* * Lotus Freelance demo programs depend on GetCapture returning their hwnd * when in menumode. */ xxxCapture(PtiCurrent(), ppopupmenu->spwndNotify, SCREEN_CAPTURE); xxxSendMessage(pwndMenu, WM_SETCURSOR, (DWORD)HWq(pwndMenu), MAKELONG(MSGF_MENU, 0)); if (ppopupmenu->fIsMenuBar) { BOOL fSystemMenu; PMENU pMenu; pMenu = GetInitMenuParam(pwndMenu, &fSystemMenu); if (pMenu == NULL) { pMenuState->fMenuStarted = FALSE; xxxSetCapture(NULL); ThreadUnlock(&tlpwndMenu); return(FALSE); } Lock(&(ppopupmenu->spmenu), pMenu); ppopupmenu->fIsSysMenu = (fSystemMenu != 0); if (!fSystemMenu) Lock(&(ppopupmenu->spmenuAlternate), GetSysMenu(pwndMenu, FALSE)); } pMenuState->fIsSysMenu = (ppopupmenu->fIsSysMenu != 0); if (!ppopupmenu->fNoNotify) { PMENU pMenu; if (ppopupmenu->fIsTrackPopup && ppopupmenu->fIsSysMenu) pMenu = GetInitMenuParam(pwndMenu, NULL); else pMenu = ppopupmenu->spmenu; xxxSendMessage(pwndMenu, WM_INITMENU, (DWORD)PtoH(pMenu), 0L); } if (!ppopupmenu->fIsTrackPopup) { if (ppopupmenu->fIsSysMenu) { MNPositionSysMenu(pwndMenu, ppopupmenu->spmenu); } else if (ppopupmenu->fIsMenuBar) { ThreadLock(ppopupmenu->spmenu, &tlpmenu); xxxMNRecomputeBarIfNeeded(pwndMenu, ppopupmenu->spmenu); ThreadUnlock(&tlpmenu); MNPositionSysMenu(pwndMenu, ppopupmenu->spmenuAlternate); } } ThreadUnlock(&tlpwndMenu); return !ppopupmenu->fDestroyed; }