[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 FASTCALL 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
173 typedef struct _W32HEAP_USER_MAPPING
174 {
175 struct _W32HEAP_USER_MAPPING *Next;
176 PVOID KernelMapping;
177 PVOID UserMapping;
178 ULONG_PTR Limit;
179 ULONG Count;
180 } W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING;
181
182
183 /*
184 Information from STARTUPINFOW, psdk/winbase.h.
185 Set from PsGetCurrentProcess()->Peb->ProcessParameters.
186 */
187 typedef struct tagUSERSTARTUPINFO
188 {
189 ULONG cb;
190 DWORD dwX; // STARTF_USEPOSITION StartupInfo->dwX/Y
191 DWORD dwY;
192 DWORD dwXSize; // STARTF_USESIZE StartupInfo->dwX/YSize
193 DWORD dwYSize;
194 DWORD dwFlags; // STARTF_ StartupInfo->dwFlags
195 WORD wShowWindow; // StartupInfo->wShowWindow
196 USHORT cbReserved2;
197 } USERSTARTUPINFO, *PUSERSTARTUPINFO;
198
199 typedef struct _W32PROCESS
200 {
201 PEPROCESS peProcess;
202 DWORD RefCount;
203 ULONG W32PF_flags;
204 PKEVENT InputIdleEvent;
205 DWORD StartCursorHideTime;
206 struct _W32PROCESS * NextStart;
207 PVOID pDCAttrList;
208 PVOID pBrushAttrList;
209 DWORD W32Pid;
210 LONG GDIHandleCount;
211 LONG UserHandleCount;
212 PEX_PUSH_LOCK GDIPushLock; /* Locking Process during access to structure. */
213 RTL_AVL_TABLE GDIEngUserMemAllocTable; /* Process AVL Table. */
214 LIST_ENTRY GDIDcAttrFreeList;
215 LIST_ENTRY GDIBrushAttrFreeList;
216 } W32PROCESS, *PW32PROCESS;
217
218 #define CLIBS 32
219
220 typedef struct _PROCESSINFO
221 {
222 W32PROCESS;
223 PTHREADINFO ptiList;
224 PTHREADINFO ptiMainThread;
225 struct _DESKTOP* rpdeskStartup;
226 PCLS pclsPrivateList;
227 PCLS pclsPublicList;
228 PPROCESSINFO ppiNext;
229 INT cThreads;
230 HDESK hdeskStartup;
231 DWORD dwhmodLibLoadedMask;
232 HANDLE ahmodLibLoaded[CLIBS];
233 struct _WINSTATION_OBJECT *prpwinsta;
234 HWINSTA hwinsta;
235 ACCESS_MASK amwinsta;
236 DWORD dwHotkey;
237 HMONITOR hMonitor;
238 struct _CURICON_OBJECT* pCursorCache;
239 LUID luidSession;
240 USERSTARTUPINFO usi;
241 PVOID pW32Job;
242 DWORD dwLayout;
243 DWORD dwRegisteredClasses;
244 /* ReactOS */
245 LIST_ENTRY MenuListHead;
246 FAST_MUTEX PrivateFontListLock;
247 LIST_ENTRY PrivateFontListHead;
248 FAST_MUTEX DriverObjListLock;
249 LIST_ENTRY DriverObjListHead;
250 struct tagKL* KeyboardLayout; // THREADINFO only
251 W32HEAP_USER_MAPPING HeapMappings;
252 struct _GDI_POOL *pPoolDcAttr;
253 struct _GDI_POOL *pPoolBrushAttr;
254 struct _GDI_POOL *pPoolRgnAttr;
255
256 #if DBG
257 BYTE DbgChannelLevel[DbgChCount];
258 DWORD DbgHandleCount[TYPE_CTYPES];
259 #endif
260 } PROCESSINFO;
261
262 #if DBG
263 void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
264 ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
265 #endif
266