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