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 #ifdef __cplusplus 76 typedef struct _THREADINFO : _W32THREAD 77 { 78 #else 79 typedef struct _THREADINFO 80 { 81 W32THREAD; 82 #endif 83 PTL ptl; 84 PPROCESSINFO ppi; 85 struct _USER_MESSAGE_QUEUE* MessageQueue; 86 struct tagKL* KeyboardLayout; 87 struct _CLIENTTHREADINFO * pcti; 88 struct _DESKTOP* rpdesk; 89 struct _DESKTOPINFO * pDeskInfo; 90 struct _CLIENTINFO * pClientInfo; 91 FLONG TIF_flags; 92 PUNICODE_STRING pstrAppName; 93 struct _USER_SENT_MESSAGE *pusmSent; 94 struct _USER_SENT_MESSAGE *pusmCurrent; 95 /* Queue of messages sent to the queue. */ 96 LIST_ENTRY SentMessagesListHead; // psmsReceiveList 97 /* Last message time and ID */ 98 LONG timeLast; 99 ULONG_PTR idLast; 100 /* True if a WM_QUIT message is pending. */ 101 BOOLEAN QuitPosted; 102 /* The quit exit code. */ 103 INT exitCode; 104 HDESK hdesk; 105 UINT cPaintsReady; /* Count of paints pending. */ 106 UINT cTimersReady; /* Count of timers pending. */ 107 struct tagMENUSTATE* pMenuState; 108 DWORD dwExpWinVer; 109 DWORD dwCompatFlags; 110 DWORD dwCompatFlags2; 111 struct _USER_MESSAGE_QUEUE* pqAttach; 112 PTHREADINFO ptiSibling; 113 ULONG fsHooks; 114 struct tagHOOK * sphkCurrent; 115 LPARAM lParamHkCurrent; 116 WPARAM wParamHkCurrent; 117 struct tagSBTRACK* pSBTrack; 118 /* Set if there are new messages specified by WakeMask in any of the queues. */ 119 HANDLE hEventQueueClient; 120 /* Handle for the above event (in the context of the process owning the queue). */ 121 PKEVENT pEventQueueServer; 122 LIST_ENTRY PtiLink; 123 INT iCursorLevel; 124 /* Last message cursor position */ 125 POINT ptLast; 126 /* Input context-related */ 127 struct _WND* spwndDefaultIme; 128 struct tagIMC* spDefaultImc; 129 HKL hklPrev; 130 131 INT cEnterCount; 132 /* Queue of messages posted to the queue. */ 133 LIST_ENTRY PostedMessagesListHead; // mlPost 134 WORD fsChangeBitsRemoved; 135 WCHAR wchInjected; 136 UINT cWindows; 137 UINT cVisWindows; 138 #ifndef __cplusplus /// FIXME! 139 LIST_ENTRY aphkStart[NB_HOOKS]; 140 CLIENTTHREADINFO cti; // Used only when no Desktop or pcti NULL. 141 142 /* ReactOS */ 143 144 /* Thread Queue state tracking */ 145 // Send list QS_SENDMESSAGE 146 // Post list QS_POSTMESSAGE|QS_HOTKEY|QS_PAINT|QS_TIMER|QS_KEY 147 // Hard list QS_MOUSE|QS_KEY only 148 // Accounting of queue bit sets, the rest are flags. QS_TIMER QS_PAINT counts are handled in thread information. 149 DWORD nCntsQBits[QSIDCOUNTS]; // QS_KEY QS_MOUSEMOVE QS_MOUSEBUTTON QS_POSTMESSAGE QS_SENDMESSAGE QS_HOTKEY 150 151 LIST_ENTRY WindowListHead; 152 LIST_ENTRY W32CallbackListHead; 153 SINGLE_LIST_ENTRY ReferencesList; 154 ULONG cExclusiveLocks; 155 #if DBG 156 USHORT acExclusiveLockCount[GDIObjTypeTotal + 1]; 157 #endif 158 #endif // __cplusplus 159 } THREADINFO; 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