[WIN32K:NTUSER]
[reactos.git] / reactos / win32ss / user / ntuser / win32.h
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 /* Messages that are currently dispatched to other threads */
97 LIST_ENTRY DispatchingMessagesHead; // psmsSent
98 struct _USER_SENT_MESSAGE *pusmCurrent;
99 /* Queue of messages sent to the queue. */
100 LIST_ENTRY SentMessagesListHead; // psmsReceiveList
101 /* Last time PeekMessage() was called. */
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 POINT ptLast;
129
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 /* Messages that are currently dispatched by this message queue, required for cleanup */
150 LIST_ENTRY LocalDispatchingMessagesHead;
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 #include <poppack.h>
162
163
164 #define IntReferenceThreadInfo(pti) \
165 InterlockedIncrement(&(pti)->RefCount)
166
167 VOID UserDeleteW32Thread(PTHREADINFO);
168
169 #define IntDereferenceThreadInfo(pti) \
170 do { \
171 if (InterlockedDecrement(&(pti)->RefCount) == 0) \
172 { \
173 ASSERT(((pti)->TIF_flags & (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)) == (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)); \
174 UserDeleteW32Thread(pti); \
175 } \
176 } while(0)
177
178
179 #define IntReferenceProcessInfo(ppi) \
180 InterlockedIncrement((volatile LONG*)(&(ppi)->RefCount))
181
182 VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO);
183
184 #define IntDereferenceProcessInfo(ppi) \
185 do { \
186 if (InterlockedDecrement((volatile LONG*)(&(ppi)->RefCount)) == 0) \
187 { \
188 ASSERT(((ppi)->W32PF_flags & W32PF_TERMINATED) != 0); \
189 UserDeleteW32Process(ppi); \
190 } \
191 } while(0)
192
193
194 typedef struct _W32HEAP_USER_MAPPING
195 {
196 struct _W32HEAP_USER_MAPPING* Next;
197 PVOID KernelMapping;
198 PVOID UserMapping;
199 ULONG_PTR Limit;
200 ULONG Count;
201 } W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING;
202
203
204 /*
205 Information from STARTUPINFOW, psdk/winbase.h.
206 Set from PsGetCurrentProcess()->Peb->ProcessParameters.
207 */
208 typedef struct tagUSERSTARTUPINFO
209 {
210 ULONG cb;
211 DWORD dwX; // STARTF_USEPOSITION StartupInfo->dwX/Y
212 DWORD dwY;
213 DWORD dwXSize; // STARTF_USESIZE StartupInfo->dwX/YSize
214 DWORD dwYSize;
215 DWORD dwFlags; // STARTF_ StartupInfo->dwFlags
216 WORD wShowWindow; // StartupInfo->wShowWindow
217 USHORT cbReserved2;
218 } USERSTARTUPINFO, *PUSERSTARTUPINFO;
219
220 typedef struct _W32PROCESS
221 {
222 PEPROCESS peProcess;
223 DWORD RefCount;
224 ULONG W32PF_flags;
225 PKEVENT InputIdleEvent;
226 DWORD StartCursorHideTime;
227 struct _W32PROCESS* NextStart;
228 PVOID pDCAttrList;
229 PVOID pBrushAttrList;
230 DWORD W32Pid;
231 LONG GDIHandleCount;
232 LONG UserHandleCount;
233 PEX_PUSH_LOCK GDIPushLock; /* Locking Process during access to structure. */
234 RTL_AVL_TABLE GDIEngUserMemAllocTable; /* Process AVL Table. */
235 LIST_ENTRY GDIDcAttrFreeList;
236 LIST_ENTRY GDIBrushAttrFreeList;
237 } W32PROCESS, *PW32PROCESS;
238
239 #define CLIBS 32
240
241 #ifdef __cplusplus
242 typedef struct _PROCESSINFO : _W32PROCESS
243 {
244 #else
245 typedef struct _PROCESSINFO
246 {
247 W32PROCESS;
248 #endif
249 PTHREADINFO ptiList;
250 PTHREADINFO ptiMainThread;
251 struct _DESKTOP* rpdeskStartup;
252 struct _CLS *pclsPrivateList;
253 struct _CLS *pclsPublicList;
254 PPROCESSINFO ppiNext;
255 INT cThreads;
256 HDESK hdeskStartup;
257 DWORD dwhmodLibLoadedMask;
258 HANDLE ahmodLibLoaded[CLIBS];
259 struct _WINSTATION_OBJECT* prpwinsta;
260 HWINSTA hwinsta;
261 ACCESS_MASK amwinsta;
262 DWORD dwHotkey;
263 HMONITOR hMonitor;
264 UINT iClipSerialNumber;
265 struct _CURICON_OBJECT* pCursorCache;
266 PVOID pClientBase;
267 DWORD dwLpkEntryPoints;
268 PVOID pW32Job;
269 DWORD dwImeCompatFlags;
270 LUID luidSession;
271 USERSTARTUPINFO usi;
272 DWORD dwLayout;
273 DWORD dwRegisteredClasses;
274
275 /* ReactOS */
276 FAST_MUTEX PrivateFontListLock;
277 LIST_ENTRY PrivateFontListHead;
278 FAST_MUTEX DriverObjListLock;
279 LIST_ENTRY DriverObjListHead;
280 struct tagKL* KeyboardLayout; // THREADINFO only
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