1 #pragma once 2 3 static __inline PVOID 4 SharedPtrToUser(PVOID Ptr) 5 { 6 ASSERT(Ptr != NULL); 7 ASSERT(g_ulSharedDelta != 0); 8 return (PVOID)((ULONG_PTR)Ptr - g_ulSharedDelta); 9 } 10 11 static __inline PVOID 12 DesktopPtrToUser(PVOID Ptr) 13 { 14 PCLIENTINFO pci; 15 PDESKTOPINFO pdi; 16 GetW32ThreadInfo(); 17 pci = GetWin32ClientInfo(); 18 pdi = pci->pDeskInfo; 19 20 ASSERT(Ptr != NULL); 21 ASSERT(pdi != NULL); 22 if ((ULONG_PTR)Ptr >= (ULONG_PTR)pdi->pvDesktopBase && 23 (ULONG_PTR)Ptr < (ULONG_PTR)pdi->pvDesktopLimit) 24 { 25 return (PVOID)((ULONG_PTR)Ptr - pci->ulClientDelta); 26 } 27 else 28 { 29 /* NOTE: This is slow as it requires a call to win32k. This should only be 30 neccessary if a thread wants to access an object on a different 31 desktop */ 32 return (PVOID)NtUserxGetDesktopMapping(Ptr); 33 } 34 } 35 36 static __inline BOOL 37 IsThreadHooked(PCLIENTINFO pci) 38 { 39 return (pci->fsHooks|pci->pDeskInfo->fsHooks) != 0; 40 } 41 42 static __inline PDESKTOPINFO 43 GetThreadDesktopInfo(VOID) 44 { 45 PTHREADINFO ti; 46 PDESKTOPINFO di = NULL; 47 48 ti = GetW32ThreadInfo(); 49 if (ti != NULL) 50 di = GetWin32ClientInfo()->pDeskInfo; 51 52 return di; 53 } 54 55 static __inline BOOL 56 IsCallProcHandle(IN WNDPROC lpWndProc) 57 { 58 /* FIXME - check for 64 bit architectures... */ 59 return ((ULONG_PTR)lpWndProc & 0xFFFF0000) == 0xFFFF0000; 60 } 61 62 #define STATIC_UISTATE_GWL_OFFSET (sizeof(HFONT)+sizeof(HICON))// see UISTATE_GWL_OFFSET in static.c 63 64 /* Retrieve the UI state for the control */ 65 static __inline BOOL STATIC_update_uistate(HWND hwnd, BOOL unicode) 66 { 67 LONG flags, prevflags; 68 69 if (unicode) 70 flags = DefWindowProcW(hwnd, WM_QUERYUISTATE, 0, 0); 71 else 72 flags = DefWindowProcA(hwnd, WM_QUERYUISTATE, 0, 0); 73 74 prevflags = GetWindowLongW(hwnd, STATIC_UISTATE_GWL_OFFSET); 75 76 if (prevflags != flags) 77 { 78 SetWindowLongW(hwnd, STATIC_UISTATE_GWL_OFFSET, flags); 79 return TRUE; 80 } 81 82 return FALSE; 83 } 84 85 static __inline void LoadUserApiHook() 86 { 87 if (!gfServerProcess && 88 !IsInsideUserApiHook() && 89 (gpsi->dwSRVIFlags & SRVINFO_APIHOOK) && 90 !RtlIsThreadWithinLoaderCallout()) 91 { 92 NtUserCallNoParam(NOPARAM_ROUTINE_LOADUSERAPIHOOK); 93 } 94 } 95 96 #define UserHasDlgFrameStyle(Style, ExStyle) \ 97 (((ExStyle) & WS_EX_DLGMODALFRAME) || \ 98 (((Style) & WS_DLGFRAME) && (!((Style) & WS_THICKFRAME)))) 99 100 #define UserHasThickFrameStyle(Style, ExStyle) \ 101 (((Style) & WS_THICKFRAME) && \ 102 (!(((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME))) 103 104 #define UserHasThinFrameStyle(Style, ExStyle) \ 105 (((Style) & WS_BORDER) || (!((Style) & (WS_CHILD | WS_POPUP)))) 106 107 /* macro for source compatibility with wine */ 108 #define WIN_GetFullHandle(h) ((HWND)(h)) 109 110 #define HOOKID_TO_FLAG(HookId) (1 << ((HookId) + 1)) 111 #define ISITHOOKED(HookId) (GetWin32ClientInfo()->fsHooks & HOOKID_TO_FLAG(HookId) ||\ 112 (GetWin32ClientInfo()->pDeskInfo && GetWin32ClientInfo()->pDeskInfo->fsHooks & HOOKID_TO_FLAG(HookId))) 113