Added process ids.
[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
7 #ifndef TLS_MINIMUM_AVAILABLE
8 #define TLS_MINIMUM_AVAILABLE (64)
9 #endif
10 #ifndef MAX_PATH
11 #define MAX_PATH (260)
12 #endif
13
14 typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
15
16 typedef struct _STACK_INFORMATION
17 {
18 PVOID BaseAddress;
19 PVOID UpperAddress;
20 } STACK_INFORMATION, *PSTACK_INFORMATION;
21
22 typedef struct linux_sigcontext {
23 int sc_gs;
24 int sc_fs;
25 int sc_es;
26 int sc_ds;
27 int sc_edi;
28 int sc_esi;
29 int sc_ebp;
30 int sc_esp;
31 int sc_ebx;
32 int sc_edx;
33 int sc_ecx;
34 int sc_eax;
35 int sc_trapno;
36 int sc_err;
37 int sc_eip;
38 int sc_cs;
39 int sc_eflags;
40 int sc_esp_at_signal;
41 int sc_ss;
42 int sc_387;
43 int sc_mask;
44 int sc_cr2;
45 } TRAP_FRAME, *PTRAP_FRAME;
46
47 typedef ULONG THREADINFOCLASS;
48
49 typedef struct _STARTUPINFOW {
50 DWORD cb;
51 WCHAR WindowTitle[MAX_PATH];
52 WCHAR ImageFile[MAX_PATH];
53 WCHAR CommandLine[MAX_PATH];
54 WCHAR DllPath[MAX_PATH];
55 LPWSTR Reserved[MAX_PATH];
56 LPWSTR Desktop[MAX_PATH];
57 LPWSTR Title[MAX_PATH];
58 DWORD dwX;
59 DWORD dwY;
60 DWORD dwXSize;
61 DWORD dwYSize;
62 DWORD dwXCountChars;
63 DWORD dwYCountChars;
64 DWORD dwFillAttribute;
65 DWORD dwFlags;
66 WORD wShowWindow;
67 WORD cbReserved2;
68 unsigned char * lpReserved2;
69 HANDLE hStdInput;
70 HANDLE hStdOutput;
71 HANDLE hStdError;
72 } PROCESSINFOW, *PPROCESSINFOW;
73
74
75
76 typedef struct _LDR {
77 UCHAR Initialized;
78 UCHAR InInitializationOrderModuleList;
79 PVOID InLoadOrderModuleList;
80 PVOID InMemoryOrderModuleList;
81 } LDR, *PLDR;
82
83
84 typedef struct _NT_PEB
85 {
86 UCHAR InheritedAddressSpace;
87 UCHAR ReadImageFileExecOptions;
88 UCHAR BeingDebugged;
89 LONG ImageBaseAddress;
90 LDR Ldr;
91
92 WORD NumberOfProcessors;
93 WORD NtGlobalFlag;
94
95 PPROCESSINFOW StartupInfo;
96 HANDLE ProcessHeap;
97 ATOMTABLE LocalAtomTable;
98 LPCRITICAL_SECTION CriticalSection;
99 DWORD CriticalSectionTimeout;
100 WORD MajorVersion;
101 WORD MinorVersion;
102 WORD BuildNumber;
103 WORD PlatformId;
104 } NT_PEB, *PNT_PEB;
105
106 typedef struct _CLIENT_ID
107 {
108 HANDLE UniqueProcess;
109 HANDLE UniqueThread;
110 } CLIENT_ID, *PCLIENT_ID;
111
112 typedef struct _NT_TIB {
113 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
114 PVOID StackBase;
115 PVOID StackLimit;
116 PVOID SubSystemTib;
117 union {
118 PVOID FiberData;
119 ULONG Version;
120 } Fib;
121 PVOID ArbitraryUserPointer;
122 struct _NT_TIB *Self;
123 } NT_TIB, *PNT_TIB;
124
125 typedef struct _NT_TEB
126 {
127 NT_TIB Tib;
128 CLIENT_ID Cid;
129 HANDLE RPCHandle;
130 PVOID TlsData[TLS_MINIMUM_AVAILABLE];
131 DWORD dwTlsIndex;
132 NT_PEB *Peb;
133 DWORD LastErrorCode;
134 NTSTATUS LastStatusValue;
135 DWORD LockCount;
136 UCHAR HardErrorMode;
137 } NT_TEB;
138
139 typedef struct _KTHREAD
140 {
141 DISPATCHER_HEADER DispatcherHeader;
142 TIME ElapsedTime;
143 TIME KernelTime;
144 TIME UserTime;
145 STACK_INFORMATION StackInformation;
146 PVOID ServiceDescriptorTable; // points to KeServiceDescriptorTable
147 KAFFINITY Affinity;
148 KPRIORITY CurrentPriority;
149 KPRIORITY BasePriority;
150 ULONG Quantum;
151 UCHAR ThreadState; //Thread state is a typeless enum, otherwise it should be const integer
152 ULONG FreezeCount;
153 LONG SuspendCount;
154 PTRAP_FRAME TrapFrame;
155 PVOID *Tls;
156 KWAIT_BLOCK WaitBlock[4];
157 struct _KMUTANT* MutantList;
158 PLIST_ENTRY ApcList;
159 UCHAR KernelApcDisable;
160 KTIMER TimerBlock;
161 KDEVICE_QUEUE DeviceQueue;
162 NT_TEB* Teb;
163
164 /*
165 * PURPOSE: CPU state
166 * NOTE: I have temporarily added this to give somewhere to store
167 * cpu state when the thread isn't running
168 */
169 hal_thread_state Context;
170 LIST_ENTRY Entry;
171 ULONG LastTick;
172 } KTHREAD, *PKTHREAD;
173
174
175 // According to documentation the stack should have a commited [ 1 page ] and
176 // a reserved part [ 1 M ] but can be specified otherwise in the image file.
177
178 typedef struct _INITIAL_TEB {
179 PVOID StackBase;
180 PVOID StackLimit;
181 PVOID StackCommit;
182 PVOID StackCommitMax;
183 PVOID StackReserved;
184 } INITIAL_TEB, *PINITIAL_TEB;
185
186
187
188
189
190
191 // TopLevelIrp can be one of the following values:
192 // FIXME I belong somewhere else
193
194 #define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
195 #define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
196 #define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
197 #define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
198 #define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
199
200 typedef struct _TOP_LEVEL_IRP
201 {
202 PIRP TopLevelIrp;
203 ULONG TopLevelIrpConst;
204 } TOP_LEVEL_IRP;
205
206 typedef struct _ETHREAD {
207 KTHREAD Tcb;
208 TIME CreateTime;
209 TIME ExitTime;
210 NTSTATUS ExitStatus;
211 LIST_ENTRY PostBlockList;
212 LIST_ENTRY TerminationPortList;
213 ULONG ActiveTimerListLock;
214 PVOID ActiveTimerListHead;
215 CLIENT_ID Cid;
216 PLARGE_INTEGER LpcReplySemaphore;
217 PVOID LpcReplyMessage;
218 PLARGE_INTEGER LpcReplyMessageId;
219 PVOID ImpersonationInfo;
220 LIST_ENTRY IrpList; //
221 TOP_LEVEL_IRP TopLevelIrp;
222 ULONG ReadClusterSize;
223 UCHAR ForwardClusterOnly;
224 UCHAR DisablePageFaultClustering;
225 UCHAR DeadThread;
226 UCHAR HasTerminated;
227 ACCESS_MASK GrantedAccess;
228 struct _EPROCESS* ThreadsProcess;
229 PKSTART_ROUTINE StartAddress;
230 LPTHREAD_START_ROUTINE Win32StartAddress; // Should Specify a win32 start func
231 UCHAR LpcExitThreadCalled;
232 UCHAR HardErrorsAreDisabled;
233
234
235 /*
236 * Added by David Welch (welch@cwcom.net)
237 */
238 struct _EPROCESS* OldProcess;
239
240 } ETHREAD, *PETHREAD;
241
242
243 typedef struct _KPROCESS
244 {
245 DISPATCHER_HEADER DispatcherHeader;
246 PVOID PageTableDirectory; // FIXME: I shoud point to a PTD
247 TIME ElapsedTime;
248 TIME KernelTime;
249 TIME UserTime;
250 LIST_ENTRY InMemoryList;
251 LIST_ENTRY SwappedOutList;
252 KSPIN_LOCK SpinLock;
253 KAFFINITY Affinity;
254 ULONG StackCount;
255 KPRIORITY BasePriority;
256 ULONG DefaultThreadQuantum;
257 UCHAR ProcessState;
258 ULONG ThreadSeed;
259 UCHAR DisableBoost;
260
261 /*
262 * Added by David Welch (welch@mcmail.com)
263 */
264 LIST_ENTRY MemoryAreaList;
265 HANDLE_TABLE HandleTable;
266 } KPROCESS, *PKPROCESS;
267
268 typedef struct _EPROCESS
269 {
270 KPROCESS Pcb;
271
272 ULONG UniqueProcessId;
273 ULONG InheritedFromUniqueProcessId;
274 } EPROCESS, *PEPROCESS;
275
276 #define PROCESS_STATE_TERMINATED (1)
277 #define PROCESS_STATE_ACTIVE (2)
278
279 #endif /* __INCLUDE_DDK_PSTYPES_H */