1 #pragma once 2 3 /* W32PROCESS flags */ 4 #define W32PF_CONSOLEAPPLICATION 0x00000001 5 #define W32PF_FORCEOFFFEEDBACK 0x00000002 6 #define W32PF_STARTGLASS 0x00000004 7 #define W32PF_WOW 0x00000008 8 #define W32PF_READSCREENACCESSGRANTED 0x00000010 9 #define W32PF_INITIALIZED 0x00000020 10 #define W32PF_APPSTARTING 0x00000040 11 #define W32PF_WOW64 0x00000080 12 #define W32PF_ALLOWFOREGROUNDACTIVATE 0x00000100 13 #define W32PF_OWNDCCLEANUP 0x00000200 14 #define W32PF_SHOWSTARTGLASSCALLED 0x00000400 15 #define W32PF_FORCEBACKGROUNDPRIORITY 0x00000800 16 #define W32PF_TERMINATED 0x00001000 17 #define W32PF_CLASSESREGISTERED 0x00002000 18 #define W32PF_THREADCONNECTED 0x00004000 19 #define W32PF_PROCESSCONNECTED 0x00008000 20 #define W32PF_SETFOREGROUNDALLOWED 0x00008000 21 #define W32PF_WAKEWOWEXEC 0x00010000 22 #define W32PF_WAITFORINPUTIDLE 0x00020000 23 #define W32PF_IOWINSTA 0x00040000 24 #define W32PF_CONSOLEFOREGROUND 0x00080000 25 #define W32PF_OLELOADED 0x00100000 26 #define W32PF_SCREENSAVER 0x00200000 27 #define W32PF_IDLESCREENSAVER 0x00400000 28 #define W32PF_DISABLEIME 0x00800000 29 #define W32PF_ICONTITLEREGISTERED 0x10000000 30 #define W32PF_DPIAWARE 0x20000000 31 // ReactOS 32 #define W32PF_NOWINDOWGHOSTING (0x01000000) 33 #define W32PF_MANUALGUICHECK (0x02000000) 34 #define W32PF_CREATEDWINORDC (0x04000000) 35 #define W32PF_APIHOOKLOADED (0x08000000) 36 37 #define QSIDCOUNTS 7 38 39 typedef enum _QS_ROS_TYPES 40 { 41 QSRosKey = 0, 42 QSRosMouseMove, 43 QSRosMouseButton, 44 QSRosPostMessage, 45 QSRosSendMessage, 46 QSRosHotKey, 47 QSRosEvent, 48 } QS_ROS_TYPES, *PQS_ROS_TYPES; 49 50 extern BOOL ClientPfnInit; 51 extern HINSTANCE hModClient; 52 extern HANDLE hModuleWin; // This Win32k Instance. 53 extern struct _CLS *SystemClassList; 54 extern BOOL RegisteredSysClasses; 55 56 struct _TL; 57 typedef struct _TL *PTL; 58 59 typedef struct _W32THREAD 60 { 61 PETHREAD pEThread; 62 LONG RefCount; 63 PTL ptlW32; 64 PVOID pgdiDcattr; 65 PVOID pgdiBrushAttr; 66 PVOID pUMPDObjs; 67 PVOID pUMPDHeap; 68 DWORD dwEngAcquireCount; 69 PVOID pSemTable; 70 PVOID pUMPDObj; 71 } W32THREAD, *PW32THREAD; 72 73 struct tagIMC; 74 75 /* 76 * THREADINFO structure. 77 * See also: https://reactos.org/wiki/Techwiki:Win32k/THREADINFO 78 */ 79 #ifdef __cplusplus 80 typedef struct _THREADINFO : _W32THREAD 81 { 82 #else 83 typedef struct _THREADINFO 84 { 85 W32THREAD; 86 #endif 87 PTL ptl; 88 PPROCESSINFO ppi; 89 struct _USER_MESSAGE_QUEUE* MessageQueue; 90 struct tagKL* KeyboardLayout; 91 struct _CLIENTTHREADINFO * pcti; 92 struct _DESKTOP* rpdesk; 93 struct _DESKTOPINFO * pDeskInfo; 94 struct _CLIENTINFO * pClientInfo; 95 FLONG TIF_flags; 96 PUNICODE_STRING pstrAppName; 97 struct _USER_SENT_MESSAGE *pusmSent; 98 struct _USER_SENT_MESSAGE *pusmCurrent; 99 /* Queue of messages sent to the queue. */ 100 LIST_ENTRY SentMessagesListHead; // psmsReceiveList 101 /* Last message time and ID */ 102 LONG timeLast; 103 ULONG_PTR idLast; 104 /* True if a WM_QUIT message is pending. */ 105 BOOLEAN QuitPosted; 106 /* The quit exit code. */ 107 INT exitCode; 108 HDESK hdesk; 109 UINT cPaintsReady; /* Count of paints pending. */ 110 UINT cTimersReady; /* Count of timers pending. */ 111 struct tagMENUSTATE* pMenuState; 112 DWORD dwExpWinVer; 113 DWORD dwCompatFlags; 114 DWORD dwCompatFlags2; 115 struct _USER_MESSAGE_QUEUE* pqAttach; 116 PTHREADINFO ptiSibling; 117 ULONG fsHooks; 118 struct tagHOOK * sphkCurrent; 119 LPARAM lParamHkCurrent; 120 WPARAM wParamHkCurrent; 121 struct tagSBTRACK* pSBTrack; 122 /* Set if there are new messages specified by WakeMask in any of the queues. */ 123 HANDLE hEventQueueClient; 124 /* Handle for the above event (in the context of the process owning the queue). */ 125 PKEVENT pEventQueueServer; 126 LIST_ENTRY PtiLink; 127 INT iCursorLevel; 128 /* Last message cursor position */ 129 POINT ptLast; 130 /* Input context-related */ 131 struct _WND* spwndDefaultIme; 132 struct tagIMC* spDefaultImc; 133 HKL hklPrev; 134 135 INT cEnterCount; 136 /* Queue of messages posted to the queue. */ 137 LIST_ENTRY PostedMessagesListHead; // mlPost 138 WORD fsChangeBitsRemoved; 139 WCHAR wchInjected; 140 UINT cWindows; 141 UINT cVisWindows; 142 #ifndef __cplusplus /// FIXME! 143 LIST_ENTRY aphkStart[NB_HOOKS]; 144 CLIENTTHREADINFO cti; // Used only when no Desktop or pcti NULL. 145 146 /* ReactOS */ 147 148 /* Thread Queue state tracking */ 149 // Send list QS_SENDMESSAGE 150 // Post list QS_POSTMESSAGE|QS_HOTKEY|QS_PAINT|QS_TIMER|QS_KEY 151 // Hard list QS_MOUSE|QS_KEY only 152 // Accounting of queue bit sets, the rest are flags. QS_TIMER QS_PAINT counts are handled in thread information. 153 DWORD nCntsQBits[QSIDCOUNTS]; // QS_KEY QS_MOUSEMOVE QS_MOUSEBUTTON QS_POSTMESSAGE QS_SENDMESSAGE QS_HOTKEY 154 155 LIST_ENTRY WindowListHead; 156 LIST_ENTRY W32CallbackListHead; 157 SINGLE_LIST_ENTRY ReferencesList; 158 ULONG cExclusiveLocks; 159 #if DBG 160 USHORT acExclusiveLockCount[GDIObjTypeTotal + 1]; 161 UINT cRefObjectCo; 162 #endif 163 #endif // __cplusplus 164 } THREADINFO; 165 166 167 #define IntReferenceThreadInfo(pti) \ 168 InterlockedIncrement(&(pti)->RefCount) 169 170 VOID UserDeleteW32Thread(PTHREADINFO); 171 172 #define IntDereferenceThreadInfo(pti) \ 173 do { \ 174 if (InterlockedDecrement(&(pti)->RefCount) == 0) \ 175 { \ 176 ASSERT(((pti)->TIF_flags & (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)) == (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)); \ 177 UserDeleteW32Thread(pti); \ 178 } \ 179 } while(0) 180 181 182 #define IntReferenceProcessInfo(ppi) \ 183 InterlockedIncrement((volatile LONG*)(&(ppi)->RefCount)) 184 185 VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO); 186 187 #define IntDereferenceProcessInfo(ppi) \ 188 do { \ 189 if (InterlockedDecrement((volatile LONG*)(&(ppi)->RefCount)) == 0) \ 190 { \ 191 ASSERT(((ppi)->W32PF_flags & W32PF_TERMINATED) != 0); \ 192 UserDeleteW32Process(ppi); \ 193 } \ 194 } while(0) 195 196 197 typedef struct _W32HEAP_USER_MAPPING 198 { 199 struct _W32HEAP_USER_MAPPING* Next; 200 PVOID KernelMapping; 201 PVOID UserMapping; 202 ULONG_PTR Limit; 203 ULONG Count; 204 } W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING; 205 206 207 /* 208 * Information from STARTUPINFOW, psdk/winbase.h. 209 * Set from PsGetCurrentProcess()->Peb->ProcessParameters. 210 * See also: https://reactos.org/wiki/Techwiki:Win32k/PROCESSINFO 211 */ 212 typedef struct tagUSERSTARTUPINFO 213 { 214 ULONG cb; 215 DWORD dwX; // STARTF_USEPOSITION StartupInfo->dwX/Y 216 DWORD dwY; 217 DWORD dwXSize; // STARTF_USESIZE StartupInfo->dwX/YSize 218 DWORD dwYSize; 219 DWORD dwFlags; // STARTF_ StartupInfo->dwFlags 220 WORD wShowWindow; // StartupInfo->wShowWindow 221 USHORT cbReserved2; 222 } USERSTARTUPINFO, *PUSERSTARTUPINFO; 223 224 typedef struct _W32PROCESS 225 { 226 PEPROCESS peProcess; 227 DWORD RefCount; 228 ULONG W32PF_flags; 229 PKEVENT InputIdleEvent; 230 DWORD StartCursorHideTime; 231 struct _W32PROCESS* NextStart; 232 PVOID pDCAttrList; 233 PVOID pBrushAttrList; 234 DWORD W32Pid; 235 LONG GDIHandleCount; 236 LONG UserHandleCount; 237 PEX_PUSH_LOCK GDIPushLock; /* Locking Process during access to structure. */ 238 RTL_AVL_TABLE GDIEngUserMemAllocTable; /* Process AVL Table. */ 239 LIST_ENTRY GDIDcAttrFreeList; 240 LIST_ENTRY GDIBrushAttrFreeList; 241 } W32PROCESS, *PW32PROCESS; 242 243 #define CLIBS 32 244 245 /* 246 * PROCESSINFO structure. 247 * See also: https://reactos.org/wiki/Techwiki:Win32k/PROCESSINFO 248 */ 249 #ifdef __cplusplus 250 typedef struct _PROCESSINFO : _W32PROCESS 251 { 252 #else 253 typedef struct _PROCESSINFO 254 { 255 W32PROCESS; 256 #endif 257 PTHREADINFO ptiList; 258 PTHREADINFO ptiMainThread; 259 struct _DESKTOP* rpdeskStartup; 260 struct _CLS *pclsPrivateList; 261 struct _CLS *pclsPublicList; 262 PPROCESSINFO ppiNext; 263 INT cThreads; 264 HDESK hdeskStartup; 265 DWORD dwhmodLibLoadedMask; 266 HANDLE ahmodLibLoaded[CLIBS]; 267 struct _WINSTATION_OBJECT* prpwinsta; 268 HWINSTA hwinsta; 269 ACCESS_MASK amwinsta; 270 DWORD dwHotkey; 271 HMONITOR hMonitor; 272 UINT iClipSerialNumber; 273 struct _CURICON_OBJECT* pCursorCache; 274 PVOID pClientBase; 275 DWORD dwLpkEntryPoints; 276 PVOID pW32Job; 277 DWORD dwImeCompatFlags; 278 LUID luidSession; 279 USERSTARTUPINFO usi; 280 DWORD dwLayout; 281 DWORD dwRegisteredClasses; 282 283 /* ReactOS */ 284 FAST_MUTEX PrivateFontListLock; 285 LIST_ENTRY PrivateFontListHead; 286 LIST_ENTRY PrivateMemFontListHead; 287 UINT PrivateMemFontHandleCount; 288 289 FAST_MUTEX DriverObjListLock; 290 LIST_ENTRY DriverObjListHead; 291 W32HEAP_USER_MAPPING HeapMappings; 292 struct _GDI_POOL* pPoolDcAttr; 293 struct _GDI_POOL* pPoolBrushAttr; 294 struct _GDI_POOL* pPoolRgnAttr; 295 296 #if DBG 297 BYTE DbgChannelLevel[DbgChCount]; 298 #ifndef __cplusplus 299 DWORD DbgHandleCount[TYPE_CTYPES]; 300 #endif // __cplusplus 301 #endif // DBG 302 } PROCESSINFO; 303 304 #if DBG 305 void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments); 306 ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult); 307 #endif 308 309 /* Helper function used by some wine code */ 310 311 __forceinline 312 int 313 lstrlenW( 314 _In_ LPCWSTR lpString) 315 { 316 size_t size = wcslen(lpString); 317 if (size > ULONG_MAX) __fastfail(FAST_FAIL_RANGE_CHECK_FAILURE); 318 return (int)size; 319 } 320 321 #define strlenW lstrlenW 322