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