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