ReactOS  0.4.11-dev-765-g5e024bf
win32.h
Go to the documentation of this file.
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,
48 
49 extern BOOL ClientPfnInit;
50 extern HINSTANCE hModClient;
51 extern HANDLE hModuleWin; // This Win32k Instance.
52 extern struct _CLS *SystemClassList;
54 
55 #include <pshpack1.h>
56 // FIXME: Move to ntuser.h
57 typedef struct _TL
58 {
59  struct _TL* next;
62 } TL, *PTL;
63 
64 typedef struct _W32THREAD
65 {
68  PTL ptlW32;
77 
78 #ifdef __cplusplus
79 typedef struct _THREADINFO : _W32THREAD
80 {
81 #else
82 typedef struct _THREADINFO
83 {
85 #endif
86  PTL ptl;
91  struct _DESKTOP* rpdesk;
98  /* Queue of messages sent to the queue. */
99  LIST_ENTRY SentMessagesListHead; // psmsReceiveList
100  /* Last time PeekMessage() was called. */
103  /* True if a WM_QUIT message is pending. */
105  /* The quit exit code. */
108  UINT cPaintsReady; /* Count of paints pending. */
109  UINT cTimersReady; /* Count of timers pending. */
121  /* Set if there are new messages specified by WakeMask in any of the queues. */
123  /* Handle for the above event (in the context of the process owning the queue). */
128 
130  /* Queue of messages posted to the queue. */
136 #ifndef __cplusplus
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 
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 
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 
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 {
200 
201 
202 /*
203  Information from STARTUPINFOW, psdk/winbase.h.
204  Set from PsGetCurrentProcess()->Peb->ProcessParameters.
205 */
206 typedef struct tagUSERSTARTUPINFO
207 {
209  DWORD dwX; // STARTF_USEPOSITION StartupInfo->dwX/Y
211  DWORD dwXSize; // STARTF_USESIZE StartupInfo->dwX/YSize
213  DWORD dwFlags; // STARTF_ StartupInfo->dwFlags
214  WORD wShowWindow; // StartupInfo->wShowWindow
217 
218 typedef struct _W32PROCESS
219 {
231  PEX_PUSH_LOCK GDIPushLock; /* Locking Process during access to structure. */
232  RTL_AVL_TABLE GDIEngUserMemAllocTable; /* Process AVL Table. */
236 
237 #define CLIBS 32
238 
239 #ifdef __cplusplus
240 typedef struct _PROCESSINFO : _W32PROCESS
241 {
242 #else
243 typedef struct _PROCESSINFO
244 {
246 #endif
256  HANDLE ahmodLibLoaded[CLIBS];
258  HWINSTA hwinsta;
272 
273  /* ReactOS */
278 
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
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
PTL ptlW32
Definition: win32.h:68
DWORD *typedef PVOID
Definition: winlogon.h:61
PVOID pgdiBrushAttr
Definition: win32.h:70
LPARAM lParamHkCurrent
Definition: win32.h:118
USERSTARTUPINFO usi
Definition: win32.h:269
unsigned short WORD
Definition: ntddk_ex.h:93
struct _GDI_POOL * pPoolBrushAttr
Definition: win32.h:283
struct _USER_SENT_MESSAGE * pusmSent
Definition: win32.h:96
UINT PrivateMemFontHandleCount
Definition: win32.h:277
DWORD dwEngAcquireCount
Definition: win32.h:73
DWORD dwCompatFlags2
Definition: win32.h:113
DWORD dwRegisteredClasses
Definition: win32.h:271
PPROCESSINFO ppiNext
Definition: win32.h:252
Definition: ntbasedef.h:635
ULONG_PTR idLast
Definition: win32.h:102
DWORD StartCursorHideTime
Definition: win32.h:224
__wchar_t WCHAR
Definition: xmlstorage.h:180
LIST_ENTRY WindowListHead
Definition: win32.h:149
PTHREADINFO ptiSibling
Definition: win32.h:115
enum _QS_ROS_TYPES * PQS_ROS_TYPES
PKEVENT InputIdleEvent
Definition: win32.h:223
Definition: win32.h:57
PVOID pClientBase
Definition: win32.h:264
struct _W32PROCESS * PW32PROCESS
DWORD W32Pid
Definition: win32.h:228
FLONG TIF_flags
Definition: win32.h:94
UINT cPaintsReady
Definition: win32.h:108
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_QS_ROS_TYPES
Definition: win32.h:38
BOOLEAN QuitPosted
Definition: win32.h:104
Definition: win32.h:40
LIST_ENTRY PtiLink
Definition: win32.h:125
struct _TL * PTL
struct _W32PROCESS W32PROCESS
struct _W32THREAD * PW32THREAD
PVOID pobj
Definition: win32.h:60
HINSTANCE hModClient
Definition: ntuser.c:25
struct _W32THREAD W32THREAD
struct _WINSTATION_OBJECT * prpwinsta
Definition: win32.h:257
struct _USER_SENT_MESSAGE * pusmCurrent
Definition: win32.h:97
VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO)
Definition: main.c:103
struct _DESKTOP * rpdesk
Definition: win32.h:91
int32_t INT
Definition: typedefs.h:56
DWORD DWORD
Definition: winlogon.h:84
PUNICODE_STRING pstrAppName
Definition: win32.h:95
PVOID pDCAttrList
Definition: win32.h:226
struct _CLS * pclsPrivateList
Definition: win32.h:250
struct _CURICON_OBJECT * pCursorCache
Definition: win32.h:263
DWORD dwLayout
Definition: win32.h:270
UINT_PTR WPARAM
Definition: windef.h:207
UINT cTimersReady
Definition: win32.h:109
PPROCESSINFO ppi
Definition: win32.h:87
uint32_t ULONG_PTR
Definition: typedefs.h:63
typedef HDESK
Definition: winlogon.h:83
WPARAM wParamHkCurrent
Definition: win32.h:119
DWORD dwImeCompatFlags
Definition: win32.h:267
struct _W32PROCESS * NextStart
Definition: win32.h:225
HDESK hdesk
Definition: win32.h:107
ULONG cExclusiveLocks
Definition: win32.h:152
struct _USER_MESSAGE_QUEUE * pqAttach
Definition: win32.h:114
HDESK hdeskStartup
Definition: win32.h:254
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
UINT cWindows
Definition: win32.h:134
struct _GDI_POOL * pPoolDcAttr
Definition: win32.h:282
FAST_MUTEX PrivateFontListLock
Definition: win32.h:274
DWORD dwhmodLibLoadedMask
Definition: win32.h:255
long LONG
Definition: pedump.c:60
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
LONG_PTR LPARAM
Definition: windef.h:208
PVOID pgdiDcattr
Definition: win32.h:69
PTHREADINFO ptiMainThread
Definition: win32.h:248
INT exitCode
Definition: win32.h:106
Definition: input.h:26
LIST_ENTRY W32CallbackListHead
Definition: win32.h:150
Definition: ntuser.h:533
W32HEAP_USER_MAPPING HeapMappings
Definition: win32.h:281
struct tagSBTRACK * pSBTrack
Definition: win32.h:120
LIST_ENTRY GDIDcAttrFreeList
Definition: win32.h:233
RTL_AVL_TABLE GDIEngUserMemAllocTable
Definition: win32.h:232
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
PVOID pBrushAttrList
Definition: win32.h:227
ULONG W32PF_flags
Definition: win32.h:222
unsigned long FLONG
Definition: ntbasedef.h:373
PEPROCESS peProcess
Definition: win32.h:220
DWORD dwLpkEntryPoints
Definition: win32.h:265
INT cThreads
Definition: win32.h:253
DWORD dwCompatFlags
Definition: win32.h:112
DWORD dwExpWinVer
Definition: win32.h:111
struct _TL TL
void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
Definition: misc.c:757
WORD fsChangeBitsRemoved
Definition: win32.h:132
FAST_MUTEX
Definition: extypes.h:17
ULONG_PTR Limit
Definition: win32.h:197
unsigned char BOOLEAN
#define FAST_FAIL_RANGE_CHECK_FAILURE
VOID UserDeleteW32Thread(PTHREADINFO)
Definition: main.c:417
ULONG fsHooks
Definition: win32.h:116
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
struct _CLS * pclsPublicList
Definition: win32.h:251
HMONITOR hMonitor
Definition: win32.h:261
struct _DESKTOP * rpdeskStartup
Definition: win32.h:249
LIST_ENTRY PrivateMemFontListHead
Definition: win32.h:276
PKEVENT pEventQueueServer
Definition: win32.h:124
HANDLE HMONITOR
Definition: axextend.idl:426
DWORD nCntsQBits[QSIDCOUNTS]
Definition: win32.h:147
LUID luidSession
Definition: win32.h:268
#define CLIBS
Definition: win32.h:237
LONG GDIHandleCount
Definition: win32.h:229
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
HANDLE HINSTANCE
Definition: typedefs.h:75
#define QSIDCOUNTS
Definition: win32.h:36
enum _QS_ROS_TYPES QS_ROS_TYPES
LONG timeLast
Definition: win32.h:101
struct _THREADINFO THREADINFO
ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
Definition: misc.c:764
DWORD RefCount
Definition: win32.h:221
UINT iClipSerialNumber
Definition: win32.h:262
Definition: typedefs.h:117
CLIENTTHREADINFO cti
Definition: win32.h:138
struct tagHOOK * sphkCurrent
Definition: win32.h:117
HANDLE hModuleWin
Definition: main.c:16
#define _Pre_notnull_
Definition: no_sal2.h:496
struct tagKL * KeyboardLayout
Definition: win32.h:89
PTL ptl
Definition: win32.h:86
struct _PROCESSINFO PROCESSINFO
PVOID pW32Job
Definition: win32.h:266
PVOID pUMPDHeap
Definition: win32.h:72
unsigned char BYTE
Definition: ntddk_ex.h:96
LIST_ENTRY DriverObjListHead
Definition: win32.h:280
POINT ptLast
Definition: win32.h:127
#define _In_
Definition: no_sal2.h:204
HANDLE hEventQueueClient
Definition: win32.h:122
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
struct _GDI_POOL * pPoolRgnAttr
Definition: win32.h:284
DWORD *typedef HANDLE
Definition: winlogon.h:61
LIST_ENTRY GDIBrushAttrFreeList
Definition: win32.h:234
BOOL RegisteredSysClasses
HWINSTA hwinsta
Definition: win32.h:258
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:131
struct tagMENUSTATE * pMenuState
Definition: win32.h:110
unsigned short USHORT
Definition: pedump.c:61
LONG RefCount
Definition: win32.h:67
WCHAR wchInjected
Definition: win32.h:133
struct tagUSERSTARTUPINFO USERSTARTUPINFO
struct _W32HEAP_USER_MAPPING * PW32HEAP_USER_MAPPING
unsigned int UINT
Definition: ndis.h:50
#define __drv_freesMem(kind)
Definition: driverspecs.h:254
DWORD dwHotkey
Definition: win32.h:260
struct _CLS * SystemClassList
WORD wShowWindow
Definition: win32.h:214
struct _W32HEAP_USER_MAPPING W32HEAP_USER_MAPPING
PVOID pUMPDObj
Definition: win32.h:75
UINT cVisWindows
Definition: win32.h:135
SINGLE_LIST_ENTRY ReferencesList
Definition: win32.h:151
struct _TL * next
Definition: win32.h:59
USHORT cbReserved2
Definition: win32.h:215
unsigned int ULONG
Definition: retypes.h:1
struct tagUSERSTARTUPINFO * PUSERSTARTUPINFO
uint32_t * PULONG_PTR
Definition: typedefs.h:63
PTHREADINFO ptiList
Definition: win32.h:247
INT iCursorLevel
Definition: win32.h:126
FAST_MUTEX DriverObjListLock
Definition: win32.h:279
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92
PEX_PUSH_LOCK GDIPushLock
Definition: win32.h:231
ACCESS_MASK amwinsta
Definition: win32.h:259
BOOL ClientPfnInit
Definition: ntuser.c:26
INT cEnterCount
Definition: win32.h:129
LONG UserHandleCount
Definition: win32.h:230
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
struct _W32HEAP_USER_MAPPING * Next
Definition: win32.h:194
ULONG ACCESS_MASK
Definition: nt_native.h:40
PVOID pSemTable
Definition: win32.h:74
PVOID pUMPDObjs
Definition: win32.h:71
#define ULONG_MAX
Definition: limits.h:44
LIST_ENTRY PrivateFontListHead
Definition: win32.h:275
PVOID pfnFree
Definition: win32.h:61
PETHREAD pEThread
Definition: win32.h:66
__forceinline int lstrlenW(_In_ LPCWSTR lpString)
Definition: win32.h:303