c2d17e9468765f4d481464a8dabacd183a850c44
[reactos.git] / reactos / ntoskrnl / include / internal / ex.h
1 /*
2 * internal executive prototypes
3 */
4
5 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H
6 #define __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H
7
8 #define NTOS_MODE_KERNEL
9 #include <ntos.h>
10
11 typedef enum
12 {
13 wmCenter = 0,
14 wmTile,
15 wmStretch
16 } WALLPAPER_MODE;
17
18 typedef struct _WINSTATION_OBJECT
19 {
20 PVOID SharedHeap; /* points to kmode memory! */
21
22 CSHORT Type;
23 CSHORT Size;
24 KSPIN_LOCK Lock;
25 UNICODE_STRING Name;
26 LIST_ENTRY DesktopListHead;
27 PRTL_ATOM_TABLE AtomTable;
28 PVOID HandleTable;
29 HANDLE SystemMenuTemplate;
30 PVOID SystemCursor;
31 UINT CaretBlinkRate;
32 HANDLE ShellWindow;
33 HANDLE ShellListView;
34
35 /* Wallpaper */
36 HANDLE hbmWallpaper;
37 ULONG cxWallpaper, cyWallpaper;
38 WALLPAPER_MODE WallpaperMode;
39
40 ULONG Flags;
41 struct _DESKTOP_OBJECT* ActiveDesktop;
42 /* FIXME: Clipboard */
43 LIST_ENTRY HotKeyListHead;
44 FAST_MUTEX HotKeyListLock;
45 } WINSTATION_OBJECT, *PWINSTATION_OBJECT;
46
47 typedef struct _DESKTOP_OBJECT
48 {
49 PVOID DesktopHeap; /* points to kmode memory! */
50
51 CSHORT Type;
52 CSHORT Size;
53 LIST_ENTRY ListEntry;
54 KSPIN_LOCK Lock;
55 UNICODE_STRING Name;
56 /* Pointer to the associated window station. */
57 struct _WINSTATION_OBJECT *WindowStation;
58 /* Pointer to the active queue. */
59 PVOID ActiveMessageQueue;
60 /* Rectangle of the work area */
61 #ifdef __WIN32K__
62 RECT WorkArea;
63 #else
64 LONG WorkArea[4];
65 #endif
66 /* Handle of the desktop window. */
67 HANDLE DesktopWindow;
68 HANDLE PrevActiveWindow;
69 /* Thread blocking input */
70 PVOID BlockInputThread;
71
72 LIST_ENTRY ShellHookWindows;
73 } DESKTOP_OBJECT, *PDESKTOP_OBJECT;
74
75
76 typedef VOID (*PLOOKASIDE_MINMAX_ROUTINE)(
77 POOL_TYPE PoolType,
78 ULONG Size,
79 PUSHORT MinimumDepth,
80 PUSHORT MaximumDepth);
81
82 /* GLOBAL VARIABLES *********************************************************/
83
84 extern TIME_ZONE_INFORMATION ExpTimeZoneInfo;
85 extern LARGE_INTEGER ExpTimeZoneBias;
86 extern ULONG ExpTimeZoneId;
87
88 extern POBJECT_TYPE ExEventPairObjectType;
89 extern POBJECT_TYPE EXPORTED ExMutantObjectType;
90 extern POBJECT_TYPE EXPORTED ExSemaphoreObjectType;
91 extern POBJECT_TYPE EXPORTED ExTimerType;
92
93 /* INITIALIZATION FUNCTIONS *************************************************/
94
95 VOID
96 ExpWin32kInit(VOID);
97
98 VOID
99 ExInit2(VOID);
100 VOID
101 ExInit3(VOID);
102 VOID
103 ExpInitTimeZoneInfo(VOID);
104 VOID
105 ExpInitializeWorkerThreads(VOID);
106 VOID
107 ExpInitLookasideLists(VOID);
108 VOID
109 ExpInitializeCallbacks(VOID);
110 VOID
111 ExpInitUuids(VOID);
112 VOID
113 STDCALL
114 ExpInitializeExecutive(VOID);
115
116 /* HANDLE TABLE FUNCTIONS ***************************************************/
117
118 #define EX_HANDLE_ENTRY_LOCKED (1 << ((sizeof(PVOID) * 8) - 1))
119 #define EX_HANDLE_ENTRY_PROTECTFROMCLOSE (1 << 0)
120 #define EX_HANDLE_ENTRY_INHERITABLE (1 << 1)
121 #define EX_HANDLE_ENTRY_AUDITONCLOSE (1 << 2)
122
123 #define EX_HANDLE_TABLE_CLOSING 0x1
124
125 #define EX_INVALID_HANDLE (~0)
126
127 #define EX_HANDLE_ENTRY_FLAGSMASK (EX_HANDLE_ENTRY_LOCKED | \
128 EX_HANDLE_ENTRY_PROTECTFROMCLOSE | \
129 EX_HANDLE_ENTRY_INHERITABLE | \
130 EX_HANDLE_ENTRY_AUDITONCLOSE)
131
132 typedef VOID (STDCALL PEX_DESTROY_HANDLE_CALLBACK)(PHANDLE_TABLE HandleTable, PVOID Object, ULONG GrantedAccess, PVOID Context);
133 typedef BOOLEAN (STDCALL PEX_DUPLICATE_HANDLE_CALLBACK)(PHANDLE_TABLE HandleTable, PHANDLE_TABLE_ENTRY HandleTableEntry, PVOID Context);
134 typedef BOOLEAN (STDCALL PEX_CHANGE_HANDLE_CALLBACK)(PHANDLE_TABLE HandleTable, PHANDLE_TABLE_ENTRY HandleTableEntry, PVOID Context);
135
136 VOID
137 ExpInitializeHandleTables(VOID);
138 PHANDLE_TABLE
139 ExCreateHandleTable(IN PEPROCESS QuotaProcess OPTIONAL);
140 VOID
141 ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable,
142 IN PEX_DESTROY_HANDLE_CALLBACK DestroyHandleCallback OPTIONAL,
143 IN PVOID Context OPTIONAL);
144 PHANDLE_TABLE
145 ExDupHandleTable(IN PEPROCESS QuotaProcess OPTIONAL,
146 IN PEX_DUPLICATE_HANDLE_CALLBACK DuplicateHandleCallback OPTIONAL,
147 IN PVOID Context OPTIONAL,
148 IN PHANDLE_TABLE SourceHandleTable);
149 BOOLEAN
150 ExLockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
151 IN PHANDLE_TABLE_ENTRY Entry);
152 VOID
153 ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
154 IN PHANDLE_TABLE_ENTRY Entry);
155 LONG
156 ExCreateHandle(IN PHANDLE_TABLE HandleTable,
157 IN PHANDLE_TABLE_ENTRY Entry);
158 BOOLEAN
159 ExDestroyHandle(IN PHANDLE_TABLE HandleTable,
160 IN LONG Handle);
161 VOID
162 ExDestroyHandleByEntry(IN PHANDLE_TABLE HandleTable,
163 IN PHANDLE_TABLE_ENTRY Entry,
164 IN LONG Handle);
165 PHANDLE_TABLE_ENTRY
166 ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable,
167 IN LONG Handle);
168
169 BOOLEAN
170 ExChangeHandle(IN PHANDLE_TABLE HandleTable,
171 IN LONG Handle,
172 IN PEX_CHANGE_HANDLE_CALLBACK ChangeHandleCallback,
173 IN PVOID Context);
174
175 /* OTHER FUNCTIONS **********************************************************/
176
177 LONGLONG
178 FASTCALL
179 ExfpInterlockedExchange64(LONGLONG volatile * Destination,
180 PLONGLONG Exchange);
181
182 NTSTATUS
183 ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation);
184
185 NTSTATUS
186 ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId);
187
188 #define InterlockedDecrementUL(Addend) \
189 (ULONG)InterlockedDecrement((PLONG)(Addend))
190
191 #define InterlockedIncrementUL(Addend) \
192 (ULONG)InterlockedIncrement((PLONG)(Addend))
193
194 #define InterlockedExchangeUL(Target, Value) \
195 (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
196
197 #define InterlockedExchangeAddUL(Addend, Value) \
198 (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
199
200 #define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
201 (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
202
203 #define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
204 (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
205
206 #define ExfpInterlockedExchange64UL(Target, Value) \
207 (ULONGLONG)ExfpInterlockedExchange64((PLONGLONG)(Target), (PLONGLONG)(Value))
208
209 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H */