[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 PCLS SystemClassList;
53 extern BOOL RegisteredSysClasses;
54
55 typedef struct _WIN32HEAP WIN32HEAP, *PWIN32HEAP;
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 typedef struct _THREADINFO
81 {
82 W32THREAD;
83 PTL ptl;
84 PPROCESSINFO ppi;
85 struct _USER_MESSAGE_QUEUE* MessageQueue;
86 struct tagKL* KeyboardLayout;
87 PCLIENTTHREADINFO pcti;
88 struct _DESKTOP* rpdesk;
89 PDESKTOPINFO pDeskInfo;
90 PCLIENTINFO pClientInfo;
91 FLONG TIF_flags;
92 PUNICODE_STRING pstrAppName;
93 /* Messages that are currently dispatched to other threads */
94 LIST_ENTRY DispatchingMessagesHead; // psmsSent
95 struct _USER_SENT_MESSAGE *pusmCurrent;
96 /* Queue of messages sent to the queue. */
97 LIST_ENTRY SentMessagesListHead; // psmsReceiveList
98 /* Last time PeekMessage() was called. */
99 LONG timeLast;
100 ULONG_PTR idLast;
101 /* True if a WM_QUIT message is pending. */
102 BOOLEAN QuitPosted;
103 /* The quit exit code. */
104 INT exitCode;
105 HDESK hdesk;
106 UINT cPaintsReady; /* Count of paints pending. */
107 UINT cTimersReady; /* Count of timers pending. */
108 DWORD dwExpWinVer;
109 DWORD dwCompatFlags;
110 DWORD dwCompatFlags2;
111 struct _USER_MESSAGE_QUEUE* pqAttach;
112 PTHREADINFO ptiSibling;
113 ULONG fsHooks;
114 PHOOK 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 POINT ptLast;
125
126 /* Queue of messages posted to the queue. */
127 LIST_ENTRY PostedMessagesListHead; // mlPost
128 UINT fsChangeBitsRemoved;
129 UINT cWindows;
130 UINT cVisWindows;
131 LIST_ENTRY aphkStart[NB_HOOKS];
132 CLIENTTHREADINFO cti; // Used only when no Desktop or pcti NULL.
133
134 /* ReactOS */
135
136 /* Thread Queue state tracking */
137 // Send list QS_SENDMESSAGE
138 // Post list QS_POSTMESSAGE|QS_HOTKEY|QS_PAINT|QS_TIMER|QS_KEY
139 // Hard list QS_MOUSE|QS_KEY only
140 // Accounting of queue bit sets, the rest are flags. QS_TIMER QS_PAINT counts are handled in thread information.
141 DWORD nCntsQBits[QSIDCOUNTS]; // QS_KEY QS_MOUSEMOVE QS_MOUSEBUTTON QS_POSTMESSAGE QS_SENDMESSAGE QS_HOTKEY
142
143 /* Messages that are currently dispatched by this message queue, required for cleanup */
144 LIST_ENTRY LocalDispatchingMessagesHead;
145 LIST_ENTRY WindowListHead;
146 LIST_ENTRY W32CallbackListHead;
147 SINGLE_LIST_ENTRY ReferencesList;
148 ULONG cExclusiveLocks;
149 #if DBG
150 USHORT acExclusiveLockCount[GDIObjTypeTotal + 1];
151 #endif
152
153 } THREADINFO;
154
155 #include <poppack.h>
156
157
158 #define IntReferenceThreadInfo(pti) \
159 InterlockedIncrement(&(pti)->RefCount)
160
161 VOID UserDeleteW32Thread(PTHREADINFO);
162
163 #define IntDereferenceThreadInfo(pti) \
164 do { \
165 if(InterlockedDecrement(&(pti)->RefCount) == 0) \
166 { \
167 ASSERT(((pti)->TIF_flags & (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)) == (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)); \
168 UserDeleteW32Thread(pti); \
169 } \
170 } while(0)
171
172 #define IntReferenceProcessInfo(ppi) \
173 InterlockedIncrement((volatile LONG*)(&(ppi)->RefCount))
174
175 VOID UserDeleteW32Process(PPROCESSINFO);
176
177 #define IntDereferenceProcessInfo(ppi) \
178 do { \
179 if(InterlockedDecrement((volatile LONG*)(&(ppi)->RefCount)) == 0) \
180 { \
181 ASSERT(((ppi)->W32PF_flags & W32PF_TERMINATED) != 0); \
182 UserDeleteW32Process(ppi); \
183 } \
184 } while(0)
185
186
187 typedef struct _W32HEAP_USER_MAPPING
188 {
189 struct _W32HEAP_USER_MAPPING *Next;
190 PVOID KernelMapping;
191 PVOID UserMapping;
192 ULONG_PTR Limit;
193 ULONG Count;
194 } W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING;
195
196
197 /*
198 Information from STARTUPINFOW, psdk/winbase.h.
199 Set from PsGetCurrentProcess()->Peb->ProcessParameters.
200 */
201 typedef struct tagUSERSTARTUPINFO
202 {
203 ULONG cb;
204 DWORD dwX; // STARTF_USEPOSITION StartupInfo->dwX/Y
205 DWORD dwY;
206 DWORD dwXSize; // STARTF_USESIZE StartupInfo->dwX/YSize
207 DWORD dwYSize;
208 DWORD dwFlags; // STARTF_ StartupInfo->dwFlags
209 WORD wShowWindow; // StartupInfo->wShowWindow
210 USHORT cbReserved2;
211 } USERSTARTUPINFO, *PUSERSTARTUPINFO;
212
213 typedef struct _W32PROCESS
214 {
215 PEPROCESS peProcess;
216 DWORD RefCount;
217 ULONG W32PF_flags;
218 PKEVENT InputIdleEvent;
219 DWORD StartCursorHideTime;
220 struct _W32PROCESS * NextStart;
221 PVOID pDCAttrList;
222 PVOID pBrushAttrList;
223 DWORD W32Pid;
224 LONG GDIHandleCount;
225 LONG UserHandleCount;
226 PEX_PUSH_LOCK GDIPushLock; /* Locking Process during access to structure. */
227 RTL_AVL_TABLE GDIEngUserMemAllocTable; /* Process AVL Table. */
228 LIST_ENTRY GDIDcAttrFreeList;
229 LIST_ENTRY GDIBrushAttrFreeList;
230 } W32PROCESS, *PW32PROCESS;
231
232 #define CLIBS 32
233
234 typedef struct _PROCESSINFO
235 {
236 W32PROCESS;
237 PTHREADINFO ptiList;
238 PTHREADINFO ptiMainThread;
239 struct _DESKTOP* rpdeskStartup;
240 PCLS pclsPrivateList;
241 PCLS pclsPublicList;
242 PPROCESSINFO ppiNext;
243 INT cThreads;
244 HDESK hdeskStartup;
245 DWORD dwhmodLibLoadedMask;
246 HANDLE ahmodLibLoaded[CLIBS];
247 struct _WINSTATION_OBJECT *prpwinsta;
248 HWINSTA hwinsta;
249 ACCESS_MASK amwinsta;
250 DWORD dwHotkey;
251 HMONITOR hMonitor;
252 struct _CURICON_OBJECT* pCursorCache;
253 LUID luidSession;
254 USERSTARTUPINFO usi;
255 PVOID pW32Job;
256 DWORD dwLayout;
257 DWORD dwRegisteredClasses;
258 /* ReactOS */
259 FAST_MUTEX PrivateFontListLock;
260 LIST_ENTRY PrivateFontListHead;
261 FAST_MUTEX DriverObjListLock;
262 LIST_ENTRY DriverObjListHead;
263 struct tagKL* KeyboardLayout; // THREADINFO only
264 W32HEAP_USER_MAPPING HeapMappings;
265 struct _GDI_POOL *pPoolDcAttr;
266 struct _GDI_POOL *pPoolBrushAttr;
267 struct _GDI_POOL *pPoolRgnAttr;
268
269 #if DBG
270 BYTE DbgChannelLevel[DbgChCount];
271 DWORD DbgHandleCount[TYPE_CTYPES];
272 #endif
273 } PROCESSINFO;
274
275 #if DBG
276 void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
277 ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
278 #endif
279