[WIN32K]
[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 typedef struct tagMENUSTATE MENUSTATE, *PMENUSTATE;
56
57 #include <pshpack1.h>
58 // FIXME: Move to ntuser.h
59 typedef struct _TL
60 {
61 struct _TL* next;
62 PVOID pobj;
63 PVOID pfnFree;
64 } TL, *PTL;
65
66 typedef struct _W32THREAD
67 {
68 PETHREAD pEThread;
69 LONG RefCount;
70 PTL ptlW32;
71 PVOID pgdiDcattr;
72 PVOID pgdiBrushAttr;
73 PVOID pUMPDObjs;
74 PVOID pUMPDHeap;
75 DWORD dwEngAcquireCount;
76 PVOID pSemTable;
77 PVOID pUMPDObj;
78 } W32THREAD, *PW32THREAD;
79
80 #ifdef __cplusplus
81 typedef struct _THREADINFO : _W32THREAD
82 {
83 #else
84 typedef struct _THREADINFO
85 {
86 W32THREAD;
87 #endif
88 PTL ptl;
89 PPROCESSINFO ppi;
90 struct _USER_MESSAGE_QUEUE* MessageQueue;
91 struct tagKL* KeyboardLayout;
92 struct _CLIENTTHREADINFO * pcti;
93 struct _DESKTOP* rpdesk;
94 struct _DESKTOPINFO * pDeskInfo;
95 struct _CLIENTINFO * pClientInfo;
96 FLONG TIF_flags;
97 PUNICODE_STRING pstrAppName;
98 /* Messages that are currently dispatched to other threads */
99 LIST_ENTRY DispatchingMessagesHead; // psmsSent
100 struct _USER_SENT_MESSAGE *pusmCurrent;
101 /* Queue of messages sent to the queue. */
102 LIST_ENTRY SentMessagesListHead; // psmsReceiveList
103 /* Last time PeekMessage() was called. */
104 LONG timeLast;
105 ULONG_PTR idLast;
106 /* True if a WM_QUIT message is pending. */
107 BOOLEAN QuitPosted;
108 /* The quit exit code. */
109 INT exitCode;
110 HDESK hdesk;
111 UINT cPaintsReady; /* Count of paints pending. */
112 UINT cTimersReady; /* Count of timers pending. */
113 PMENUSTATE pMenuState;
114 DWORD dwExpWinVer;
115 DWORD dwCompatFlags;
116 DWORD dwCompatFlags2;
117 struct _USER_MESSAGE_QUEUE* pqAttach;
118 PTHREADINFO ptiSibling;
119 ULONG fsHooks;
120 struct tagHOOK * sphkCurrent;
121 LPARAM lParamHkCurrent;
122 WPARAM wParamHkCurrent;
123 struct tagSBTRACK* pSBTrack;
124 /* Set if there are new messages specified by WakeMask in any of the queues. */
125 HANDLE hEventQueueClient;
126 /* Handle for the above event (in the context of the process owning the queue). */
127 PKEVENT pEventQueueServer;
128 LIST_ENTRY PtiLink;
129 INT iCursorLevel;
130 POINT ptLast;
131
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 /* Messages that are currently dispatched by this message queue, required for cleanup */
152 LIST_ENTRY LocalDispatchingMessagesHead;
153 LIST_ENTRY WindowListHead;
154 LIST_ENTRY W32CallbackListHead;
155 SINGLE_LIST_ENTRY ReferencesList;
156 ULONG cExclusiveLocks;
157 #if DBG
158 USHORT acExclusiveLockCount[GDIObjTypeTotal + 1];
159 #endif
160 #endif // __cplusplus
161 } THREADINFO;
162
163 #include <poppack.h>
164
165
166 #define IntReferenceThreadInfo(pti) \
167 InterlockedIncrement(&(pti)->RefCount)
168
169 VOID UserDeleteW32Thread(PTHREADINFO);
170
171 #define IntDereferenceThreadInfo(pti) \
172 do { \
173 if (InterlockedDecrement(&(pti)->RefCount) == 0) \
174 { \
175 ASSERT(((pti)->TIF_flags & (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)) == (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)); \
176 UserDeleteW32Thread(pti); \
177 } \
178 } while(0)
179
180
181 #define IntReferenceProcessInfo(ppi) \
182 InterlockedIncrement((volatile LONG*)(&(ppi)->RefCount))
183
184 VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO);
185
186 #define IntDereferenceProcessInfo(ppi) \
187 do { \
188 if (InterlockedDecrement((volatile LONG*)(&(ppi)->RefCount)) == 0) \
189 { \
190 ASSERT(((ppi)->W32PF_flags & W32PF_TERMINATED) != 0); \
191 UserDeleteW32Process(ppi); \
192 } \
193 } while(0)
194
195
196 typedef struct _W32HEAP_USER_MAPPING
197 {
198 struct _W32HEAP_USER_MAPPING* Next;
199 PVOID KernelMapping;
200 PVOID UserMapping;
201 ULONG_PTR Limit;
202 ULONG Count;
203 } W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING;
204
205
206 /*
207 Information from STARTUPINFOW, psdk/winbase.h.
208 Set from PsGetCurrentProcess()->Peb->ProcessParameters.
209 */
210 typedef struct tagUSERSTARTUPINFO
211 {
212 ULONG cb;
213 DWORD dwX; // STARTF_USEPOSITION StartupInfo->dwX/Y
214 DWORD dwY;
215 DWORD dwXSize; // STARTF_USESIZE StartupInfo->dwX/YSize
216 DWORD dwYSize;
217 DWORD dwFlags; // STARTF_ StartupInfo->dwFlags
218 WORD wShowWindow; // StartupInfo->wShowWindow
219 USHORT cbReserved2;
220 } USERSTARTUPINFO, *PUSERSTARTUPINFO;
221
222 typedef struct _W32PROCESS
223 {
224 PEPROCESS peProcess;
225 DWORD RefCount;
226 ULONG W32PF_flags;
227 PKEVENT InputIdleEvent;
228 DWORD StartCursorHideTime;
229 struct _W32PROCESS* NextStart;
230 PVOID pDCAttrList;
231 PVOID pBrushAttrList;
232 DWORD W32Pid;
233 LONG GDIHandleCount;
234 LONG UserHandleCount;
235 PEX_PUSH_LOCK GDIPushLock; /* Locking Process during access to structure. */
236 RTL_AVL_TABLE GDIEngUserMemAllocTable; /* Process AVL Table. */
237 LIST_ENTRY GDIDcAttrFreeList;
238 LIST_ENTRY GDIBrushAttrFreeList;
239 } W32PROCESS, *PW32PROCESS;
240
241 #define CLIBS 32
242
243 #ifdef __cplusplus
244 typedef struct _PROCESSINFO : _W32PROCESS
245 {
246 #else
247 typedef struct _PROCESSINFO
248 {
249 W32PROCESS;
250 #endif
251 PTHREADINFO ptiList;
252 PTHREADINFO ptiMainThread;
253 struct _DESKTOP* rpdeskStartup;
254 struct _CLS *pclsPrivateList;
255 struct _CLS *pclsPublicList;
256 PPROCESSINFO ppiNext;
257 INT cThreads;
258 HDESK hdeskStartup;
259 DWORD dwhmodLibLoadedMask;
260 HANDLE ahmodLibLoaded[CLIBS];
261 struct _WINSTATION_OBJECT* prpwinsta;
262 HWINSTA hwinsta;
263 ACCESS_MASK amwinsta;
264 DWORD dwHotkey;
265 HMONITOR hMonitor;
266 UINT iClipSerialNumber;
267 struct _CURICON_OBJECT* pCursorCache;
268 PVOID pClientBase;
269 DWORD dwLpkEntryPoints;
270 PVOID pW32Job;
271 DWORD dwImeCompatFlags;
272 LUID luidSession;
273 USERSTARTUPINFO usi;
274 DWORD dwLayout;
275 DWORD dwRegisteredClasses;
276
277 /* ReactOS */
278 FAST_MUTEX PrivateFontListLock;
279 LIST_ENTRY PrivateFontListHead;
280 FAST_MUTEX DriverObjListLock;
281 LIST_ENTRY DriverObjListHead;
282 struct tagKL* KeyboardLayout; // THREADINFO only
283 W32HEAP_USER_MAPPING HeapMappings;
284 struct _GDI_POOL* pPoolDcAttr;
285 struct _GDI_POOL* pPoolBrushAttr;
286 struct _GDI_POOL* pPoolRgnAttr;
287
288 #if DBG
289 BYTE DbgChannelLevel[DbgChCount];
290 #ifndef __cplusplus
291 DWORD DbgHandleCount[TYPE_CTYPES];
292 #endif // __cplusplus
293 #endif // DBG
294 } PROCESSINFO;
295
296 #if DBG
297 void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
298 ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
299 #endif