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