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