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