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