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