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