- Fix MmCreateKernelStack to actually take into account the GuiStack parameter.
[reactos.git] / reactos / w32api / include / ddk / winddk.h
1 /*
2 * winddk.h
3 *
4 * Windows Device Driver Kit
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23 #ifndef __WINDDK_H
24 #define __WINDDK_H
25
26 #if __GNUC__ >= 3
27 #pragma GCC system_header
28 #endif
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /*
35 ** Definitions specific to this Device Driver Kit
36 */
37 #define DDKAPI __stdcall
38 #define DDKFASTAPI __fastcall
39 #define FASTCALL __fastcall
40 #define DDKCDECLAPI __cdecl
41
42 /* FIXME: REMOVE THIS UNCOMPATIBLE CRUFT!!! */
43 #if defined(_NTOSKRNL_)
44 #ifndef NTOSAPI
45 #define NTOSAPI DECL_EXPORT
46 #endif
47 #define DECLARE_INTERNAL_OBJECT(x) typedef struct _##x; typedef struct _##x *P##x;
48 #define DECLARE_INTERNAL_OBJECT2(x,y) typedef struct _##x; typedef struct _##x *P##y;
49 #else
50 #ifndef NTOSAPI
51 #define NTOSAPI DECL_IMPORT
52 #endif
53 #define DECLARE_INTERNAL_OBJECT(x) struct _##x; typedef struct _##x *P##x;
54 #define DECLARE_INTERNAL_OBJECT2(x,y) struct _##x; typedef struct _##x *P##y;
55 #endif
56
57 #if defined(_NTHAL_)
58 #ifndef NTHALAPI
59 #define NTHALAPI DECL_EXPORT
60 #endif
61 #else
62 #ifndef NTHALAPI
63 #define NTHALAPI DECL_IMPORT
64 #endif
65 #endif
66
67 /* Pseudo modifiers for parameters */
68 #define IN
69 #define OUT
70 #define OPTIONAL
71 #define UNALLIGNED
72
73 #define CONST const
74 #define VOLATILE volatile
75
76 #define RESTRICTED_POINTER
77 #define POINTER_ALIGNMENT
78 #define DECLSPEC_ADDRSAFE
79
80 #ifdef NONAMELESSUNION
81 # define _DDK_DUMMYUNION_MEMBER(name) DUMMYUNIONNAME.name
82 # define _DDK_DUMMYUNION_N_MEMBER(n, name) DUMMYUNIONNAME##n.name
83 #else
84 # define _DDK_DUMMYUNION_MEMBER(name) name
85 # define _DDK_DUMMYUNION_N_MEMBER(n, name) name
86 #endif
87
88 #if !defined(_NTSYSTEM_)
89 #define NTSYSAPI DECLSPEC_IMPORT
90 #define NTSYSCALLAPI DECLSPEC_IMPORT
91 #else
92 #define NTSYSAPI
93 #if defined(_NTDLLBUILD_)
94 #define NTSYSCALLAPI
95 #else
96 #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
97 #endif
98 #endif
99
100 /*
101 * Alignment Macros
102 */
103 #define ALIGN_DOWN(s, t) \
104 ((ULONG)(s) & ~(sizeof(t) - 1))
105
106 #define ALIGN_UP(s, t) \
107 (ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
108
109 #define ALIGN_DOWN_POINTER(p, t) \
110 ((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
111
112 #define ALIGN_UP_POINTER(p, t) \
113 (ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
114
115 /*
116 ** Forward declarations
117 */
118
119 struct _IRP;
120 struct _MDL;
121 struct _KAPC;
122 struct _KDPC;
123 struct _KPCR;
124 struct _KPRCB;
125 struct _KTSS;
126 struct _FILE_OBJECT;
127 struct _DMA_ADAPTER;
128 struct _DEVICE_OBJECT;
129 struct _DRIVER_OBJECT;
130 struct _IO_STATUS_BLOCK;
131 struct _DEVICE_DESCRIPTION;
132 struct _SCATTER_GATHER_LIST;
133 struct _DRIVE_LAYOUT_INFORMATION;
134 struct _DRIVE_LAYOUT_INFORMATION_EX;
135
136 typedef PVOID PSECURITY_DESCRIPTOR;
137 typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION;
138 typedef PVOID PSID;
139
140 DECLARE_INTERNAL_OBJECT(ADAPTER_OBJECT)
141 DECLARE_INTERNAL_OBJECT(DMA_ADAPTER)
142 DECLARE_INTERNAL_OBJECT(IO_STATUS_BLOCK)
143
144 #if 1
145 /* FIXME: Unknown definitions */
146 struct _SET_PARTITION_INFORMATION_EX;
147 typedef ULONG WAIT_TYPE;
148 #define WaitAll 0
149 #define WaitAny 1
150 typedef HANDLE TRACEHANDLE;
151 typedef PVOID PWMILIB_CONTEXT;
152 typedef PVOID PSYSCTL_IRP_DISPOSITION;
153 typedef ULONG LOGICAL;
154 #endif
155
156 /*
157 ** Routines specific to this DDK
158 */
159 #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )
160
161 /*
162 ** Simple structures
163 */
164
165 typedef LONG KPRIORITY;
166 typedef UCHAR KIRQL, *PKIRQL;
167 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
168 typedef UCHAR KPROCESSOR_MODE;
169
170 typedef enum _MODE {
171 KernelMode,
172 UserMode,
173 MaximumMode
174 } MODE;
175
176 typedef struct _QUAD
177 {
178 union
179 {
180 LONGLONG UseThisFieldToCopy;
181 float DoNotUseThisField;
182 };
183 } QUAD, *PQUAD;
184
185 /* Structures not exposed to drivers */
186 typedef struct _IO_TIMER *PIO_TIMER;
187 typedef struct _KPROCESS *PKPROCESS;
188 typedef struct _EPROCESS *PEPROCESS;
189 typedef struct _ETHREAD *PETHREAD;
190 typedef struct _KINTERRUPT *PKINTERRUPT;
191 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
192 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
193 typedef struct _COMPRESSED_DATA_INFO *PCOMPRESSED_DATA_INFO;
194 typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE;
195 typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE;
196 typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
197 typedef struct _BUS_HANDLER *PBUS_HANDLER;
198 typedef struct _PEB *PPEB;
199 typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
200
201 /* Constants */
202 #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 )
203 #define ZwCurrentProcess() NtCurrentProcess()
204 #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )
205 #define ZwCurrentThread() NtCurrentThread()
206
207 #define KERNEL_STACK_SIZE 12288
208 #define KERNEL_LARGE_STACK_SIZE 61440
209
210
211 #define DPFLTR_ERROR_LEVEL 0
212 #define DPFLTR_WARNING_LEVEL 1
213 #define DPFLTR_TRACE_LEVEL 2
214 #define DPFLTR_INFO_LEVEL 3
215 #define DPFLTR_MASK 0x80000000
216
217 #define MAXIMUM_PROCESSORS 32
218
219 #define MAXIMUM_WAIT_OBJECTS 64
220
221 #define EX_RUNDOWN_ACTIVE 0x1
222 #define EX_RUNDOWN_COUNT_SHIFT 0x1
223 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT)
224
225 #define METHOD_BUFFERED 0
226 #define METHOD_IN_DIRECT 1
227 #define METHOD_OUT_DIRECT 2
228 #define METHOD_NEITHER 3
229
230 #define LOW_PRIORITY 0
231 #define LOW_REALTIME_PRIORITY 16
232 #define HIGH_PRIORITY 31
233 #define MAXIMUM_PRIORITY 32
234
235 #define FILE_SUPERSEDED 0x00000000
236 #define FILE_OPENED 0x00000001
237 #define FILE_CREATED 0x00000002
238 #define FILE_OVERWRITTEN 0x00000003
239 #define FILE_EXISTS 0x00000004
240 #define FILE_DOES_NOT_EXIST 0x00000005
241
242 #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
243 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
244
245 /* also in winnt.h */
246 #define FILE_LIST_DIRECTORY 0x00000001
247 #define FILE_READ_DATA 0x00000001
248 #define FILE_ADD_FILE 0x00000002
249 #define FILE_WRITE_DATA 0x00000002
250 #define FILE_ADD_SUBDIRECTORY 0x00000004
251 #define FILE_APPEND_DATA 0x00000004
252 #define FILE_CREATE_PIPE_INSTANCE 0x00000004
253 #define FILE_READ_EA 0x00000008
254 #define FILE_WRITE_EA 0x00000010
255 #define FILE_EXECUTE 0x00000020
256 #define FILE_TRAVERSE 0x00000020
257 #define FILE_DELETE_CHILD 0x00000040
258 #define FILE_READ_ATTRIBUTES 0x00000080
259 #define FILE_WRITE_ATTRIBUTES 0x00000100
260
261 #define FILE_SHARE_READ 0x00000001
262 #define FILE_SHARE_WRITE 0x00000002
263 #define FILE_SHARE_DELETE 0x00000004
264 #define FILE_SHARE_VALID_FLAGS 0x00000007
265
266 #define FILE_ATTRIBUTE_READONLY 0x00000001
267 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
268 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
269 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
270 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
271 #define FILE_ATTRIBUTE_DEVICE 0x00000040
272 #define FILE_ATTRIBUTE_NORMAL 0x00000080
273 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
274 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
275 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
276 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
277 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
278 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
279 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
280
281 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
282 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
283
284 #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
285 #define FILE_STRUCTURED_STORAGE 0x00000441
286
287 #define FILE_VALID_OPTION_FLAGS 0x00ffffff
288 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
289 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
290 #define FILE_VALID_SET_FLAGS 0x00000036
291
292 #define FILE_SUPERSEDE 0x00000000
293 #define FILE_OPEN 0x00000001
294 #define FILE_CREATE 0x00000002
295 #define FILE_OPEN_IF 0x00000003
296 #define FILE_OVERWRITE 0x00000004
297 #define FILE_OVERWRITE_IF 0x00000005
298 #define FILE_MAXIMUM_DISPOSITION 0x00000005
299
300 #define FILE_DIRECTORY_FILE 0x00000001
301 #define FILE_WRITE_THROUGH 0x00000002
302 #define FILE_SEQUENTIAL_ONLY 0x00000004
303 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
304 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
305 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
306 #define FILE_NON_DIRECTORY_FILE 0x00000040
307 #define FILE_CREATE_TREE_CONNECTION 0x00000080
308 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
309 #define FILE_NO_EA_KNOWLEDGE 0x00000200
310 #define FILE_OPEN_FOR_RECOVERY 0x00000400
311 #define FILE_RANDOM_ACCESS 0x00000800
312 #define FILE_DELETE_ON_CLOSE 0x00001000
313 #define FILE_OPEN_BY_FILE_ID 0x00002000
314 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
315 #define FILE_NO_COMPRESSION 0x00008000
316 #define FILE_RESERVE_OPFILTER 0x00100000
317 #define FILE_OPEN_REPARSE_POINT 0x00200000
318 #define FILE_OPEN_NO_RECALL 0x00400000
319 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
320
321 #define FILE_ANY_ACCESS 0x00000000
322 #define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS
323 #define FILE_READ_ACCESS 0x00000001
324 #define FILE_WRITE_ACCESS 0x00000002
325
326 #define FILE_ALL_ACCESS \
327 (STANDARD_RIGHTS_REQUIRED | \
328 SYNCHRONIZE | \
329 0x1FF)
330
331 #define FILE_GENERIC_EXECUTE \
332 (STANDARD_RIGHTS_EXECUTE | \
333 FILE_READ_ATTRIBUTES | \
334 FILE_EXECUTE | \
335 SYNCHRONIZE)
336
337 #define FILE_GENERIC_READ \
338 (STANDARD_RIGHTS_READ | \
339 FILE_READ_DATA | \
340 FILE_READ_ATTRIBUTES | \
341 FILE_READ_EA | \
342 SYNCHRONIZE)
343
344 #define FILE_GENERIC_WRITE \
345 (STANDARD_RIGHTS_WRITE | \
346 FILE_WRITE_DATA | \
347 FILE_WRITE_ATTRIBUTES | \
348 FILE_WRITE_EA | \
349 FILE_APPEND_DATA | \
350 SYNCHRONIZE)
351 /* end winnt.h */
352
353 #define OBJECT_TYPE_CREATE (0x0001)
354 #define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
355
356 #define DIRECTORY_QUERY (0x0001)
357 #define DIRECTORY_TRAVERSE (0x0002)
358 #define DIRECTORY_CREATE_OBJECT (0x0004)
359 #define DIRECTORY_CREATE_SUBDIRECTORY (0x0008)
360 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
361
362 #define EVENT_QUERY_STATE (0x0001)
363 #define EVENT_MODIFY_STATE (0x0002)
364 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
365
366 #define SEMAPHORE_QUERY_STATE (0x0001)
367 #define SEMAPHORE_MODIFY_STATE (0x0002)
368 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
369
370 #define THREAD_ALERT (0x0004)
371
372 #define FM_LOCK_BIT (0x1)
373 #define FM_LOCK_BIT_V (0x0)
374 #define FM_LOCK_WAITER_WOKEN (0x2)
375 #define FM_LOCK_WAITER_INC (0x4)
376
377 /* Exported object types */
378 extern NTOSAPI POBJECT_TYPE ExDesktopObjectType;
379 extern NTOSAPI POBJECT_TYPE ExEventObjectType;
380 extern NTOSAPI POBJECT_TYPE ExSemaphoreObjectType;
381 extern NTOSAPI POBJECT_TYPE ExWindowStationObjectType;
382 extern NTOSAPI ULONG IoDeviceHandlerObjectSize;
383 extern NTOSAPI POBJECT_TYPE IoDeviceHandlerObjectType;
384 extern NTOSAPI POBJECT_TYPE IoDeviceObjectType;
385 extern NTOSAPI POBJECT_TYPE IoDriverObjectType;
386 extern NTOSAPI POBJECT_TYPE IoFileObjectType;
387 extern NTOSAPI POBJECT_TYPE PsThreadType;
388 extern NTOSAPI POBJECT_TYPE LpcPortObjectType;
389 extern NTOSAPI POBJECT_TYPE MmSectionObjectType;
390 extern NTOSAPI POBJECT_TYPE SeTokenObjectType;
391
392 extern NTOSAPI CCHAR KeNumberProcessors;
393
394 #define PROCESSOR_FEATURE_MAX 64
395 #define MAX_WOW64_SHARED_ENTRIES 16
396
397 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
398 {
399 StandardDesign,
400 NEC98x86,
401 EndAlternatives
402 } ALTERNATIVE_ARCHITECTURE_TYPE;
403
404 typedef struct _KSYSTEM_TIME
405 {
406 ULONG LowPart;
407 LONG High1Time;
408 LONG High2Time;
409 } KSYSTEM_TIME, *PKSYSTEM_TIME;
410
411 typedef struct _KUSER_SHARED_DATA
412 {
413 ULONG TickCountLowDeprecated;
414 ULONG TickCountMultiplier;
415 volatile KSYSTEM_TIME InterruptTime;
416 volatile KSYSTEM_TIME SystemTime;
417 volatile KSYSTEM_TIME TimeZoneBias;
418 USHORT ImageNumberLow;
419 USHORT ImageNumberHigh;
420 WCHAR NtSystemRoot[260];
421 ULONG MaxStackTraceDepth;
422 ULONG CryptoExponent;
423 ULONG TimeZoneId;
424 ULONG LargePageMinimum;
425 ULONG Reserved2[7];
426 NT_PRODUCT_TYPE NtProductType;
427 BOOLEAN ProductTypeIsValid;
428 ULONG NtMajorVersion;
429 ULONG NtMinorVersion;
430 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
431 ULONG Reserved1;
432 ULONG Reserved3;
433 volatile ULONG TimeSlip;
434 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
435 LARGE_INTEGER SystemExpirationDate;
436 ULONG SuiteMask;
437 BOOLEAN KdDebuggerEnabled;
438 volatile ULONG ActiveConsoleId;
439 volatile ULONG DismountCount;
440 ULONG ComPlusPackage;
441 ULONG LastSystemRITEventTickCount;
442 ULONG NumberOfPhysicalPages;
443 BOOLEAN SafeBootMode;
444 ULONG TraceLogging;
445 ULONG Fill0;
446 ULONGLONG TestRetInstruction;
447 ULONG SystemCall;
448 ULONG SystemCallReturn;
449 ULONGLONG SystemCallPad[3];
450 union {
451 volatile KSYSTEM_TIME TickCount;
452 volatile ULONG64 TickCountQuad;
453 };
454 ULONG Cookie;
455 LONGLONG ConsoleSessionForegroundProcessId;
456 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
457 ULONG UserModeGlobalLogging;
458 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
459
460 /*
461 ** IRP function codes
462 */
463
464 #define IRP_MJ_CREATE 0x00
465 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
466 #define IRP_MJ_CLOSE 0x02
467 #define IRP_MJ_READ 0x03
468 #define IRP_MJ_WRITE 0x04
469 #define IRP_MJ_QUERY_INFORMATION 0x05
470 #define IRP_MJ_SET_INFORMATION 0x06
471 #define IRP_MJ_QUERY_EA 0x07
472 #define IRP_MJ_SET_EA 0x08
473 #define IRP_MJ_FLUSH_BUFFERS 0x09
474 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
475 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
476 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
477 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
478 #define IRP_MJ_DEVICE_CONTROL 0x0e
479 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
480 #define IRP_MJ_SCSI 0x0f
481 #define IRP_MJ_SHUTDOWN 0x10
482 #define IRP_MJ_LOCK_CONTROL 0x11
483 #define IRP_MJ_CLEANUP 0x12
484 #define IRP_MJ_CREATE_MAILSLOT 0x13
485 #define IRP_MJ_QUERY_SECURITY 0x14
486 #define IRP_MJ_SET_SECURITY 0x15
487 #define IRP_MJ_POWER 0x16
488 #define IRP_MJ_SYSTEM_CONTROL 0x17
489 #define IRP_MJ_DEVICE_CHANGE 0x18
490 #define IRP_MJ_QUERY_QUOTA 0x19
491 #define IRP_MJ_SET_QUOTA 0x1a
492 #define IRP_MJ_PNP 0x1b
493 #define IRP_MJ_PNP_POWER 0x1b
494 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
495
496 #define IRP_MN_QUERY_DIRECTORY 0x01
497 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
498
499 #define IRP_MN_USER_FS_REQUEST 0x00
500 #define IRP_MN_MOUNT_VOLUME 0x01
501 #define IRP_MN_VERIFY_VOLUME 0x02
502 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
503 #define IRP_MN_TRACK_LINK 0x04
504 #define IRP_MN_KERNEL_CALL 0x04
505
506 #define IRP_MN_LOCK 0x01
507 #define IRP_MN_UNLOCK_SINGLE 0x02
508 #define IRP_MN_UNLOCK_ALL 0x03
509 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
510
511 #define IRP_MN_NORMAL 0x00
512 #define IRP_MN_DPC 0x01
513 #define IRP_MN_MDL 0x02
514 #define IRP_MN_COMPLETE 0x04
515 #define IRP_MN_COMPRESSED 0x08
516
517 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
518 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
519 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
520
521 #define IRP_MN_SCSI_CLASS 0x01
522
523 #define IRP_MN_START_DEVICE 0x00
524 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
525 #define IRP_MN_REMOVE_DEVICE 0x02
526 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
527 #define IRP_MN_STOP_DEVICE 0x04
528 #define IRP_MN_QUERY_STOP_DEVICE 0x05
529 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
530
531 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
532 #define IRP_MN_QUERY_INTERFACE 0x08
533 #define IRP_MN_QUERY_CAPABILITIES 0x09
534 #define IRP_MN_QUERY_RESOURCES 0x0A
535 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
536 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
537 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
538
539 #define IRP_MN_READ_CONFIG 0x0F
540 #define IRP_MN_WRITE_CONFIG 0x10
541 #define IRP_MN_EJECT 0x11
542 #define IRP_MN_SET_LOCK 0x12
543 #define IRP_MN_QUERY_ID 0x13
544 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
545 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
546 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
547 #define IRP_MN_SURPRISE_REMOVAL 0x17
548 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
549
550 #define IRP_MN_WAIT_WAKE 0x00
551 #define IRP_MN_POWER_SEQUENCE 0x01
552 #define IRP_MN_SET_POWER 0x02
553 #define IRP_MN_QUERY_POWER 0x03
554
555 #define IRP_MN_QUERY_ALL_DATA 0x00
556 #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
557 #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
558 #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
559 #define IRP_MN_ENABLE_EVENTS 0x04
560 #define IRP_MN_DISABLE_EVENTS 0x05
561 #define IRP_MN_ENABLE_COLLECTION 0x06
562 #define IRP_MN_DISABLE_COLLECTION 0x07
563 #define IRP_MN_REGINFO 0x08
564 #define IRP_MN_EXECUTE_METHOD 0x09
565
566 #define IRP_MN_REGINFO_EX 0x0b
567
568 typedef enum _IO_ALLOCATION_ACTION {
569 KeepObject = 1,
570 DeallocateObject,
571 DeallocateObjectKeepRegisters
572 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
573
574 typedef IO_ALLOCATION_ACTION
575 (DDKAPI *PDRIVER_CONTROL)(
576 IN struct _DEVICE_OBJECT *DeviceObject,
577 IN struct _IRP *Irp,
578 IN PVOID MapRegisterBase,
579 IN PVOID Context);
580
581 typedef EXCEPTION_DISPOSITION
582 (DDKAPI *PEXCEPTION_ROUTINE)(
583 IN struct _EXCEPTION_RECORD *ExceptionRecord,
584 IN PVOID EstablisherFrame,
585 IN OUT struct _CONTEXT *ContextRecord,
586 IN OUT PVOID DispatcherContext);
587
588 typedef VOID
589 (DDKAPI *PDRIVER_LIST_CONTROL)(
590 IN struct _DEVICE_OBJECT *DeviceObject,
591 IN struct _IRP *Irp,
592 IN struct _SCATTER_GATHER_LIST *ScatterGather,
593 IN PVOID Context);
594
595 typedef NTSTATUS
596 (DDKAPI *PDRIVER_ADD_DEVICE)(
597 IN struct _DRIVER_OBJECT *DriverObject,
598 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
599
600 typedef NTSTATUS
601 (DDKAPI *PIO_COMPLETION_ROUTINE)(
602 IN struct _DEVICE_OBJECT *DeviceObject,
603 IN struct _IRP *Irp,
604 IN PVOID Context);
605
606 typedef VOID
607 (DDKAPI *PDRIVER_CANCEL)(
608 IN struct _DEVICE_OBJECT *DeviceObject,
609 IN struct _IRP *Irp);
610
611 typedef VOID
612 (DDKAPI *PKDEFERRED_ROUTINE)(
613 IN struct _KDPC *Dpc,
614 IN PVOID DeferredContext,
615 IN PVOID SystemArgument1,
616 IN PVOID SystemArgument2);
617
618 typedef NTSTATUS
619 (DDKAPI *PDRIVER_DISPATCH)(
620 IN struct _DEVICE_OBJECT *DeviceObject,
621 IN struct _IRP *Irp);
622
623 typedef VOID
624 (DDKAPI *PIO_DPC_ROUTINE)(
625 IN struct _KDPC *Dpc,
626 IN struct _DEVICE_OBJECT *DeviceObject,
627 IN struct _IRP *Irp,
628 IN PVOID Context);
629
630 typedef NTSTATUS
631 (DDKAPI *PMM_DLL_INITIALIZE)(
632 IN PUNICODE_STRING RegistryPath);
633
634 typedef NTSTATUS
635 (DDKAPI *PMM_DLL_UNLOAD)(
636 VOID);
637
638 typedef NTSTATUS
639 (DDKAPI *PDRIVER_ENTRY)(
640 IN struct _DRIVER_OBJECT *DriverObject,
641 IN PUNICODE_STRING RegistryPath);
642
643 typedef NTSTATUS
644 (DDKAPI *PDRIVER_INITIALIZE)(
645 IN struct _DRIVER_OBJECT *DriverObject,
646 IN PUNICODE_STRING RegistryPath);
647
648 typedef BOOLEAN
649 (DDKAPI *PKSERVICE_ROUTINE)(
650 IN struct _KINTERRUPT *Interrupt,
651 IN PVOID ServiceContext);
652
653 typedef VOID
654 (DDKAPI *PIO_TIMER_ROUTINE)(
655 IN struct _DEVICE_OBJECT *DeviceObject,
656 IN PVOID Context);
657
658 typedef VOID
659 (DDKAPI *PDRIVER_REINITIALIZE)(
660 IN struct _DRIVER_OBJECT *DriverObject,
661 IN PVOID Context,
662 IN ULONG Count);
663
664 typedef VOID
665 (DDKAPI *PDRIVER_STARTIO)(
666 IN struct _DEVICE_OBJECT *DeviceObject,
667 IN struct _IRP *Irp);
668
669 typedef BOOLEAN
670 (DDKAPI *PKSYNCHRONIZE_ROUTINE)(
671 IN PVOID SynchronizeContext);
672
673 typedef VOID
674 (DDKAPI *PDRIVER_UNLOAD)(
675 IN struct _DRIVER_OBJECT *DriverObject);
676
677
678
679 /*
680 ** Plug and Play structures
681 */
682
683 typedef VOID
684 (DDKAPI *PINTERFACE_REFERENCE)(
685 PVOID Context);
686
687 typedef VOID
688 (DDKAPI *PINTERFACE_DEREFERENCE)(
689 PVOID Context);
690
691 typedef BOOLEAN
692 (DDKAPI *PTRANSLATE_BUS_ADDRESS)(
693 IN PVOID Context,
694 IN PHYSICAL_ADDRESS BusAddress,
695 IN ULONG Length,
696 IN OUT PULONG AddressSpace,
697 OUT PPHYSICAL_ADDRESS TranslatedAddress);
698
699 typedef struct _DMA_ADAPTER*
700 (DDKAPI *PGET_DMA_ADAPTER)(
701 IN PVOID Context,
702 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
703 OUT PULONG NumberOfMapRegisters);
704
705 typedef ULONG
706 (DDKAPI *PGET_SET_DEVICE_DATA)(
707 IN PVOID Context,
708 IN ULONG DataType,
709 IN PVOID Buffer,
710 IN ULONG Offset,
711 IN ULONG Length);
712
713 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
714 #define PCI_USE_SUBSYSTEM_IDS 0x00000001
715 #define PCI_USE_REVISION 0x00000002
716 #define PCI_USE_VENDEV_IDS 0x00000004
717 #define PCI_USE_CLASS_SUBCLASS 0x00000008
718 #define PCI_USE_PROGIF 0x00000010
719 #define PCI_USE_LOCAL_BUS 0x00000020
720 #define PCI_USE_LOCAL_DEVICE 0x00000040
721
722 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
723 ULONG Size;
724 ULONG Flags;
725 USHORT VendorID;
726 USHORT DeviceID;
727 UCHAR RevisionID;
728 USHORT SubVendorID;
729 USHORT SubSystemID;
730 UCHAR BaseClass;
731 UCHAR SubClass;
732 UCHAR ProgIf;
733 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
734
735 typedef BOOLEAN
736 (DDKAPI *PPCI_IS_DEVICE_PRESENT)(
737 IN USHORT VendorID,
738 IN USHORT DeviceID,
739 IN UCHAR RevisionID,
740 IN USHORT SubVendorID,
741 IN USHORT SubSystemID,
742 IN ULONG Flags);
743
744 typedef BOOLEAN
745 (DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)(
746 IN PVOID Context,
747 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
748
749 typedef union _POWER_STATE {
750 SYSTEM_POWER_STATE SystemState;
751 DEVICE_POWER_STATE DeviceState;
752 } POWER_STATE, *PPOWER_STATE;
753
754 typedef enum _POWER_STATE_TYPE {
755 SystemPowerState,
756 DevicePowerState
757 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
758
759 typedef struct _BUS_INTERFACE_STANDARD {
760 USHORT Size;
761 USHORT Version;
762 PVOID Context;
763 PINTERFACE_REFERENCE InterfaceReference;
764 PINTERFACE_DEREFERENCE InterfaceDereference;
765 PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
766 PGET_DMA_ADAPTER GetDmaAdapter;
767 PGET_SET_DEVICE_DATA SetBusData;
768 PGET_SET_DEVICE_DATA GetBusData;
769 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
770
771 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
772 USHORT Size;
773 USHORT Version;
774 PVOID Context;
775 PINTERFACE_REFERENCE InterfaceReference;
776 PINTERFACE_DEREFERENCE InterfaceDereference;
777 PPCI_IS_DEVICE_PRESENT IsDevicePresent;
778 PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
779 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
780
781 typedef struct _DEVICE_CAPABILITIES {
782 USHORT Size;
783 USHORT Version;
784 ULONG DeviceD1 : 1;
785 ULONG DeviceD2 : 1;
786 ULONG LockSupported : 1;
787 ULONG EjectSupported : 1;
788 ULONG Removable : 1;
789 ULONG DockDevice : 1;
790 ULONG UniqueID : 1;
791 ULONG SilentInstall : 1;
792 ULONG RawDeviceOK : 1;
793 ULONG SurpriseRemovalOK : 1;
794 ULONG WakeFromD0 : 1;
795 ULONG WakeFromD1 : 1;
796 ULONG WakeFromD2 : 1;
797 ULONG WakeFromD3 : 1;
798 ULONG HardwareDisabled : 1;
799 ULONG NonDynamic : 1;
800 ULONG WarmEjectSupported : 1;
801 ULONG NoDisplayInUI : 1;
802 ULONG Reserved : 14;
803 ULONG Address;
804 ULONG UINumber;
805 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
806 SYSTEM_POWER_STATE SystemWake;
807 DEVICE_POWER_STATE DeviceWake;
808 ULONG D1Latency;
809 ULONG D2Latency;
810 ULONG D3Latency;
811 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
812
813 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
814 USHORT Version;
815 USHORT Size;
816 GUID Event;
817 GUID InterfaceClassGuid;
818 PUNICODE_STRING SymbolicLinkName;
819 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
820
821 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
822 USHORT Version;
823 USHORT Size;
824 GUID Event;
825 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
826
827 #undef INTERFACE
828
829 typedef struct _INTERFACE {
830 USHORT Size;
831 USHORT Version;
832 PVOID Context;
833 PINTERFACE_REFERENCE InterfaceReference;
834 PINTERFACE_DEREFERENCE InterfaceDereference;
835 } INTERFACE, *PINTERFACE;
836
837 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
838 USHORT Version;
839 USHORT Size;
840 GUID Event;
841 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
842
843 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
844
845 /* PNP_DEVICE_STATE */
846
847 #define PNP_DEVICE_DISABLED 0x00000001
848 #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
849 #define PNP_DEVICE_FAILED 0x00000004
850 #define PNP_DEVICE_REMOVED 0x00000008
851 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
852 #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
853
854 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
855 USHORT Version;
856 USHORT Size;
857 GUID Event;
858 struct _FILE_OBJECT *FileObject;
859 LONG NameBufferOffset;
860 UCHAR CustomDataBuffer[1];
861 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
862
863 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
864 USHORT Version;
865 USHORT Size;
866 GUID Event;
867 struct _FILE_OBJECT *FileObject;
868 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
869
870 typedef enum _BUS_QUERY_ID_TYPE {
871 BusQueryDeviceID,
872 BusQueryHardwareIDs,
873 BusQueryCompatibleIDs,
874 BusQueryInstanceID,
875 BusQueryDeviceSerialNumber
876 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
877
878 typedef enum _DEVICE_TEXT_TYPE {
879 DeviceTextDescription,
880 DeviceTextLocationInformation
881 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
882
883 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
884 DeviceUsageTypeUndefined,
885 DeviceUsageTypePaging,
886 DeviceUsageTypeHibernation,
887 DeviceUsageTypeDumpFile
888 } DEVICE_USAGE_NOTIFICATION_TYPE;
889
890 typedef struct _POWER_SEQUENCE {
891 ULONG SequenceD1;
892 ULONG SequenceD2;
893 ULONG SequenceD3;
894 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
895
896 typedef enum {
897 DevicePropertyDeviceDescription,
898 DevicePropertyHardwareID,
899 DevicePropertyCompatibleIDs,
900 DevicePropertyBootConfiguration,
901 DevicePropertyBootConfigurationTranslated,
902 DevicePropertyClassName,
903 DevicePropertyClassGuid,
904 DevicePropertyDriverKeyName,
905 DevicePropertyManufacturer,
906 DevicePropertyFriendlyName,
907 DevicePropertyLocationInformation,
908 DevicePropertyPhysicalDeviceObjectName,
909 DevicePropertyBusTypeGuid,
910 DevicePropertyLegacyBusType,
911 DevicePropertyBusNumber,
912 DevicePropertyEnumeratorName,
913 DevicePropertyAddress,
914 DevicePropertyUINumber,
915 DevicePropertyInstallState,
916 DevicePropertyRemovalPolicy
917 } DEVICE_REGISTRY_PROPERTY;
918
919 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
920 EventCategoryReserved,
921 EventCategoryHardwareProfileChange,
922 EventCategoryDeviceInterfaceChange,
923 EventCategoryTargetDeviceChange
924 } IO_NOTIFICATION_EVENT_CATEGORY;
925
926 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
927
928 typedef NTSTATUS
929 (DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
930 IN PVOID NotificationStructure,
931 IN PVOID Context);
932
933 typedef VOID
934 (DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)(
935 IN PVOID Context);
936
937
938 /*
939 ** System structures
940 */
941
942 #define SYMBOLIC_LINK_QUERY 0x0001
943 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
944
945 /* also in winnt,h */
946 #define DUPLICATE_CLOSE_SOURCE 0x00000001
947 #define DUPLICATE_SAME_ACCESS 0x00000002
948 #define DUPLICATE_SAME_ATTRIBUTES 0x00000004
949 /* end winnt.h */
950
951 typedef struct _OBJECT_NAME_INFORMATION {
952 UNICODE_STRING Name;
953 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
954
955 typedef VOID
956 (DDKAPI *PIO_APC_ROUTINE)(
957 IN PVOID ApcContext,
958 IN PIO_STATUS_BLOCK IoStatusBlock,
959 IN ULONG Reserved);
960
961 typedef struct _IO_STATUS_BLOCK {
962 _ANONYMOUS_UNION union {
963 NTSTATUS Status;
964 PVOID Pointer;
965 } DUMMYUNIONNAME;
966 ULONG_PTR Information;
967 } IO_STATUS_BLOCK;
968
969 typedef VOID
970 (DDKAPI *PKNORMAL_ROUTINE)(
971 IN PVOID NormalContext,
972 IN PVOID SystemArgument1,
973 IN PVOID SystemArgument2);
974
975 typedef VOID
976 (DDKAPI *PKKERNEL_ROUTINE)(
977 IN struct _KAPC *Apc,
978 IN OUT PKNORMAL_ROUTINE *NormalRoutine,
979 IN OUT PVOID *NormalContext,
980 IN OUT PVOID *SystemArgument1,
981 IN OUT PVOID *SystemArgument2);
982
983 typedef VOID
984 (DDKAPI *PKRUNDOWN_ROUTINE)(
985 IN struct _KAPC *Apc);
986
987 typedef BOOLEAN
988 (DDKAPI *PKTRANSFER_ROUTINE)(
989 VOID);
990
991 typedef struct _KAPC
992 {
993 UCHAR Type;
994 UCHAR SpareByte0;
995 UCHAR Size;
996 UCHAR SpareByte1;
997 ULONG SpareLong0;
998 struct _KTHREAD *Thread;
999 LIST_ENTRY ApcListEntry;
1000 PKKERNEL_ROUTINE KernelRoutine;
1001 PKRUNDOWN_ROUTINE RundownRoutine;
1002 PKNORMAL_ROUTINE NormalRoutine;
1003 PVOID NormalContext;
1004 PVOID SystemArgument1;
1005 PVOID SystemArgument2;
1006 CCHAR ApcStateIndex;
1007 KPROCESSOR_MODE ApcMode;
1008 BOOLEAN Inserted;
1009 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
1010
1011 typedef struct _KDEVICE_QUEUE {
1012 CSHORT Type;
1013 CSHORT Size;
1014 LIST_ENTRY DeviceListHead;
1015 KSPIN_LOCK Lock;
1016 BOOLEAN Busy;
1017 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
1018
1019 typedef struct _KDEVICE_QUEUE_ENTRY {
1020 LIST_ENTRY DeviceListEntry;
1021 ULONG SortKey;
1022 BOOLEAN Inserted;
1023 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
1024 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
1025
1026 #define LOCK_QUEUE_WAIT 1
1027 #define LOCK_QUEUE_OWNER 2
1028
1029 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
1030 LockQueueDispatcherLock,
1031 LockQueueContextSwapLock,
1032 LockQueuePfnLock,
1033 LockQueueSystemSpaceLock,
1034 LockQueueVacbLock,
1035 LockQueueMasterLock,
1036 LockQueueNonPagedPoolLock,
1037 LockQueueIoCancelLock,
1038 LockQueueWorkQueueLock,
1039 LockQueueIoVpbLock,
1040 LockQueueIoDatabaseLock,
1041 LockQueueIoCompletionLock,
1042 LockQueueNtfsStructLock,
1043 LockQueueAfdWorkQueueLock,
1044 LockQueueBcbLock,
1045 LockQueueMaximumLock
1046 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
1047
1048 typedef struct _KSPIN_LOCK_QUEUE {
1049 struct _KSPIN_LOCK_QUEUE *VOLATILE Next;
1050 PKSPIN_LOCK VOLATILE Lock;
1051 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
1052
1053 typedef struct _KLOCK_QUEUE_HANDLE {
1054 KSPIN_LOCK_QUEUE LockQueue;
1055 KIRQL OldIrql;
1056 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
1057
1058 typedef struct _KDPC {
1059 CSHORT Type;
1060 UCHAR Number;
1061 UCHAR Importance;
1062 LIST_ENTRY DpcListEntry;
1063 PKDEFERRED_ROUTINE DeferredRoutine;
1064 PVOID DeferredContext;
1065 PVOID SystemArgument1;
1066 PVOID SystemArgument2;
1067 PVOID DpcData;
1068 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
1069
1070 typedef struct _WAIT_CONTEXT_BLOCK {
1071 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
1072 PDRIVER_CONTROL DeviceRoutine;
1073 PVOID DeviceContext;
1074 ULONG NumberOfMapRegisters;
1075 PVOID DeviceObject;
1076 PVOID CurrentIrp;
1077 PKDPC BufferChainingDpc;
1078 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
1079
1080 typedef struct _DISPATCHER_HEADER
1081 {
1082 union
1083 {
1084 struct
1085 {
1086 UCHAR Type;
1087 union
1088 {
1089 UCHAR Absolute;
1090 UCHAR NpxIrql;
1091 };
1092 union
1093 {
1094 UCHAR Size;
1095 UCHAR Hand;
1096 };
1097 union
1098 {
1099 UCHAR Inserted;
1100 BOOLEAN DebugActive;
1101 };
1102 };
1103 volatile LONG Lock;
1104 };
1105 LONG SignalState;
1106 LIST_ENTRY WaitListHead;
1107 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
1108
1109 typedef struct _KEVENT {
1110 DISPATCHER_HEADER Header;
1111 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
1112
1113 typedef struct _KSEMAPHORE {
1114 DISPATCHER_HEADER Header;
1115 LONG Limit;
1116 } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE;
1117
1118 typedef struct _FAST_MUTEX
1119 {
1120 LONG Count;
1121 PKTHREAD Owner;
1122 ULONG Contention;
1123 KEVENT Gate;
1124 ULONG OldIrql;
1125 } FAST_MUTEX, *PFAST_MUTEX;
1126
1127 typedef struct _EX_RUNDOWN_REF
1128 {
1129 union
1130 {
1131 ULONG_PTR Count;
1132 PVOID Ptr;
1133 };
1134 } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
1135
1136 typedef struct _KGATE
1137 {
1138 DISPATCHER_HEADER Header;
1139 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
1140
1141 typedef struct _KGUARDED_MUTEX
1142 {
1143 LONG Count;
1144 struct _KTHREAD* Owner;
1145 ULONG Contention;
1146 KGATE Gate;
1147 union {
1148 struct {
1149 SHORT KernelApcDisable;
1150 SHORT SpecialApcDisable;
1151 };
1152 ULONG CombinedApcDisable;
1153 };
1154 } KGUARDED_MUTEX, *PKGUARDED_MUTEX, *RESTRICTED_POINTER PRKGUARDED_MUTEX;
1155
1156 typedef struct _KTIMER {
1157 DISPATCHER_HEADER Header;
1158 ULARGE_INTEGER DueTime;
1159 LIST_ENTRY TimerListEntry;
1160 struct _KDPC *Dpc;
1161 LONG Period;
1162 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
1163
1164 typedef struct _KMUTANT {
1165 DISPATCHER_HEADER Header;
1166 LIST_ENTRY MutantListEntry;
1167 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
1168 BOOLEAN Abandoned;
1169 UCHAR ApcDisable;
1170 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
1171
1172 typedef enum _TIMER_TYPE {
1173 NotificationTimer,
1174 SynchronizationTimer
1175 } TIMER_TYPE;
1176
1177 #define EVENT_INCREMENT 1
1178 #define IO_NO_INCREMENT 0
1179 #define IO_CD_ROM_INCREMENT 1
1180 #define IO_DISK_INCREMENT 1
1181 #define IO_KEYBOARD_INCREMENT 6
1182 #define IO_MAILSLOT_INCREMENT 2
1183 #define IO_MOUSE_INCREMENT 6
1184 #define IO_NAMED_PIPE_INCREMENT 2
1185 #define IO_NETWORK_INCREMENT 2
1186 #define IO_PARALLEL_INCREMENT 1
1187 #define IO_SERIAL_INCREMENT 2
1188 #define IO_SOUND_INCREMENT 8
1189 #define IO_VIDEO_INCREMENT 1
1190 #define SEMAPHORE_INCREMENT 1
1191
1192 typedef struct _IRP {
1193 CSHORT Type;
1194 USHORT Size;
1195 struct _MDL *MdlAddress;
1196 ULONG Flags;
1197 union {
1198 struct _IRP *MasterIrp;
1199 LONG IrpCount;
1200 PVOID SystemBuffer;
1201 } AssociatedIrp;
1202 LIST_ENTRY ThreadListEntry;
1203 IO_STATUS_BLOCK IoStatus;
1204 KPROCESSOR_MODE RequestorMode;
1205 BOOLEAN PendingReturned;
1206 CHAR StackCount;
1207 CHAR CurrentLocation;
1208 BOOLEAN Cancel;
1209 KIRQL CancelIrql;
1210 CCHAR ApcEnvironment;
1211 UCHAR AllocationFlags;
1212 PIO_STATUS_BLOCK UserIosb;
1213 PKEVENT UserEvent;
1214 union {
1215 struct {
1216 PIO_APC_ROUTINE UserApcRoutine;
1217 PVOID UserApcContext;
1218 } AsynchronousParameters;
1219 LARGE_INTEGER AllocationSize;
1220 } Overlay;
1221 PDRIVER_CANCEL CancelRoutine;
1222 PVOID UserBuffer;
1223 union {
1224 struct {
1225 _ANONYMOUS_UNION union {
1226 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
1227 _ANONYMOUS_STRUCT struct {
1228 PVOID DriverContext[4];
1229 } DUMMYSTRUCTNAME;
1230 } DUMMYUNIONNAME;
1231 PETHREAD Thread;
1232 PCHAR AuxiliaryBuffer;
1233 _ANONYMOUS_STRUCT struct {
1234 LIST_ENTRY ListEntry;
1235 _ANONYMOUS_UNION union {
1236 struct _IO_STACK_LOCATION *CurrentStackLocation;
1237 ULONG PacketType;
1238 } DUMMYUNIONNAME;
1239 } DUMMYSTRUCTNAME;
1240 struct _FILE_OBJECT *OriginalFileObject;
1241 } Overlay;
1242 KAPC Apc;
1243 PVOID CompletionKey;
1244 } Tail;
1245 } IRP;
1246 typedef struct _IRP *PIRP;
1247
1248 /* IRP.Flags */
1249
1250 #define SL_FORCE_ACCESS_CHECK 0x01
1251 #define SL_OPEN_PAGING_FILE 0x02
1252 #define SL_OPEN_TARGET_DIRECTORY 0x04
1253 #define SL_CASE_SENSITIVE 0x80
1254
1255 #define SL_KEY_SPECIFIED 0x01
1256 #define SL_OVERRIDE_VERIFY_VOLUME 0x02
1257 #define SL_WRITE_THROUGH 0x04
1258 #define SL_FT_SEQUENTIAL_WRITE 0x08
1259
1260 #define SL_FAIL_IMMEDIATELY 0x01
1261 #define SL_EXCLUSIVE_LOCK 0x02
1262
1263 #define SL_RESTART_SCAN 0x01
1264 #define SL_RETURN_SINGLE_ENTRY 0x02
1265 #define SL_INDEX_SPECIFIED 0x04
1266
1267 #define SL_WATCH_TREE 0x01
1268
1269 #define SL_ALLOW_RAW_MOUNT 0x01
1270
1271 #define CTL_CODE(DeviceType, Function, Method, Access)( \
1272 ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1273
1274 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
1275
1276 enum
1277 {
1278 IRP_NOCACHE = 0x1,
1279 IRP_PAGING_IO = 0x2,
1280 IRP_MOUNT_COMPLETION = 0x2,
1281 IRP_SYNCHRONOUS_API = 0x4,
1282 IRP_ASSOCIATED_IRP = 0x8,
1283 IRP_BUFFERED_IO = 0x10,
1284 IRP_DEALLOCATE_BUFFER = 0x20,
1285 IRP_INPUT_OPERATION = 0x40,
1286 IRP_SYNCHRONOUS_PAGING_IO = 0x40,
1287 IRP_CREATE_OPERATION = 0x80,
1288 IRP_READ_OPERATION = 0x100,
1289 IRP_WRITE_OPERATION = 0x200,
1290 IRP_CLOSE_OPERATION = 0x400,
1291 IRP_DEFER_IO_COMPLETION = 0x800,
1292 IRP_OB_QUERY_NAME = 0x1000,
1293 IRP_HOLD_DEVICE_QUEUE = 0x2000,
1294 IRP_RETRY_IO_COMPLETION = 0x4000
1295 };
1296
1297 #define IRP_QUOTA_CHARGED 0x01
1298 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
1299 #define IRP_ALLOCATED_FIXED_SIZE 0x04
1300 #define IRP_LOOKASIDE_ALLOCATION 0x08
1301
1302 typedef struct _BOOTDISK_INFORMATION {
1303 LONGLONG BootPartitionOffset;
1304 LONGLONG SystemPartitionOffset;
1305 ULONG BootDeviceSignature;
1306 ULONG SystemDeviceSignature;
1307 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
1308
1309 typedef struct _BOOTDISK_INFORMATION_EX {
1310 LONGLONG BootPartitionOffset;
1311 LONGLONG SystemPartitionOffset;
1312 ULONG BootDeviceSignature;
1313 ULONG SystemDeviceSignature;
1314 GUID BootDeviceGuid;
1315 GUID SystemDeviceGuid;
1316 BOOLEAN BootDeviceIsGpt;
1317 BOOLEAN SystemDeviceIsGpt;
1318 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
1319
1320 typedef struct _EISA_MEMORY_TYPE {
1321 UCHAR ReadWrite : 1;
1322 UCHAR Cached : 1;
1323 UCHAR Reserved0 : 1;
1324 UCHAR Type : 2;
1325 UCHAR Shared : 1;
1326 UCHAR Reserved1 : 1;
1327 UCHAR MoreEntries : 1;
1328 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
1329
1330 #include <pshpack1.h>
1331 typedef struct _EISA_MEMORY_CONFIGURATION {
1332 EISA_MEMORY_TYPE ConfigurationByte;
1333 UCHAR DataSize;
1334 USHORT AddressLowWord;
1335 UCHAR AddressHighByte;
1336 USHORT MemorySize;
1337 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
1338 #include <poppack.h>
1339
1340 typedef struct _EISA_IRQ_DESCRIPTOR {
1341 UCHAR Interrupt : 4;
1342 UCHAR Reserved : 1;
1343 UCHAR LevelTriggered : 1;
1344 UCHAR Shared : 1;
1345 UCHAR MoreEntries : 1;
1346 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
1347
1348 typedef struct _EISA_IRQ_CONFIGURATION {
1349 EISA_IRQ_DESCRIPTOR ConfigurationByte;
1350 UCHAR Reserved;
1351 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
1352
1353 typedef struct _DMA_CONFIGURATION_BYTE0 {
1354 UCHAR Channel : 3;
1355 UCHAR Reserved : 3;
1356 UCHAR Shared : 1;
1357 UCHAR MoreEntries : 1;
1358 } DMA_CONFIGURATION_BYTE0;
1359
1360 typedef struct _DMA_CONFIGURATION_BYTE1 {
1361 UCHAR Reserved0 : 2;
1362 UCHAR TransferSize : 2;
1363 UCHAR Timing : 2;
1364 UCHAR Reserved1 : 2;
1365 } DMA_CONFIGURATION_BYTE1;
1366
1367 typedef struct _EISA_DMA_CONFIGURATION {
1368 DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
1369 DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
1370 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
1371
1372 #include <pshpack1.h>
1373 typedef struct _EISA_PORT_DESCRIPTOR {
1374 UCHAR NumberPorts : 5;
1375 UCHAR Reserved : 1;
1376 UCHAR Shared : 1;
1377 UCHAR MoreEntries : 1;
1378 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
1379
1380 typedef struct _EISA_PORT_CONFIGURATION {
1381 EISA_PORT_DESCRIPTOR Configuration;
1382 USHORT PortAddress;
1383 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
1384 #include <poppack.h>
1385
1386 typedef struct _CM_EISA_FUNCTION_INFORMATION {
1387 ULONG CompressedId;
1388 UCHAR IdSlotFlags1;
1389 UCHAR IdSlotFlags2;
1390 UCHAR MinorRevision;
1391 UCHAR MajorRevision;
1392 UCHAR Selections[26];
1393 UCHAR FunctionFlags;
1394 UCHAR TypeString[80];
1395 EISA_MEMORY_CONFIGURATION EisaMemory[9];
1396 EISA_IRQ_CONFIGURATION EisaIrq[7];
1397 EISA_DMA_CONFIGURATION EisaDma[4];
1398 EISA_PORT_CONFIGURATION EisaPort[20];
1399 UCHAR InitializationData[60];
1400 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
1401
1402 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
1403
1404 #define EISA_FUNCTION_ENABLED 0x80
1405 #define EISA_FREE_FORM_DATA 0x40
1406 #define EISA_HAS_PORT_INIT_ENTRY 0x20
1407 #define EISA_HAS_PORT_RANGE 0x10
1408 #define EISA_HAS_DMA_ENTRY 0x08
1409 #define EISA_HAS_IRQ_ENTRY 0x04
1410 #define EISA_HAS_MEMORY_ENTRY 0x02
1411 #define EISA_HAS_TYPE_ENTRY 0x01
1412 #define EISA_HAS_INFORMATION \
1413 (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
1414 + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
1415
1416 typedef struct _CM_EISA_SLOT_INFORMATION {
1417 UCHAR ReturnCode;
1418 UCHAR ReturnFlags;
1419 UCHAR MajorRevision;
1420 UCHAR MinorRevision;
1421 USHORT Checksum;
1422 UCHAR NumberFunctions;
1423 UCHAR FunctionInformation;
1424 ULONG CompressedId;
1425 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
1426
1427 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
1428
1429 #define EISA_INVALID_SLOT 0x80
1430 #define EISA_INVALID_FUNCTION 0x81
1431 #define EISA_INVALID_CONFIGURATION 0x82
1432 #define EISA_EMPTY_SLOT 0x83
1433 #define EISA_INVALID_BIOS_CALL 0x86
1434
1435 typedef struct _CM_FLOPPY_DEVICE_DATA {
1436 USHORT Version;
1437 USHORT Revision;
1438 CHAR Size[8];
1439 ULONG MaxDensity;
1440 ULONG MountDensity;
1441 UCHAR StepRateHeadUnloadTime;
1442 UCHAR HeadLoadTime;
1443 UCHAR MotorOffTime;
1444 UCHAR SectorLengthCode;
1445 UCHAR SectorPerTrack;
1446 UCHAR ReadWriteGapLength;
1447 UCHAR DataTransferLength;
1448 UCHAR FormatGapLength;
1449 UCHAR FormatFillCharacter;
1450 UCHAR HeadSettleTime;
1451 UCHAR MotorSettleTime;
1452 UCHAR MaximumTrackValue;
1453 UCHAR DataTransferRate;
1454 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
1455
1456 typedef enum _INTERFACE_TYPE {
1457 InterfaceTypeUndefined = -1,
1458 Internal,
1459 Isa,
1460 Eisa,
1461 MicroChannel,
1462 TurboChannel,
1463 PCIBus,
1464 VMEBus,
1465 NuBus,
1466 PCMCIABus,
1467 CBus,
1468 MPIBus,
1469 MPSABus,
1470 ProcessorInternal,
1471 InternalPowerBus,
1472 PNPISABus,
1473 PNPBus,
1474 MaximumInterfaceType
1475 } INTERFACE_TYPE, *PINTERFACE_TYPE;
1476
1477 typedef struct _PNP_BUS_INFORMATION {
1478 GUID BusTypeGuid;
1479 INTERFACE_TYPE LegacyBusType;
1480 ULONG BusNumber;
1481 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
1482
1483 #include <pshpack1.h>
1484 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
1485 UCHAR Type;
1486 UCHAR ShareDisposition;
1487 USHORT Flags;
1488 union {
1489 struct {
1490 PHYSICAL_ADDRESS Start;
1491 ULONG Length;
1492 } Generic;
1493 struct {
1494 PHYSICAL_ADDRESS Start;
1495 ULONG Length;
1496 } Port;
1497 struct {
1498 ULONG Level;
1499 ULONG Vector;
1500 ULONG Affinity;
1501 } Interrupt;
1502 struct {
1503 PHYSICAL_ADDRESS Start;
1504 ULONG Length;
1505 } Memory;
1506 struct {
1507 ULONG Channel;
1508 ULONG Port;
1509 ULONG Reserved1;
1510 } Dma;
1511 struct {
1512 ULONG Data[3];
1513 } DevicePrivate;
1514 struct {
1515 ULONG Start;
1516 ULONG Length;
1517 ULONG Reserved;
1518 } BusNumber;
1519 struct {
1520 ULONG DataSize;
1521 ULONG Reserved1;
1522 ULONG Reserved2;
1523 } DeviceSpecificData;
1524 } u;
1525 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
1526
1527 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
1528
1529 #define CmResourceTypeNull 0
1530 #define CmResourceTypePort 1
1531 #define CmResourceTypeInterrupt 2
1532 #define CmResourceTypeMemory 3
1533 #define CmResourceTypeDma 4
1534 #define CmResourceTypeDeviceSpecific 5
1535 #define CmResourceTypeBusNumber 6
1536 #define CmResourceTypeMaximum 7
1537 #define CmResourceTypeNonArbitrated 128
1538 #define CmResourceTypeConfigData 128
1539 #define CmResourceTypeDevicePrivate 129
1540 #define CmResourceTypePcCardConfig 130
1541 #define CmResourceTypeMfCardConfig 131
1542
1543 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
1544
1545 typedef enum _CM_SHARE_DISPOSITION {
1546 CmResourceShareUndetermined,
1547 CmResourceShareDeviceExclusive,
1548 CmResourceShareDriverExclusive,
1549 CmResourceShareShared
1550 } CM_SHARE_DISPOSITION;
1551
1552 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
1553
1554 #define CM_RESOURCE_PORT_MEMORY 0x0000
1555 #define CM_RESOURCE_PORT_IO 0x0001
1556 #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
1557 #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
1558 #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
1559 #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
1560 #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
1561 #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
1562
1563 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
1564
1565 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
1566 #define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
1567
1568 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
1569
1570 #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
1571 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
1572 #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
1573 #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
1574 #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
1575 #define CM_RESOURCE_MEMORY_24 0x0010
1576 #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
1577
1578 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
1579
1580 #define CM_RESOURCE_DMA_8 0x0000
1581 #define CM_RESOURCE_DMA_16 0x0001
1582 #define CM_RESOURCE_DMA_32 0x0002
1583 #define CM_RESOURCE_DMA_8_AND_16 0x0004
1584 #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
1585 #define CM_RESOURCE_DMA_TYPE_A 0x0010
1586 #define CM_RESOURCE_DMA_TYPE_B 0x0020
1587 #define CM_RESOURCE_DMA_TYPE_F 0x0040
1588
1589 typedef struct _CM_PARTIAL_RESOURCE_LIST {
1590 USHORT Version;
1591 USHORT Revision;
1592 ULONG Count;
1593 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
1594 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
1595
1596 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
1597 INTERFACE_TYPE InterfaceType;
1598 ULONG BusNumber;
1599 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
1600 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
1601
1602 typedef struct _CM_RESOURCE_LIST {
1603 ULONG Count;
1604 CM_FULL_RESOURCE_DESCRIPTOR List[1];
1605 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
1606
1607 typedef struct _CM_INT13_DRIVE_PARAMETER {
1608 USHORT DriveSelect;
1609 ULONG MaxCylinders;
1610 USHORT SectorsPerTrack;
1611 USHORT MaxHeads;
1612 USHORT NumberDrives;
1613 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
1614 #include <poppack.h>
1615
1616 typedef struct _CM_KEYBOARD_DEVICE_DATA {
1617 USHORT Version;
1618 USHORT Revision;
1619 UCHAR Type;
1620 UCHAR Subtype;
1621 USHORT KeyboardFlags;
1622 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
1623
1624 #define KEYBOARD_INSERT_ON 0x08
1625 #define KEYBOARD_CAPS_LOCK_ON 0x04
1626 #define KEYBOARD_NUM_LOCK_ON 0x02
1627 #define KEYBOARD_SCROLL_LOCK_ON 0x01
1628 #define KEYBOARD_ALT_KEY_DOWN 0x80
1629 #define KEYBOARD_CTRL_KEY_DOWN 0x40
1630 #define KEYBOARD_LEFT_SHIFT_DOWN 0x20
1631 #define KEYBOARD_RIGHT_SHIFT_DOWN 0x10
1632
1633 typedef struct _CM_MCA_POS_DATA {
1634 USHORT AdapterId;
1635 UCHAR PosData1;
1636 UCHAR PosData2;
1637 UCHAR PosData3;
1638 UCHAR PosData4;
1639 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
1640
1641 typedef struct CM_Power_Data_s {
1642 ULONG PD_Size;
1643 DEVICE_POWER_STATE PD_MostRecentPowerState;
1644 ULONG PD_Capabilities;
1645 ULONG PD_D1Latency;
1646 ULONG PD_D2Latency;
1647 ULONG PD_D3Latency;
1648 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
1649 } CM_POWER_DATA, *PCM_POWER_DATA;
1650
1651 #define PDCAP_D0_SUPPORTED 0x00000001
1652 #define PDCAP_D1_SUPPORTED 0x00000002
1653 #define PDCAP_D2_SUPPORTED 0x00000004
1654 #define PDCAP_D3_SUPPORTED 0x00000008
1655 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
1656 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
1657 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
1658 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
1659 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
1660
1661 typedef struct _CM_SCSI_DEVICE_DATA {
1662 USHORT Version;
1663 USHORT Revision;
1664 UCHAR HostIdentifier;
1665 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
1666
1667 typedef struct _CM_SERIAL_DEVICE_DATA {
1668 USHORT Version;
1669 USHORT Revision;
1670 ULONG BaudClock;
1671 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
1672
1673 typedef struct _VM_COUNTERS
1674 {
1675 SIZE_T PeakVirtualSize;
1676 SIZE_T VirtualSize;
1677 ULONG PageFaultCount;
1678 SIZE_T PeakWorkingSetSize;
1679 SIZE_T WorkingSetSize;
1680 SIZE_T QuotaPeakPagedPoolUsage;
1681 SIZE_T QuotaPagedPoolUsage;
1682 SIZE_T QuotaPeakNonPagedPoolUsage;
1683 SIZE_T QuotaNonPagedPoolUsage;
1684 SIZE_T PagefileUsage;
1685 SIZE_T PeakPagefileUsage;
1686 } VM_COUNTERS, *PVM_COUNTERS;
1687
1688 typedef struct _VM_COUNTERS_EX
1689 {
1690 SIZE_T PeakVirtualSize;
1691 SIZE_T VirtualSize;
1692 ULONG PageFaultCount;
1693 SIZE_T PeakWorkingSetSize;
1694 SIZE_T WorkingSetSize;
1695 SIZE_T QuotaPeakPagedPoolUsage;
1696 SIZE_T QuotaPagedPoolUsage;
1697 SIZE_T QuotaPeakNonPagedPoolUsage;
1698 SIZE_T QuotaNonPagedPoolUsage;
1699 SIZE_T PagefileUsage;
1700 SIZE_T PeakPagefileUsage;
1701 SIZE_T PrivateUsage;
1702 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
1703
1704 typedef struct _POOLED_USAGE_AND_LIMITS
1705 {
1706 SIZE_T PeakPagedPoolUsage;
1707 SIZE_T PagedPoolUsage;
1708 SIZE_T PagedPoolLimit;
1709 SIZE_T PeakNonPagedPoolUsage;
1710 SIZE_T NonPagedPoolUsage;
1711 SIZE_T NonPagedPoolLimit;
1712 SIZE_T PeakPagefileUsage;
1713 SIZE_T PagefileUsage;
1714 SIZE_T PagefileLimit;
1715 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
1716
1717 /* IO_RESOURCE_DESCRIPTOR.Option */
1718
1719 #define IO_RESOURCE_PREFERRED 0x01
1720 #define IO_RESOURCE_DEFAULT 0x02
1721 #define IO_RESOURCE_ALTERNATIVE 0x08
1722
1723 typedef struct _IO_RESOURCE_DESCRIPTOR {
1724 UCHAR Option;
1725 UCHAR Type;
1726 UCHAR ShareDisposition;
1727 UCHAR Spare1;
1728 USHORT Flags;
1729 USHORT Spare2;
1730 union {
1731 struct {
1732 ULONG Length;
1733 ULONG Alignment;
1734 PHYSICAL_ADDRESS MinimumAddress;
1735 PHYSICAL_ADDRESS MaximumAddress;
1736 } Port;
1737 struct {
1738 ULONG Length;
1739 ULONG Alignment;
1740 PHYSICAL_ADDRESS MinimumAddress;
1741 PHYSICAL_ADDRESS MaximumAddress;
1742 } Memory;
1743 struct {
1744 ULONG MinimumVector;
1745 ULONG MaximumVector;
1746 } Interrupt;
1747 struct {
1748 ULONG MinimumChannel;
1749 ULONG MaximumChannel;
1750 } Dma;
1751 struct {
1752 ULONG Length;
1753 ULONG Alignment;
1754 PHYSICAL_ADDRESS MinimumAddress;
1755 PHYSICAL_ADDRESS MaximumAddress;
1756 } Generic;
1757 struct {
1758 ULONG Data[3];
1759 } DevicePrivate;
1760 struct {
1761 ULONG Length;
1762 ULONG MinBusNumber;
1763 ULONG MaxBusNumber;
1764 ULONG Reserved;
1765 } BusNumber;
1766 struct {
1767 ULONG Priority;
1768 ULONG Reserved1;
1769 ULONG Reserved2;
1770 } ConfigData;
1771 } u;
1772 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
1773
1774 typedef struct _IO_RESOURCE_LIST {
1775 USHORT Version;
1776 USHORT Revision;
1777 ULONG Count;
1778 IO_RESOURCE_DESCRIPTOR Descriptors[1];
1779 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
1780
1781 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
1782 ULONG ListSize;
1783 INTERFACE_TYPE InterfaceType;
1784 ULONG BusNumber;
1785 ULONG SlotNumber;
1786 ULONG Reserved[3];
1787 ULONG AlternativeLists;
1788 IO_RESOURCE_LIST List[1];
1789 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
1790
1791 typedef struct _IO_ERROR_LOG_PACKET {
1792 UCHAR MajorFunctionCode;
1793 UCHAR RetryCount;
1794 USHORT DumpDataSize;
1795 USHORT NumberOfStrings;
1796 USHORT StringOffset;
1797 USHORT EventCategory;
1798 NTSTATUS ErrorCode;
1799 ULONG UniqueErrorValue;
1800 NTSTATUS FinalStatus;
1801 ULONG SequenceNumber;
1802 ULONG IoControlCode;
1803 LARGE_INTEGER DeviceOffset;
1804 ULONG DumpData[1];
1805 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
1806
1807 typedef struct _IO_ERROR_LOG_MESSAGE {
1808 USHORT Type;
1809 USHORT Size;
1810 USHORT DriverNameLength;
1811 LARGE_INTEGER TimeStamp;
1812 ULONG DriverNameOffset;
1813 IO_ERROR_LOG_PACKET EntryData;
1814 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
1815
1816 #define ERROR_LOG_LIMIT_SIZE 240
1817 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
1818 sizeof(IO_ERROR_LOG_PACKET) + \
1819 (sizeof(WCHAR) * 40))
1820
1821 typedef struct _CONTROLLER_OBJECT {
1822 CSHORT Type;
1823 CSHORT Size;
1824 PVOID ControllerExtension;
1825 KDEVICE_QUEUE DeviceWaitQueue;
1826 ULONG Spare1;
1827 LARGE_INTEGER Spare2;
1828 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
1829
1830 typedef enum _DMA_WIDTH {
1831 Width8Bits,
1832 Width16Bits,
1833 Width32Bits,
1834 MaximumDmaWidth
1835 } DMA_WIDTH, *PDMA_WIDTH;
1836
1837 typedef enum _DMA_SPEED {
1838 Compatible,
1839 TypeA,
1840 TypeB,
1841 TypeC,
1842 TypeF,
1843 MaximumDmaSpeed
1844 } DMA_SPEED, *PDMA_SPEED;
1845
1846 /* DEVICE_DESCRIPTION.Version */
1847
1848 #define DEVICE_DESCRIPTION_VERSION 0x0000
1849 #define DEVICE_DESCRIPTION_VERSION1 0x0001
1850 #define DEVICE_DESCRIPTION_VERSION2 0x0002
1851
1852 typedef struct _DEVICE_DESCRIPTION {
1853 ULONG Version;
1854 BOOLEAN Master;
1855 BOOLEAN ScatterGather;
1856 BOOLEAN DemandMode;
1857 BOOLEAN AutoInitialize;
1858 BOOLEAN Dma32BitAddresses;
1859 BOOLEAN IgnoreCount;
1860 BOOLEAN Reserved1;
1861 BOOLEAN Dma64BitAddresses;
1862 ULONG BusNumber;
1863 ULONG DmaChannel;
1864 INTERFACE_TYPE InterfaceType;
1865 DMA_WIDTH DmaWidth;
1866 DMA_SPEED DmaSpeed;
1867 ULONG MaximumLength;
1868 ULONG DmaPort;
1869 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
1870
1871 /* VPB.Flags */
1872 #define VPB_MOUNTED 0x0001
1873 #define VPB_LOCKED 0x0002
1874 #define VPB_PERSISTENT 0x0004
1875 #define VPB_REMOVE_PENDING 0x0008
1876 #define VPB_RAW_MOUNT 0x0010
1877
1878 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
1879
1880 typedef struct _VPB {
1881 CSHORT Type;
1882 CSHORT Size;
1883 USHORT Flags;
1884 USHORT VolumeLabelLength;
1885 struct _DEVICE_OBJECT *DeviceObject;
1886 struct _DEVICE_OBJECT *RealDevice;
1887 ULONG SerialNumber;
1888 ULONG ReferenceCount;
1889 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
1890 } VPB, *PVPB;
1891
1892 /* DEVICE_OBJECT.Flags */
1893
1894 #define DO_VERIFY_VOLUME 0x00000002
1895 #define DO_BUFFERED_IO 0x00000004
1896 #define DO_EXCLUSIVE 0x00000008
1897 #define DO_DIRECT_IO 0x00000010
1898 #define DO_MAP_IO_BUFFER 0x00000020
1899 #define DO_DEVICE_HAS_NAME 0x00000040
1900 #define DO_DEVICE_INITIALIZING 0x00000080
1901 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
1902 #define DO_LONG_TERM_REQUESTS 0x00000200
1903 #define DO_NEVER_LAST_DEVICE 0x00000400
1904 #define DO_SHUTDOWN_REGISTERED 0x00000800
1905 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
1906 #define DO_POWER_PAGABLE 0x00002000
1907 #define DO_POWER_INRUSH 0x00004000
1908 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
1909
1910 /* DEVICE_OBJECT.Characteristics */
1911
1912 #define FILE_REMOVABLE_MEDIA 0x00000001
1913 #define FILE_READ_ONLY_DEVICE 0x00000002
1914 #define FILE_FLOPPY_DISKETTE 0x00000004
1915 #define FILE_WRITE_ONCE_MEDIA 0x00000008
1916 #define FILE_REMOTE_DEVICE 0x00000010
1917 #define FILE_DEVICE_IS_MOUNTED 0x00000020
1918 #define FILE_VIRTUAL_VOLUME 0x00000040
1919 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
1920 #define FILE_DEVICE_SECURE_OPEN 0x00000100
1921
1922 /* DEVICE_OBJECT.AlignmentRequirement */
1923
1924 #define FILE_BYTE_ALIGNMENT 0x00000000
1925 #define FILE_WORD_ALIGNMENT 0x00000001
1926 #define FILE_LONG_ALIGNMENT 0x00000003
1927 #define FILE_QUAD_ALIGNMENT 0x00000007
1928 #define FILE_OCTA_ALIGNMENT 0x0000000f
1929 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
1930 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
1931 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
1932 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
1933 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
1934
1935 /* DEVICE_OBJECT.DeviceType */
1936
1937 #define DEVICE_TYPE ULONG
1938
1939 #define FILE_DEVICE_BEEP 0x00000001
1940 #define FILE_DEVICE_CD_ROM 0x00000002
1941 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1942 #define FILE_DEVICE_CONTROLLER 0x00000004
1943 #define FILE_DEVICE_DATALINK 0x00000005
1944 #define FILE_DEVICE_DFS 0x00000006
1945 #define FILE_DEVICE_DISK 0x00000007
1946 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1947 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
1948 #define FILE_DEVICE_INPORT_PORT 0x0000000a
1949 #define FILE_DEVICE_KEYBOARD 0x0000000b
1950 #define FILE_DEVICE_MAILSLOT 0x0000000c
1951 #define FILE_DEVICE_MIDI_IN 0x0000000d
1952 #define FILE_DEVICE_MIDI_OUT 0x0000000e
1953 #define FILE_DEVICE_MOUSE 0x0000000f
1954 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
1955 #define FILE_DEVICE_NAMED_PIPE 0x00000011
1956 #define FILE_DEVICE_NETWORK 0x00000012
1957 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
1958 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1959 #define FILE_DEVICE_NULL 0x00000015
1960 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
1961 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
1962 #define FILE_DEVICE_PRINTER 0x00000018
1963 #define FILE_DEVICE_SCANNER 0x00000019
1964 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
1965 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
1966 #define FILE_DEVICE_SCREEN 0x0000001c
1967 #define FILE_DEVICE_SOUND 0x0000001d
1968 #define FILE_DEVICE_STREAMS 0x0000001e
1969 #define FILE_DEVICE_TAPE 0x0000001f
1970 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1971 #define FILE_DEVICE_TRANSPORT 0x00000021
1972 #define FILE_DEVICE_UNKNOWN 0x00000022
1973 #define FILE_DEVICE_VIDEO 0x00000023
1974 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1975 #define FILE_DEVICE_WAVE_IN 0x00000025
1976 #define FILE_DEVICE_WAVE_OUT 0x00000026
1977 #define FILE_DEVICE_8042_PORT 0x00000027
1978 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1979 #define FILE_DEVICE_BATTERY 0x00000029
1980 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
1981 #define FILE_DEVICE_MODEM 0x0000002b
1982 #define FILE_DEVICE_VDM 0x0000002c
1983 #define FILE_DEVICE_MASS_STORAGE 0x0000002d
1984 #define FILE_DEVICE_SMB 0x0000002e
1985 #define FILE_DEVICE_KS 0x0000002f
1986 #define FILE_DEVICE_CHANGER 0x00000030
1987 #define FILE_DEVICE_SMARTCARD 0x00000031
1988 #define FILE_DEVICE_ACPI 0x00000032
1989 #define FILE_DEVICE_DVD 0x00000033
1990 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
1991 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
1992 #define FILE_DEVICE_DFS_VOLUME 0x00000036
1993 #define FILE_DEVICE_SERENUM 0x00000037
1994 #define FILE_DEVICE_TERMSRV 0x00000038
1995 #define FILE_DEVICE_KSEC 0x00000039
1996 #define FILE_DEVICE_FIPS 0x0000003a
1997
1998 typedef struct _DEVICE_OBJECT {
1999 CSHORT Type;
2000 USHORT Size;
2001 LONG ReferenceCount;
2002 struct _DRIVER_OBJECT *DriverObject;
2003 struct _DEVICE_OBJECT *NextDevice;
2004 struct _DEVICE_OBJECT *AttachedDevice;
2005 struct _IRP *CurrentIrp;
2006 PIO_TIMER Timer;
2007 ULONG Flags;
2008 ULONG Characteristics;
2009 PVPB Vpb;
2010 PVOID DeviceExtension;
2011 DEVICE_TYPE DeviceType;
2012 CCHAR StackSize;
2013 union {
2014 LIST_ENTRY ListEntry;
2015 WAIT_CONTEXT_BLOCK Wcb;
2016 } Queue;
2017 ULONG AlignmentRequirement;
2018 KDEVICE_QUEUE DeviceQueue;
2019 KDPC Dpc;
2020 ULONG ActiveThreadCount;
2021 PSECURITY_DESCRIPTOR SecurityDescriptor;
2022 KEVENT DeviceLock;
2023 USHORT SectorSize;
2024 USHORT Spare1;
2025 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
2026 PVOID Reserved;
2027 } DEVICE_OBJECT, *PDEVICE_OBJECT;
2028
2029 typedef enum _DEVICE_RELATION_TYPE {
2030 BusRelations,
2031 EjectionRelations,
2032 PowerRelations,
2033 RemovalRelations,
2034 TargetDeviceRelation,
2035 SingleBusRelations
2036 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
2037
2038 typedef struct _DEVICE_RELATIONS {
2039 ULONG Count;
2040 PDEVICE_OBJECT Objects[1];
2041 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
2042
2043 typedef struct _SCATTER_GATHER_ELEMENT {
2044 PHYSICAL_ADDRESS Address;
2045 ULONG Length;
2046 ULONG_PTR Reserved;
2047 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
2048
2049 typedef struct _SCATTER_GATHER_LIST {
2050 ULONG NumberOfElements;
2051 ULONG_PTR Reserved;
2052 SCATTER_GATHER_ELEMENT Elements[0];
2053 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2054
2055 typedef struct _MDL {
2056 struct _MDL *Next;
2057 CSHORT Size;
2058 CSHORT MdlFlags;
2059 struct _EPROCESS *Process;
2060 PVOID MappedSystemVa;
2061 PVOID StartVa;
2062 ULONG ByteCount;
2063 ULONG ByteOffset;
2064 } MDL, *PMDL;
2065
2066 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
2067 #define MDL_PAGES_LOCKED 0x0002
2068 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
2069 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
2070 #define MDL_PARTIAL 0x0010
2071 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
2072 #define MDL_IO_PAGE_READ 0x0040
2073 #define MDL_WRITE_OPERATION 0x0080
2074 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
2075 #define MDL_FREE_EXTRA_PTES 0x0200
2076 #define MDL_IO_SPACE 0x0800
2077 #define MDL_NETWORK_HEADER 0x1000
2078 #define MDL_MAPPING_CAN_FAIL 0x2000
2079 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
2080
2081 #define MDL_MAPPING_FLAGS ( \
2082 MDL_MAPPED_TO_SYSTEM_VA | \
2083 MDL_PAGES_LOCKED | \
2084 MDL_SOURCE_IS_NONPAGED_POOL | \
2085 MDL_PARTIAL_HAS_BEEN_MAPPED | \
2086 MDL_PARENT_MAPPED_SYSTEM_VA | \
2087 MDL_SYSTEM_VA | \
2088 MDL_IO_SPACE)
2089
2090 typedef VOID
2091 (DDKAPI *PPUT_DMA_ADAPTER)(
2092 IN PDMA_ADAPTER DmaAdapter);
2093
2094 typedef PVOID
2095 (DDKAPI *PALLOCATE_COMMON_BUFFER)(
2096 IN PDMA_ADAPTER DmaAdapter,
2097 IN ULONG Length,
2098 OUT PPHYSICAL_ADDRESS LogicalAddress,
2099 IN BOOLEAN CacheEnabled);
2100
2101 typedef VOID
2102 (DDKAPI *PFREE_COMMON_BUFFER)(
2103 IN PDMA_ADAPTER DmaAdapter,
2104 IN ULONG Length,
2105 IN PHYSICAL_ADDRESS LogicalAddress,
2106 IN PVOID VirtualAddress,
2107 IN BOOLEAN CacheEnabled);
2108
2109 typedef NTSTATUS
2110 (DDKAPI *PALLOCATE_ADAPTER_CHANNEL)(
2111 IN PDMA_ADAPTER DmaAdapter,
2112 IN PDEVICE_OBJECT DeviceObject,
2113 IN ULONG NumberOfMapRegisters,
2114 IN PDRIVER_CONTROL ExecutionRoutine,
2115 IN PVOID Context);
2116
2117 typedef BOOLEAN
2118 (DDKAPI *PFLUSH_ADAPTER_BUFFERS)(
2119 IN PDMA_ADAPTER DmaAdapter,
2120 IN PMDL Mdl,
2121 IN PVOID MapRegisterBase,
2122 IN PVOID CurrentVa,
2123 IN ULONG Length,
2124 IN BOOLEAN WriteToDevice);
2125
2126 typedef VOID
2127 (DDKAPI *PFREE_ADAPTER_CHANNEL)(
2128 IN PDMA_ADAPTER DmaAdapter);
2129
2130 typedef VOID
2131 (DDKAPI *PFREE_MAP_REGISTERS)(
2132 IN PDMA_ADAPTER DmaAdapter,
2133 PVOID MapRegisterBase,
2134 ULONG NumberOfMapRegisters);
2135
2136 typedef PHYSICAL_ADDRESS
2137 (DDKAPI *PMAP_TRANSFER)(
2138 IN PDMA_ADAPTER DmaAdapter,
2139 IN PMDL Mdl,
2140 IN PVOID MapRegisterBase,
2141 IN PVOID CurrentVa,
2142 IN OUT PULONG Length,
2143 IN BOOLEAN WriteToDevice);
2144
2145 typedef ULONG
2146 (DDKAPI *PGET_DMA_ALIGNMENT)(
2147 IN PDMA_ADAPTER DmaAdapter);
2148
2149 typedef ULONG
2150 (DDKAPI *PREAD_DMA_COUNTER)(
2151 IN PDMA_ADAPTER DmaAdapter);
2152
2153 typedef NTSTATUS
2154 (DDKAPI *PGET_SCATTER_GATHER_LIST)(
2155 IN PDMA_ADAPTER DmaAdapter,
2156 IN PDEVICE_OBJECT DeviceObject,
2157 IN PMDL Mdl,
2158 IN PVOID CurrentVa,
2159 IN ULONG Length,
2160 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2161 IN PVOID Context,
2162 IN BOOLEAN WriteToDevice);
2163
2164 typedef VOID
2165 (DDKAPI *PPUT_SCATTER_GATHER_LIST)(
2166 IN PDMA_ADAPTER DmaAdapter,
2167 IN PSCATTER_GATHER_LIST ScatterGather,
2168 IN BOOLEAN WriteToDevice);
2169
2170 typedef NTSTATUS
2171 (DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
2172 IN PDMA_ADAPTER DmaAdapter,
2173 IN PMDL Mdl OPTIONAL,
2174 IN PVOID CurrentVa,
2175 IN ULONG Length,
2176 OUT PULONG ScatterGatherListSize,
2177 OUT PULONG pNumberOfMapRegisters OPTIONAL);
2178
2179 typedef NTSTATUS
2180 (DDKAPI *PBUILD_SCATTER_GATHER_LIST)(
2181 IN PDMA_ADAPTER DmaAdapter,
2182 IN PDEVICE_OBJECT DeviceObject,
2183 IN PMDL Mdl,
2184 IN PVOID CurrentVa,
2185 IN ULONG Length,
2186 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2187 IN PVOID Context,
2188 IN BOOLEAN WriteToDevice,
2189 IN PVOID ScatterGatherBuffer,
2190 IN ULONG ScatterGatherLength);
2191
2192 typedef NTSTATUS
2193 (DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
2194 IN PDMA_ADAPTER DmaAdapter,
2195 IN PSCATTER_GATHER_LIST ScatterGather,
2196 IN PMDL OriginalMdl,
2197 OUT PMDL *TargetMdl);
2198
2199 typedef struct _DMA_OPERATIONS {
2200 ULONG Size;
2201 PPUT_DMA_ADAPTER PutDmaAdapter;
2202 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
2203 PFREE_COMMON_BUFFER FreeCommonBuffer;
2204 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
2205 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
2206 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
2207 PFREE_MAP_REGISTERS FreeMapRegisters;
2208 PMAP_TRANSFER MapTransfer;
2209 PGET_DMA_ALIGNMENT GetDmaAlignment;
2210 PREAD_DMA_COUNTER ReadDmaCounter;
2211 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
2212 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
2213 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
2214 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
2215 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
2216 } DMA_OPERATIONS, *PDMA_OPERATIONS;
2217
2218 typedef struct _DMA_ADAPTER {
2219 USHORT Version;
2220 USHORT Size;
2221 PDMA_OPERATIONS DmaOperations;
2222 } DMA_ADAPTER;
2223
2224
2225 typedef enum _ARBITER_REQUEST_SOURCE {
2226 ArbiterRequestUndefined = -1,
2227 ArbiterRequestLegacyReported,
2228 ArbiterRequestHalReported,
2229 ArbiterRequestLegacyAssigned,
2230 ArbiterRequestPnpDetected,
2231 ArbiterRequestPnpEnumerated
2232 } ARBITER_REQUEST_SOURCE;
2233
2234 typedef enum _ARBITER_RESULT {
2235 ArbiterResultUndefined = -1,
2236 ArbiterResultSuccess,
2237 ArbiterResultExternalConflict,
2238 ArbiterResultNullRequest
2239 } ARBITER_RESULT;
2240
2241 typedef enum _ARBITER_ACTION {
2242 ArbiterActionTestAllocation,
2243 ArbiterActionRetestAllocation,
2244 ArbiterActionCommitAllocation,
2245 ArbiterActionRollbackAllocation,
2246 ArbiterActionQueryAllocatedResources,
2247 ArbiterActionWriteReservedResources,
2248 ArbiterActionQueryConflict,
2249 ArbiterActionQueryArbitrate,
2250 ArbiterActionAddReserved,
2251 ArbiterActionBootAllocation
2252 } ARBITER_ACTION, *PARBITER_ACTION;
2253
2254 typedef struct _ARBITER_CONFLICT_INFO {
2255 PDEVICE_OBJECT OwningObject;
2256 ULONGLONG Start;
2257 ULONGLONG End;
2258 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
2259
2260 typedef struct _ARBITER_PARAMETERS {
2261 union {
2262 struct {
2263 IN OUT PLIST_ENTRY ArbitrationList;
2264 IN ULONG AllocateFromCount;
2265 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
2266 } TestAllocation;
2267
2268 struct {
2269 IN OUT PLIST_ENTRY ArbitrationList;
2270 IN ULONG AllocateFromCount;
2271 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
2272 } RetestAllocation;
2273
2274 struct {
2275 IN OUT PLIST_ENTRY ArbitrationList;
2276 } BootAllocation;
2277
2278 struct {
2279 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
2280 } QueryAllocatedResources;
2281
2282 struct {
2283 IN PDEVICE_OBJECT PhysicalDeviceObject;
2284 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
2285 OUT PULONG ConflictCount;
2286 OUT PARBITER_CONFLICT_INFO *Conflicts;
2287 } QueryConflict;
2288
2289 struct {
2290 IN PLIST_ENTRY ArbitrationList;
2291 } QueryArbitrate;
2292
2293 struct {
2294 IN PDEVICE_OBJECT ReserveDevice;
2295 } AddReserved;
2296 } Parameters;
2297 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
2298
2299 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
2300
2301 typedef struct _ARBITER_LIST_ENTRY {
2302 LIST_ENTRY ListEntry;
2303 ULONG AlternativeCount;
2304 PIO_RESOURCE_DESCRIPTOR Alternatives;
2305 PDEVICE_OBJECT PhysicalDeviceObject;
2306 ARBITER_REQUEST_SOURCE RequestSource;
2307 ULONG Flags;
2308 LONG_PTR WorkSpace;
2309 INTERFACE_TYPE InterfaceType;
2310 ULONG SlotNumber;
2311 ULONG BusNumber;
2312 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
2313 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
2314 ARBITER_RESULT Result;
2315 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
2316
2317 typedef NTSTATUS
2318 (DDKAPI *PARBITER_HANDLER)(
2319 IN PVOID Context,
2320 IN ARBITER_ACTION Action,
2321 IN OUT PARBITER_PARAMETERS Parameters);
2322
2323 #define ARBITER_PARTIAL 0x00000001
2324
2325 typedef struct _ARBITER_INTERFACE {
2326 USHORT Size;
2327 USHORT Version;
2328 PVOID Context;
2329 PINTERFACE_REFERENCE InterfaceReference;
2330 PINTERFACE_DEREFERENCE InterfaceDereference;
2331 PARBITER_HANDLER ArbiterHandler;
2332 ULONG Flags;
2333 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
2334
2335 typedef enum _HAL_QUERY_INFORMATION_CLASS {
2336 HalInstalledBusInformation,
2337 HalProfileSourceInformation,
2338 HalInformationClassUnused1,
2339 HalPowerInformation,
2340 HalProcessorSpeedInformation,
2341 HalCallbackInformation,
2342 HalMapRegisterInformation,
2343 HalMcaLogInformation,
2344 HalFrameBufferCachingInformation,
2345 HalDisplayBiosInformation,
2346 HalProcessorFeatureInformation,
2347 HalNumaTopologyInterface,
2348 HalErrorInformation,
2349 HalCmcLogInformation,
2350 HalCpeLogInformation,
2351 HalQueryMcaInterface,
2352 HalQueryAMLIIllegalIOPortAddresses,
2353 HalQueryMaxHotPlugMemoryAddress,
2354 HalPartitionIpiInterface,
2355 HalPlatformInformation,
2356 HalQueryProfileSourceList
2357 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
2358
2359 typedef enum _HAL_SET_INFORMATION_CLASS {
2360 HalProfileSourceInterval,
2361 HalProfileSourceInterruptHandler,
2362 HalMcaRegisterDriver,
2363 HalKernelErrorHandler,
2364 HalCmcRegisterDriver,
2365 HalCpeRegisterDriver,
2366 HalMcaLog,
2367 HalCmcLog,
2368 HalCpeLog,
2369 HalGenerateCmcInterrupt
2370 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
2371
2372 /* Function Type Defintions for Dispatch Functions */
2373
2374 typedef VOID
2375 (DDKAPI *PDEVICE_CONTROL_COMPLETION)(
2376 IN struct _DEVICE_CONTROL_CONTEXT *ControlContext);
2377
2378 typedef struct _DEVICE_CONTROL_CONTEXT {
2379 NTSTATUS Status;
2380 PDEVICE_HANDLER_OBJECT DeviceHandler;
2381 PDEVICE_OBJECT DeviceObject;
2382 ULONG ControlCode;
2383 PVOID Buffer;
2384 PULONG BufferLength;
2385 PVOID Context;
2386 } DEVICE_CONTROL_CONTEXT, *PDEVICE_CONTROL_CONTEXT;
2387
2388 typedef struct _PM_DISPATCH_TABLE {
2389 ULONG Signature;
2390 ULONG Version;
2391 PVOID Function[1];
2392 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
2393
2394 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
2395 TranslateChildToParent,
2396 TranslateParentToChild
2397 } RESOURCE_TRANSLATION_DIRECTION;
2398
2399 typedef NTSTATUS
2400 (DDKAPI *PTRANSLATE_RESOURCE_HANDLER)(
2401 IN PVOID Context,
2402 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
2403 IN RESOURCE_TRANSLATION_DIRECTION Direction,
2404 IN ULONG AlternativesCount,
2405 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
2406 IN PDEVICE_OBJECT PhysicalDeviceObject,
2407 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
2408
2409 typedef NTSTATUS
2410 (DDKAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
2411 IN PVOID Context,
2412 IN PIO_RESOURCE_DESCRIPTOR Source,
2413 IN PDEVICE_OBJECT PhysicalDeviceObject,
2414 OUT PULONG TargetCount,
2415 OUT PIO_RESOURCE_DESCRIPTOR *Target);
2416
2417 typedef struct _TRANSLATOR_INTERFACE {
2418 USHORT Size;
2419 USHORT Version;
2420 PVOID Context;
2421 PINTERFACE_REFERENCE InterfaceReference;
2422 PINTERFACE_DEREFERENCE InterfaceDereference;
2423 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
2424 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
2425 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
2426
2427 typedef NTSTATUS
2428 (DDKAPI *pHalDeviceControl)(
2429 IN PDEVICE_HANDLER_OBJECT DeviceHandler,
2430 IN PDEVICE_OBJECT DeviceObject,
2431 IN ULONG ControlCode,
2432 IN OUT PVOID Buffer OPTIONAL,
2433 IN OUT PULONG BufferLength OPTIONAL,
2434 IN PVOID Context,
2435 IN PDEVICE_CONTROL_COMPLETION CompletionRoutine);
2436
2437 typedef VOID
2438 (DDKFASTAPI *pHalExamineMBR)(
2439 IN PDEVICE_OBJECT DeviceObject,
2440 IN ULONG SectorSize,
2441 IN ULONG MBRTypeIdentifier,
2442 OUT PVOID *Buffer);
2443
2444 typedef VOID
2445 (DDKFASTAPI *pHalIoAssignDriveLetters)(
2446 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2447 IN PSTRING NtDeviceName,
2448 OUT PUCHAR NtSystemPath,
2449 OUT PSTRING NtSystemPathString);
2450
2451 typedef NTSTATUS
2452 (DDKFASTAPI *pHalIoReadPartitionTable)(
2453 IN PDEVICE_OBJECT DeviceObject,
2454 IN ULONG SectorSize,
2455 IN BOOLEAN ReturnRecognizedPartitions,
2456 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2457
2458 typedef NTSTATUS
2459 (DDKFASTAPI *pHalIoSetPartitionInformation)(
2460 IN PDEVICE_OBJECT DeviceObject,
2461 IN ULONG SectorSize,
2462 IN ULONG PartitionNumber,
2463 IN ULONG PartitionType);
2464
2465 typedef NTSTATUS
2466 (DDKFASTAPI *pHalIoWritePartitionTable)(
2467 IN PDEVICE_OBJECT DeviceObject,
2468 IN ULONG SectorSize,
2469 IN ULONG SectorsPerTrack,
2470 IN ULONG NumberOfHeads,
2471 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
2472
2473 typedef PBUS_HANDLER
2474 (DDKFASTAPI *pHalHandlerForBus)(
2475 IN INTERFACE_TYPE InterfaceType,
2476 IN ULONG BusNumber);
2477
2478 typedef VOID
2479 (DDKFASTAPI *pHalReferenceBusHandler)(
2480 IN PBUS_HANDLER BusHandler);
2481
2482 typedef NTSTATUS
2483 (DDKAPI *pHalQuerySystemInformation)(
2484 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
2485 IN ULONG BufferSize,
2486 IN OUT PVOID Buffer,
2487 OUT PULONG ReturnedLength);
2488
2489 typedef NTSTATUS
2490 (DDKAPI *pHalSetSystemInformation)(
2491 IN HAL_SET_INFORMATION_CLASS InformationClass,
2492 IN ULONG BufferSize,
2493 IN PVOID Buffer);
2494
2495 typedef NTSTATUS
2496 (DDKAPI *pHalQueryBusSlots)(
2497 IN PBUS_HANDLER BusHandler,
2498 IN ULONG BufferSize,
2499 OUT PULONG SlotNumbers,
2500 OUT PULONG ReturnedLength);
2501
2502 typedef NTSTATUS
2503 (DDKAPI *pHalInitPnpDriver)(
2504 VOID);
2505
2506 typedef NTSTATUS
2507 (DDKAPI *pHalInitPowerManagement)(
2508 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
2509 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
2510
2511 typedef struct _DMA_ADAPTER*
2512 (DDKAPI *pHalGetDmaAdapter)(
2513 IN PVOID Context,
2514 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
2515 OUT PULONG NumberOfMapRegisters);
2516
2517 typedef NTSTATUS
2518 (DDKAPI *pHalGetInterruptTranslator)(
2519 IN INTERFACE_TYPE ParentInterfaceType,
2520 IN ULONG ParentBusNumber,
2521 IN INTERFACE_TYPE BridgeInterfaceType,
2522 IN USHORT Size,
2523 IN USHORT Version,
2524 OUT PTRANSLATOR_INTERFACE Translator,
2525 OUT PULONG BridgeBusNumber);
2526
2527 typedef NTSTATUS
2528 (DDKAPI *pHalStartMirroring)(
2529 VOID);
2530
2531 typedef NTSTATUS
2532 (DDKAPI *pHalEndMirroring)(
2533 IN ULONG PassNumber);
2534
2535 typedef NTSTATUS
2536 (DDKAPI *pHalMirrorPhysicalMemory)(
2537 IN PHYSICAL_ADDRESS PhysicalAddress,
2538 IN LARGE_INTEGER NumberOfBytes);
2539
2540 typedef NTSTATUS
2541 (DDKAPI *pHalMirrorVerify)(
2542 IN PHYSICAL_ADDRESS PhysicalAddress,
2543 IN LARGE_INTEGER NumberOfBytes);
2544
2545 typedef VOID
2546 (DDKAPI *pHalEndOfBoot)(
2547 VOID);
2548
2549 typedef BOOLEAN
2550 (DDKAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
2551 ULONG Columns, ULONG Rows);
2552
2553 typedef struct {
2554 ULONG Version;
2555 pHalQuerySystemInformation HalQuerySystemInformation;
2556 pHalSetSystemInformation HalSetSystemInformation;
2557 pHalQueryBusSlots HalQueryBusSlots;
2558 ULONG Spare1;
2559 pHalExamineMBR HalExamineMBR;
2560 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
2561 pHalIoReadPartitionTable HalIoReadPartitionTable;
2562 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
2563 pHalIoWritePartitionTable HalIoWritePartitionTable;
2564 pHalHandlerForBus HalReferenceHandlerForBus;
2565 pHalReferenceBusHandler HalReferenceBusHandler;
2566 pHalReferenceBusHandler HalDereferenceBusHandler;
2567 pHalInitPnpDriver HalInitPnpDriver;
2568 pHalInitPowerManagement HalInitPowerManagement;
2569 pHalGetDmaAdapter HalGetDmaAdapter;
2570 pHalGetInterruptTranslator HalGetInterruptTranslator;
2571 pHalStartMirroring HalStartMirroring;
2572 pHalEndMirroring HalEndMirroring;
2573 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
2574 pHalEndOfBoot HalEndOfBoot;
2575 pHalMirrorVerify HalMirrorVerify;
2576 } HAL_DISPATCH, *PHAL_DISPATCH;
2577
2578 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTHAL_)
2579 extern DECL_IMPORT PHAL_DISPATCH HalDispatchTable;
2580 #define HALDISPATCH ((PHAL_DISPATCH)&HalDispatchTable)
2581 #else
2582 extern DECL_EXPORT HAL_DISPATCH HalDispatchTable;
2583 #define HALDISPATCH (&HalDispatchTable)
2584 #endif
2585
2586 #define HAL_DISPATCH_VERSION 3
2587 #define HalDispatchTableVersion HALDISPATCH->Version
2588 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
2589 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
2590 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
2591 #define HalDeviceControl HALDISPATCH->HalDeviceControl
2592 #define HalIoAssignDriveLetters HALDISPATCH->HalIoAssignDriveLetters
2593 #define HalIoReadPartitionTable HALDISPATCH->HalIoReadPartitionTable
2594 #define HalIoSetPartitionInformation HALDISPATCH->HalIoSetPartitionInformation
2595 #define HalIoWritePartitionTable HALDISPATCH->HalIoWritePartitionTable
2596 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
2597 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
2598 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
2599 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
2600 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
2601 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
2602 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
2603 #define HalStartMirroring HALDISPATCH->HalStartMirroring
2604 #define HalEndMirroring HALDISPATCH->HalEndMirroring
2605 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
2606 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
2607 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
2608
2609 typedef enum _FILE_INFORMATION_CLASS {
2610 FileDirectoryInformation = 1,
2611 FileFullDirectoryInformation,
2612 FileBothDirectoryInformation,
2613 FileBasicInformation,
2614 FileStandardInformation,
2615 FileInternalInformation,
2616 FileEaInformation,
2617 FileAccessInformation,
2618 FileNameInformation,
2619 FileRenameInformation,
2620 FileLinkInformation,
2621 FileNamesInformation,
2622 FileDispositionInformation,
2623 FilePositionInformation,
2624 FileFullEaInformation,
2625 FileModeInformation,
2626 FileAlignmentInformation,
2627 FileAllInformation,
2628 FileAllocationInformation,
2629 FileEndOfFileInformation,
2630 FileAlternateNameInformation,
2631 FileStreamInformation,
2632 FilePipeInformation,
2633 FilePipeLocalInformation,
2634 FilePipeRemoteInformation,
2635 FileMailslotQueryInformation,
2636 FileMailslotSetInformation,
2637 FileCompressionInformation,
2638 FileObjectIdInformation,
2639 FileCompletionInformation,
2640 FileMoveClusterInformation,
2641 FileQuotaInformation,
2642 FileReparsePointInformation,
2643 FileNetworkOpenInformation,
2644 FileAttributeTagInformation,
2645 FileTrackingInformation,
2646 FileIdBothDirectoryInformation,
2647 FileIdFullDirectoryInformation,
2648 FileValidDataLengthInformation,
2649 FileShortNameInformation,
2650 FileMaximumInformation
2651 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
2652
2653 typedef struct _FILE_POSITION_INFORMATION {
2654 LARGE_INTEGER CurrentByteOffset;
2655 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
2656
2657 typedef struct _FILE_ALIGNMENT_INFORMATION {
2658 ULONG AlignmentRequirement;
2659 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
2660
2661 typedef struct _FILE_NAME_INFORMATION {
2662 ULONG FileNameLength;
2663 WCHAR FileName[1];
2664 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
2665
2666 #include <pshpack8.h>
2667 typedef struct _FILE_BASIC_INFORMATION {
2668 LARGE_INTEGER CreationTime;
2669 LARGE_INTEGER LastAccessTime;
2670 LARGE_INTEGER LastWriteTime;
2671 LARGE_INTEGER ChangeTime;
2672 ULONG FileAttributes;
2673 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
2674 #include <poppack.h>
2675
2676 typedef struct _FILE_STANDARD_INFORMATION {
2677 LARGE_INTEGER AllocationSize;
2678 LARGE_INTEGER EndOfFile;
2679 ULONG NumberOfLinks;
2680 BOOLEAN DeletePending;
2681 BOOLEAN Directory;
2682 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
2683
2684 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
2685 LARGE_INTEGER CreationTime;
2686 LARGE_INTEGER LastAccessTime;
2687 LARGE_INTEGER LastWriteTime;
2688 LARGE_INTEGER ChangeTime;
2689 LARGE_INTEGER AllocationSize;
2690 LARGE_INTEGER EndOfFile;
2691 ULONG FileAttributes;
2692 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
2693
2694 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
2695 ULONG FileAttributes;
2696 ULONG ReparseTag;
2697 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
2698
2699 typedef struct _FILE_DISPOSITION_INFORMATION {
2700 BOOLEAN DeleteFile;
2701 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
2702
2703 typedef struct _FILE_END_OF_FILE_INFORMATION {
2704 LARGE_INTEGER EndOfFile;
2705 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
2706
2707 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
2708 LARGE_INTEGER ValidDataLength;
2709 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
2710
2711 typedef enum _FSINFOCLASS {
2712 FileFsVolumeInformation = 1,
2713 FileFsLabelInformation,
2714 FileFsSizeInformation,
2715 FileFsDeviceInformation,
2716 FileFsAttributeInformation,
2717 FileFsControlInformation,
2718 FileFsFullSizeInformation,
2719 FileFsObjectIdInformation,
2720 FileFsDriverPathInformation,
2721 FileFsMaximumInformation
2722 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
2723
2724 typedef struct _FILE_FS_DEVICE_INFORMATION {
2725 DEVICE_TYPE DeviceType;
2726 ULONG Characteristics;
2727 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
2728
2729 typedef struct _FILE_FULL_EA_INFORMATION {
2730 ULONG NextEntryOffset;
2731 UCHAR Flags;
2732 UCHAR EaNameLength;
2733 USHORT EaValueLength;
2734 CHAR EaName[1];
2735 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
2736
2737 typedef ULONG_PTR ERESOURCE_THREAD;
2738 typedef ERESOURCE_THREAD *PERESOURCE_THREAD;
2739
2740 typedef struct _OWNER_ENTRY {
2741 ERESOURCE_THREAD OwnerThread;
2742 _ANONYMOUS_UNION union {
2743 LONG OwnerCount;
2744 ULONG TableSize;
2745 } DUMMYUNIONNAME;
2746 } OWNER_ENTRY, *POWNER_ENTRY;
2747
2748 /* ERESOURCE.Flag */
2749
2750 #define ResourceNeverExclusive 0x0010
2751 #define ResourceReleaseByOtherThread 0x0020
2752 #define ResourceOwnedExclusive 0x0080
2753
2754 #define RESOURCE_HASH_TABLE_SIZE 64
2755
2756 typedef struct _ERESOURCE {
2757 LIST_ENTRY SystemResourcesList;
2758 POWNER_ENTRY OwnerTable;
2759 SHORT ActiveCount;
2760 USHORT Flag;
2761 PKSEMAPHORE SharedWaiters;
2762 PKEVENT ExclusiveWaiters;
2763 OWNER_ENTRY OwnerThreads[2];
2764 ULONG ContentionCount;
2765 USHORT NumberOfSharedWaiters;
2766 USHORT NumberOfExclusiveWaiters;
2767 _ANONYMOUS_UNION union {
2768 PVOID Address;
2769 ULONG_PTR CreatorBackTraceIndex;
2770 } DUMMYUNIONNAME;
2771 KSPIN_LOCK SpinLock;
2772 } ERESOURCE, *PERESOURCE;
2773
2774 typedef struct _DEVOBJ_EXTENSION
2775 {
2776 CSHORT Type;
2777 USHORT Size;
2778 PDEVICE_OBJECT DeviceObject;
2779 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
2780
2781 typedef struct _DRIVER_EXTENSION {
2782 struct _DRIVER_OBJECT *DriverObject;
2783 PDRIVER_ADD_DEVICE AddDevice;
2784 ULONG Count;
2785 UNICODE_STRING ServiceKeyName;
2786 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
2787
2788 typedef BOOLEAN
2789 (DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
2790 IN struct _FILE_OBJECT *FileObject,
2791 IN PLARGE_INTEGER FileOffset,
2792 IN ULONG Length,
2793 IN BOOLEAN Wait,
2794 IN ULONG LockKey,
2795 IN BOOLEAN CheckForReadOperation,
2796 OUT PIO_STATUS_BLOCK IoStatus,
2797 IN struct _DEVICE_OBJECT *DeviceObject);
2798
2799 typedef BOOLEAN
2800 (DDKAPI *PFAST_IO_READ)(
2801 IN struct _FILE_OBJECT *FileObject,
2802 IN PLARGE_INTEGER FileOffset,
2803 IN ULONG Length,
2804 IN BOOLEAN Wait,
2805 IN ULONG LockKey,
2806 OUT PVOID Buffer,
2807 OUT PIO_STATUS_BLOCK IoStatus,
2808 IN struct _DEVICE_OBJECT *DeviceObject);
2809
2810 typedef BOOLEAN
2811 (DDKAPI *PFAST_IO_WRITE)(
2812 IN struct _FILE_OBJECT *FileObject,
2813 IN PLARGE_INTEGER FileOffset,
2814 IN ULONG Length,
2815 IN BOOLEAN Wait,
2816 IN ULONG LockKey,
2817 IN PVOID Buffer,
2818 OUT PIO_STATUS_BLOCK IoStatus,
2819 IN struct _DEVICE_OBJECT *DeviceObject);
2820
2821 typedef BOOLEAN
2822 (DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
2823 IN struct _FILE_OBJECT *FileObject,
2824 IN BOOLEAN Wait,
2825 OUT PFILE_BASIC_INFORMATION Buffer,
2826 OUT PIO_STATUS_BLOCK IoStatus,
2827 IN struct _DEVICE_OBJECT *DeviceObject);
2828
2829 typedef BOOLEAN
2830 (DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
2831 IN struct _FILE_OBJECT *FileObject,
2832 IN BOOLEAN Wait,
2833 OUT PFILE_STANDARD_INFORMATION Buffer,
2834 OUT PIO_STATUS_BLOCK IoStatus,
2835 IN struct _DEVICE_OBJECT *DeviceObject);
2836
2837 typedef BOOLEAN
2838 (DDKAPI *PFAST_IO_LOCK)(
2839 IN struct _FILE_OBJECT *FileObject,
2840 IN PLARGE_INTEGER FileOffset,
2841 IN PLARGE_INTEGER Length,
2842 PEPROCESS ProcessId,
2843 ULONG Key,
2844 BOOLEAN FailImmediately,
2845 BOOLEAN ExclusiveLock,
2846 OUT PIO_STATUS_BLOCK IoStatus,
2847 IN struct _DEVICE_OBJECT *DeviceObject);
2848
2849 typedef BOOLEAN
2850 (DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
2851 IN struct _FILE_OBJECT *FileObject,
2852 IN PLARGE_INTEGER FileOffset,
2853 IN PLARGE_INTEGER Length,
2854 PEPROCESS ProcessId,
2855 ULONG Key,
2856 OUT PIO_STATUS_BLOCK IoStatus,
2857 IN struct _DEVICE_OBJECT *DeviceObject);
2858
2859 typedef BOOLEAN
2860 (DDKAPI *PFAST_IO_UNLOCK_ALL)(
2861 IN struct _FILE_OBJECT *FileObject,
2862 PEPROCESS ProcessId,
2863 OUT PIO_STATUS_BLOCK IoStatus,
2864 IN struct _DEVICE_OBJECT *DeviceObject);
2865
2866 typedef BOOLEAN
2867 (DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
2868 IN struct _FILE_OBJECT *FileObject,
2869 PEPROCESS ProcessId,
2870 ULONG Key,
2871 OUT PIO_STATUS_BLOCK IoStatus,
2872 IN struct _DEVICE_OBJECT *DeviceObject);
2873
2874 typedef BOOLEAN
2875 (DDKAPI *PFAST_IO_DEVICE_CONTROL)(
2876 IN struct _FILE_OBJECT *FileObject,
2877 IN BOOLEAN Wait,
2878 IN PVOID InputBuffer OPTIONAL,
2879 IN ULONG InputBufferLength,
2880 OUT PVOID OutputBuffer OPTIONAL,
2881 IN ULONG OutputBufferLength,
2882 IN ULONG IoControlCode,
2883 OUT PIO_STATUS_BLOCK IoStatus,
2884 IN struct _DEVICE_OBJECT *DeviceObject);
2885
2886 typedef VOID
2887 (DDKAPI *PFAST_IO_ACQUIRE_FILE)(
2888 IN struct _FILE_OBJECT *FileObject);
2889
2890 typedef VOID
2891 (DDKAPI *PFAST_IO_RELEASE_FILE)(
2892 IN struct _FILE_OBJECT *FileObject);
2893
2894 typedef VOID
2895 (DDKAPI *PFAST_IO_DETACH_DEVICE)(
2896 IN struct _DEVICE_OBJECT *SourceDevice,
2897 IN struct _DEVICE_OBJECT *TargetDevice);
2898
2899 typedef BOOLEAN
2900 (DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
2901 IN struct _FILE_OBJECT *FileObject,
2902 IN BOOLEAN Wait,
2903 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
2904 OUT struct _IO_STATUS_BLOCK *IoStatus,
2905 IN struct _DEVICE_OBJECT *DeviceObject);
2906
2907 typedef NTSTATUS
2908 (DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
2909 IN struct _FILE_OBJECT *FileObject,
2910 IN PLARGE_INTEGER EndingOffset,
2911 OUT struct _ERESOURCE **ResourceToRelease,
2912 IN struct _DEVICE_OBJECT *DeviceObject);
2913
2914 typedef BOOLEAN
2915 (DDKAPI *PFAST_IO_MDL_READ)(
2916 IN struct _FILE_OBJECT *FileObject,
2917 IN PLARGE_INTEGER FileOffset,
2918 IN ULONG Length,
2919 IN ULONG LockKey,
2920 OUT PMDL *MdlChain,
2921 OUT PIO_STATUS_BLOCK IoStatus,
2922 IN struct _DEVICE_OBJECT *DeviceObject);
2923
2924 typedef BOOLEAN
2925 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
2926 IN struct _FILE_OBJECT *FileObject,
2927 IN PMDL MdlChain,
2928 IN struct _DEVICE_OBJECT *DeviceObject);
2929
2930 typedef BOOLEAN
2931 (DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
2932 IN struct _FILE_OBJECT *FileObject,
2933 IN PLARGE_INTEGER FileOffset,
2934 IN ULONG Length,
2935 IN ULONG LockKey,
2936 OUT PMDL *MdlChain,
2937 OUT PIO_STATUS_BLOCK IoStatus,
2938 IN struct _DEVICE_OBJECT *DeviceObject);
2939
2940 typedef BOOLEAN
2941 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
2942 IN struct _FILE_OBJECT *FileObject,
2943 IN PLARGE_INTEGER FileOffset,
2944 IN PMDL MdlChain,
2945 IN struct _DEVICE_OBJECT *DeviceObject);
2946
2947 typedef BOOLEAN
2948 (DDKAPI *PFAST_IO_READ_COMPRESSED)(
2949 IN struct _FILE_OBJECT *FileObject,
2950 IN PLARGE_INTEGER FileOffset,
2951 IN ULONG Length,
2952 IN ULONG LockKey,
2953 OUT PVOID Buffer,
2954 OUT PMDL *MdlChain,
2955 OUT PIO_STATUS_BLOCK IoStatus,
2956 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
2957 IN ULONG CompressedDataInfoLength,
2958 IN struct _DEVICE_OBJECT *DeviceObject);
2959
2960 typedef BOOLEAN
2961 (DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
2962 IN struct _FILE_OBJECT *FileObject,
2963 IN PLARGE_INTEGER FileOffset,
2964 IN ULONG Length,
2965 IN ULONG LockKey,
2966 IN PVOID Buffer,
2967 OUT PMDL *MdlChain,
2968 OUT PIO_STATUS_BLOCK IoStatus,
2969 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
2970 IN ULONG CompressedDataInfoLength,
2971 IN struct _DEVICE_OBJECT *DeviceObject);
2972
2973 typedef BOOLEAN
2974 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
2975 IN struct _FILE_OBJECT *FileObject,
2976 IN PMDL MdlChain,
2977 IN struct _DEVICE_OBJECT *DeviceObject);
2978
2979 typedef BOOLEAN
2980 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
2981 IN struct _FILE_OBJECT *FileObject,
2982 IN PLARGE_INTEGER FileOffset,
2983 IN PMDL MdlChain,
2984 IN struct _DEVICE_OBJECT *DeviceObject);
2985
2986 typedef BOOLEAN
2987 (DDKAPI *PFAST_IO_QUERY_OPEN)(
2988 IN struct _IRP *Irp,
2989 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
2990 IN struct _DEVICE_OBJECT *DeviceObject);
2991
2992 typedef NTSTATUS
2993 (DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
2994 IN struct _FILE_OBJECT *FileObject,
2995 IN struct _ERESOURCE *ResourceToRelease,
2996 IN struct _DEVICE_OBJECT *DeviceObject);
2997
2998 typedef NTSTATUS
2999 (DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
3000 IN struct _FILE_OBJECT *FileObject,
3001 IN struct _DEVICE_OBJECT *DeviceObject);
3002
3003 typedef NTSTATUS
3004 (DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
3005 IN struct _FILE_OBJECT *FileObject,
3006 IN struct _DEVICE_OBJECT *DeviceObject);
3007
3008 typedef struct _FAST_IO_DISPATCH {
3009 ULONG SizeOfFastIoDispatch;
3010 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
3011 PFAST_IO_READ FastIoRead;
3012 PFAST_IO_WRITE FastIoWrite;
3013 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
3014 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
3015 PFAST_IO_LOCK FastIoLock;
3016 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
3017 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
3018 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
3019 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
3020 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
3021 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
3022 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
3023 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
3024 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
3025 PFAST_IO_MDL_READ MdlRead;
3026 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
3027 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
3028 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
3029 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
3030 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
3031 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
3032 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
3033 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
3034 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
3035 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
3036 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
3037 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
3038
3039 #define DRVO_UNLOAD_INVOKED 0x00000001
3040 #define DRVO_LEGACY_DRIVER 0x00000002
3041 #define DRVO_BUILTIN_DRIVER 0x00000004
3042 #define DRVO_REINIT_REGISTERED 0x00000008
3043 #define DRVO_INITIALIZED 0x00000010
3044 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
3045 #define DRVO_LEGACY_RESOURCES 0x00000040
3046
3047 typedef struct _DRIVER_OBJECT {
3048 CSHORT Type;
3049 CSHORT Size;
3050 PDEVICE_OBJECT DeviceObject;
3051 ULONG Flags;
3052 PVOID DriverStart;
3053 ULONG DriverSize;
3054 PVOID DriverSection;
3055 PDRIVER_EXTENSION DriverExtension;
3056 UNICODE_STRING DriverName;
3057 PUNICODE_STRING HardwareDatabase;
3058 PFAST_IO_DISPATCH FastIoDispatch;
3059 PDRIVER_INITIALIZE DriverInit;
3060 PDRIVER_STARTIO DriverStartIo;
3061 PDRIVER_UNLOAD DriverUnload;
3062 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
3063 } DRIVER_OBJECT;
3064 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
3065
3066 typedef struct _SECTION_OBJECT_POINTERS {
3067 PVOID DataSectionObject;
3068 PVOID SharedCacheMap;
3069 PVOID ImageSectionObject;
3070 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
3071
3072 typedef struct _IO_COMPLETION_CONTEXT {
3073 PVOID Port;
3074 PVOID Key;
3075 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
3076
3077 /* FILE_OBJECT.Flags */
3078
3079 #define FO_FILE_OPEN 0x00000001
3080 #define FO_SYNCHRONOUS_IO 0x00000002
3081 #define FO_ALERTABLE_IO 0x00000004
3082 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
3083 #define FO_WRITE_THROUGH 0x00000010
3084 #define FO_SEQUENTIAL_ONLY 0x00000020
3085 #define FO_CACHE_SUPPORTED 0x00000040
3086 #define FO_NAMED_PIPE 0x00000080
3087 #define FO_STREAM_FILE 0x00000100
3088 #define FO_MAILSLOT 0x00000200
3089 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
3090 #define FO_DIRECT_DEVICE_OPEN 0x00000800
3091 #define FO_FILE_MODIFIED 0x00001000
3092 #define FO_FILE_SIZE_CHANGED 0x00002000
3093 #define FO_CLEANUP_COMPLETE 0x00004000
3094 #define FO_TEMPORARY_FILE 0x00008000
3095 #define FO_DELETE_ON_CLOSE 0x00010000
3096 #define FO_OPENED_CASE_SENSITIVE 0x00020000
3097 #define FO_HANDLE_CREATED 0x00040000
3098 #define FO_FILE_FAST_IO_READ 0x00080000
3099 #define FO_RANDOM_ACCESS 0x00100000
3100 #define FO_FILE_OPEN_CANCELLED 0x00200000
3101 #define FO_VOLUME_OPEN 0x00400000
3102 #define FO_FILE_OBJECT_HAS_EXTENSION 0x00800000
3103 #define FO_REMOTE_ORIGIN 0x01000000
3104
3105 typedef struct _FILE_OBJECT {
3106 CSHORT Type;
3107 CSHORT Size;
3108 PDEVICE_OBJECT DeviceObject;
3109 PVPB Vpb;
3110 PVOID FsContext;
3111 PVOID FsContext2;
3112 PSECTION_OBJECT_POINTERS SectionObjectPointer;
3113 PVOID PrivateCacheMap;
3114 NTSTATUS FinalStatus;
3115 struct _FILE_OBJECT *RelatedFileObject;
3116 BOOLEAN LockOperation;
3117 BOOLEAN DeletePending;
3118 BOOLEAN ReadAccess;
3119 BOOLEAN WriteAccess;
3120 BOOLEAN DeleteAccess;
3121 BOOLEAN SharedRead;
3122 BOOLEAN SharedWrite;
3123 BOOLEAN SharedDelete;
3124 ULONG Flags;
3125 UNICODE_STRING FileName;
3126 LARGE_INTEGER CurrentByteOffset;
3127 ULONG Waiters;
3128 ULONG Busy;
3129 PVOID LastLock;
3130 KEVENT Lock;
3131 KEVENT Event;
3132 PIO_COMPLETION_CONTEXT CompletionContext;
3133 } FILE_OBJECT;
3134 typedef struct _FILE_OBJECT *PFILE_OBJECT;
3135
3136 typedef enum _SECURITY_OPERATION_CODE {
3137 SetSecurityDescriptor,
3138 QuerySecurityDescriptor,
3139 DeleteSecurityDescriptor,
3140 AssignSecurityDescriptor
3141 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
3142
3143 #define INITIAL_PRIVILEGE_COUNT 3
3144
3145 typedef struct _INITIAL_PRIVILEGE_SET {
3146 ULONG PrivilegeCount;
3147 ULONG Control;
3148 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
3149 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
3150
3151 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
3152 #define SE_CREATE_TOKEN_PRIVILEGE 2
3153 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
3154 #define SE_LOCK_MEMORY_PRIVILEGE 4
3155 #define SE_INCREASE_QUOTA_PRIVILEGE 5
3156 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
3157 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
3158 #define SE_TCB_PRIVILEGE 7
3159 #define SE_SECURITY_PRIVILEGE 8
3160 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
3161 #define SE_LOAD_DRIVER_PRIVILEGE 10
3162 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
3163 #define SE_SYSTEMTIME_PRIVILEGE 12
3164 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
3165 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
3166 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
3167 #define SE_CREATE_PERMANENT_PRIVILEGE 16
3168 #define SE_BACKUP_PRIVILEGE 17
3169 #define SE_RESTORE_PRIVILEGE 18
3170 #define SE_SHUTDOWN_PRIVILEGE 19
3171 #define SE_DEBUG_PRIVILEGE 20
3172 #define SE_AUDIT_PRIVILEGE 21
3173 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
3174 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
3175 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
3176 #define SE_UNDOCK_PRIVILEGE 25
3177 #define SE_SYNC_AGENT_PRIVILEGE 26
3178 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
3179 #define SE_MANAGE_VOLUME_PRIVILEGE 28
3180 #define SE_IMPERSONATE_PRIVILEGE 29
3181 #define SE_CREATE_GLOBAL_PRIVILEGE 30
3182 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_GLOBAL_PRIVILEGE
3183
3184 typedef struct _SECURITY_SUBJECT_CONTEXT {
3185 PACCESS_TOKEN ClientToken;
3186 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3187 PACCESS_TOKEN PrimaryToken;
3188 PVOID ProcessAuditId;
3189 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
3190
3191 #include <pshpack4.h>
3192 typedef struct _ACCESS_STATE {
3193 LUID OperationID;
3194 BOOLEAN SecurityEvaluated;
3195 BOOLEAN GenerateAudit;
3196 BOOLEAN GenerateOnClose;
3197 BOOLEAN PrivilegesAllocated;
3198 ULONG Flags;
3199 ACCESS_MASK RemainingDesiredAccess;
3200 ACCESS_MASK PreviouslyGrantedAccess;
3201 ACCESS_MASK OriginalDesiredAccess;
3202 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
3203 PSECURITY_DESCRIPTOR SecurityDescriptor;
3204 PVOID AuxData;
3205 union {
3206 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
3207 PRIVILEGE_SET PrivilegeSet;
3208 } Privileges;
3209
3210 BOOLEAN AuditPrivileges;
3211 UNICODE_STRING ObjectName;
3212 UNICODE_STRING ObjectTypeName;
3213 } ACCESS_STATE, *PACCESS_STATE;
3214 #include <poppack.h>
3215
3216 typedef struct _IO_SECURITY_CONTEXT {
3217 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
3218 PACCESS_STATE AccessState;
3219 ACCESS_MASK DesiredAccess;
3220 ULONG FullCreateOptions;
3221 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
3222
3223 #define IO_TYPE_ADAPTER 1
3224 #define IO_TYPE_CONTROLLER 2
3225 #define IO_TYPE_DEVICE 3
3226 #define IO_TYPE_DRIVER 4
3227 #define IO_TYPE_FILE 5
3228 #define IO_TYPE_IRP 6
3229 #define IO_TYPE_MASTER_ADAPTER 7
3230 #define IO_TYPE_OPEN_PACKET 8
3231 #define IO_TYPE_TIMER 9
3232 #define IO_TYPE_VPB 10
3233 #define IO_TYPE_ERROR_LOG 11
3234 #define IO_TYPE_ERROR_MESSAGE 12
3235 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
3236
3237 #define IO_TYPE_CSQ_IRP_CONTEXT 1
3238 #define IO_TYPE_CSQ 2
3239
3240 struct _IO_CSQ;
3241
3242 typedef struct _IO_CSQ_IRP_CONTEXT {
3243 ULONG Type;
3244 struct _IRP *Irp;
3245 struct _IO_CSQ *Csq;
3246 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
3247
3248 typedef VOID
3249 (DDKAPI *PIO_CSQ_INSERT_IRP)(
3250 IN struct _IO_CSQ *Csq,
3251 IN PIRP Irp);
3252
3253 typedef VOID
3254 (DDKAPI *PIO_CSQ_REMOVE_IRP)(
3255 IN struct _IO_CSQ *Csq,
3256 IN PIRP Irp);
3257
3258 typedef PIRP
3259 (DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)(
3260 IN struct _IO_CSQ *Csq,
3261 IN PIRP Irp,
3262 IN PVOID PeekContext);
3263
3264 typedef VOID
3265 (DDKAPI *PIO_CSQ_ACQUIRE_LOCK)(
3266 IN struct _IO_CSQ *Csq,
3267 OUT PKIRQL Irql);
3268
3269 typedef VOID
3270 (DDKAPI *PIO_CSQ_RELEASE_LOCK)(
3271 IN struct _IO_CSQ *Csq,
3272 IN KIRQL Irql);
3273
3274 typedef VOID
3275 (DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
3276 IN struct _IO_CSQ *Csq,
3277 IN PIRP Irp);
3278
3279 typedef struct _IO_CSQ {
3280 ULONG Type;
3281 PIO_CSQ_INSERT_IRP CsqInsertIrp;
3282 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
3283 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
3284 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
3285 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
3286 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
3287 PVOID ReservePointer;
3288 } IO_CSQ, *PIO_CSQ;
3289
3290 #if !defined(_ALPHA_)
3291 #include <pshpack4.h>
3292 #endif
3293 typedef struct _IO_STACK_LOCATION {
3294 UCHAR MajorFunction;
3295 UCHAR MinorFunction;
3296 UCHAR Flags;
3297 UCHAR Control;
3298 union {
3299 struct {
3300 PIO_SECURITY_CONTEXT SecurityContext;
3301 ULONG Options;
3302 USHORT POINTER_ALIGNMENT FileAttributes;
3303 USHORT ShareAccess;
3304 ULONG POINTER_ALIGNMENT EaLength;
3305 } Create;
3306 struct {
3307 ULONG Length;
3308 ULONG POINTER_ALIGNMENT Key;
3309 LARGE_INTEGER ByteOffset;
3310 } Read;
3311 struct {
3312 ULONG Length;
3313 ULONG POINTER_ALIGNMENT Key;
3314 LARGE_INTEGER ByteOffset;
3315 } Write;
3316 struct {
3317 ULONG Length;
3318 PUNICODE_STRING FileName;
3319 FILE_INFORMATION_CLASS FileInformationClass;
3320 ULONG FileIndex;
3321 } QueryDirectory;
3322 struct {
3323 ULONG Length;
3324 ULONG CompletionFilter;
3325 } NotifyDirectory;
3326 struct {
3327 ULONG Length;
3328 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
3329 } QueryFile;
3330 struct {
3331 ULONG Length;
3332 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
3333 PFILE_OBJECT FileObject;
3334 _ANONYMOUS_UNION union {
3335 _ANONYMOUS_STRUCT struct {
3336 BOOLEAN ReplaceIfExists;
3337 BOOLEAN AdvanceOnly;
3338 } DUMMYSTRUCTNAME;
3339 ULONG ClusterCount;
3340 HANDLE DeleteHandle;
3341 } DUMMYUNIONNAME;
3342 } SetFile;
3343 struct {
3344 ULONG Length;
3345 PVOID EaList;
3346 ULONG EaListLength;
3347 ULONG EaIndex;
3348 } QueryEa;
3349 struct {
3350 ULONG Length;
3351 } SetEa;
3352 struct {
3353 ULONG Length;
3354 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
3355 } QueryVolume;
3356 struct {
3357 ULONG Length;
3358 FS_INFORMATION_CLASS FsInformationClass;
3359 } SetVolume;
3360 struct {
3361 ULONG OutputBufferLength;
3362 ULONG InputBufferLength;
3363 ULONG FsControlCode;
3364 PVOID Type3InputBuffer;
3365 } FileSystemControl;
3366 struct {
3367 PLARGE_INTEGER Length;
3368 ULONG Key;
3369 LARGE_INTEGER ByteOffset;
3370 } LockControl;
3371 struct {
3372 ULONG OutputBufferLength;
3373 ULONG POINTER_ALIGNMENT InputBufferLength;
3374 ULONG POINTER_ALIGNMENT IoControlCode;
3375 PVOID Type3InputBuffer;
3376 } DeviceIoControl;
3377 struct {
3378 SECURITY_INFORMATION SecurityInformation;
3379 ULONG POINTER_ALIGNMENT Length;
3380 } QuerySecurity;
3381 struct {
3382 SECURITY_INFORMATION SecurityInformation;
3383 PSECURITY_DESCRIPTOR SecurityDescriptor;
3384 } SetSecurity;
3385 struct {
3386 PVPB Vpb;
3387 PDEVICE_OBJECT DeviceObject;
3388 } MountVolume;
3389 struct {
3390 PVPB Vpb;
3391 PDEVICE_OBJECT DeviceObject;
3392 } VerifyVolume;
3393 struct {
3394 struct _SCSI_REQUEST_BLOCK *Srb;
3395 } Scsi;
3396 struct {
3397 ULONG Length;
3398 PSID StartSid;
3399 struct _FILE_GET_QUOTA_INFORMATION *SidList;
3400 ULONG SidListLength;
3401 } QueryQuota;
3402 struct {
3403 ULONG Length;
3404 } SetQuota;
3405 struct {
3406 DEVICE_RELATION_TYPE Type;
3407 } QueryDeviceRelations;
3408 struct {
3409 CONST GUID *InterfaceType;
3410 USHORT Size;
3411 USHORT Version;
3412 PINTERFACE Interface;
3413 PVOID InterfaceSpecificData;
3414 } QueryInterface;
3415 struct {
3416 PDEVICE_CAPABILITIES Capabilities;
3417 } DeviceCapabilities;
3418 struct {
3419 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
3420 } FilterResourceRequirements;
3421 struct {
3422 ULONG WhichSpace;
3423 PVOID Buffer;
3424 ULONG Offset;
3425 ULONG POINTER_ALIGNMENT Length;
3426 } ReadWriteConfig;
3427 struct {
3428 BOOLEAN Lock;
3429 } SetLock;
3430 struct {
3431 BUS_QUERY_ID_TYPE IdType;
3432 } QueryId;
3433 struct {
3434 DEVICE_TEXT_TYPE DeviceTextType;
3435 LCID POINTER_ALIGNMENT LocaleId;
3436 } QueryDeviceText;
3437 struct {
3438 BOOLEAN InPath;
3439 BOOLEAN Reserved[3];
3440 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
3441 } UsageNotification;
3442 struct {
3443 SYSTEM_POWER_STATE PowerState;
3444 } WaitWake;
3445 struct {
3446 PPOWER_SEQUENCE PowerSequence;
3447 } PowerSequence;
3448 struct {
3449 ULONG SystemContext;
3450 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
3451 POWER_STATE POINTER_ALIGNMENT State;
3452 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
3453 } Power;
3454 struct {
3455 PCM_RESOURCE_LIST AllocatedResources;
3456 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
3457 } StartDevice;
3458 struct {
3459 ULONG_PTR ProviderId;
3460 PVOID DataPath;
3461 ULONG BufferSize;
3462 PVOID Buffer;
3463 } WMI;
3464 struct {
3465 PVOID Argument1;
3466 PVOID Argument2;
3467 PVOID Argument3;
3468 PVOID Argument4;
3469 } Others;
3470 } Parameters;
3471 PDEVICE_OBJECT DeviceObject;
3472 PFILE_OBJECT FileObject;
3473 PIO_COMPLETION_ROUTINE CompletionRoutine;
3474 PVOID Context;
3475 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
3476 #if !defined(_ALPHA_)
3477 #include <poppack.h>
3478 #endif
3479
3480 /* IO_STACK_LOCATION.Control */
3481
3482 #define SL_PENDING_RETURNED 0x01
3483 #define SL_INVOKE_ON_CANCEL 0x20
3484 #define SL_INVOKE_ON_SUCCESS 0x40
3485 #define SL_INVOKE_ON_ERROR 0x80
3486
3487 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
3488
3489 #define PCI_WHICHSPACE_CONFIG 0x0
3490 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
3491
3492 typedef enum _KEY_INFORMATION_CLASS {
3493 KeyBasicInformation,
3494 KeyNodeInformation,
3495 KeyFullInformation,
3496 KeyNameInformation,
3497 KeyCachedInformation,
3498 KeyFlagsInformation
3499 } KEY_INFORMATION_CLASS;
3500
3501 typedef struct _KEY_BASIC_INFORMATION {
3502 LARGE_INTEGER LastWriteTime;
3503 ULONG TitleIndex;
3504 ULONG NameLength;
3505 WCHAR Name[1];
3506 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
3507
3508 typedef struct _KEY_FULL_INFORMATION {
3509 LARGE_INTEGER LastWriteTime;
3510 ULONG TitleIndex;
3511 ULONG ClassOffset;
3512 ULONG ClassLength;
3513 ULONG SubKeys;
3514 ULONG MaxNameLen;
3515 ULONG MaxClassLen;
3516 ULONG Values;
3517 ULONG MaxValueNameLen;
3518 ULONG MaxValueDataLen;
3519 WCHAR Class[1];
3520 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
3521
3522 typedef struct _KEY_NODE_INFORMATION {
3523 LARGE_INTEGER LastWriteTime;
3524 ULONG TitleIndex;
3525 ULONG ClassOffset;
3526 ULONG ClassLength;
3527 ULONG NameLength;
3528 WCHAR Name[1];
3529 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
3530
3531 typedef struct _KEY_VALUE_BASIC_INFORMATION {
3532 ULONG TitleIndex;
3533 ULONG Type;
3534 ULONG NameLength;
3535 WCHAR Name[1];
3536 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
3537
3538 typedef struct _KEY_VALUE_FULL_INFORMATION {
3539 ULONG TitleIndex;
3540 ULONG Type;
3541 ULONG DataOffset;
3542 ULONG DataLength;
3543 ULONG NameLength;
3544 WCHAR Name[1];
3545 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
3546
3547 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
3548 ULONG TitleIndex;
3549 ULONG Type;
3550 ULONG DataLength;
3551 UCHAR Data[1];
3552 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
3553
3554 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
3555 ULONG Type;
3556 ULONG DataLength;
3557 UCHAR Data[1];
3558 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
3559
3560 typedef struct _KEY_VALUE_ENTRY {
3561 PUNICODE_STRING ValueName;
3562 ULONG DataLength;
3563 ULONG DataOffset;
3564 ULONG Type;
3565 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
3566
3567 typedef enum _KEY_VALUE_INFORMATION_CLASS {
3568 KeyValueBasicInformation,
3569 KeyValueFullInformation,
3570 KeyValuePartialInformation,
3571 KeyValueFullInformationAlign64,
3572 KeyValuePartialInformationAlign64
3573 } KEY_VALUE_INFORMATION_CLASS;
3574
3575 typedef struct _KEY_WRITE_TIME_INFORMATION {
3576 LARGE_INTEGER LastWriteTime;
3577 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
3578
3579 typedef struct _KEY_USER_FLAGS_INFORMATION {
3580 ULONG UserFlags;
3581 } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
3582
3583 typedef enum _KEY_SET_INFORMATION_CLASS {
3584 KeyWriteTimeInformation,
3585 KeyUserFlagsInformation,
3586 MaxKeySetInfoClass
3587 } KEY_SET_INFORMATION_CLASS;
3588
3589 #define REG_CREATED_NEW_KEY 0x00000001L
3590 #define REG_OPENED_EXISTING_KEY 0x00000002L
3591
3592
3593 /* KEY_VALUE_Xxx.Type */
3594
3595 #define REG_NONE 0
3596 #define REG_SZ 1
3597 #define REG_EXPAND_SZ 2
3598 #define REG_BINARY 3
3599 #define REG_DWORD 4
3600 #define REG_DWORD_LITTLE_ENDIAN 4
3601 #define REG_DWORD_BIG_ENDIAN 5
3602 #define REG_LINK 6
3603 #define REG_MULTI_SZ 7
3604 #define REG_RESOURCE_LIST 8
3605 #define REG_FULL_RESOURCE_DESCRIPTOR 9
3606 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3607 #define REG_QWORD 11
3608 #define REG_QWORD_LITTLE_ENDIAN 11
3609
3610 #define PCI_TYPE0_ADDRESSES 6
3611 #define PCI_TYPE1_ADDRESSES 2
3612 #define PCI_TYPE2_ADDRESSES 5
3613
3614 typedef struct _PCI_COMMON_CONFIG {
3615 USHORT VendorID;
3616 USHORT DeviceID;
3617 USHORT Command;
3618 USHORT Status;
3619 UCHAR RevisionID;
3620 UCHAR ProgIf;
3621 UCHAR SubClass;
3622 UCHAR BaseClass;
3623 UCHAR CacheLineSize;
3624 UCHAR LatencyTimer;
3625 UCHAR HeaderType;
3626 UCHAR BIST;
3627 union {
3628 struct _PCI_HEADER_TYPE_0 {
3629 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
3630 ULONG CIS;
3631 USHORT SubVendorID;
3632 USHORT SubSystemID;