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