Merge the following revisions from kernel-fun branch:
[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 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 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 PMENUSTATE pMenuState;
109 DWORD dwExpWinVer;
110 DWORD dwCompatFlags;
111 DWORD dwCompatFlags2;
112 struct _USER_MESSAGE_QUEUE* pqAttach;
113 PTHREADINFO ptiSibling;
114 ULONG fsHooks;
115 PHOOK sphkCurrent;
116 LPARAM lParamHkCurrent;
117 WPARAM wParamHkCurrent;
118 struct tagSBTRACK* pSBTrack;
119 /* Set if there are new messages specified by WakeMask in any of the queues. */
120 HANDLE hEventQueueClient;
121 /* Handle for the above event (in the context of the process owning the queue). */
122 PKEVENT pEventQueueServer;
123 LIST_ENTRY PtiLink;
124 INT iCursorLevel;
125 POINT ptLast;
126
127 /* Queue of messages posted to the queue. */
128 LIST_ENTRY PostedMessagesListHead; // mlPost
129 WORD fsChangeBitsRemoved;
130 WCHAR wchInjected;
131 UINT cWindows;
132 UINT cVisWindows;
133 LIST_ENTRY aphkStart[NB_HOOKS];
134 CLIENTTHREADINFO cti; // Used only when no Desktop or pcti NULL.
135
136 /* ReactOS */
137
138 /* Thread Queue state tracking */
139 // Send list QS_SENDMESSAGE
140 // Post list QS_POSTMESSAGE|QS_HOTKEY|QS_PAINT|QS_TIMER|QS_KEY
141 // Hard list QS_MOUSE|QS_KEY only
142 // Accounting of queue bit sets, the rest are flags. QS_TIMER QS_PAINT counts are handled in thread information.
143 DWORD nCntsQBits[QSIDCOUNTS]; // QS_KEY QS_MOUSEMOVE QS_MOUSEBUTTON QS_POSTMESSAGE QS_SENDMESSAGE QS_HOTKEY
144
145 /* Messages that are currently dispatched by this message queue, required for cleanup */
146 LIST_ENTRY LocalDispatchingMessagesHead;
147 LIST_ENTRY WindowListHead;
148 LIST_ENTRY W32CallbackListHead;
149 SINGLE_LIST_ENTRY ReferencesList;
150 ULONG cExclusiveLocks;
151 #if DBG
152 USHORT acExclusiveLockCount[GDIObjTypeTotal + 1];
153 #endif
154
155 } THREADINFO;
156
157 #include <poppack.h>
158
159
160 #define IntReferenceThreadInfo(pti) \
161 InterlockedIncrement(&(pti)->RefCount)
162
163 VOID UserDeleteW32Thread(PTHREADINFO);
164
165 #define IntDereferenceThreadInfo(pti) \
166 do { \
167 if (InterlockedDecrement(&(pti)->RefCount) == 0) \
168 { \
169 ASSERT(((pti)->TIF_flags & (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)) == (TIF_INCLEANUP|TIF_DONTATTACHQUEUE)); \
170 UserDeleteW32Thread(pti); \
171 } \
172 } while(0)
173
174
175 #define IntReferenceProcessInfo(ppi) \
176 InterlockedIncrement((volatile LONG*)(&(ppi)->RefCount))
177
178 VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO);
179
180 #define IntDereferenceProcessInfo(ppi) \
181 do { \
182 if (InterlockedDecrement((volatile LONG*)(&(ppi)->RefCount)) == 0) \
183 { \
184 ASSERT(((ppi)->W32PF_flags & W32PF_TERMINATED) != 0); \
185 UserDeleteW32Process(ppi); \
186 } \
187 } while(0)
188
189
190 typedef struct _W32HEAP_USER_MAPPING
191 {
192 struct _W32HEAP_USER_MAPPING* Next;
193 PVOID KernelMapping;
194 PVOID UserMapping;
195 ULONG_PTR Limit;
196 ULONG Count;
197 } W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING;
198
199
200 /*
201 Information from STARTUPINFOW, psdk/winbase.h.
202 Set from PsGetCurrentProcess()->Peb->ProcessParameters.
203 */
204 typedef struct tagUSERSTARTUPINFO
205 {
206 ULONG cb;
207 DWORD dwX; // STARTF_USEPOSITION StartupInfo->dwX/Y
208 DWORD dwY;
209 DWORD dwXSize; // STARTF_USESIZE StartupInfo->dwX/YSize
210 DWORD dwYSize;
211 DWORD dwFlags; // STARTF_ StartupInfo->dwFlags
212 WORD wShowWindow; // StartupInfo->wShowWindow
213 USHORT cbReserved2;
214 } USERSTARTUPINFO, *PUSERSTARTUPINFO;
215
216 typedef struct _W32PROCESS
217 {
218 PEPROCESS peProcess;
219 DWORD RefCount;
220 ULONG W32PF_flags;
221 PKEVENT InputIdleEvent;
222 DWORD StartCursorHideTime;
223 struct _W32PROCESS* NextStart;
224 PVOID pDCAttrList;
225 PVOID pBrushAttrList;
226 DWORD W32Pid;
227 LONG GDIHandleCount;
228 LONG UserHandleCount;
229 PEX_PUSH_LOCK GDIPushLock; /* Locking Process during access to structure. */
230 RTL_AVL_TABLE GDIEngUserMemAllocTable; /* Process AVL Table. */
231 LIST_ENTRY GDIDcAttrFreeList;
232 LIST_ENTRY GDIBrushAttrFreeList;
233 } W32PROCESS, *PW32PROCESS;
234
235 #define CLIBS 32
236
237 typedef struct _PROCESSINFO
238 {
239 W32PROCESS;
240 PTHREADINFO ptiList;
241 PTHREADINFO ptiMainThread;
242 struct _DESKTOP* rpdeskStartup;
243 PCLS pclsPrivateList;
244 PCLS pclsPublicList;
245 PPROCESSINFO ppiNext;
246 INT cThreads;
247 HDESK hdeskStartup;
248 DWORD dwhmodLibLoadedMask;
249 HANDLE ahmodLibLoaded[CLIBS];
250 struct _WINSTATION_OBJECT* prpwinsta;
251 HWINSTA hwinsta;
252 ACCESS_MASK amwinsta;
253 DWORD dwHotkey;
254 HMONITOR hMonitor;
255 UINT iClipSerialNumber;
256 struct _CURICON_OBJECT* pCursorCache;
257 PVOID pClientBase;
258 DWORD dwLpkEntryPoints;
259 PVOID pW32Job;
260 DWORD dwImeCompatFlags;
261 LUID luidSession;
262 USERSTARTUPINFO usi;
263 DWORD dwLayout;
264 DWORD dwRegisteredClasses;
265
266 /* ReactOS */
267 FAST_MUTEX PrivateFontListLock;
268 LIST_ENTRY PrivateFontListHead;
269 FAST_MUTEX DriverObjListLock;
270 LIST_ENTRY DriverObjListHead;
271 struct tagKL* KeyboardLayout; // THREADINFO only
272 W32HEAP_USER_MAPPING HeapMappings;
273 struct _GDI_POOL* pPoolDcAttr;
274 struct _GDI_POOL* pPoolBrushAttr;
275 struct _GDI_POOL* pPoolRgnAttr;
276
277 #if DBG
278 BYTE DbgChannelLevel[DbgChCount];
279 DWORD DbgHandleCount[TYPE_CTYPES];
280 #endif
281 } PROCESSINFO;
282
283 #if DBG
284 void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
285 ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
286 #endif