713c689d75ed3898ca1f94cf6244f6330cc19bb0
[reactos.git] / reactos / include / ddk / pstypes.h
1 #ifndef __INCLUDE_DDK_PSTYPES_H
2 #define __INCLUDE_DDK_PSTYPES_H
3
4 #include <kernel32/atom.h>
5 #include <internal/hal.h>
6 #include <internal/teb.h>
7
8 #ifndef TLS_MINIMUM_AVAILABLE
9 #define TLS_MINIMUM_AVAILABLE (64)
10 #endif
11 #ifndef MAX_PATH
12 #define MAX_PATH (260)
13 #endif
14
15 typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
16
17 typedef struct _STACK_INFORMATION
18 {
19 PVOID BaseAddress;
20 PVOID UpperAddress;
21 } STACK_INFORMATION, *PSTACK_INFORMATION;
22
23 typedef struct linux_sigcontext {
24 int sc_gs;
25 int sc_fs;
26 int sc_es;
27 int sc_ds;
28 int sc_edi;
29 int sc_esi;
30 int sc_ebp;
31 int sc_esp;
32 int sc_ebx;
33 int sc_edx;
34 int sc_ecx;
35 int sc_eax;
36 int sc_trapno;
37 int sc_err;
38 int sc_eip;
39 int sc_cs;
40 int sc_eflags;
41 int sc_esp_at_signal;
42 int sc_ss;
43 int sc_387;
44 int sc_mask;
45 int sc_cr2;
46 } TRAP_FRAME, *PTRAP_FRAME;
47
48 typedef ULONG THREADINFOCLASS;
49
50 struct _KPROCESS;
51
52 typedef struct _KAPC_STATE
53 {
54 LIST_ENTRY ApcListHead[2];
55 struct _KPROCESS* Process;
56 ULONG KernelApcInProgress;
57 ULONG KernelApcPending;
58 USHORT UserApcPending;
59 } KAPC_STATE, *PKAPC_STATE;
60
61 typedef struct _KTHREAD
62 {
63 DISPATCHER_HEADER DispatcherHeader; // For waiting for the thread
64 LIST_ENTRY MutantListHead;
65 PVOID InitialStack;
66 ULONG StackLimit;
67 NT_TEB* Teb;
68 PVOID TlsArray;
69 PVOID KernelStack;
70 UCHAR DebugActive;
71 UCHAR State;
72 UCHAR Alerted[2];
73 UCHAR Iopl;
74 UCHAR NpxState;
75 UCHAR Saturation;
76 KPRIORITY Priority;
77 KAPC_STATE ApcState;
78 ULONG ContextSwitches;
79 ULONG WaitStatus;
80 KIRQL WaitIrql;
81 ULONG WaitMode;
82 UCHAR WaitNext;
83 UCHAR WaitReason;
84 PKWAIT_BLOCK WaitBlockList;
85 LIST_ENTRY WaitListEntry;
86 ULONG WaitTime;
87 KPRIORITY BasePriority;
88 UCHAR DecrementCount;
89 UCHAR PriorityDecrement;
90 UCHAR Quantum;
91 KWAIT_BLOCK WaitBlock[4];
92 PVOID LegoData; // ??
93 LONG KernelApcDisable;
94 KAFFINITY UserAffinity;
95 UCHAR SystemAffinityActive;
96 UCHAR Pad;
97 PKQUEUE Queue;
98 KSPIN_LOCK ApcQueueLock;
99 KTIMER Timer;
100 LIST_ENTRY QueueListEntry;
101 KAFFINITY Affinity;
102 UCHAR Preempted;
103 UCHAR ProcessReadyQueue;
104 UCHAR KernelStackResident;
105 UCHAR NextProcessor;
106 PVOID CallbackStack;
107 BOOL Win32Thread;
108 PVOID TrapFrame;
109 PVOID ApcStatePointer; // Is actually eight bytes
110 UCHAR EnableStackSwap;
111 UCHAR LargeStack;
112 UCHAR ResourceIndex;
113 UCHAR PreviousMode;
114 TIME KernelTime;
115 TIME UserTime;
116 KAPC_STATE SavedApcState;
117 UCHAR Alertable;
118 UCHAR ApcQueueable;
119 ULONG AutoAlignment;
120 PVOID StackBase;
121 KAPC SuspendApc;
122 KSEMAPHORE SuspendSemaphore;
123 LIST_ENTRY ThreadListEntry;
124 CHAR FreezeCount;
125 ULONG SuspendCount;
126 UCHAR IdealProcessor;
127 UCHAR DisableBoost;
128 LIST_ENTRY ProcessThreadListEntry; // Added by Phillip Susi for list of threads in a process
129
130 /* Provisionally added by David Welch */
131 hal_thread_state Context;
132 KDPC TimerDpc; // Added by Phillip Susi for internal KeAddThreadTimeout() impl.
133 } KTHREAD, *PKTHREAD;
134
135 // According to documentation the stack should have a commited [ 1 page ] and
136 // a reserved part [ 1 M ] but can be specified otherwise in the image file.
137
138 typedef struct _INITIAL_TEB
139 {
140 PVOID StackBase;
141 PVOID StackLimit;
142 PVOID StackCommit;
143 PVOID StackCommitMax;
144 PVOID StackReserved;
145 } INITIAL_TEB, *PINITIAL_TEB;
146
147
148
149
150
151
152 // TopLevelIrp can be one of the following values:
153 // FIXME I belong somewhere else
154
155 #define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
156 #define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
157 #define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
158 #define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
159 #define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
160
161 typedef struct _TOP_LEVEL_IRP
162 {
163 PIRP TopLevelIrp;
164 ULONG TopLevelIrpConst;
165 } TOP_LEVEL_IRP;
166
167 typedef struct
168 {
169 PACCESS_TOKEN Token; // 0x0
170 UCHAR Unknown1; // 0x4
171 UCHAR Unknown2; // 0x5
172 UCHAR Pad[2]; // 0x6
173 SECURITY_IMPERSONATION_LEVEL Level; // 0x8
174 } PS_IMPERSONATION_INFO, *PPS_IMPERSONATION_INFO;
175
176 typedef struct _ETHREAD
177 {
178 KTHREAD Tcb;
179 TIME CreateTime;
180 TIME ExitTime;
181 NTSTATUS ExitStatus;
182 LIST_ENTRY PostBlockList;
183 LIST_ENTRY TerminationPortList;
184 KSPIN_LOCK ActiveTimerListLock;
185 PVOID ActiveTimerListHead;
186 CLIENT_ID Cid;
187 PLARGE_INTEGER LpcReplySemaphore;
188 PVOID LpcReplyMessage;
189 PLARGE_INTEGER LpcReplyMessageId;
190 PPS_IMPERSONATION_INFO ImpersonationInfo;
191 LIST_ENTRY IrpList;
192 TOP_LEVEL_IRP TopLevelIrp;
193 ULONG ReadClusterSize;
194 UCHAR ForwardClusterOnly;
195 UCHAR DisablePageFaultClustering;
196 UCHAR DeadThread;
197 UCHAR HasTerminated;
198 ACCESS_MASK GrantedAccess;
199 struct _EPROCESS* ThreadsProcess;
200 PKSTART_ROUTINE StartAddress;
201 LPTHREAD_START_ROUTINE Win32StartAddress;
202 UCHAR LpcExitThreadCalled;
203 UCHAR HardErrorsAreDisabled;
204 UCHAR LpcReceivedMsgIdValid;
205 UCHAR ActiveImpersonationInfo;
206 ULONG PerformanceCountHigh;
207
208 /*
209 * Added by David Welch (welch@cwcom.net)
210 */
211 struct _EPROCESS* OldProcess;
212
213 } ETHREAD, *PETHREAD;
214
215
216 typedef struct _KPROCESS
217 {
218 DISPATCHER_HEADER DispatcherHeader;
219 PVOID PageTableDirectory; // FIXME: I should point to a PTD
220 TIME ElapsedTime;
221 TIME KernelTime;
222 TIME UserTime;
223 LIST_ENTRY InMemoryList;
224 LIST_ENTRY SwappedOutList;
225 KSPIN_LOCK SpinLock;
226 KAFFINITY Affinity;
227 ULONG StackCount;
228 KPRIORITY BasePriority;
229 ULONG DefaultThreadQuantum;
230 UCHAR ProcessState;
231 ULONG ThreadSeed;
232 UCHAR DisableBoost;
233
234 /*
235 * Added by David Welch (welch@mcmail.com)
236 */
237 MADDRESS_SPACE AddressSpace;
238 HANDLE_TABLE HandleTable;
239 LIST_ENTRY ProcessListEntry;
240
241 LIST_ENTRY ThreadListHead; // Added by Phillip Susi for list of threads in process
242
243 } KPROCESS, *PKPROCESS;
244
245 typedef struct _EPROCESS
246 {
247 KPROCESS Pcb;
248 NTSTATUS ExitStatus;
249 KEVENT LockEvent;
250 ULONG LockCount;
251 TIME CreateTime;
252 TIME ExitTime;
253 PVOID LockOwner;
254 ULONG UniqueProcessId;
255 LIST_ENTRY ActiveProcessLinks;
256 ULONG QuotaPeakPoolUsage[2];
257 ULONG QuotaPoolUsage[2];
258 ULONG PagefileUsage;
259 ULONG CommitCharge;
260 ULONG PeakPagefileUsage;
261 ULONG PeakVirtualUsage;
262 LARGE_INTEGER VirtualSize;
263 PVOID Vm; // Actually 48 bytes
264 PVOID LastProtoPteFault;
265 PVOID DebugPort;
266 PVOID ExceptionPort;
267 PVOID ObjectTable;
268 PVOID Token;
269 KMUTEX WorkingSetLock;
270 PVOID WorkingSetPage;
271 UCHAR ProcessOutswapEnabled;
272 UCHAR ProcessOutswapped;
273 UCHAR AddressSpaceInitialized;
274 UCHAR AddressSpaceDeleted;
275 KMUTEX AddressCreationLock;
276 PVOID ForkInProgress;
277 PVOID VmOperation;
278 PKEVENT VmOperationEvent;
279 PVOID PageDirectoryPte;
280 LARGE_INTEGER LastFaultCount;
281 PVOID VadRoot;
282 PVOID VadHint;
283 PVOID CloneRoot;
284 ULONG NumberOfPrivatePages;
285 ULONG NumberOfLockedPages;
286 UCHAR ForkWasSuccessFul;
287 UCHAR ExitProcessCalled;
288 UCHAR CreateProcessReported;
289 HANDLE SectionHandle;
290 PPEB Peb;
291 PVOID SectionBaseAddress;
292 PVOID QuotaBlock;
293 NTSTATUS LastThreadExitStatus;
294 LARGE_INTEGER WorkingSetWatch; //
295 ULONG InheritedFromUniqueProcessId;
296 ACCESS_MASK GrantedAccess;
297 ULONG DefaultHardErrorProcessing;
298 PVOID LdtInformation;
299 ULONG VadFreeHint;
300 PVOID VdmObjects;
301 KMUTANT ProcessMutant;
302 CHAR ImageFileName[16];
303 LARGE_INTEGER VmTrimFaultValue;
304 PVOID Win32Process; // Actually 12 bytes
305 PVOID Win32WindowStation;
306 } EPROCESS, *PEPROCESS;
307
308 #define PROCESS_STATE_TERMINATED (1)
309 #define PROCESS_STATE_ACTIVE (2)
310
311 #define LOW_PRIORITY (0)
312 #define LOW_REALTIME_PRIORITY (16)
313 #define HIGH_PRIORITY (31)
314 #define MAXIMUM_PRIORITY (32)
315
316
317 #endif /* __INCLUDE_DDK_PSTYPES_H */