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