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