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