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