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