- 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 #ifndef IN
53 #define IN
54 #endif
55 #ifndef OUT
56 #define OUT
57 #endif
58 #ifndef OPTIONAL
59 #define OPTIONAL
60 #endif
61 #ifndef UNALLIGNED
62 #define UNALLIGNED
63 #endif
64
65 #define CONST const
66
67 #define RESTRICTED_POINTER
68
69 #if defined(_WIN64)
70 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
71 #else
72 #define POINTER_ALIGNMENT
73 #endif
74
75 #define DECLSPEC_ADDRSAFE
76
77 #ifdef NONAMELESSUNION
78 # define _DDK_DUMMYUNION_MEMBER(name) DUMMYUNIONNAME.name
79 # define _DDK_DUMMYUNION_N_MEMBER(n, name) DUMMYUNIONNAME##n.name
80 #else
81 # define _DDK_DUMMYUNION_MEMBER(name) name
82 # define _DDK_DUMMYUNION_N_MEMBER(n, name) name
83 #endif
84
85 /*
86 ** Forward declarations
87 */
88
89 struct _KPCR;
90 struct _KPRCB;
91 struct _KTSS;
92 struct _DRIVE_LAYOUT_INFORMATION_EX;
93 struct _LOADER_PARAMETER_BLOCK;
94
95
96 #if 1
97 /* FIXME: Unknown definitions */
98 struct _SET_PARTITION_INFORMATION_EX;
99 typedef ULONG WAIT_TYPE;
100 #define WaitAll 0
101 #define WaitAny 1
102 typedef HANDLE TRACEHANDLE;
103 typedef PVOID PWMILIB_CONTEXT;
104 typedef ULONG LOGICAL;
105 #endif
106
107 /*
108 ** WmiLib specific structure
109 */
110 typedef enum
111 {
112 IrpProcessed, // Irp was processed and possibly completed
113 IrpNotCompleted, // Irp was process and NOT completed
114 IrpNotWmi, // Irp is not a WMI irp
115 IrpForward // Irp is wmi irp, but targeted at another device object
116 } SYSCTL_IRP_DISPOSITION, *PSYSCTL_IRP_DISPOSITION;
117
118 //
119 // Forwarder
120 //
121 struct _COMPRESSED_DATA_INFO;
122
123 #define KERNEL_STACK_SIZE 12288
124 #define KERNEL_LARGE_STACK_SIZE 61440
125 #define KERNEL_LARGE_STACK_COMMIT 12288
126
127 #define EXCEPTION_READ_FAULT 0
128 #define EXCEPTION_WRITE_FAULT 1
129 #define EXCEPTION_EXECUTE_FAULT 8
130
131 #define DPFLTR_ERROR_LEVEL 0
132 #define DPFLTR_WARNING_LEVEL 1
133 #define DPFLTR_TRACE_LEVEL 2
134 #define DPFLTR_INFO_LEVEL 3
135 #define DPFLTR_MASK 0x80000000
136
137 typedef enum _DPFLTR_TYPE
138 {
139 DPFLTR_SYSTEM_ID = 0,
140 DPFLTR_SMSS_ID = 1,
141 DPFLTR_SETUP_ID = 2,
142 DPFLTR_NTFS_ID = 3,
143 DPFLTR_FSTUB_ID = 4,
144 DPFLTR_CRASHDUMP_ID = 5,
145 DPFLTR_CDAUDIO_ID = 6,
146 DPFLTR_CDROM_ID = 7,
147 DPFLTR_CLASSPNP_ID = 8,
148 DPFLTR_DISK_ID = 9,
149 DPFLTR_REDBOOK_ID = 10,
150 DPFLTR_STORPROP_ID = 11,
151 DPFLTR_SCSIPORT_ID = 12,
152 DPFLTR_SCSIMINIPORT_ID = 13,
153 DPFLTR_CONFIG_ID = 14,
154 DPFLTR_I8042PRT_ID = 15,
155 DPFLTR_SERMOUSE_ID = 16,
156 DPFLTR_LSERMOUS_ID = 17,
157 DPFLTR_KBDHID_ID = 18,
158 DPFLTR_MOUHID_ID = 19,
159 DPFLTR_KBDCLASS_ID = 20,
160 DPFLTR_MOUCLASS_ID = 21,
161 DPFLTR_TWOTRACK_ID = 22,
162 DPFLTR_WMILIB_ID = 23,
163 DPFLTR_ACPI_ID = 24,
164 DPFLTR_AMLI_ID = 25,
165 DPFLTR_HALIA64_ID = 26,
166 DPFLTR_VIDEO_ID = 27,
167 DPFLTR_SVCHOST_ID = 28,
168 DPFLTR_VIDEOPRT_ID = 29,
169 DPFLTR_TCPIP_ID = 30,
170 DPFLTR_DMSYNTH_ID = 31,
171 DPFLTR_NTOSPNP_ID = 32,
172 DPFLTR_FASTFAT_ID = 33,
173 DPFLTR_SAMSS_ID = 34,
174 DPFLTR_PNPMGR_ID = 35,
175 DPFLTR_NETAPI_ID = 36,
176 DPFLTR_SCSERVER_ID = 37,
177 DPFLTR_SCCLIENT_ID = 38,
178 DPFLTR_SERIAL_ID = 39,
179 DPFLTR_SERENUM_ID = 40,
180 DPFLTR_UHCD_ID = 41,
181 DPFLTR_BOOTOK_ID = 42,
182 DPFLTR_BOOTVRFY_ID = 43,
183 DPFLTR_RPCPROXY_ID = 44,
184 DPFLTR_AUTOCHK_ID = 45,
185 DPFLTR_DCOMSS_ID = 46,
186 DPFLTR_UNIMODEM_ID = 47,
187 DPFLTR_SIS_ID = 48,
188 DPFLTR_FLTMGR_ID = 49,
189 DPFLTR_WMICORE_ID = 50,
190 DPFLTR_BURNENG_ID = 51,
191 DPFLTR_IMAPI_ID = 52,
192 DPFLTR_SXS_ID = 53,
193 DPFLTR_FUSION_ID = 54,
194 DPFLTR_IDLETASK_ID = 55,
195 DPFLTR_SOFTPCI_ID = 56,
196 DPFLTR_TAPE_ID = 57,
197 DPFLTR_MCHGR_ID = 58,
198 DPFLTR_IDEP_ID = 59,
199 DPFLTR_PCIIDE_ID = 60,
200 DPFLTR_FLOPPY_ID = 61,
201 DPFLTR_FDC_ID = 62,
202 DPFLTR_TERMSRV_ID = 63,
203 DPFLTR_W32TIME_ID = 64,
204 DPFLTR_PREFETCHER_ID = 65,
205 DPFLTR_RSFILTER_ID = 66,
206 DPFLTR_FCPORT_ID = 67,
207 DPFLTR_PCI_ID = 68,
208 DPFLTR_DMIO_ID = 69,
209 DPFLTR_DMCONFIG_ID = 70,
210 DPFLTR_DMADMIN_ID = 71,
211 DPFLTR_WSOCKTRANSPORT_ID = 72,
212 DPFLTR_VSS_ID = 73,
213 DPFLTR_PNPMEM_ID = 74,
214 DPFLTR_PROCESSOR_ID = 75,
215 DPFLTR_DMSERVER_ID = 76,
216 DPFLTR_SR_ID = 77,
217 DPFLTR_INFINIBAND_ID = 78,
218 DPFLTR_IHVDRIVER_ID = 79,
219 DPFLTR_IHVVIDEO_ID = 80,
220 DPFLTR_IHVAUDIO_ID = 81,
221 DPFLTR_IHVNETWORK_ID = 82,
222 DPFLTR_IHVSTREAMING_ID = 83,
223 DPFLTR_IHVBUS_ID = 84,
224 DPFLTR_HPS_ID = 85,
225 DPFLTR_RTLTHREADPOOL_ID = 86,
226 DPFLTR_LDR_ID = 87,
227 DPFLTR_TCPIP6_ID = 88,
228 DPFLTR_ISAPNP_ID = 89,
229 DPFLTR_SHPC_ID = 90,
230 DPFLTR_STORPORT_ID = 91,
231 DPFLTR_STORMINIPORT_ID = 92,
232 DPFLTR_PRINTSPOOLER_ID = 93,
233 DPFLTR_VDS_ID = 94,
234 DPFLTR_VDSBAS_ID = 95,
235 DPFLTR_VDSDYNDR_ID = 96,
236 DPFLTR_VDSUTIL_ID = 97,
237 DPFLTR_DFRGIFC_ID = 98,
238 DPFLTR_DEFAULT_ID = 99,
239 DPFLTR_MM_ID = 100,
240 DPFLTR_DFSC_ID = 101,
241 DPFLTR_WOW64_ID = 102,
242 DPFLTR_ENDOFTABLE_ID
243 } DPFLTR_TYPE;
244
245 /* also in winnt.h */
246
247 #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
248 #define FILE_STRUCTURED_STORAGE 0x00000441
249
250 /* end winnt.h */
251
252 #define THREAD_ALERT (0x0004)
253
254 /* Exported object types */
255 extern POBJECT_TYPE NTSYSAPI ExDesktopObjectType;
256 extern POBJECT_TYPE NTSYSAPI ExEventObjectType;
257 extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType;
258 extern POBJECT_TYPE NTSYSAPI ExWindowStationObjectType;
259 extern ULONG NTSYSAPI IoDeviceHandlerObjectSize;
260 extern POBJECT_TYPE NTSYSAPI IoDeviceHandlerObjectType;
261 extern POBJECT_TYPE NTSYSAPI IoDeviceObjectType;
262 extern POBJECT_TYPE NTSYSAPI IoDriverObjectType;
263 extern POBJECT_TYPE NTSYSAPI IoFileObjectType;
264 extern POBJECT_TYPE NTSYSAPI PsThreadType;
265 extern POBJECT_TYPE NTSYSAPI LpcPortObjectType;
266 extern POBJECT_TYPE NTSYSAPI SeTokenObjectType;
267 extern POBJECT_TYPE NTSYSAPI PsProcessType;
268
269 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
270 extern volatile CCHAR NTSYSAPI KeNumberProcessors;
271 #else
272 #if (NTDDI_VERSION >= NTDDI_WINXP)
273 extern CCHAR NTSYSAPI KeNumberProcessors;
274 #else
275 //extern PCCHAR KeNumberProcessors;
276 extern NTSYSAPI CCHAR KeNumberProcessors; //FIXME: Note to Alex: I won't fix this atm, since I prefer to discuss this with you first.
277 #endif
278 #endif
279
280 #define MAX_WOW64_SHARED_ENTRIES 16
281
282 extern volatile KSYSTEM_TIME KeTickCount;
283
284 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
285 #define NX_SUPPORT_POLICY_ALWAYSON 1
286 #define NX_SUPPORT_POLICY_OPTIN 2
287 #define NX_SUPPORT_POLICY_OPTOUT 3
288
289 typedef struct _KUSER_SHARED_DATA
290 {
291 ULONG TickCountLowDeprecated;
292 ULONG TickCountMultiplier;
293 volatile KSYSTEM_TIME InterruptTime;
294 volatile KSYSTEM_TIME SystemTime;
295 volatile KSYSTEM_TIME TimeZoneBias;
296 USHORT ImageNumberLow;
297 USHORT ImageNumberHigh;
298 WCHAR NtSystemRoot[260];
299 ULONG MaxStackTraceDepth;
300 ULONG CryptoExponent;
301 ULONG TimeZoneId;
302 ULONG LargePageMinimum;
303 ULONG Reserved2[7];
304 NT_PRODUCT_TYPE NtProductType;
305 BOOLEAN ProductTypeIsValid;
306 ULONG NtMajorVersion;
307 ULONG NtMinorVersion;
308 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
309 ULONG Reserved1;
310 ULONG Reserved3;
311 volatile ULONG TimeSlip;
312 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
313 LARGE_INTEGER SystemExpirationDate;
314 ULONG SuiteMask;
315 BOOLEAN KdDebuggerEnabled;
316 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
317 UCHAR NXSupportPolicy;
318 #endif
319 volatile ULONG ActiveConsoleId;
320 volatile ULONG DismountCount;
321 ULONG ComPlusPackage;
322 ULONG LastSystemRITEventTickCount;
323 ULONG NumberOfPhysicalPages;
324 BOOLEAN SafeBootMode;
325 ULONG TraceLogging;
326 ULONG Fill0;
327 ULONGLONG TestRetInstruction;
328 ULONG SystemCall;
329 ULONG SystemCallReturn;
330 ULONGLONG SystemCallPad[3];
331 __GNU_EXTENSION union {
332 volatile KSYSTEM_TIME TickCount;
333 volatile ULONG64 TickCountQuad;
334 };
335 ULONG Cookie;
336 #if (NTDDI_VERSION >= NTDDI_WS03)
337 LONGLONG ConsoleSessionForegroundProcessId;
338 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
339 #endif
340 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
341 USHORT UserModeGlobalLogger[8];
342 ULONG HeapTracingPid[2];
343 ULONG CritSecTracingPid[2];
344 __GNU_EXTENSION union
345 {
346 ULONG SharedDataFlags;
347 __GNU_EXTENSION struct
348 {
349 ULONG DbgErrorPortPresent:1;
350 ULONG DbgElevationEnabled:1;
351 ULONG DbgVirtEnabled:1;
352 ULONG DbgInstallerDetectEnabled:1;
353 ULONG SpareBits:28;
354 };
355 };
356 ULONG ImageFileExecutionOptions;
357 KAFFINITY ActiveProcessorAffinity;
358 #endif
359 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
360
361 /*
362 ** IRP function codes
363 */
364
365 #define IRP_MN_QUERY_DIRECTORY 0x01
366 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
367
368 #define IRP_MN_USER_FS_REQUEST 0x00
369 #define IRP_MN_MOUNT_VOLUME 0x01
370 #define IRP_MN_VERIFY_VOLUME 0x02
371 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
372 #define IRP_MN_TRACK_LINK 0x04
373 #define IRP_MN_KERNEL_CALL 0x04
374
375 #define IRP_MN_LOCK 0x01
376 #define IRP_MN_UNLOCK_SINGLE 0x02
377 #define IRP_MN_UNLOCK_ALL 0x03
378 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
379
380 #define IRP_MN_NORMAL 0x00
381 #define IRP_MN_DPC 0x01
382 #define IRP_MN_MDL 0x02
383 #define IRP_MN_COMPLETE 0x04
384 #define IRP_MN_COMPRESSED 0x08
385
386 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
387 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
388 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
389
390 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
391
392 typedef EXCEPTION_DISPOSITION
393 (DDKAPI *PEXCEPTION_ROUTINE)(
394 IN struct _EXCEPTION_RECORD *ExceptionRecord,
395 IN PVOID EstablisherFrame,
396 IN OUT struct _CONTEXT *ContextRecord,
397 IN OUT PVOID DispatcherContext);
398
399 typedef NTSTATUS
400 (DDKAPI *PDRIVER_ENTRY)(
401 IN struct _DRIVER_OBJECT *DriverObject,
402 IN PUNICODE_STRING RegistryPath);
403
404 typedef VOID
405 (DDKAPI *PDRIVER_REINITIALIZE)(
406 IN struct _DRIVER_OBJECT *DriverObject,
407 IN PVOID Context,
408 IN ULONG Count);
409
410 typedef enum _BUS_QUERY_ID_TYPE {
411 BusQueryDeviceID,
412 BusQueryHardwareIDs,
413 BusQueryCompatibleIDs,
414 BusQueryInstanceID,
415 BusQueryDeviceSerialNumber
416 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
417
418 typedef enum _DEVICE_TEXT_TYPE {
419 DeviceTextDescription,
420 DeviceTextLocationInformation
421 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
422
423 typedef BOOLEAN
424 (DDKAPI *PKTRANSFER_ROUTINE)(
425 VOID);
426
427 #define ASSERT_GATE(object) \
428 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
429 (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
430
431 #define TIMER_TABLE_SIZE 512
432 #define TIMER_TABLE_SHIFT 9
433
434 #define ASSERT_TIMER(E) \
435 ASSERT(((E)->Header.Type == TimerNotificationObject) || \
436 ((E)->Header.Type == TimerSynchronizationObject))
437
438 #define ASSERT_MUTANT(E) \
439 ASSERT((E)->Header.Type == MutantObject)
440
441 #define ASSERT_SEMAPHORE(E) \
442 ASSERT((E)->Header.Type == SemaphoreObject)
443
444 #define ASSERT_EVENT(E) \
445 ASSERT(((E)->Header.Type == NotificationEvent) || \
446 ((E)->Header.Type == SynchronizationEvent))
447
448
449 typedef enum _TIMER_TYPE {
450 NotificationTimer,
451 SynchronizationTimer
452 } TIMER_TYPE;
453
454 #define KEYBOARD_INSERT_ON 0x08
455 #define KEYBOARD_CAPS_LOCK_ON 0x04
456 #define KEYBOARD_NUM_LOCK_ON 0x02
457 #define KEYBOARD_SCROLL_LOCK_ON 0x01
458 #define KEYBOARD_ALT_KEY_DOWN 0x80
459 #define KEYBOARD_CTRL_KEY_DOWN 0x40
460 #define KEYBOARD_LEFT_SHIFT_DOWN 0x20
461 #define KEYBOARD_RIGHT_SHIFT_DOWN 0x10
462
463 typedef struct _IO_COUNTERS {
464 ULONGLONG ReadOperationCount;
465 ULONGLONG WriteOperationCount;
466 ULONGLONG OtherOperationCount;
467 ULONGLONG ReadTransferCount;
468 ULONGLONG WriteTransferCount;
469 ULONGLONG OtherTransferCount;
470 } IO_COUNTERS, *PIO_COUNTERS;
471
472 typedef struct _VM_COUNTERS
473 {
474 SIZE_T PeakVirtualSize;
475 SIZE_T VirtualSize;
476 ULONG PageFaultCount;
477 SIZE_T PeakWorkingSetSize;
478 SIZE_T WorkingSetSize;
479 SIZE_T QuotaPeakPagedPoolUsage;
480 SIZE_T QuotaPagedPoolUsage;
481 SIZE_T QuotaPeakNonPagedPoolUsage;
482 SIZE_T QuotaNonPagedPoolUsage;
483 SIZE_T PagefileUsage;
484 SIZE_T PeakPagefileUsage;
485 } VM_COUNTERS, *PVM_COUNTERS;
486
487 typedef struct _VM_COUNTERS_EX
488 {
489 SIZE_T PeakVirtualSize;
490 SIZE_T VirtualSize;
491 ULONG PageFaultCount;
492 SIZE_T PeakWorkingSetSize;
493 SIZE_T WorkingSetSize;
494 SIZE_T QuotaPeakPagedPoolUsage;
495 SIZE_T QuotaPagedPoolUsage;
496 SIZE_T QuotaPeakNonPagedPoolUsage;
497 SIZE_T QuotaNonPagedPoolUsage;
498 SIZE_T PagefileUsage;
499 SIZE_T PeakPagefileUsage;
500 SIZE_T PrivateUsage;
501 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
502
503 typedef struct _POOLED_USAGE_AND_LIMITS
504 {
505 SIZE_T PeakPagedPoolUsage;
506 SIZE_T PagedPoolUsage;
507 SIZE_T PagedPoolLimit;
508 SIZE_T PeakNonPagedPoolUsage;
509 SIZE_T NonPagedPoolUsage;
510 SIZE_T NonPagedPoolLimit;
511 SIZE_T PeakPagefileUsage;
512 SIZE_T PagefileUsage;
513 SIZE_T PagefileLimit;
514 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
515
516 typedef struct _CONTROLLER_OBJECT {
517 CSHORT Type;
518 CSHORT Size;
519 PVOID ControllerExtension;
520 KDEVICE_QUEUE DeviceWaitQueue;
521 ULONG Spare1;
522 LARGE_INTEGER Spare2;
523 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
524
525 /* DEVICE_DESCRIPTION.Version */
526
527 #define DEVICE_DESCRIPTION_VERSION 0x0000
528 #define DEVICE_DESCRIPTION_VERSION1 0x0001
529 #define DEVICE_DESCRIPTION_VERSION2 0x0002
530
531 typedef struct _DEVICE_DESCRIPTION {
532 ULONG Version;
533 BOOLEAN Master;
534 BOOLEAN ScatterGather;
535 BOOLEAN DemandMode;
536 BOOLEAN AutoInitialize;
537 BOOLEAN Dma32BitAddresses;
538 BOOLEAN IgnoreCount;
539 BOOLEAN Reserved1;
540 BOOLEAN Dma64BitAddresses;
541 ULONG BusNumber;
542 ULONG DmaChannel;
543 INTERFACE_TYPE InterfaceType;
544 DMA_WIDTH DmaWidth;
545 DMA_SPEED DmaSpeed;
546 ULONG MaximumLength;
547 ULONG DmaPort;
548 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
549
550 /* VPB.Flags */
551 #define VPB_MOUNTED 0x0001
552 #define VPB_LOCKED 0x0002
553 #define VPB_PERSISTENT 0x0004
554 #define VPB_REMOVE_PENDING 0x0008
555 #define VPB_RAW_MOUNT 0x0010
556
557 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
558
559 typedef struct _VPB {
560 CSHORT Type;
561 CSHORT Size;
562 USHORT Flags;
563 USHORT VolumeLabelLength;
564 struct _DEVICE_OBJECT *DeviceObject;
565 struct _DEVICE_OBJECT *RealDevice;
566 ULONG SerialNumber;
567 ULONG ReferenceCount;
568 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
569 } VPB, *PVPB;
570
571 /* DEVICE_OBJECT.Flags */
572
573 #define DO_VERIFY_VOLUME 0x00000002
574 #define DO_BUFFERED_IO 0x00000004
575 #define DO_EXCLUSIVE 0x00000008
576 #define DO_DIRECT_IO 0x00000010
577 #define DO_MAP_IO_BUFFER 0x00000020
578 #define DO_DEVICE_HAS_NAME 0x00000040
579 #define DO_DEVICE_INITIALIZING 0x00000080
580 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
581 #define DO_LONG_TERM_REQUESTS 0x00000200
582 #define DO_NEVER_LAST_DEVICE 0x00000400
583 #define DO_SHUTDOWN_REGISTERED 0x00000800
584 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
585 #define DO_POWER_PAGABLE 0x00002000
586 #define DO_POWER_INRUSH 0x00004000
587 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
588 #define DO_XIP 0x00020000
589
590 /* DEVICE_OBJECT.Characteristics */
591
592 #define FILE_REMOVABLE_MEDIA 0x00000001
593 #define FILE_READ_ONLY_DEVICE 0x00000002
594 #define FILE_FLOPPY_DISKETTE 0x00000004
595 #define FILE_WRITE_ONCE_MEDIA 0x00000008
596 #define FILE_REMOTE_DEVICE 0x00000010
597 #define FILE_DEVICE_IS_MOUNTED 0x00000020
598 #define FILE_VIRTUAL_VOLUME 0x00000040
599 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
600 #define FILE_DEVICE_SECURE_OPEN 0x00000100
601
602 /* DEVICE_OBJECT.AlignmentRequirement */
603
604 #define FILE_BYTE_ALIGNMENT 0x00000000
605 #define FILE_WORD_ALIGNMENT 0x00000001
606 #define FILE_LONG_ALIGNMENT 0x00000003
607 #define FILE_QUAD_ALIGNMENT 0x00000007
608 #define FILE_OCTA_ALIGNMENT 0x0000000f
609 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
610 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
611 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
612 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
613 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
614
615 /* DEVICE_OBJECT.DeviceType */
616
617 #define DEVICE_TYPE ULONG
618
619 #define FILE_DEVICE_BEEP 0x00000001
620 #define FILE_DEVICE_CD_ROM 0x00000002
621 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
622 #define FILE_DEVICE_CONTROLLER 0x00000004
623 #define FILE_DEVICE_DATALINK 0x00000005
624 #define FILE_DEVICE_DFS 0x00000006
625 #define FILE_DEVICE_DISK 0x00000007
626 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
627 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
628 #define FILE_DEVICE_INPORT_PORT 0x0000000a
629 #define FILE_DEVICE_KEYBOARD 0x0000000b
630 #define FILE_DEVICE_MAILSLOT 0x0000000c
631 #define FILE_DEVICE_MIDI_IN 0x0000000d
632 #define FILE_DEVICE_MIDI_OUT 0x0000000e
633 #define FILE_DEVICE_MOUSE 0x0000000f
634 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
635 #define FILE_DEVICE_NAMED_PIPE 0x00000011
636 #define FILE_DEVICE_NETWORK 0x00000012
637 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
638 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
639 #define FILE_DEVICE_NULL 0x00000015
640 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
641 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
642 #define FILE_DEVICE_PRINTER 0x00000018
643 #define FILE_DEVICE_SCANNER 0x00000019
644 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
645 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
646 #define FILE_DEVICE_SCREEN 0x0000001c
647 #define FILE_DEVICE_SOUND 0x0000001d
648 #define FILE_DEVICE_STREAMS 0x0000001e
649 #define FILE_DEVICE_TAPE 0x0000001f
650 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
651 #define FILE_DEVICE_TRANSPORT 0x00000021
652 #define FILE_DEVICE_UNKNOWN 0x00000022
653 #define FILE_DEVICE_VIDEO 0x00000023
654 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
655 #define FILE_DEVICE_WAVE_IN 0x00000025
656 #define FILE_DEVICE_WAVE_OUT 0x00000026
657 #define FILE_DEVICE_8042_PORT 0x00000027
658 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
659 #define FILE_DEVICE_BATTERY 0x00000029
660 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
661 #define FILE_DEVICE_MODEM 0x0000002b
662 #define FILE_DEVICE_VDM 0x0000002c
663 #define FILE_DEVICE_MASS_STORAGE 0x0000002d
664 #define FILE_DEVICE_SMB 0x0000002e
665 #define FILE_DEVICE_KS 0x0000002f
666 #define FILE_DEVICE_CHANGER 0x00000030
667 #define FILE_DEVICE_SMARTCARD 0x00000031
668 #define FILE_DEVICE_ACPI 0x00000032
669 #define FILE_DEVICE_DVD 0x00000033
670 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
671 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
672 #define FILE_DEVICE_DFS_VOLUME 0x00000036
673 #define FILE_DEVICE_SERENUM 0x00000037
674 #define FILE_DEVICE_TERMSRV 0x00000038
675 #define FILE_DEVICE_KSEC 0x00000039
676 #define FILE_DEVICE_FIPS 0x0000003a
677
678 typedef struct _DEVICE_OBJECT {
679 CSHORT Type;
680 USHORT Size;
681 LONG ReferenceCount;
682 struct _DRIVER_OBJECT *DriverObject;
683 struct _DEVICE_OBJECT *NextDevice;
684 struct _DEVICE_OBJECT *AttachedDevice;
685 struct _IRP *CurrentIrp;
686 PIO_TIMER Timer;
687 ULONG Flags;
688 ULONG Characteristics;
689 volatile PVPB Vpb;
690 PVOID DeviceExtension;
691 DEVICE_TYPE DeviceType;
692 CCHAR StackSize;
693 union {
694 LIST_ENTRY ListEntry;
695 WAIT_CONTEXT_BLOCK Wcb;
696 } Queue;
697 ULONG AlignmentRequirement;
698 KDEVICE_QUEUE DeviceQueue;
699 KDPC Dpc;
700 ULONG ActiveThreadCount;
701 PSECURITY_DESCRIPTOR SecurityDescriptor;
702 KEVENT DeviceLock;
703 USHORT SectorSize;
704 USHORT Spare1;
705 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
706 PVOID Reserved;
707 } DEVICE_OBJECT, *PDEVICE_OBJECT;
708
709 typedef enum _DEVICE_RELATION_TYPE {
710 BusRelations,
711 EjectionRelations,
712 PowerRelations,
713 RemovalRelations,
714 TargetDeviceRelation,
715 SingleBusRelations
716 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
717
718 typedef struct _DEVICE_RELATIONS {
719 ULONG Count;
720 PDEVICE_OBJECT Objects[1];
721 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
722
723 typedef struct _SCATTER_GATHER_ELEMENT {
724 PHYSICAL_ADDRESS Address;
725 ULONG Length;
726 ULONG_PTR Reserved;
727 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
728
729 typedef struct _SCATTER_GATHER_LIST {
730 ULONG NumberOfElements;
731 ULONG_PTR Reserved;
732 SCATTER_GATHER_ELEMENT Elements[1];
733 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
734
735 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
736 #define MDL_PAGES_LOCKED 0x0002
737 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
738 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
739 #define MDL_PARTIAL 0x0010
740 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
741 #define MDL_IO_PAGE_READ 0x0040
742 #define MDL_WRITE_OPERATION 0x0080
743 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
744 #define MDL_FREE_EXTRA_PTES 0x0200
745 #define MDL_DESCRIBES_AWE 0x0400
746 #define MDL_IO_SPACE 0x0800
747 #define MDL_NETWORK_HEADER 0x1000
748 #define MDL_MAPPING_CAN_FAIL 0x2000
749 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
750 #define MDL_INTERNAL 0x8000
751
752
753 #define MDL_MAPPING_FLAGS ( \
754 MDL_MAPPED_TO_SYSTEM_VA | \
755 MDL_PAGES_LOCKED | \
756 MDL_SOURCE_IS_NONPAGED_POOL | \
757 MDL_PARTIAL_HAS_BEEN_MAPPED | \
758 MDL_PARENT_MAPPED_SYSTEM_VA | \
759 MDL_SYSTEM_VA | \
760 MDL_IO_SPACE)
761
762 typedef struct _DRIVER_EXTENSION {
763 struct _DRIVER_OBJECT *DriverObject;
764 PDRIVER_ADD_DEVICE AddDevice;
765 ULONG Count;
766 UNICODE_STRING ServiceKeyName;
767 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
768
769 #define DRVO_UNLOAD_INVOKED 0x00000001
770 #define DRVO_LEGACY_DRIVER 0x00000002
771 #define DRVO_BUILTIN_DRIVER 0x00000004
772 #define DRVO_REINIT_REGISTERED 0x00000008
773 #define DRVO_INITIALIZED 0x00000010
774 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
775 #define DRVO_LEGACY_RESOURCES 0x00000040
776
777 typedef struct _DRIVER_OBJECT {
778 CSHORT Type;
779 CSHORT Size;
780 PDEVICE_OBJECT DeviceObject;
781 ULONG Flags;
782 PVOID DriverStart;
783 ULONG DriverSize;
784 PVOID DriverSection;
785 PDRIVER_EXTENSION DriverExtension;
786 UNICODE_STRING DriverName;
787 PUNICODE_STRING HardwareDatabase;
788 struct _FAST_IO_DISPATCH *FastIoDispatch;
789 PDRIVER_INITIALIZE DriverInit;
790 PDRIVER_STARTIO DriverStartIo;
791 PDRIVER_UNLOAD DriverUnload;
792 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
793 } DRIVER_OBJECT;
794 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
795
796 typedef struct _DMA_ADAPTER {
797 USHORT Version;
798 USHORT Size;
799 struct _DMA_OPERATIONS* DmaOperations;
800 } DMA_ADAPTER, *PDMA_ADAPTER;
801
802 typedef VOID
803 (DDKAPI *PPUT_DMA_ADAPTER)(
804 IN PDMA_ADAPTER DmaAdapter);
805
806 typedef PVOID
807 (DDKAPI *PALLOCATE_COMMON_BUFFER)(
808 IN PDMA_ADAPTER DmaAdapter,
809 IN ULONG Length,
810 OUT PPHYSICAL_ADDRESS LogicalAddress,
811 IN BOOLEAN CacheEnabled);
812
813 typedef VOID
814 (DDKAPI *PFREE_COMMON_BUFFER)(
815 IN PDMA_ADAPTER DmaAdapter,
816 IN ULONG Length,
817 IN PHYSICAL_ADDRESS LogicalAddress,
818 IN PVOID VirtualAddress,
819 IN BOOLEAN CacheEnabled);
820
821 typedef NTSTATUS
822 (DDKAPI *PALLOCATE_ADAPTER_CHANNEL)(
823 IN PDMA_ADAPTER DmaAdapter,
824 IN PDEVICE_OBJECT DeviceObject,
825 IN ULONG NumberOfMapRegisters,
826 IN PDRIVER_CONTROL ExecutionRoutine,
827 IN PVOID Context);
828
829 typedef BOOLEAN
830 (DDKAPI *PFLUSH_ADAPTER_BUFFERS)(
831 IN PDMA_ADAPTER DmaAdapter,
832 IN PMDL Mdl,
833 IN PVOID MapRegisterBase,
834 IN PVOID CurrentVa,
835 IN ULONG Length,
836 IN BOOLEAN WriteToDevice);
837
838 typedef VOID
839 (DDKAPI *PFREE_ADAPTER_CHANNEL)(
840 IN PDMA_ADAPTER DmaAdapter);
841
842 typedef VOID
843 (DDKAPI *PFREE_MAP_REGISTERS)(
844 IN PDMA_ADAPTER DmaAdapter,
845 PVOID MapRegisterBase,
846 ULONG NumberOfMapRegisters);
847
848 typedef PHYSICAL_ADDRESS
849 (DDKAPI *PMAP_TRANSFER)(
850 IN PDMA_ADAPTER DmaAdapter,
851 IN PMDL Mdl,
852 IN PVOID MapRegisterBase,
853 IN PVOID CurrentVa,
854 IN OUT PULONG Length,
855 IN BOOLEAN WriteToDevice);
856
857 typedef ULONG
858 (DDKAPI *PGET_DMA_ALIGNMENT)(
859 IN PDMA_ADAPTER DmaAdapter);
860
861 typedef ULONG
862 (DDKAPI *PREAD_DMA_COUNTER)(
863 IN PDMA_ADAPTER DmaAdapter);
864
865 typedef NTSTATUS
866 (DDKAPI *PGET_SCATTER_GATHER_LIST)(
867 IN PDMA_ADAPTER DmaAdapter,
868 IN PDEVICE_OBJECT DeviceObject,
869 IN PMDL Mdl,
870 IN PVOID CurrentVa,
871 IN ULONG Length,
872 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
873 IN PVOID Context,
874 IN BOOLEAN WriteToDevice);
875
876 typedef VOID
877 (DDKAPI *PPUT_SCATTER_GATHER_LIST)(
878 IN PDMA_ADAPTER DmaAdapter,
879 IN PSCATTER_GATHER_LIST ScatterGather,
880 IN BOOLEAN WriteToDevice);
881
882 typedef NTSTATUS
883 (DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
884 IN PDMA_ADAPTER DmaAdapter,
885 IN PMDL Mdl OPTIONAL,
886 IN PVOID CurrentVa,
887 IN ULONG Length,
888 OUT PULONG ScatterGatherListSize,
889 OUT PULONG pNumberOfMapRegisters OPTIONAL);
890
891 typedef NTSTATUS
892 (DDKAPI *PBUILD_SCATTER_GATHER_LIST)(
893 IN PDMA_ADAPTER DmaAdapter,
894 IN PDEVICE_OBJECT DeviceObject,
895 IN PMDL Mdl,
896 IN PVOID CurrentVa,
897 IN ULONG Length,
898 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
899 IN PVOID Context,
900 IN BOOLEAN WriteToDevice,
901 IN PVOID ScatterGatherBuffer,
902 IN ULONG ScatterGatherLength);
903
904 typedef NTSTATUS
905 (DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
906 IN PDMA_ADAPTER DmaAdapter,
907 IN PSCATTER_GATHER_LIST ScatterGather,
908 IN PMDL OriginalMdl,
909 OUT PMDL *TargetMdl);
910
911 typedef struct _DMA_OPERATIONS {
912 ULONG Size;
913 PPUT_DMA_ADAPTER PutDmaAdapter;
914 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
915 PFREE_COMMON_BUFFER FreeCommonBuffer;
916 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
917 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
918 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
919 PFREE_MAP_REGISTERS FreeMapRegisters;
920 PMAP_TRANSFER MapTransfer;
921 PGET_DMA_ALIGNMENT GetDmaAlignment;
922 PREAD_DMA_COUNTER ReadDmaCounter;
923 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
924 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
925 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
926 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
927 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
928 } DMA_OPERATIONS, *PDMA_OPERATIONS;
929
930 typedef enum _ARBITER_REQUEST_SOURCE {
931 ArbiterRequestUndefined = -1,
932 ArbiterRequestLegacyReported,
933 ArbiterRequestHalReported,
934 ArbiterRequestLegacyAssigned,
935 ArbiterRequestPnpDetected,
936 ArbiterRequestPnpEnumerated
937 } ARBITER_REQUEST_SOURCE;
938
939 typedef enum _ARBITER_RESULT {
940 ArbiterResultUndefined = -1,
941 ArbiterResultSuccess,
942 ArbiterResultExternalConflict,
943 ArbiterResultNullRequest
944 } ARBITER_RESULT;
945
946 typedef enum _ARBITER_ACTION {
947 ArbiterActionTestAllocation,
948 ArbiterActionRetestAllocation,
949 ArbiterActionCommitAllocation,
950 ArbiterActionRollbackAllocation,
951 ArbiterActionQueryAllocatedResources,
952 ArbiterActionWriteReservedResources,
953 ArbiterActionQueryConflict,
954 ArbiterActionQueryArbitrate,
955 ArbiterActionAddReserved,
956 ArbiterActionBootAllocation
957 } ARBITER_ACTION, *PARBITER_ACTION;
958
959 typedef struct _ARBITER_CONFLICT_INFO {
960 PDEVICE_OBJECT OwningObject;
961 ULONGLONG Start;
962 ULONGLONG End;
963 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
964
965 typedef struct _ARBITER_PARAMETERS {
966 union {
967 struct {
968 IN OUT PLIST_ENTRY ArbitrationList;
969 IN ULONG AllocateFromCount;
970 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
971 } TestAllocation;
972
973 struct {
974 IN OUT PLIST_ENTRY ArbitrationList;
975 IN ULONG AllocateFromCount;
976 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
977 } RetestAllocation;
978
979 struct {
980 IN OUT PLIST_ENTRY ArbitrationList;
981 } BootAllocation;
982
983 struct {
984 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
985 } QueryAllocatedResources;
986
987 struct {
988 IN PDEVICE_OBJECT PhysicalDeviceObject;
989 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
990 OUT PULONG ConflictCount;
991 OUT PARBITER_CONFLICT_INFO *Conflicts;
992 } QueryConflict;
993
994 struct {
995 IN PLIST_ENTRY ArbitrationList;
996 } QueryArbitrate;
997
998 struct {
999 IN PDEVICE_OBJECT ReserveDevice;
1000 } AddReserved;
1001 } Parameters;
1002 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
1003
1004 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
1005
1006 typedef struct _ARBITER_LIST_ENTRY {
1007 LIST_ENTRY ListEntry;
1008 ULONG AlternativeCount;
1009 PIO_RESOURCE_DESCRIPTOR Alternatives;
1010 PDEVICE_OBJECT PhysicalDeviceObject;
1011 ARBITER_REQUEST_SOURCE RequestSource;
1012 ULONG Flags;
1013 LONG_PTR WorkSpace;
1014 INTERFACE_TYPE InterfaceType;
1015 ULONG SlotNumber;
1016 ULONG BusNumber;
1017 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
1018 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
1019 ARBITER_RESULT Result;
1020 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
1021
1022 typedef NTSTATUS
1023 (DDKAPI *PARBITER_HANDLER)(
1024 IN PVOID Context,
1025 IN ARBITER_ACTION Action,
1026 IN OUT PARBITER_PARAMETERS Parameters);
1027
1028 #define ARBITER_PARTIAL 0x00000001
1029
1030 typedef struct _ARBITER_INTERFACE {
1031 USHORT Size;
1032 USHORT Version;
1033 PVOID Context;
1034 PINTERFACE_REFERENCE InterfaceReference;
1035 PINTERFACE_DEREFERENCE InterfaceDereference;
1036 PARBITER_HANDLER ArbiterHandler;
1037 ULONG Flags;
1038 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
1039
1040 typedef enum _KPROFILE_SOURCE {
1041 ProfileTime,
1042 ProfileAlignmentFixup,
1043 ProfileTotalIssues,
1044 ProfilePipelineDry,
1045 ProfileLoadInstructions,
1046 ProfilePipelineFrozen,
1047 ProfileBranchInstructions,
1048 ProfileTotalNonissues,
1049 ProfileDcacheMisses,
1050 ProfileIcacheMisses,
1051 ProfileCacheMisses,
1052 ProfileBranchMispredictions,
1053 ProfileStoreInstructions,
1054 ProfileFpInstructions,
1055 ProfileIntegerInstructions,
1056 Profile2Issue,
1057 Profile3Issue,
1058 Profile4Issue,
1059 ProfileSpecialInstructions,
1060 ProfileTotalCycles,
1061 ProfileIcacheIssues,
1062 ProfileDcacheAccesses,
1063 ProfileMemoryBarrierCycles,
1064 ProfileLoadLinkedIssues,
1065 ProfileMaximum
1066 } KPROFILE_SOURCE;
1067
1068 typedef enum _HAL_QUERY_INFORMATION_CLASS {
1069 HalInstalledBusInformation,
1070 HalProfileSourceInformation,
1071 HalInformationClassUnused1,
1072 HalPowerInformation,
1073 HalProcessorSpeedInformation,
1074 HalCallbackInformation,
1075 HalMapRegisterInformation,
1076 HalMcaLogInformation,
1077 HalFrameBufferCachingInformation,
1078 HalDisplayBiosInformation,
1079 HalProcessorFeatureInformation,
1080 HalNumaTopologyInterface,
1081 HalErrorInformation,
1082 HalCmcLogInformation,
1083 HalCpeLogInformation,
1084 HalQueryMcaInterface,
1085 HalQueryAMLIIllegalIOPortAddresses,
1086 HalQueryMaxHotPlugMemoryAddress,
1087 HalPartitionIpiInterface,
1088 HalPlatformInformation,
1089 HalQueryProfileSourceList
1090 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
1091
1092 typedef enum _HAL_SET_INFORMATION_CLASS {
1093 HalProfileSourceInterval,
1094 HalProfileSourceInterruptHandler,
1095 HalMcaRegisterDriver,
1096 HalKernelErrorHandler,
1097 HalCmcRegisterDriver,
1098 HalCpeRegisterDriver,
1099 HalMcaLog,
1100 HalCmcLog,
1101 HalCpeLog,
1102 HalGenerateCmcInterrupt
1103 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
1104
1105 typedef struct _HAL_PROFILE_SOURCE_INTERVAL
1106 {
1107 KPROFILE_SOURCE Source;
1108 ULONG_PTR Interval;
1109 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
1110
1111 typedef struct _HAL_PROFILE_SOURCE_INFORMATION
1112 {
1113 KPROFILE_SOURCE Source;
1114 BOOLEAN Supported;
1115 ULONG Interval;
1116 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
1117
1118 typedef struct _MAP_REGISTER_ENTRY
1119 {
1120 PVOID MapRegister;
1121 BOOLEAN WriteToDevice;
1122 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
1123
1124 typedef struct
1125 {
1126 UCHAR Type;
1127 BOOLEAN Valid;
1128 UCHAR Reserved[2];
1129 PUCHAR TranslatedAddress;
1130 ULONG Length;
1131 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
1132
1133 typedef struct
1134 {
1135 PHYSICAL_ADDRESS Start;
1136 PHYSICAL_ADDRESS MaxEnd;
1137 PVOID VirtualAddress;
1138 ULONG Length;
1139 BOOLEAN Cached;
1140 BOOLEAN Aligned;
1141 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
1142
1143 typedef struct
1144 {
1145 ULONG Bus;
1146 ULONG Slot;
1147 USHORT VendorID;
1148 USHORT DeviceID;
1149 UCHAR BaseClass;
1150 UCHAR SubClass;
1151 UCHAR ProgIf;
1152 BOOLEAN Initialized;
1153 DEBUG_DEVICE_ADDRESS BaseAddress[6];
1154 DEBUG_MEMORY_REQUIREMENTS Memory;
1155 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
1156
1157 typedef enum _KD_OPTION {
1158 KD_OPTION_SET_BLOCK_ENABLE,
1159 } KD_OPTION;
1160
1161 /* Function Type Defintions for Dispatch Functions */
1162 struct _DEVICE_CONTROL_CONTEXT;
1163
1164 typedef VOID
1165 (DDKAPI *PDEVICE_CONTROL_COMPLETION)(
1166 IN struct _DEVICE_CONTROL_CONTEXT *ControlContext);
1167
1168 typedef struct _DEVICE_CONTROL_CONTEXT {
1169 NTSTATUS Status;
1170 PDEVICE_HANDLER_OBJECT DeviceHandler;
1171 PDEVICE_OBJECT DeviceObject;
1172 ULONG ControlCode;
1173 PVOID Buffer;
1174 PULONG BufferLength;
1175 PVOID Context;
1176 } DEVICE_CONTROL_CONTEXT, *PDEVICE_CONTROL_CONTEXT;
1177
1178 typedef struct _PM_DISPATCH_TABLE {
1179 ULONG Signature;
1180 ULONG Version;
1181 PVOID Function[1];
1182 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
1183
1184 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
1185 TranslateChildToParent,
1186 TranslateParentToChild
1187 } RESOURCE_TRANSLATION_DIRECTION;
1188
1189 typedef NTSTATUS
1190 (DDKAPI *PTRANSLATE_RESOURCE_HANDLER)(
1191 IN PVOID Context,
1192 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
1193 IN RESOURCE_TRANSLATION_DIRECTION Direction,
1194 IN ULONG AlternativesCount,
1195 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
1196 IN PDEVICE_OBJECT PhysicalDeviceObject,
1197 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
1198
1199 typedef NTSTATUS
1200 (DDKAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
1201 IN PVOID Context,
1202 IN PIO_RESOURCE_DESCRIPTOR Source,
1203 IN PDEVICE_OBJECT PhysicalDeviceObject,
1204 OUT PULONG TargetCount,
1205 OUT PIO_RESOURCE_DESCRIPTOR *Target);
1206
1207 typedef struct _TRANSLATOR_INTERFACE {
1208 USHORT Size;
1209 USHORT Version;
1210 PVOID Context;
1211 PINTERFACE_REFERENCE InterfaceReference;
1212 PINTERFACE_DEREFERENCE InterfaceDereference;
1213 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
1214 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
1215 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
1216
1217 typedef NTSTATUS
1218 (DDKAPI *pHalDeviceControl)(
1219 IN PDEVICE_HANDLER_OBJECT DeviceHandler,
1220 IN PDEVICE_OBJECT DeviceObject,
1221 IN ULONG ControlCode,
1222 IN OUT PVOID Buffer OPTIONAL,
1223 IN OUT PULONG BufferLength OPTIONAL,
1224 IN PVOID Context,
1225 IN PDEVICE_CONTROL_COMPLETION CompletionRoutine);
1226
1227 typedef VOID
1228 (FASTCALL *pHalExamineMBR)(
1229 IN PDEVICE_OBJECT DeviceObject,
1230 IN ULONG SectorSize,
1231 IN ULONG MBRTypeIdentifier,
1232 OUT PVOID *Buffer);
1233
1234 typedef VOID
1235 (FASTCALL *pHalIoAssignDriveLetters)(
1236 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1237 IN PSTRING NtDeviceName,
1238 OUT PUCHAR NtSystemPath,
1239 OUT PSTRING NtSystemPathString);
1240
1241 typedef NTSTATUS
1242 (FASTCALL *pHalIoReadPartitionTable)(
1243 IN PDEVICE_OBJECT DeviceObject,
1244 IN ULONG SectorSize,
1245 IN BOOLEAN ReturnRecognizedPartitions,
1246 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
1247
1248 typedef NTSTATUS
1249 (FASTCALL *pHalIoSetPartitionInformation)(
1250 IN PDEVICE_OBJECT DeviceObject,
1251 IN ULONG SectorSize,
1252 IN ULONG PartitionNumber,
1253 IN ULONG PartitionType);
1254
1255 typedef NTSTATUS
1256 (FASTCALL *pHalIoWritePartitionTable)(
1257 IN PDEVICE_OBJECT DeviceObject,
1258 IN ULONG SectorSize,
1259 IN ULONG SectorsPerTrack,
1260 IN ULONG NumberOfHeads,
1261 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
1262
1263 typedef PBUS_HANDLER
1264 (FASTCALL *pHalHandlerForBus)(
1265 IN INTERFACE_TYPE InterfaceType,
1266 IN ULONG BusNumber);
1267
1268 typedef VOID
1269 (FASTCALL *pHalReferenceBusHandler)(
1270 IN PBUS_HANDLER BusHandler);
1271
1272 typedef NTSTATUS
1273 (DDKAPI *pHalQuerySystemInformation)(
1274 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
1275 IN ULONG BufferSize,
1276 IN OUT PVOID Buffer,
1277 OUT PULONG ReturnedLength);
1278
1279 typedef NTSTATUS
1280 (DDKAPI *pHalSetSystemInformation)(
1281 IN HAL_SET_INFORMATION_CLASS InformationClass,
1282 IN ULONG BufferSize,
1283 IN PVOID Buffer);
1284
1285 typedef NTSTATUS
1286 (DDKAPI *pHalQueryBusSlots)(
1287 IN PBUS_HANDLER BusHandler,
1288 IN ULONG BufferSize,
1289 OUT PULONG SlotNumbers,
1290 OUT PULONG ReturnedLength);
1291
1292 typedef NTSTATUS
1293 (DDKAPI *pHalInitPnpDriver)(
1294 VOID);
1295
1296 typedef NTSTATUS
1297 (DDKAPI *pHalInitPowerManagement)(
1298 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
1299 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
1300
1301 typedef struct _DMA_ADAPTER*
1302 (DDKAPI *pHalGetDmaAdapter)(
1303 IN PVOID Context,
1304 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
1305 OUT PULONG NumberOfMapRegisters);
1306
1307 typedef NTSTATUS
1308 (DDKAPI *pHalGetInterruptTranslator)(
1309 IN INTERFACE_TYPE ParentInterfaceType,
1310 IN ULONG ParentBusNumber,
1311 IN INTERFACE_TYPE BridgeInterfaceType,
1312 IN USHORT Size,
1313 IN USHORT Version,
1314 OUT PTRANSLATOR_INTERFACE Translator,
1315 OUT PULONG BridgeBusNumber);
1316
1317 typedef NTSTATUS
1318 (DDKAPI *pHalStartMirroring)(
1319 VOID);
1320
1321 typedef NTSTATUS
1322 (DDKAPI *pHalEndMirroring)(
1323 IN ULONG PassNumber);
1324
1325 typedef NTSTATUS
1326 (DDKAPI *pHalMirrorPhysicalMemory)(
1327 IN PHYSICAL_ADDRESS PhysicalAddress,
1328 IN LARGE_INTEGER NumberOfBytes);
1329
1330 typedef NTSTATUS
1331 (DDKAPI *pHalMirrorVerify)(
1332 IN PHYSICAL_ADDRESS PhysicalAddress,
1333 IN LARGE_INTEGER NumberOfBytes);
1334
1335 typedef VOID
1336 (DDKAPI *pHalEndOfBoot)(
1337 VOID);
1338
1339 typedef
1340 BOOLEAN
1341 (DDKAPI *pHalTranslateBusAddress)(
1342 IN INTERFACE_TYPE InterfaceType,
1343 IN ULONG BusNumber,
1344 IN PHYSICAL_ADDRESS BusAddress,
1345 IN OUT PULONG AddressSpace,
1346 OUT PPHYSICAL_ADDRESS TranslatedAddress
1347 );
1348
1349 typedef
1350 NTSTATUS
1351 (DDKAPI *pHalAssignSlotResources)(
1352 IN PUNICODE_STRING RegistryPath,
1353 IN PUNICODE_STRING DriverClassName OPTIONAL,
1354 IN PDRIVER_OBJECT DriverObject,
1355 IN PDEVICE_OBJECT DeviceObject,
1356 IN INTERFACE_TYPE BusType,
1357 IN ULONG BusNumber,
1358 IN ULONG SlotNumber,
1359 IN OUT PCM_RESOURCE_LIST *AllocatedResources
1360 );
1361
1362 typedef
1363 VOID
1364 (DDKAPI *pHalHaltSystem)(
1365 VOID
1366 );
1367
1368 typedef
1369 BOOLEAN
1370 (DDKAPI *pHalResetDisplay)(
1371 VOID
1372 );
1373
1374 typedef
1375 UCHAR
1376 (DDKAPI *pHalVectorToIDTEntry)(
1377 ULONG Vector
1378 );
1379
1380 typedef
1381 BOOLEAN
1382 (DDKAPI *pHalFindBusAddressTranslation)(
1383 IN PHYSICAL_ADDRESS BusAddress,
1384 IN OUT PULONG AddressSpace,
1385 OUT PPHYSICAL_ADDRESS TranslatedAddress,
1386 IN OUT PULONG_PTR Context,
1387 IN BOOLEAN NextBus
1388 );
1389
1390 typedef
1391 NTSTATUS
1392 (DDKAPI *pKdSetupPciDeviceForDebugging)(
1393 IN PVOID LoaderBlock OPTIONAL,
1394 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
1395 );
1396
1397 typedef
1398 NTSTATUS
1399 (DDKAPI *pKdReleasePciDeviceForDebugging)(
1400 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
1401 );
1402
1403 typedef
1404 PVOID
1405 (DDKAPI *pKdGetAcpiTablePhase0)(
1406 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1407 IN ULONG Signature
1408 );
1409
1410 typedef
1411 VOID
1412 (DDKAPI *pKdCheckPowerButton)(
1413 VOID
1414 );
1415
1416 typedef
1417 ULONG
1418 (DDKAPI *pHalGetInterruptVector)(
1419 IN INTERFACE_TYPE InterfaceType,
1420 IN ULONG BusNumber,
1421 IN ULONG BusInterruptLevel,
1422 IN ULONG BusInterruptVector,
1423 OUT PKIRQL Irql,
1424 OUT PKAFFINITY Affinity
1425 );
1426
1427 typedef
1428 NTSTATUS
1429 (DDKAPI *pHalGetVectorInput)(
1430 IN ULONG Vector,
1431 IN KAFFINITY Affinity,
1432 OUT PULONG Input,
1433 OUT PKINTERRUPT_POLARITY Polarity
1434 );
1435
1436 typedef
1437 PVOID
1438 (DDKAPI *pKdMapPhysicalMemory64)(
1439 IN PHYSICAL_ADDRESS PhysicalAddress,
1440 IN ULONG NumberPages
1441 );
1442
1443 typedef
1444 VOID
1445 (DDKAPI *pKdUnmapVirtualAddress)(
1446 IN PVOID VirtualAddress,
1447 IN ULONG NumberPages
1448 );
1449
1450 typedef
1451 ULONG
1452 (DDKAPI *pKdGetPciDataByOffset)(
1453 IN ULONG BusNumber,
1454 IN ULONG SlotNumber,
1455 OUT PVOID Buffer,
1456 IN ULONG Offset,
1457 IN ULONG Length
1458 );
1459
1460 typedef
1461 ULONG
1462 (DDKAPI *pKdSetPciDataByOffset)(
1463 IN ULONG BusNumber,
1464 IN ULONG SlotNumber,
1465 IN PVOID Buffer,
1466 IN ULONG Offset,
1467 IN ULONG Length
1468 );
1469
1470 typedef BOOLEAN
1471 (DDKAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
1472 ULONG Columns, ULONG Rows);
1473
1474 typedef struct {
1475 ULONG Version;
1476 pHalQuerySystemInformation HalQuerySystemInformation;
1477 pHalSetSystemInformation HalSetSystemInformation;
1478 pHalQueryBusSlots HalQueryBusSlots;
1479 ULONG Spare1;
1480 pHalExamineMBR HalExamineMBR;
1481 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
1482 pHalIoReadPartitionTable HalIoReadPartitionTable;
1483 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
1484 pHalIoWritePartitionTable HalIoWritePartitionTable;
1485 pHalHandlerForBus HalReferenceHandlerForBus;
1486 pHalReferenceBusHandler HalReferenceBusHandler;
1487 pHalReferenceBusHandler HalDereferenceBusHandler;
1488 pHalInitPnpDriver HalInitPnpDriver;
1489 pHalInitPowerManagement HalInitPowerManagement;
1490 pHalGetDmaAdapter HalGetDmaAdapter;
1491 pHalGetInterruptTranslator HalGetInterruptTranslator;
1492 pHalStartMirroring HalStartMirroring;
1493 pHalEndMirroring HalEndMirroring;
1494 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
1495 pHalEndOfBoot HalEndOfBoot;
1496 pHalMirrorVerify HalMirrorVerify;
1497 } HAL_DISPATCH, *PHAL_DISPATCH;
1498
1499 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTHAL_)
1500 extern NTSYSAPI PHAL_DISPATCH HalDispatchTable;
1501 #define HALDISPATCH ((PHAL_DISPATCH)&HalDispatchTable)
1502 #else
1503 extern __declspec(dllexport) HAL_DISPATCH HalDispatchTable;
1504 #define HALDISPATCH (&HalDispatchTable)
1505 #endif
1506
1507 #define HAL_DISPATCH_VERSION 3
1508 #define HalDispatchTableVersion HALDISPATCH->Version
1509 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
1510 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
1511 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
1512 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
1513 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
1514 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
1515 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
1516 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
1517 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
1518 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
1519 #define HalStartMirroring HALDISPATCH->HalStartMirroring
1520 #define HalEndMirroring HALDISPATCH->HalEndMirroring
1521 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
1522 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
1523 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
1524
1525 typedef enum _FILE_INFORMATION_CLASS {
1526 FileDirectoryInformation = 1,
1527 FileFullDirectoryInformation,
1528 FileBothDirectoryInformation,
1529 FileBasicInformation,
1530 FileStandardInformation,
1531 FileInternalInformation,
1532 FileEaInformation,
1533 FileAccessInformation,
1534 FileNameInformation,
1535 FileRenameInformation,
1536 FileLinkInformation,
1537 FileNamesInformation,
1538 FileDispositionInformation,
1539 FilePositionInformation,
1540 FileFullEaInformation,
1541 FileModeInformation,
1542 FileAlignmentInformation,
1543 FileAllInformation,
1544 FileAllocationInformation,
1545 FileEndOfFileInformation,
1546 FileAlternateNameInformation,
1547 FileStreamInformation,
1548 FilePipeInformation,
1549 FilePipeLocalInformation,
1550 FilePipeRemoteInformation,
1551 FileMailslotQueryInformation,
1552 FileMailslotSetInformation,
1553 FileCompressionInformation,
1554 FileObjectIdInformation,
1555 FileCompletionInformation,
1556 FileMoveClusterInformation,
1557 FileQuotaInformation,
1558 FileReparsePointInformation,
1559 FileNetworkOpenInformation,
1560 FileAttributeTagInformation,
1561 FileTrackingInformation,
1562 FileIdBothDirectoryInformation,
1563 FileIdFullDirectoryInformation,
1564 FileValidDataLengthInformation,
1565 FileShortNameInformation,
1566 FileMaximumInformation
1567 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
1568
1569 typedef struct _FILE_POSITION_INFORMATION {
1570 LARGE_INTEGER CurrentByteOffset;
1571 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
1572
1573 typedef struct _FILE_ALIGNMENT_INFORMATION {
1574 ULONG AlignmentRequirement;
1575 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
1576
1577 typedef struct _FILE_NAME_INFORMATION {
1578 ULONG FileNameLength;
1579 WCHAR FileName[1];
1580 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
1581
1582 #include <pshpack8.h>
1583 typedef struct _FILE_BASIC_INFORMATION {
1584 LARGE_INTEGER CreationTime;
1585 LARGE_INTEGER LastAccessTime;
1586 LARGE_INTEGER LastWriteTime;
1587 LARGE_INTEGER ChangeTime;
1588 ULONG FileAttributes;
1589 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
1590 #include <poppack.h>
1591
1592 typedef struct _FILE_STANDARD_INFORMATION {
1593 LARGE_INTEGER AllocationSize;
1594 LARGE_INTEGER EndOfFile;
1595 ULONG NumberOfLinks;
1596 BOOLEAN DeletePending;
1597 BOOLEAN Directory;
1598 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
1599
1600 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
1601 LARGE_INTEGER CreationTime;
1602 LARGE_INTEGER LastAccessTime;
1603 LARGE_INTEGER LastWriteTime;
1604 LARGE_INTEGER ChangeTime;
1605 LARGE_INTEGER AllocationSize;
1606 LARGE_INTEGER EndOfFile;
1607 ULONG FileAttributes;
1608 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
1609
1610 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
1611 ULONG FileAttributes;
1612 ULONG ReparseTag;
1613 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
1614
1615 typedef struct _FILE_DISPOSITION_INFORMATION {
1616 BOOLEAN DeleteFile;
1617 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
1618
1619 typedef struct _FILE_END_OF_FILE_INFORMATION {
1620 LARGE_INTEGER EndOfFile;
1621 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
1622
1623 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
1624 LARGE_INTEGER ValidDataLength;
1625 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
1626
1627 typedef union _FILE_SEGMENT_ELEMENT {
1628 PVOID64 Buffer;
1629 ULONGLONG Alignment;
1630 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
1631
1632 typedef enum _FSINFOCLASS {
1633 FileFsVolumeInformation = 1,
1634 FileFsLabelInformation,
1635 FileFsSizeInformation,
1636 FileFsDeviceInformation,
1637 FileFsAttributeInformation,
1638 FileFsControlInformation,
1639 FileFsFullSizeInformation,
1640 FileFsObjectIdInformation,
1641 FileFsDriverPathInformation,
1642 FileFsMaximumInformation
1643 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
1644
1645 typedef struct _FILE_FS_DEVICE_INFORMATION {
1646 DEVICE_TYPE DeviceType;
1647 ULONG Characteristics;
1648 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
1649
1650 typedef struct _FILE_FULL_EA_INFORMATION {
1651 ULONG NextEntryOffset;
1652 UCHAR Flags;
1653 UCHAR EaNameLength;
1654 USHORT EaValueLength;
1655 CHAR EaName[1];
1656 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
1657
1658 /* ERESOURCE.Flag */
1659
1660 #define ResourceNeverExclusive 0x0010
1661 #define ResourceReleaseByOtherThread 0x0020
1662 #define ResourceOwnedExclusive 0x0080
1663
1664 #define RESOURCE_HASH_TABLE_SIZE 64
1665
1666 typedef struct _DEVOBJ_EXTENSION
1667 {
1668 CSHORT Type;
1669 USHORT Size;
1670 PDEVICE_OBJECT DeviceObject;
1671 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
1672
1673 typedef BOOLEAN
1674 (DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
1675 IN struct _FILE_OBJECT *FileObject,
1676 IN PLARGE_INTEGER FileOffset,
1677 IN ULONG Length,
1678 IN BOOLEAN Wait,
1679 IN ULONG LockKey,
1680 IN BOOLEAN CheckForReadOperation,
1681 OUT PIO_STATUS_BLOCK IoStatus,
1682 IN struct _DEVICE_OBJECT *DeviceObject);
1683
1684 typedef BOOLEAN
1685 (DDKAPI *PFAST_IO_READ)(
1686 IN struct _FILE_OBJECT *FileObject,
1687 IN PLARGE_INTEGER FileOffset,
1688 IN ULONG Length,
1689 IN BOOLEAN Wait,
1690 IN ULONG LockKey,
1691 OUT PVOID Buffer,
1692 OUT PIO_STATUS_BLOCK IoStatus,
1693 IN struct _DEVICE_OBJECT *DeviceObject);
1694
1695 typedef BOOLEAN
1696 (DDKAPI *PFAST_IO_WRITE)(
1697 IN struct _FILE_OBJECT *FileObject,
1698 IN PLARGE_INTEGER FileOffset,
1699 IN ULONG Length,
1700 IN BOOLEAN Wait,
1701 IN ULONG LockKey,
1702 IN PVOID Buffer,
1703 OUT PIO_STATUS_BLOCK IoStatus,
1704 IN struct _DEVICE_OBJECT *DeviceObject);
1705
1706 typedef BOOLEAN
1707 (DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
1708 IN struct _FILE_OBJECT *FileObject,
1709 IN BOOLEAN Wait,
1710 OUT PFILE_BASIC_INFORMATION Buffer,
1711 OUT PIO_STATUS_BLOCK IoStatus,
1712 IN struct _DEVICE_OBJECT *DeviceObject);
1713
1714 typedef BOOLEAN
1715 (DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
1716 IN struct _FILE_OBJECT *FileObject,
1717 IN BOOLEAN Wait,
1718 OUT PFILE_STANDARD_INFORMATION Buffer,
1719 OUT PIO_STATUS_BLOCK IoStatus,
1720 IN struct _DEVICE_OBJECT *DeviceObject);
1721
1722 typedef BOOLEAN
1723 (DDKAPI *PFAST_IO_LOCK)(
1724 IN struct _FILE_OBJECT *FileObject,
1725 IN PLARGE_INTEGER FileOffset,
1726 IN PLARGE_INTEGER Length,
1727 PEPROCESS ProcessId,
1728 ULONG Key,
1729 BOOLEAN FailImmediately,
1730 BOOLEAN ExclusiveLock,
1731 OUT PIO_STATUS_BLOCK IoStatus,
1732 IN struct _DEVICE_OBJECT *DeviceObject);
1733
1734 typedef BOOLEAN
1735 (DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
1736 IN struct _FILE_OBJECT *FileObject,
1737 IN PLARGE_INTEGER FileOffset,
1738 IN PLARGE_INTEGER Length,
1739 PEPROCESS ProcessId,
1740 ULONG Key,
1741 OUT PIO_STATUS_BLOCK IoStatus,
1742 IN struct _DEVICE_OBJECT *DeviceObject);
1743
1744 typedef BOOLEAN
1745 (DDKAPI *PFAST_IO_UNLOCK_ALL)(
1746 IN struct _FILE_OBJECT *FileObject,
1747 PEPROCESS ProcessId,
1748 OUT PIO_STATUS_BLOCK IoStatus,
1749 IN struct _DEVICE_OBJECT *DeviceObject);
1750
1751 typedef BOOLEAN
1752 (DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
1753 IN struct _FILE_OBJECT *FileObject,
1754 PVOID ProcessId,
1755 ULONG Key,
1756 OUT PIO_STATUS_BLOCK IoStatus,
1757 IN struct _DEVICE_OBJECT *DeviceObject);
1758
1759 typedef BOOLEAN
1760 (DDKAPI *PFAST_IO_DEVICE_CONTROL)(
1761 IN struct _FILE_OBJECT *FileObject,
1762 IN BOOLEAN Wait,
1763 IN PVOID InputBuffer OPTIONAL,
1764 IN ULONG InputBufferLength,
1765 OUT PVOID OutputBuffer OPTIONAL,
1766 IN ULONG OutputBufferLength,
1767 IN ULONG IoControlCode,
1768 OUT PIO_STATUS_BLOCK IoStatus,
1769 IN struct _DEVICE_OBJECT *DeviceObject);
1770
1771 typedef VOID
1772 (DDKAPI *PFAST_IO_ACQUIRE_FILE)(
1773 IN struct _FILE_OBJECT *FileObject);
1774
1775 typedef VOID
1776 (DDKAPI *PFAST_IO_RELEASE_FILE)(
1777 IN struct _FILE_OBJECT *FileObject);
1778
1779 typedef VOID
1780 (DDKAPI *PFAST_IO_DETACH_DEVICE)(
1781 IN struct _DEVICE_OBJECT *SourceDevice,
1782 IN struct _DEVICE_OBJECT *TargetDevice);
1783
1784 typedef BOOLEAN
1785 (DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
1786 IN struct _FILE_OBJECT *FileObject,
1787 IN BOOLEAN Wait,
1788 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
1789 OUT struct _IO_STATUS_BLOCK *IoStatus,
1790 IN struct _DEVICE_OBJECT *DeviceObject);
1791
1792 typedef NTSTATUS
1793 (DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
1794 IN struct _FILE_OBJECT *FileObject,
1795 IN PLARGE_INTEGER EndingOffset,
1796 OUT struct _ERESOURCE **ResourceToRelease,
1797 IN struct _DEVICE_OBJECT *DeviceObject);
1798
1799 typedef BOOLEAN
1800 (DDKAPI *PFAST_IO_MDL_READ)(
1801 IN struct _FILE_OBJECT *FileObject,
1802 IN PLARGE_INTEGER FileOffset,
1803 IN ULONG Length,
1804 IN ULONG LockKey,
1805 OUT PMDL *MdlChain,
1806 OUT PIO_STATUS_BLOCK IoStatus,
1807 IN struct _DEVICE_OBJECT *DeviceObject);
1808
1809 typedef BOOLEAN
1810 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
1811 IN struct _FILE_OBJECT *FileObject,
1812 IN PMDL MdlChain,
1813 IN struct _DEVICE_OBJECT *DeviceObject);
1814
1815 typedef BOOLEAN
1816 (DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
1817 IN struct _FILE_OBJECT *FileObject,
1818 IN PLARGE_INTEGER FileOffset,
1819 IN ULONG Length,
1820 IN ULONG LockKey,
1821 OUT PMDL *MdlChain,
1822 OUT PIO_STATUS_BLOCK IoStatus,
1823 IN struct _DEVICE_OBJECT *DeviceObject);
1824
1825 typedef BOOLEAN
1826 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
1827 IN struct _FILE_OBJECT *FileObject,
1828 IN PLARGE_INTEGER FileOffset,
1829 IN PMDL MdlChain,
1830 IN struct _DEVICE_OBJECT *DeviceObject);
1831
1832 typedef BOOLEAN
1833 (DDKAPI *PFAST_IO_READ_COMPRESSED)(
1834 IN struct _FILE_OBJECT *FileObject,
1835 IN PLARGE_INTEGER FileOffset,
1836 IN ULONG Length,
1837 IN ULONG LockKey,
1838 OUT PVOID Buffer,
1839 OUT PMDL *MdlChain,
1840 OUT PIO_STATUS_BLOCK IoStatus,
1841 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1842 IN ULONG CompressedDataInfoLength,
1843 IN struct _DEVICE_OBJECT *DeviceObject);
1844
1845 typedef BOOLEAN
1846 (DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
1847 IN struct _FILE_OBJECT *FileObject,
1848 IN PLARGE_INTEGER FileOffset,
1849 IN ULONG Length,
1850 IN ULONG LockKey,
1851 IN PVOID Buffer,
1852 OUT PMDL *MdlChain,
1853 OUT PIO_STATUS_BLOCK IoStatus,
1854 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1855 IN ULONG CompressedDataInfoLength,
1856 IN struct _DEVICE_OBJECT *DeviceObject);
1857
1858 typedef BOOLEAN
1859 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
1860 IN struct _FILE_OBJECT *FileObject,
1861 IN PMDL MdlChain,
1862 IN struct _DEVICE_OBJECT *DeviceObject);
1863
1864 typedef BOOLEAN
1865 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
1866 IN struct _FILE_OBJECT *FileObject,
1867 IN PLARGE_INTEGER FileOffset,
1868 IN PMDL MdlChain,
1869 IN struct _DEVICE_OBJECT *DeviceObject);
1870
1871 typedef BOOLEAN
1872 (DDKAPI *PFAST_IO_QUERY_OPEN)(
1873 IN struct _IRP *Irp,
1874 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
1875 IN struct _DEVICE_OBJECT *DeviceObject);
1876
1877 typedef NTSTATUS
1878 (DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
1879 IN struct _FILE_OBJECT *FileObject,
1880 IN struct _ERESOURCE *ResourceToRelease,
1881 IN struct _DEVICE_OBJECT *DeviceObject);
1882
1883 typedef NTSTATUS
1884 (DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
1885 IN struct _FILE_OBJECT *FileObject,
1886 IN struct _DEVICE_OBJECT *DeviceObject);
1887
1888 typedef NTSTATUS
1889 (DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
1890 IN struct _FILE_OBJECT *FileObject,
1891 IN struct _DEVICE_OBJECT *DeviceObject);
1892
1893 typedef struct _FAST_IO_DISPATCH {
1894 ULONG SizeOfFastIoDispatch;
1895 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
1896 PFAST_IO_READ FastIoRead;
1897 PFAST_IO_WRITE FastIoWrite;
1898 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
1899 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
1900 PFAST_IO_LOCK FastIoLock;
1901 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
1902 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
1903 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
1904 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
1905 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
1906 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
1907 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
1908 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
1909 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
1910 PFAST_IO_MDL_READ MdlRead;
1911 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
1912 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
1913 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
1914 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
1915 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
1916 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
1917 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
1918 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
1919 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
1920 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
1921 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
1922 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
1923
1924 typedef struct _SECTION_OBJECT_POINTERS {
1925 PVOID DataSectionObject;
1926 PVOID SharedCacheMap;
1927 PVOID ImageSectionObject;
1928 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
1929
1930 typedef struct _IO_COMPLETION_CONTEXT {
1931 PVOID Port;
1932 PVOID Key;
1933 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
1934
1935 /* FILE_OBJECT.Flags */
1936
1937 #define FO_FILE_OPEN 0x00000001
1938 #define FO_SYNCHRONOUS_IO 0x00000002
1939 #define FO_ALERTABLE_IO 0x00000004
1940 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
1941 #define FO_WRITE_THROUGH 0x00000010
1942 #define FO_SEQUENTIAL_ONLY 0x00000020
1943 #define FO_CACHE_SUPPORTED 0x00000040
1944 #define FO_NAMED_PIPE 0x00000080
1945 #define FO_STREAM_FILE 0x00000100
1946 #define FO_MAILSLOT 0x00000200
1947 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
1948 #define FO_DIRECT_DEVICE_OPEN 0x00000800
1949 #define FO_FILE_MODIFIED 0x00001000
1950 #define FO_FILE_SIZE_CHANGED 0x00002000
1951 #define FO_CLEANUP_COMPLETE 0x00004000
1952 #define FO_TEMPORARY_FILE 0x00008000
1953 #define FO_DELETE_ON_CLOSE 0x00010000
1954 #define FO_OPENED_CASE_SENSITIVE 0x00020000
1955 #define FO_HANDLE_CREATED 0x00040000
1956 #define FO_FILE_FAST_IO_READ 0x00080000
1957 #define FO_RANDOM_ACCESS 0x00100000
1958 #define FO_FILE_OPEN_CANCELLED 0x00200000
1959 #define FO_VOLUME_OPEN 0x00400000
1960 #define FO_REMOTE_ORIGIN 0x01000000
1961
1962 typedef struct _FILE_OBJECT
1963 {
1964 CSHORT Type;
1965 CSHORT Size;
1966 PDEVICE_OBJECT DeviceObject;
1967 PVPB Vpb;
1968 PVOID FsContext;
1969 PVOID FsContext2;
1970 PSECTION_OBJECT_POINTERS SectionObjectPointer;
1971 PVOID PrivateCacheMap;
1972 NTSTATUS FinalStatus;
1973 struct _FILE_OBJECT *RelatedFileObject;
1974 BOOLEAN LockOperation;
1975 BOOLEAN DeletePending;
1976 BOOLEAN ReadAccess;
1977 BOOLEAN WriteAccess;
1978 BOOLEAN DeleteAccess;
1979 BOOLEAN SharedRead;
1980 BOOLEAN SharedWrite;
1981 BOOLEAN SharedDelete;
1982 ULONG Flags;
1983 UNICODE_STRING FileName;
1984 LARGE_INTEGER CurrentByteOffset;
1985 volatile ULONG Waiters;
1986 volatile ULONG Busy;
1987 PVOID LastLock;
1988 KEVENT Lock;
1989 KEVENT Event;
1990 volatile PIO_COMPLETION_CONTEXT CompletionContext;
1991 KSPIN_LOCK IrpListLock;
1992 LIST_ENTRY IrpList;
1993 volatile PVOID FileObjectExtension;
1994 } FILE_OBJECT;
1995 typedef struct _FILE_OBJECT *PFILE_OBJECT;
1996
1997 typedef enum _SECURITY_OPERATION_CODE {
1998 SetSecurityDescriptor,
1999 QuerySecurityDescriptor,
2000 DeleteSecurityDescriptor,
2001 AssignSecurityDescriptor
2002 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
2003
2004 #define INITIAL_PRIVILEGE_COUNT 3
2005
2006 typedef struct _INITIAL_PRIVILEGE_SET {
2007 ULONG PrivilegeCount;
2008 ULONG Control;
2009 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
2010 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
2011
2012 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
2013 #define SE_CREATE_TOKEN_PRIVILEGE 2
2014 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
2015 #define SE_LOCK_MEMORY_PRIVILEGE 4
2016 #define SE_INCREASE_QUOTA_PRIVILEGE 5
2017 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
2018 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
2019 #define SE_TCB_PRIVILEGE 7
2020 #define SE_SECURITY_PRIVILEGE 8
2021 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
2022 #define SE_LOAD_DRIVER_PRIVILEGE 10
2023 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
2024 #define SE_SYSTEMTIME_PRIVILEGE 12
2025 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
2026 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
2027 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
2028 #define SE_CREATE_PERMANENT_PRIVILEGE 16
2029 #define SE_BACKUP_PRIVILEGE 17
2030 #define SE_RESTORE_PRIVILEGE 18
2031 #define SE_SHUTDOWN_PRIVILEGE 19
2032 #define SE_DEBUG_PRIVILEGE 20
2033 #define SE_AUDIT_PRIVILEGE 21
2034 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
2035 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
2036 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
2037 #define SE_UNDOCK_PRIVILEGE 25
2038 #define SE_SYNC_AGENT_PRIVILEGE 26
2039 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
2040 #define SE_MANAGE_VOLUME_PRIVILEGE 28
2041 #define SE_IMPERSONATE_PRIVILEGE 29
2042 #define SE_CREATE_GLOBAL_PRIVILEGE 30
2043 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_GLOBAL_PRIVILEGE
2044
2045 typedef struct _SECURITY_SUBJECT_CONTEXT {
2046 PACCESS_TOKEN ClientToken;
2047 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
2048 PACCESS_TOKEN PrimaryToken;
2049 PVOID ProcessAuditId;
2050 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
2051
2052 #include <pshpack4.h>
2053 typedef struct _ACCESS_STATE {
2054 LUID OperationID;
2055 BOOLEAN SecurityEvaluated;
2056 BOOLEAN GenerateAudit;
2057 BOOLEAN GenerateOnClose;
2058 BOOLEAN PrivilegesAllocated;
2059 ULONG Flags;
2060 ACCESS_MASK RemainingDesiredAccess;
2061 ACCESS_MASK PreviouslyGrantedAccess;
2062 ACCESS_MASK OriginalDesiredAccess;
2063 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
2064 PSECURITY_DESCRIPTOR SecurityDescriptor;
2065 PVOID AuxData;
2066 union {
2067 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
2068 PRIVILEGE_SET PrivilegeSet;
2069 } Privileges;
2070
2071 BOOLEAN AuditPrivileges;
2072 UNICODE_STRING ObjectName;
2073 UNICODE_STRING ObjectTypeName;
2074 } ACCESS_STATE, *PACCESS_STATE;
2075 #include <poppack.h>
2076
2077 typedef struct _IO_SECURITY_CONTEXT {
2078 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
2079 PACCESS_STATE AccessState;
2080 ACCESS_MASK DesiredAccess;
2081 ULONG FullCreateOptions;
2082 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
2083
2084 #define IO_TYPE_ADAPTER 1
2085 #define IO_TYPE_CONTROLLER 2
2086 #define IO_TYPE_DEVICE 3
2087 #define IO_TYPE_DRIVER 4
2088 #define IO_TYPE_FILE 5
2089 #define IO_TYPE_IRP 6
2090 #define IO_TYPE_MASTER_ADAPTER 7
2091 #define IO_TYPE_OPEN_PACKET 8
2092 #define IO_TYPE_TIMER 9
2093 #define IO_TYPE_VPB 10
2094 #define IO_TYPE_ERROR_LOG 11
2095 #define IO_TYPE_ERROR_MESSAGE 12
2096 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
2097
2098 #define IO_TYPE_CSQ_IRP_CONTEXT 1
2099 #define IO_TYPE_CSQ 2
2100
2101 struct _IO_CSQ;
2102
2103 typedef struct _IO_CSQ_IRP_CONTEXT {
2104 ULONG Type;
2105 struct _IRP *Irp;
2106 struct _IO_CSQ *Csq;
2107 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
2108
2109 typedef VOID
2110 (DDKAPI *PIO_CSQ_INSERT_IRP)(
2111 IN struct _IO_CSQ *Csq,
2112 IN PIRP Irp);
2113
2114 typedef VOID
2115 (DDKAPI *PIO_CSQ_REMOVE_IRP)(
2116 IN struct _IO_CSQ *Csq,
2117 IN PIRP Irp);
2118
2119 typedef PIRP
2120 (DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)(
2121 IN struct _IO_CSQ *Csq,
2122 IN PIRP Irp,
2123 IN PVOID PeekContext);
2124
2125 typedef VOID
2126 (DDKAPI *PIO_CSQ_ACQUIRE_LOCK)(
2127 IN struct _IO_CSQ *Csq,
2128 OUT PKIRQL Irql);
2129
2130 typedef VOID
2131 (DDKAPI *PIO_CSQ_RELEASE_LOCK)(
2132 IN struct _IO_CSQ *Csq,
2133 IN KIRQL Irql);
2134
2135 typedef VOID
2136 (DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
2137 IN struct _IO_CSQ *Csq,
2138 IN PIRP Irp);
2139
2140 typedef struct _IO_CSQ {
2141 ULONG Type;
2142 PIO_CSQ_INSERT_IRP CsqInsertIrp;
2143 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
2144 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
2145 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
2146 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
2147 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
2148 PVOID ReservePointer;
2149 } IO_CSQ, *PIO_CSQ;
2150
2151 #if !defined(_ALPHA_)
2152 #include <pshpack4.h>
2153 #endif
2154 typedef struct _IO_STACK_LOCATION {
2155 UCHAR MajorFunction;
2156 UCHAR MinorFunction;
2157 UCHAR Flags;
2158 UCHAR Control;
2159 union {
2160 struct {
2161 PIO_SECURITY_CONTEXT SecurityContext;
2162 ULONG Options;
2163 USHORT POINTER_ALIGNMENT FileAttributes;
2164 USHORT ShareAccess;
2165 ULONG POINTER_ALIGNMENT EaLength;
2166 } Create;
2167 struct {
2168 ULONG Length;
2169 ULONG POINTER_ALIGNMENT Key;
2170 LARGE_INTEGER ByteOffset;
2171 } Read;
2172 struct {
2173 ULONG Length;
2174 ULONG POINTER_ALIGNMENT Key;
2175 LARGE_INTEGER ByteOffset;
2176 } Write;
2177 struct {
2178 ULONG Length;
2179 PUNICODE_STRING FileName;
2180 FILE_INFORMATION_CLASS FileInformationClass;
2181 ULONG FileIndex;
2182 } QueryDirectory;
2183 struct {
2184 ULONG Length;
2185 ULONG CompletionFilter;
2186 } NotifyDirectory;
2187 struct {
2188 ULONG Length;
2189 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2190 } QueryFile;
2191 struct {
2192 ULONG Length;
2193 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2194 PFILE_OBJECT FileObject;
2195 _ANONYMOUS_UNION union {
2196 _ANONYMOUS_STRUCT struct {
2197 BOOLEAN ReplaceIfExists;
2198 BOOLEAN AdvanceOnly;
2199 } DUMMYSTRUCTNAME;
2200 ULONG ClusterCount;
2201 HANDLE DeleteHandle;
2202 } DUMMYUNIONNAME;
2203 } SetFile;
2204 struct {
2205 ULONG Length;
2206 PVOID EaList;
2207 ULONG EaListLength;
2208 ULONG EaIndex;
2209 } QueryEa;
2210 struct {
2211 ULONG Length;
2212 } SetEa;
2213 struct {
2214 ULONG Length;
2215 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
2216 } QueryVolume;
2217 struct {
2218 ULONG Length;
2219 FS_INFORMATION_CLASS FsInformationClass;
2220 } SetVolume;
2221 struct {
2222 ULONG OutputBufferLength;
2223 ULONG InputBufferLength;
2224 ULONG FsControlCode;
2225 PVOID Type3InputBuffer;
2226 } FileSystemControl;
2227 struct {
2228 PLARGE_INTEGER Length;
2229 ULONG Key;
2230 LARGE_INTEGER ByteOffset;
2231 } LockControl;
2232 struct {
2233 ULONG OutputBufferLength;
2234 ULONG POINTER_ALIGNMENT InputBufferLength;
2235 ULONG POINTER_ALIGNMENT IoControlCode;
2236 PVOID Type3InputBuffer;
2237 } DeviceIoControl;
2238 struct {
2239 SECURITY_INFORMATION SecurityInformation;
2240 ULONG POINTER_ALIGNMENT Length;
2241 } QuerySecurity;
2242 struct {
2243 SECURITY_INFORMATION SecurityInformation;
2244 PSECURITY_DESCRIPTOR SecurityDescriptor;
2245 } SetSecurity;
2246 struct {
2247 PVPB Vpb;
2248 PDEVICE_OBJECT DeviceObject;
2249 } MountVolume;
2250 struct {
2251 PVPB Vpb;
2252 PDEVICE_OBJECT DeviceObject;
2253 } VerifyVolume;
2254 struct {
2255 struct _SCSI_REQUEST_BLOCK *Srb;
2256 } Scsi;
2257 struct {
2258 ULONG Length;
2259 PSID StartSid;
2260 struct _FILE_GET_QUOTA_INFORMATION *SidList;
2261 ULONG SidListLength;
2262 } QueryQuota;
2263 struct {
2264 ULONG Length;
2265 } SetQuota;
2266 struct {
2267 DEVICE_RELATION_TYPE Type;
2268 } QueryDeviceRelations;
2269 struct {
2270 CONST GUID *InterfaceType;
2271 USHORT Size;
2272 USHORT Version;
2273 PINTERFACE Interface;
2274 PVOID InterfaceSpecificData;
2275 } QueryInterface;
2276 struct {
2277 PDEVICE_CAPABILITIES Capabilities;
2278 } DeviceCapabilities;
2279 struct {
2280 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
2281 } FilterResourceRequirements;
2282 struct {
2283 ULONG WhichSpace;
2284 PVOID Buffer;
2285 ULONG Offset;
2286 ULONG POINTER_ALIGNMENT Length;
2287 } ReadWriteConfig;
2288 struct {
2289 BOOLEAN Lock;
2290 } SetLock;
2291 struct {
2292 BUS_QUERY_ID_TYPE IdType;
2293 } QueryId;
2294 struct {
2295 DEVICE_TEXT_TYPE DeviceTextType;
2296 LCID POINTER_ALIGNMENT LocaleId;
2297 } QueryDeviceText;
2298 struct {
2299 BOOLEAN InPath;
2300 BOOLEAN Reserved[3];
2301 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
2302 } UsageNotification;
2303 struct {
2304 SYSTEM_POWER_STATE PowerState;
2305 } WaitWake;
2306 struct {
2307 PPOWER_SEQUENCE PowerSequence;
2308 } PowerSequence;
2309 struct {
2310 ULONG SystemContext;
2311 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
2312 POWER_STATE POINTER_ALIGNMENT State;
2313 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
2314 } Power;
2315 struct {
2316 PCM_RESOURCE_LIST AllocatedResources;
2317 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
2318 } StartDevice;
2319 struct {
2320 ULONG_PTR ProviderId;
2321 PVOID DataPath;
2322 ULONG BufferSize;
2323 PVOID Buffer;
2324 } WMI;
2325 struct {
2326 PVOID Argument1;
2327 PVOID Argument2;
2328 PVOID Argument3;
2329 PVOID Argument4;
2330 } Others;
2331 } Parameters;
2332 PDEVICE_OBJECT DeviceObject;
2333 PFILE_OBJECT FileObject;
2334 PIO_COMPLETION_ROUTINE CompletionRoutine;
2335 PVOID Context;
2336 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
2337 #if !defined(_ALPHA_)
2338 #include <poppack.h>
2339 #endif
2340
2341 /* IO_STACK_LOCATION.Control */
2342
2343 #define SL_PENDING_RETURNED 0x01
2344 #define SL_ERROR_RETURNED 0x02
2345 #define SL_INVOKE_ON_CANCEL 0x20
2346 #define SL_INVOKE_ON_SUCCESS 0x40
2347 #define SL_INVOKE_ON_ERROR 0x80
2348
2349 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
2350
2351 #define PCI_WHICHSPACE_CONFIG 0x0
2352 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
2353
2354 typedef enum _KEY_INFORMATION_CLASS {
2355 KeyBasicInformation,
2356 KeyNodeInformation,
2357 KeyFullInformation,
2358 KeyNameInformation,
2359 KeyCachedInformation,
2360 KeyFlagsInformation
2361 } KEY_INFORMATION_CLASS;
2362
2363 typedef struct _KEY_BASIC_INFORMATION {
2364 LARGE_INTEGER LastWriteTime;
2365 ULONG TitleIndex;
2366 ULONG NameLength;
2367 WCHAR Name[1];
2368 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
2369
2370 typedef struct _KEY_FULL_INFORMATION {
2371 LARGE_INTEGER LastWriteTime;
2372 ULONG TitleIndex;
2373 ULONG ClassOffset;
2374 ULONG ClassLength;
2375 ULONG SubKeys;
2376 ULONG MaxNameLen;
2377 ULONG MaxClassLen;
2378 ULONG Values;
2379 ULONG MaxValueNameLen;
2380 ULONG MaxValueDataLen;
2381 WCHAR Class[1];
2382 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
2383
2384 typedef struct _KEY_NODE_INFORMATION {
2385 LARGE_INTEGER LastWriteTime;
2386 ULONG TitleIndex;
2387 ULONG ClassOffset;
2388 ULONG ClassLength;
2389 ULONG NameLength;
2390 WCHAR Name[1];
2391 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
2392
2393 typedef struct _KEY_VALUE_BASIC_INFORMATION {
2394 ULONG TitleIndex;
2395 ULONG Type;
2396 ULONG NameLength;
2397 WCHAR Name[1];
2398 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
2399
2400 typedef struct _KEY_VALUE_FULL_INFORMATION {
2401 ULONG TitleIndex;
2402 ULONG Type;
2403 ULONG DataOffset;
2404 ULONG DataLength;
2405 ULONG NameLength;
2406 WCHAR Name[1];
2407 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
2408
2409 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
2410 ULONG TitleIndex;
2411 ULONG Type;
2412 ULONG DataLength;
2413 UCHAR Data[1];
2414 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
2415
2416 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
2417 ULONG Type;
2418 ULONG DataLength;
2419 UCHAR Data[1];
2420 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
2421
2422 typedef struct _KEY_VALUE_ENTRY {
2423 PUNICODE_STRING ValueName;
2424 ULONG DataLength;
2425 ULONG DataOffset;
2426 ULONG Type;
2427 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
2428
2429 typedef enum _KEY_VALUE_INFORMATION_CLASS {
2430 KeyValueBasicInformation,
2431 KeyValueFullInformation,
2432 KeyValuePartialInformation,
2433 KeyValueFullInformationAlign64,
2434 KeyValuePartialInformationAlign64
2435 } KEY_VALUE_INFORMATION_CLASS;
2436
2437 typedef struct _KEY_WRITE_TIME_INFORMATION {
2438 LARGE_INTEGER LastWriteTime;
2439 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
2440
2441 typedef struct _KEY_USER_FLAGS_INFORMATION {
2442 ULONG UserFlags;
2443 } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
2444
2445 typedef enum _KEY_SET_INFORMATION_CLASS {
2446 KeyWriteTimeInformation,
2447 KeyUserFlagsInformation,
2448 MaxKeySetInfoClass
2449 } KEY_SET_INFORMATION_CLASS;
2450
2451 /* KEY_VALUE_Xxx.Type */
2452
2453 #define REG_NONE 0
2454 #define REG_SZ 1
2455 #define REG_EXPAND_SZ 2
2456 #define REG_BINARY 3
2457 #define REG_DWORD 4
2458 #define REG_DWORD_LITTLE_ENDIAN 4
2459 #define REG_DWORD_BIG_ENDIAN 5
2460 #define REG_LINK 6
2461 #define REG_MULTI_SZ 7
2462 #define REG_RESOURCE_LIST 8
2463 #define REG_FULL_RESOURCE_DESCRIPTOR 9
2464 #define REG_RESOURCE_REQUIREMENTS_LIST 10
2465 #define REG_QWORD 11
2466 #define REG_QWORD_LITTLE_ENDIAN 11
2467
2468 #define PCI_TYPE0_ADDRESSES 6
2469 #define PCI_TYPE1_ADDRESSES 2
2470 #define PCI_TYPE2_ADDRESSES 5
2471
2472 typedef struct _PCI_COMMON_CONFIG {
2473 USHORT VendorID;
2474 USHORT DeviceID;
2475 USHORT Command;
2476 USHORT Status;
2477 UCHAR RevisionID;
2478 UCHAR ProgIf;
2479 UCHAR SubClass;
2480 UCHAR BaseClass;
2481 UCHAR CacheLineSize;
2482 UCHAR LatencyTimer;
2483 UCHAR HeaderType;
2484 UCHAR BIST;
2485 union {
2486 struct _PCI_HEADER_TYPE_0 {
2487 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
2488 ULONG CIS;
2489 USHORT SubVendorID;
2490 USHORT SubSystemID;
2491 ULONG ROMBaseAddress;
2492 UCHAR CapabilitiesPtr;
2493 UCHAR Reserved1[3];
2494 ULONG Reserved2;
2495 UCHAR InterruptLine;
2496 UCHAR InterruptPin;
2497 UCHAR MinimumGrant;
2498 UCHAR MaximumLatency;
2499 } type0;
2500 struct _PCI_HEADER_TYPE_1 {
2501 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
2502 UCHAR PrimaryBus;
2503 UCHAR SecondaryBus;
2504 UCHAR SubordinateBus;
2505 UCHAR SecondaryLatency;
2506 UCHAR IOBase;
2507 UCHAR IOLimit;
2508 USHORT SecondaryStatus;
2509 USHORT MemoryBase;
2510 USHORT MemoryLimit;
2511 USHORT PrefetchBase;
2512 USHORT PrefetchLimit;
2513 ULONG PrefetchBaseUpper32;
2514 ULONG PrefetchLimitUpper32;
2515 USHORT IOBaseUpper16;
2516 USHORT IOLimitUpper16;
2517 UCHAR CapabilitiesPtr;
2518 UCHAR Reserved1[3];
2519 ULONG ROMBaseAddress;
2520 UCHAR InterruptLine;
2521 UCHAR InterruptPin;
2522 USHORT BridgeControl;
2523 } type1;
2524 struct _PCI_HEADER_TYPE_2 {
2525 ULONG SocketRegistersBaseAddress;
2526 UCHAR CapabilitiesPtr;
2527 UCHAR Reserved;
2528 USHORT SecondaryStatus;
2529 UCHAR PrimaryBus;
2530 UCHAR SecondaryBus;
2531 UCHAR SubordinateBus;
2532 UCHAR SecondaryLatency;
2533 struct {
2534 ULONG Base;
2535 ULONG Limit;
2536 } Range[PCI_TYPE2_ADDRESSES - 1];
2537 UCHAR InterruptLine;
2538 UCHAR InterruptPin;
2539 USHORT BridgeControl;
2540 } type2;
2541 } u;
2542 UCHAR DeviceSpecific[192];
2543 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
2544
2545 /* PCI_COMMON_CONFIG.Command */
2546
2547 #define PCI_ENABLE_IO_SPACE 0x0001
2548 #define PCI_ENABLE_MEMORY_SPACE 0x0002
2549 #define PCI_ENABLE_BUS_MASTER 0x0004
2550 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
2551 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
2552 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
2553 #define PCI_ENABLE_PARITY 0x0040
2554 #define PCI_ENABLE_WAIT_CYCLE 0x0080
2555 #define PCI_ENABLE_SERR 0x0100
2556 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
2557
2558 /* PCI_COMMON_CONFIG.Status */
2559
2560 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
2561 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
2562 #define PCI_STATUS_UDF_SUPPORTED 0x0040
2563 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
2564 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
2565 #define PCI_STATUS_DEVSEL 0x0600
2566 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
2567 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
2568 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
2569 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
2570 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
2571
2572 /* PCI_COMMON_CONFIG.HeaderType */
2573
2574 #define PCI_MULTIFUNCTION 0x80
2575 #define PCI_DEVICE_TYPE 0x00
2576 #define PCI_BRIDGE_TYPE 0x01
2577 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
2578
2579 #define PCI_CONFIGURATION_TYPE(PciData) \
2580 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
2581
2582 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
2583 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
2584
2585 /* PCI device classes */
2586
2587 #define PCI_CLASS_PRE_20 0x00
2588 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
2589 #define PCI_CLASS_NETWORK_CTLR 0x02
2590 #define PCI_CLASS_DISPLAY_CTLR 0x03
2591 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
2592 #define PCI_CLASS_MEMORY_CTLR 0x05
2593 #define PCI_CLASS_BRIDGE_DEV 0x06
2594 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
2595 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
2596 #define PCI_CLASS_INPUT_DEV 0x09
2597 #define PCI_CLASS_DOCKING_STATION 0x0a
2598 #define PCI_CLASS_PROCESSOR 0x0b
2599 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
2600
2601 /* PCI device subclasses for class 0 */
2602
2603 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
2604 #define PCI_SUBCLASS_PRE_20_VGA 0x01
2605
2606 /* PCI device subclasses for class 1 (mass storage controllers)*/
2607
2608 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
2609 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
2610 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
2611 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
2612 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
2613 #define PCI_SUBCLASS_MSC_OTHER 0x80
2614
2615 /* PCI device subclasses for class 2 (network controllers)*/
2616
2617 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
2618 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
2619 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
2620 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
2621 #define PCI_SUBCLASS_NET_OTHER 0x80
2622
2623 /* PCI device subclasses for class 3 (display controllers)*/
2624
2625 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
2626 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
2627 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
2628 #define PCI_SUBCLASS_VID_OTHER 0x80
2629
2630 /* PCI device subclasses for class 4 (multimedia device)*/
2631
2632 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
2633 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
2634 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
2635 #define PCI_SUBCLASS_MM_OTHER 0x80
2636
2637 /* PCI device subclasses for class 5 (memory controller)*/
2638
2639 #define PCI_SUBCLASS_MEM_RAM 0x00
2640 #define PCI_SUBCLASS_MEM_FLASH 0x01
2641 #define PCI_SUBCLASS_MEM_OTHER 0x80
2642
2643 /* PCI device subclasses for class 6 (bridge device)*/
2644
2645 #define PCI_SUBCLASS_BR_HOST 0x00
2646 #define PCI_SUBCLASS_BR_ISA 0x01
2647 #define PCI_SUBCLASS_BR_EISA 0x02
2648 #define PCI_SUBCLASS_BR_MCA 0x03
2649 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
2650 #define PCI_SUBCLASS_BR_PCMCIA 0x05
2651 #define PCI_SUBCLASS_BR_NUBUS 0x06
2652 #define PCI_SUBCLASS_BR_CARDBUS 0x07
2653 #define PCI_SUBCLASS_BR_OTHER 0x80
2654
2655 /* PCI device subclasses for class C (serial bus controller)*/
2656
2657 #define PCI_SUBCLASS_SB_IEEE1394 0x00
2658 #define PCI_SUBCLASS_SB_ACCESS 0x01
2659 #define PCI_SUBCLASS_SB_SSA 0x02
2660 #define PCI_SUBCLASS_SB_USB 0x03
2661 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
2662 #define PCI_SUBCLASS_SB_SMBUS 0x05
2663
2664 #define PCI_MAX_DEVICES 32
2665 #define PCI_MAX_FUNCTION 8
2666 #define PCI_MAX_BRIDGE_NUMBER 0xFF
2667 #define PCI_INVALID_VENDORID 0xFFFF
2668 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
2669
2670 #define PCI_ADDRESS_MEMORY_SPACE 0x00000000
2671 #define PCI_ADDRESS_IO_SPACE 0x00000001
2672 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
2673 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
2674 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
2675 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
2676 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
2677
2678 #define PCI_TYPE_32BIT 0
2679 #define PCI_TYPE_20BIT 2
2680 #define PCI_TYPE_64BIT 4
2681
2682 typedef struct _PCI_SLOT_NUMBER {
2683 union {
2684 struct {
2685 ULONG DeviceNumber : 5;
2686 ULONG FunctionNumber : 3;
2687 ULONG Reserved : 24;
2688 } bits;
2689 ULONG AsULONG;
2690 } u;
2691 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
2692
2693 #define POOL_COLD_ALLOCATION 256
2694 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8
2695 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16
2696
2697 typedef struct _OSVERSIONINFOA {
2698 ULONG dwOSVersionInfoSize;
2699 ULONG dwMajorVersion;
2700 ULONG dwMinorVersion;
2701 ULONG dwBuildNumber;
2702 ULONG dwPlatformId;
2703 CHAR szCSDVersion[128];
2704 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
2705
2706 typedef struct _OSVERSIONINFOW {
2707 ULONG dwOSVersionInfoSize;
2708 ULONG dwMajorVersion;
2709 ULONG dwMinorVersion;
2710 ULONG dwBuildNumber;
2711 ULONG dwPlatformId;
2712 WCHAR szCSDVersion[128];
2713 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
2714
2715 #ifdef UNICODE
2716 typedef OSVERSIONINFOW OSVERSIONINFO;
2717 typedef POSVERSIONINFOW POSVERSIONINFO;
2718 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
2719 #else
2720 typedef OSVERSIONINFOA OSVERSIONINFO;
2721 typedef POSVERSIONINFOA POSVERSIONINFO;
2722 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
2723 #endif // UNICODE
2724
2725 typedef struct _OSVERSIONINFOEXA {
2726 ULONG dwOSVersionInfoSize;
2727 ULONG dwMajorVersion;
2728 ULONG dwMinorVersion;
2729 ULONG dwBuildNumber;
2730 ULONG dwPlatformId;
2731 CHAR szCSDVersion[128];
2732 USHORT wServicePackMajor;
2733 USHORT wServicePackMinor;
2734 USHORT wSuiteMask;
2735 UCHAR wProductType;
2736 UCHAR wReserved;
2737 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
2738
2739 typedef struct _OSVERSIONINFOEXW {
2740 ULONG dwOSVersionInfoSize;
2741 ULONG dwMajorVersion;
2742 ULONG dwMinorVersion;
2743 ULONG dwBuildNumber;
2744 ULONG dwPlatformId;
2745 WCHAR szCSDVersion[128];
2746 USHORT wServicePackMajor;
2747 USHORT wServicePackMinor;
2748 USHORT wSuiteMask;
2749 UCHAR wProductType;
2750 UCHAR wReserved;
2751 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
2752
2753 #ifdef UNICODE
2754 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
2755 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
2756 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
2757 #else
2758 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
2759 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
2760 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
2761 #endif // UNICODE
2762
2763 NTSYSAPI
2764 ULONGLONG
2765 DDKAPI
2766 VerSetConditionMask(
2767 IN ULONGLONG ConditionMask,
2768 IN ULONG TypeMask,
2769 IN UCHAR Condition);
2770
2771 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
2772 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
2773 (TypeBitMask), (ComparisonType)))
2774
2775 /* RtlVerifyVersionInfo() TypeMask */
2776
2777 #define VER_MINORVERSION 0x0000001
2778 #define VER_MAJORVERSION 0x0000002
2779 #define VER_BUILDNUMBER 0x0000004
2780 #define VER_PLATFORMID 0x0000008
2781 #define VER_SERVICEPACKMINOR 0x0000010
2782 #define VER_SERVICEPACKMAJOR 0x0000020
2783 #define VER_SUITENAME 0x0000040
2784 #define VER_PRODUCT_TYPE 0x0000080
2785
2786 /* RtlVerifyVersionInfo() ComparisonType */
2787
2788 #define VER_EQUAL 1
2789 #define VER_GREATER 2
2790 #define VER_GREATER_EQUAL 3
2791 #define VER_LESS 4
2792 #define VER_LESS_EQUAL 5
2793 #define VER_AND 6
2794 #define VER_OR 7
2795
2796 #define VER_CONDITION_MASK 7
2797 #define VER_NUM_BITS_PER_CONDITION_MASK 3
2798
2799 struct _RTL_RANGE;
2800
2801 typedef BOOLEAN
2802 (NTAPI *PRTL_CONFLICT_RANGE_CALLBACK) (
2803 PVOID Context,
2804 struct _RTL_RANGE *Range
2805 );
2806
2807 typedef enum _EVENT_TYPE {
2808 NotificationEvent,
2809 SynchronizationEvent
2810 } EVENT_TYPE;
2811
2812 typedef enum _KWAIT_REASON {
2813 Executive,
2814 FreePage,
2815 PageIn,
2816 PoolAllocation,
2817 DelayExecution,
2818 Suspended,
2819 UserRequest,
2820 WrExecutive,
2821 WrFreePage,
2822 WrPageIn,
2823 WrPoolAllocation,
2824 WrDelayExecution,
2825 WrSuspended,
2826 WrUserRequest,
2827 WrEventPair,
2828 WrQueue,
2829 WrLpcReceive,
2830 WrLpcReply,
2831 WrVirtualMemory,
2832 WrPageOut,
2833 WrRendezvous,
2834 Spare2,
2835 WrGuardedMutex,
2836 Spare4,
2837 Spare5,
2838 Spare6,
2839 WrKernel,
2840 WrResource,
2841 WrPushLock,
2842 WrMutex,
2843 WrQuantumEnd,
2844 WrDispatchInt,
2845 WrPreempted,
2846 WrYieldExecution,
2847 MaximumWaitReason
2848 } KWAIT_REASON;
2849
2850 typedef struct _KWAIT_BLOCK {
2851 LIST_ENTRY WaitListEntry;
2852 struct _KTHREAD * RESTRICTED_POINTER Thread;
2853 PVOID Object;
2854 struct _KWAIT_BLOCK * RESTRICTED_POINTER NextWaitBlock;
2855 USHORT WaitKey;
2856 UCHAR WaitType;
2857 UCHAR SpareByte;
2858 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
2859
2860 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
2861
2862 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
2863 BOOLEAN Removed;
2864 BOOLEAN Reserved[3];
2865 volatile LONG IoCount;
2866 KEVENT RemoveEvent;
2867 } IO_REMOVE_LOCK_COMMON_BLOCK;
2868
2869 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
2870 LONG Signature;
2871 LONG HighWatermark;
2872 LONGLONG MaxLockedTicks;
2873 LONG AllocateTag;
2874 LIST_ENTRY LockList;
2875 KSPIN_LOCK Spin;
2876 volatile LONG LowMemoryCount;
2877 ULONG Reserved1[4];
2878 PVOID Reserved2;
2879 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
2880 } IO_REMOVE_LOCK_DBG_BLOCK;
2881
2882 typedef struct _IO_REMOVE_LOCK {
2883 IO_REMOVE_LOCK_COMMON_BLOCK Common;
2884 #if DBG
2885 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
2886 #endif
2887 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
2888
2889 typedef struct _IO_WORKITEM *PIO_WORKITEM;
2890
2891 typedef VOID
2892 (DDKAPI IO_WORKITEM_ROUTINE)(
2893 IN PDEVICE_OBJECT DeviceObject,
2894 IN PVOID Context);
2895 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
2896
2897 typedef struct _SHARE_ACCESS {
2898 ULONG OpenCount;
2899 ULONG Readers;
2900 ULONG Writers;
2901 ULONG Deleters;
2902 ULONG SharedRead;
2903 ULONG SharedWrite;
2904 ULONG SharedDelete;
2905 } SHARE_ACCESS, *PSHARE_ACCESS;
2906
2907 typedef enum _KINTERRUPT_MODE {
2908 LevelSensitive,
2909 Latched
2910 } KINTERRUPT_MODE;
2911
2912 #define THREAD_WAIT_OBJECTS 3
2913
2914 typedef VOID
2915 (DDKAPI *PKINTERRUPT_ROUTINE)(
2916 VOID);
2917
2918 typedef enum _CREATE_FILE_TYPE {
2919 CreateFileTypeNone,
2920 CreateFileTypeNamedPipe,
2921 CreateFileTypeMailslot
2922 } CREATE_FILE_TYPE;
2923
2924 typedef struct _CONFIGURATION_INFORMATION {
2925 ULONG DiskCount;
2926 ULONG FloppyCount;
2927 ULONG CdRomCount;
2928 ULONG TapeCount;
2929 ULONG ScsiPortCount;
2930 ULONG SerialCount;
2931 ULONG ParallelCount;
2932 BOOLEAN AtDiskPrimaryAddressClaimed;
2933 BOOLEAN AtDiskSecondaryAddressClaimed;
2934 ULONG Version;
2935 ULONG MediumChangerCount;
2936 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
2937
2938 typedef enum _CONFIGURATION_TYPE {
2939 ArcSystem,
2940 CentralProcessor,
2941 FloatingPointProcessor,
2942 PrimaryIcache,
2943 PrimaryDcache,
2944 SecondaryIcache,
2945 SecondaryDcache,
2946 SecondaryCache,
2947 EisaAdapter,
2948 TcAdapter,
2949 ScsiAdapter,
2950 DtiAdapter,
2951 MultiFunctionAdapter,
2952 DiskController,
2953 TapeController,
2954 CdromController,
2955 WormController,
2956 SerialController,
2957 NetworkController,
2958 DisplayController,
2959 ParallelController,
2960 PointerController,
2961 KeyboardController,
2962 AudioController,
2963 OtherController,
2964 DiskPeripheral,
2965 FloppyDiskPeripheral,
2966 TapePeripheral,
2967 ModemPeripheral,
2968 MonitorPeripheral,
2969 PrinterPeripheral,
2970 PointerPeripheral,
2971 KeyboardPeripheral,
2972 TerminalPeripheral,
2973 OtherPeripheral,
2974 LinePeripheral,
2975 NetworkPeripheral,
2976 SystemMemory,
2977 DockingInformation,
2978 RealModeIrqRoutingTable,
2979 RealModePCIEnumeration,
2980 MaximumType
2981 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
2982
2983 #define IO_FORCE_ACCESS_CHECK 0x001
2984 #define IO_NO_PARAMETER_CHECKING 0x100
2985
2986 #define IO_REPARSE 0x0
2987 #define IO_REMOUNT 0x1
2988
2989 typedef NTSTATUS
2990 (DDKAPI *PIO_QUERY_DEVICE_ROUTINE)(
2991 IN PVOID Context,
2992 IN PUNICODE_STRING PathName,
2993 IN INTERFACE_TYPE BusType,
2994 IN ULONG BusNumber,
2995 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
2996 IN CONFIGURATION_TYPE ControllerType,
2997 IN ULONG ControllerNumber,
2998 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
2999 IN CONFIGURATION_TYPE PeripheralType,
3000 IN ULONG PeripheralNumber,
3001 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
3002
3003 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
3004 IoQueryDeviceIdentifier = 0,
3005 IoQueryDeviceConfigurationData,
3006 IoQueryDeviceComponentInformation,
3007 IoQueryDeviceMaxData
3008 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
3009
3010 typedef enum _KBUGCHECK_CALLBACK_REASON {
3011 KbCallbackInvalid,
3012 KbCallbackReserved1,
3013 KbCallbackSecondaryDumpData,
3014 KbCallbackDumpIo,
3015 } KBUGCHECK_CALLBACK_REASON;
3016
3017 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
3018
3019 typedef VOID
3020 (DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)(
3021 IN KBUGCHECK_CALLBACK_REASON Reason,
3022 IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
3023 IN OUT PVOID ReasonSpecificData,
3024 IN ULONG ReasonSpecificDataLength);
3025
3026 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
3027 LIST_ENTRY Entry;
3028 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
3029 PUCHAR Component;
3030 ULONG_PTR Checksum;
3031 KBUGCHECK_CALLBACK_REASON Reason;
3032 UCHAR State;
3033 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
3034
3035 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
3036 BufferEmpty,
3037 BufferInserted,
3038 BufferStarted,
3039 BufferFinished,
3040 BufferIncomplete
3041 } KBUGCHECK_BUFFER_DUMP_STATE;
3042
3043 typedef VOID
3044 (DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)(
3045 IN PVOID Buffer,
3046 IN ULONG Length);
3047
3048 typedef struct _KBUGCHECK_CALLBACK_RECORD {
3049 LIST_ENTRY Entry;
3050 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
3051 PVOID Buffer;
3052 ULONG Length;
3053 PUCHAR Component;
3054 ULONG_PTR Checksum;
3055 UCHAR State;
3056 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
3057
3058 typedef BOOLEAN
3059 (DDKAPI *PNMI_CALLBACK)(
3060 IN PVOID Context,
3061 IN BOOLEAN Handled);
3062
3063 /*
3064 * VOID
3065 * KeInitializeCallbackRecord(
3066 * IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
3067 */
3068 #define KeInitializeCallbackRecord(CallbackRecord) \
3069 CallbackRecord->State = BufferEmpty;
3070
3071 typedef enum _KDPC_IMPORTANCE {
3072 LowImportance,
3073 MediumImportance,
3074 HighImportance
3075 } KDPC_IMPORTANCE;
3076
3077 typedef enum _MEMORY_CACHING_TYPE_ORIG {
3078 MmFrameBufferCached = 2
3079 } MEMORY_CACHING_TYPE_ORIG;
3080
3081 typedef enum _MEMORY_CACHING_TYPE {
3082 MmNonCached = FALSE,
3083 MmCached = TRUE,
3084 MmWriteCombined = MmFrameBufferCached,
3085 MmHardwareCoherentCached,
3086 MmNonCachedUnordered,
3087 MmUSWCCached,
3088 MmMaximumCacheType
3089 } MEMORY_CACHING_TYPE;
3090
3091 typedef enum _MM_PAGE_PRIORITY {
3092 LowPagePriority,
3093 NormalPagePriority = 16,
3094 HighPagePriority = 32
3095 } MM_PAGE_PRIORITY;
3096
3097 typedef enum _LOCK_OPERATION {
3098 IoReadAccess,
3099 IoWriteAccess,
3100 IoModifyAccess
3101 } LOCK_OPERATION;
3102
3103 #define FLUSH_MULTIPLE_MAXIMUM 32
3104
3105 typedef enum _MM_SYSTEM_SIZE {
3106 MmSmallSystem,
3107 MmMediumSystem,
3108 MmLargeSystem
3109 } MM_SYSTEMSIZE;
3110
3111 typedef struct _OBJECT_HANDLE_INFORMATION {
3112 ULONG HandleAttributes;
3113 ACCESS_MASK GrantedAccess;
3114 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
3115
3116 typedef struct _CLIENT_ID {
3117 HANDLE UniqueProcess;
3118 HANDLE UniqueThread;
3119 } CLIENT_ID, *PCLIENT_ID;
3120
3121 typedef VOID
3122 (DDKAPI *PKSTART_ROUTINE)(
3123 IN PVOID StartContext);
3124
3125 typedef VOID
3126 (DDKAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
3127 IN HANDLE ParentId,
3128 IN HANDLE ProcessId,
3129 IN BOOLEAN Create);
3130
3131 typedef VOID
3132 (DDKAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
3133 IN HANDLE ProcessId,
3134 IN HANDLE ThreadId,
3135 IN BOOLEAN Create);
3136
3137 typedef struct _IMAGE_INFO {
3138 _ANONYMOUS_UNION union {
3139 ULONG Properties;
3140 _ANONYMOUS_STRUCT struct {
3141 ULONG ImageAddressingMode : 8;
3142 ULONG SystemModeImage : 1;
3143 ULONG ImageMappedToAllPids : 1;
3144 ULONG Reserved : 22;
3145 } DUMMYSTRUCTNAME;
3146 } DUMMYUNIONNAME;
3147 PVOID ImageBase;
3148 ULONG ImageSelector;
3149 SIZE_T ImageSize;
3150 ULONG ImageSectionNumber;
3151 } IMAGE_INFO, *PIMAGE_INFO;
3152
3153 #define IMAGE_ADDRESSING_MODE_32BIT 3
3154
3155 typedef VOID
3156 (DDKAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
3157 IN PUNICODE_STRING FullImageName,
3158 IN HANDLE ProcessId,
3159 IN PIMAGE_INFO ImageInfo);
3160
3161 #pragma pack(push,4)
3162 typedef enum _BUS_DATA_TYPE {
3163 ConfigurationSpaceUndefined = -1,
3164 Cmos,
3165 EisaConfiguration,
3166 Pos,
3167 CbusConfiguration,
3168 PCIConfiguration,
3169 VMEConfiguration,
3170 NuBusConfiguration,
3171 PCMCIAConfiguration,
3172 MPIConfiguration,
3173 MPSAConfiguration,
3174 PNPISAConfiguration,
3175 SgiInternalConfiguration,
3176 MaximumBusDataType
3177 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
3178 #pragma pack(pop)
3179
3180 typedef struct _NT_TIB {
3181 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
3182 PVOID StackBase;
3183 PVOID StackLimit;
3184 PVOID SubSystemTib;
3185 _ANONYMOUS_UNION union {
3186 PVOID FiberData;
3187 ULONG Version;
3188 } DUMMYUNIONNAME;
3189 PVOID ArbitraryUserPointer;
3190 struct _NT_TIB *Self;
3191 } NT_TIB, *PNT_TIB;
3192
3193 typedef struct _NT_TIB32 {
3194 ULONG ExceptionList;
3195 ULONG StackBase;
3196 ULONG StackLimit;
3197 ULONG SubSystemTib;
3198 __GNU_EXTENSION union {
3199 ULONG FiberData;
3200 ULONG Version;
3201 };
3202 ULONG ArbitraryUserPointer;
3203 ULONG Self;
3204 } NT_TIB32,*PNT_TIB32;
3205
3206 typedef struct _NT_TIB64 {
3207 ULONG64 ExceptionList;
3208 ULONG64 StackBase;
3209 ULONG64 StackLimit;
3210 ULONG64 SubSystemTib;
3211 __GNU_EXTENSION union {
3212 ULONG64 FiberData;
3213 ULONG Version;
3214 };
3215 ULONG64 ArbitraryUserPointer;
3216 ULONG64 Self;
3217 } NT_TIB64,*PNT_TIB64;
3218
3219 typedef enum _PROCESSINFOCLASS {
3220 ProcessBasicInformation,
3221 ProcessQuotaLimits,
3222 ProcessIoCounters,
3223 ProcessVmCounters,
3224 ProcessTimes,
3225 ProcessBasePriority,
3226 ProcessRaisePriority,
3227 ProcessDebugPort,
3228 ProcessExceptionPort,
3229 ProcessAccessToken,
3230 ProcessLdtInformation,
3231 ProcessLdtSize,
3232 ProcessDefaultHardErrorMode,
3233 ProcessIoPortHandlers,
3234 ProcessPooledUsageAndLimits,
3235 ProcessWorkingSetWatch,
3236 ProcessUserModeIOPL,
3237 ProcessEnableAlignmentFaultFixup,
3238 ProcessPriorityClass,
3239 ProcessWx86Information,
3240 ProcessHandleCount,
3241 ProcessAffinityMask,
3242 ProcessPriorityBoost,
3243 ProcessDeviceMap,
3244 ProcessSessionInformation,
3245 ProcessForegroundInformation,
3246 ProcessWow64Information,
3247 ProcessImageFileName,
3248 ProcessLUIDDeviceMapsEnabled,
3249 ProcessBreakOnTermination,
3250 ProcessDebugObjectHandle,
3251 ProcessDebugFlags,
3252 ProcessHandleTracing,
3253 ProcessIoPriority,
3254 ProcessExecuteFlags,
3255 ProcessTlsInformation,
3256 ProcessCookie,
3257 ProcessImageInformation,
3258 ProcessCycleTime,
3259 ProcessPagePriority,
3260 ProcessInstrumentationCallback,
3261 MaxProcessInfoClass
3262 } PROCESSINFOCLASS;
3263
3264 typedef enum _THREADINFOCLASS {
3265 ThreadBasicInformation,
3266 ThreadTimes,
3267 ThreadPriority,
3268 ThreadBasePriority,
3269 ThreadAffinityMask,
3270 ThreadImpersonationToken,
3271 ThreadDescriptorTableEntry,
3272 ThreadEnableAlignmentFaultFixup,
3273 ThreadEventPair_Reusable,
3274 ThreadQuerySetWin32StartAddress,
3275 ThreadZeroTlsCell,
3276 ThreadPerformanceCount,
3277 ThreadAmILastThread,
3278 ThreadIdealProcessor,
3279 ThreadPriorityBoost,
3280 ThreadSetTlsArrayAddress,
3281 ThreadIsIoPending,
3282 ThreadHideFromDebugger,
3283 ThreadBreakOnTermination,
3284 ThreadSwitchLegacyState,
3285 ThreadIsTerminated,
3286 ThreadLastSystemCall,
3287 ThreadIoPriority,
3288 ThreadCycleTime,
3289 ThreadPagePriority,
3290 ThreadActualBasePriority,
3291 MaxThreadInfoClass
3292 } THREADINFOCLASS;
3293
3294 typedef struct _PROCESS_BASIC_INFORMATION
3295 {
3296 NTSTATUS ExitStatus;
3297 struct _PEB *PebBaseAddress;
3298 ULONG_PTR AffinityMask;
3299 KPRIORITY BasePriority;
3300 ULONG_PTR UniqueProcessId;
3301 ULONG_PTR InheritedFromUniqueProcessId;
3302 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
3303
3304 typedef struct _PROCESS_WS_WATCH_INFORMATION
3305 {
3306 PVOID FaultingPc;
3307 PVOID FaultingVa;
3308 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
3309
3310 typedef struct _PROCESS_DEVICEMAP_INFORMATION
3311 {
3312 __GNU_EXTENSION union
3313 {
3314 struct
3315 {
3316 HANDLE DirectoryHandle;
3317 } Set;
3318 struct
3319 {
3320 ULONG DriveMap;
3321 UCHAR DriveType[32];
3322 } Query;
3323 };
3324 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
3325
3326 typedef struct _KERNEL_USER_TIMES
3327 {
3328 LARGE_INTEGER CreateTime;
3329 LARGE_INTEGER ExitTime;
3330 LARGE_INTEGER KernelTime;
3331 LARGE_INTEGER UserTime;
3332 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
3333
3334 typedef struct _PROCESS_ACCESS_TOKEN
3335 {
3336 HANDLE Token;
3337 HANDLE Thread;
3338 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
3339
3340 typedef struct _PROCESS_SESSION_INFORMATION
3341 {
3342 ULONG SessionId;
3343 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
3344
3345 typedef VOID
3346 (DDKAPI *PREQUEST_POWER_COMPLETE)(
3347 IN PDEVICE_OBJECT DeviceObject,
3348 IN UCHAR MinorFunction,
3349 IN POWER_STATE PowerState,
3350 IN PVOID Context,
3351 IN PIO_STATUS_BLOCK IoStatus);
3352
3353 typedef enum _TRACE_INFORMATION_CLASS {
3354 TraceIdClass,
3355 TraceHandleClass,
3356 TraceEnableFlagsClass,
3357 TraceEnableLevelClass,
3358 GlobalLoggerHandleClass,
3359 EventLoggerHandleClass,
3360 AllLoggerHandlesClass,
3361 TraceHandleByNameClass
3362 } TRACE_INFORMATION_CLASS;
3363
3364 typedef enum _REG_NOTIFY_CLASS
3365 {
3366 RegNtDeleteKey,
3367 RegNtPreDeleteKey = RegNtDeleteKey,
3368 RegNtSetValueKey,
3369 RegNtPreSetValueKey = RegNtSetValueKey,
3370 RegNtDeleteValueKey,
3371 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
3372 RegNtSetInformationKey,
3373 RegNtPreSetInformationKey = RegNtSetInformationKey,
3374 RegNtRenameKey,
3375 RegNtPreRenameKey = RegNtRenameKey,
3376 RegNtEnumerateKey,
3377 RegNtPreEnumerateKey = RegNtEnumerateKey,
3378 RegNtEnumerateValueKey,
3379 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
3380 RegNtQueryKey,
3381 RegNtPreQueryKey = RegNtQueryKey,
3382 RegNtQueryValueKey,
3383 RegNtPreQueryValueKey = RegNtQueryValueKey,
3384 RegNtQueryMultipleValueKey,
3385 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
3386 RegNtPreCreateKey,
3387 RegNtPostCreateKey,
3388 RegNtPreOpenKey,
3389 RegNtPostOpenKey,
3390 RegNtKeyHandleClose,
3391 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
3392 RegNtPostDeleteKey,
3393 RegNtPostSetValueKey,
3394 RegNtPostDeleteValueKey,
3395 RegNtPostSetInformationKey,
3396 RegNtPostRenameKey,
3397 RegNtPostEnumerateKey,
3398 RegNtPostEnumerateValueKey,
3399 RegNtPostQueryKey,
3400 RegNtPostQueryValueKey,
3401 RegNtPostQueryMultipleValueKey,
3402 RegNtPostKeyHandleClose,
3403 RegNtPreCreateKeyEx,
3404 RegNtPostCreateKeyEx,
3405 RegNtPreOpenKeyEx,
3406 RegNtPostOpenKeyEx
3407 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
3408
3409 typedef NTSTATUS
3410 (NTAPI *PEX_CALLBACK_FUNCTION)(
3411 IN PVOID CallbackContext,
3412 IN PVOID Argument1,
3413 IN PVOID Argument2
3414 );
3415
3416 typedef struct _REG_DELETE_KEY_INFORMATION
3417 {
3418 PVOID Object;
3419 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION;
3420
3421 typedef struct _REG_SET_VALUE_KEY_INFORMATION
3422 {
3423 PVOID Object;
3424 PUNICODE_STRING ValueName;
3425 ULONG TitleIndex;
3426 ULONG Type;
3427 PVOID Data;
3428 ULONG DataSize;
3429 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
3430
3431 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION
3432 {
3433 PVOID Object;
3434 PUNICODE_STRING ValueName;
3435 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
3436
3437 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION
3438 {
3439 PVOID Object;
3440 KEY_SET_INFORMATION_CLASS KeySetInformationClass;
3441 PVOID KeySetInformation;
3442 ULONG KeySetInformationLength;
3443 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
3444
3445 typedef struct _REG_ENUMERATE_KEY_INFORMATION
3446 {
3447 PVOID Object;
3448 ULONG Index;
3449 KEY_INFORMATION_CLASS KeyInformationClass;
3450 PVOID KeyInformation;
3451 ULONG Length;
3452 PULONG ResultLength;
3453 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
3454
3455 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION
3456 {
3457 PVOID Object;
3458 ULONG Index;
3459 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
3460 PVOID KeyValueInformation;
3461 ULONG Length;
3462 PULONG ResultLength;
3463 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
3464
3465 typedef struct _REG_QUERY_KEY_INFORMATION
3466 {
3467 PVOID Object;
3468 KEY_INFORMATION_CLASS KeyInformationClass;
3469 PVOID KeyInformation;
3470 ULONG Length;
3471 PULONG ResultLength;
3472 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
3473
3474 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION
3475 {
3476 PVOID Object;
3477 PUNICODE_STRING ValueName;
3478 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
3479 PVOID KeyValueInformation;
3480 ULONG Length;
3481 PULONG ResultLength;
3482 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
3483
3484 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION
3485 {
3486 PVOID Object;
3487 PKEY_VALUE_ENTRY ValueEntries;
3488 ULONG EntryCount;
3489 PVOID ValueBuffer;
3490 PULONG BufferLength;
3491 PULONG RequiredBufferLength;
3492 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
3493
3494 typedef struct _REG_PRE_CREATE_KEY_INFORMATION
3495 {
3496 PUNICODE_STRING CompleteName;
3497 } REG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_CREATE_KEY_INFORMATION;
3498
3499 typedef struct _REG_POST_CREATE_KEY_INFORMATION
3500 {
3501 PUNICODE_STRING CompleteName;
3502 PVOID Object;
3503 NTSTATUS Status;
3504 } REG_POST_CREATE_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION;
3505
3506 typedef struct _REG_PRE_OPEN_KEY_INFORMATION
3507 {
3508 PUNICODE_STRING CompleteName;
3509 } REG_PRE_OPEN_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;
3510
3511 typedef struct _REG_POST_OPEN_KEY_INFORMATION
3512 {
3513 PUNICODE_STRING CompleteName;
3514 PVOID Object;
3515 NTSTATUS Status;
3516 } REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
3517
3518 typedef struct _REG_POST_OPERATION_INFORMATION
3519 {
3520 PVOID Object;
3521 NTSTATUS Status;
3522 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
3523
3524 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION
3525 {
3526 PVOID Object;
3527 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
3528
3529 /*
3530 ** Storage structures
3531 */
3532 typedef enum _PARTITION_STYLE {
3533 PARTITION_STYLE_MBR,
3534 PARTITION_STYLE_GPT,
3535 PARTITION_STYLE_RAW
3536 } PARTITION_STYLE;
3537
3538 typedef struct _CREATE_DISK_MBR {
3539 ULONG Signature;
3540 } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
3541
3542 typedef struct _CREATE_DISK_GPT {
3543 GUID DiskId;
3544 ULONG MaxPartitionCount;
3545 } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
3546
3547 typedef struct _CREATE_DISK {
3548 PARTITION_STYLE PartitionStyle;
3549 _ANONYMOUS_UNION union {
3550 CREATE_DISK_MBR Mbr;
3551 CREATE_DISK_GPT Gpt;
3552 } DUMMYUNIONNAME;
3553 } CREATE_DISK, *PCREATE_DISK;
3554
3555 typedef struct _DISK_SIGNATURE {
3556 ULONG PartitionStyle;
3557 _ANONYMOUS_UNION union {
3558 struct {
3559 ULONG Signature;
3560 ULONG CheckSum;
3561 } Mbr;
3562 struct {
3563 GUID DiskId;
3564 } Gpt;
3565 } DUMMYUNIONNAME;
3566 } DISK_SIGNATURE, *PDISK_SIGNATURE;
3567
3568 typedef VOID
3569 (FASTCALL*PTIME_UPDATE_NOTIFY_ROUTINE)(
3570 IN HANDLE ThreadId,
3571 IN KPROCESSOR_MODE Mode);
3572
3573 #define DBG_STATUS_CONTROL_C 1
3574 #define DBG_STATUS_SYSRQ 2
3575 #define DBG_STATUS_BUGCHECK_FIRST 3
3576 #define DBG_STATUS_BUGCHECK_SECOND 4
3577 #define DBG_STATUS_FATAL 5
3578 #define DBG_STATUS_DEBUG_CONTROL 6
3579 #define DBG_STATUS_WORKER 7
3580
3581 typedef struct _PHYSICAL_MEMORY_RANGE {
3582 PHYSICAL_ADDRESS BaseAddress;
3583 LARGE_INTEGER NumberOfBytes;
3584 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
3585
3586 typedef ULONG_PTR
3587 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
3588 IN PVOID Context);
3589
3590 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
3591 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
3592 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
3593 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
3594
3595 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
3596 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
3597 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
3598 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
3599 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
3600
3601 #define HASH_STRING_ALGORITHM_DEFAULT 0
3602 #define HASH_STRING_ALGORITHM_X65599 1
3603 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
3604
3605 typedef VOID
3606 (DDKAPI *PTIMER_APC_ROUTINE)(
3607 IN PVOID TimerContext,
3608 IN ULONG TimerLowValue,
3609 IN LONG TimerHighValue);
3610
3611
3612
3613 /*
3614 ** WMI structures
3615 */
3616
3617 typedef VOID
3618 (DDKAPI *WMI_NOTIFICATION_CALLBACK)(
3619 PVOID Wnode,
3620 PVOID Context);
3621
3622
3623 /*
3624 ** Architecture specific structures
3625 */
3626 #define PCR_MINOR_VERSION 1
3627 #define PCR_MAJOR_VERSION 1
3628
3629 #ifdef _X86_
3630
3631 #define SIZE_OF_80387_REGISTERS 80
3632 #define CONTEXT_i386 0x10000
3633 #define CONTEXT_i486 0x10000
3634 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
3635 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
3636 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
3637 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
3638 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
3639 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
3640 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
3641 #define MAXIMUM_SUPPORTED_EXTENSION 512
3642
3643 typedef struct _FLOATING_SAVE_AREA {
3644 ULONG ControlWord;
3645 ULONG StatusWord;
3646 ULONG TagWord;
3647 ULONG ErrorOffset;
3648 ULONG ErrorSelector;
3649 ULONG DataOffset;
3650 ULONG DataSelector;
3651 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
3652 ULONG Cr0NpxState;
3653 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
3654
3655 typedef struct _CONTEXT {
3656 ULONG ContextFlags;
3657 ULONG Dr0;
3658 ULONG Dr1;
3659 ULONG Dr2;
3660 ULONG Dr3;
3661 ULONG Dr6;
3662 ULONG Dr7;
3663 FLOATING_SAVE_AREA FloatSave;
3664 ULONG SegGs;
3665 ULONG SegFs;
3666 ULONG SegEs;
3667 ULONG SegDs;
3668 ULONG Edi;
3669 ULONG Esi;
3670 ULONG Ebx;
3671 ULONG Edx;
3672 ULONG Ecx;
3673 ULONG Eax;
3674 ULONG Ebp;
3675 ULONG Eip;
3676 ULONG SegCs;
3677 ULONG EFlags;
3678 ULONG Esp;
3679 ULONG SegSs;
3680 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
3681 } CONTEXT;
3682
3683 //
3684 // Used to contain PFNs and PFN counts
3685 //
3686 typedef ULONG PFN_COUNT;
3687 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
3688 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
3689
3690 #define PASSIVE_LEVEL 0
3691 #define LOW_LEVEL 0
3692 #define APC_LEVEL 1
3693 #define DISPATCH_LEVEL 2
3694 #define PROFILE_LEVEL 27
3695 #define CLOCK1_LEVEL 28
3696 #define CLOCK2_LEVEL 28
3697 #define IPI_LEVEL 29
3698 #define POWER_LEVEL 30
3699 #define HIGH_LEVEL 31
3700
3701 typedef struct _KPCR_TIB {
3702 PVOID ExceptionList; /* 00 */
3703 PVOID StackBase; /* 04 */
3704 PVOID StackLimit; /* 08 */
3705 PVOID SubSystemTib; /* 0C */
3706 _ANONYMOUS_UNION union {
3707 PVOID FiberData; /* 10 */
3708 ULONG Version; /* 10 */
3709 } DUMMYUNIONNAME;
3710 PVOID ArbitraryUserPointer; /* 14 */
3711 struct _KPCR_TIB *Self; /* 18 */
3712 } KPCR_TIB, *PKPCR_TIB; /* 1C */
3713
3714 typedef struct _KPCR {
3715 KPCR_TIB Tib; /* 00 */
3716 struct _KPCR *Self; /* 1C */
3717 struct _KPRCB *Prcb; /* 20 */
3718 KIRQL Irql; /* 24 */
3719 ULONG IRR; /* 28 */
3720 ULONG IrrActive; /* 2C */
3721 ULONG IDR; /* 30 */
3722 PVOID KdVersionBlock; /* 34 */
3723 PUSHORT IDT; /* 38 */
3724 PUSHORT GDT; /* 3C */
3725 struct _KTSS *TSS; /* 40 */
3726 USHORT MajorVersion; /* 44 */
3727 USHORT MinorVersion; /* 46 */
3728 KAFFINITY SetMember; /* 48 */
3729 ULONG StallScaleFactor; /* 4C */
3730 UCHAR SpareUnused; /* 50 */
3731 UCHAR Number; /* 51 */
3732 UCHAR Spare0;
3733 UCHAR SecondLevelCacheAssociativity;
3734 ULONG VdmAlert;
3735 ULONG KernelReserved[14]; // For use by the kernel
3736 ULONG SecondLevelCacheSize;
3737 ULONG HalReserved[16]; // For use by Hal
3738 } KPCR, *PKPCR; /* 54 */
3739
3740 #define KeGetPcr() PCR
3741
3742 typedef struct _KFLOATING_SAVE {
3743 ULONG ControlWord;
3744 ULONG StatusWord;
3745 ULONG ErrorOffset;
3746 ULONG ErrorSelector;
3747 ULONG DataOffset;
3748 ULONG DataSelector;
3749 ULONG Cr0NpxState;
3750 ULONG Spare1;
3751 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3752
3753 FORCEINLINE
3754 ULONG
3755 KeGetCurrentProcessorNumber(VOID)
3756 {
3757 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
3758 }
3759
3760 NTHALAPI
3761 KIRQL
3762 DDKAPI
3763 KeGetCurrentIrql(
3764 VOID);
3765
3766 NTKERNELAPI
3767 PRKTHREAD
3768 NTAPI
3769 KeGetCurrentThread(
3770 VOID);
3771
3772 #define KI_USER_SHARED_DATA 0xffdf0000
3773
3774 #define PAGE_SIZE 0x1000
3775 #define PAGE_SHIFT 12L
3776
3777 #define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA)
3778
3779 extern NTKERNELAPI PVOID MmHighestUserAddress;
3780 extern NTKERNELAPI PVOID MmSystemRangeStart;
3781 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
3782
3783 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3784 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3785 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3786 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3787 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
3788
3789 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
3790 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
3791
3792 #elif defined(__x86_64__)
3793
3794 #define CONTEXT_AMD64 0x100000
3795 #if !defined(RC_INVOKED)
3796 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
3797 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
3798 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
3799 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
3800 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
3801
3802 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
3803 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
3804
3805 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
3806 #define CONTEXT_SERVICE_ACTIVE 0x10000000
3807 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
3808 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
3809 #endif
3810
3811 typedef struct DECLSPEC_ALIGN(16) _M128A {
3812 ULONGLONG Low;
3813 LONGLONG High;
3814 } M128A, *PM128A;
3815
3816 typedef struct _XMM_SAVE_AREA32 {
3817 USHORT ControlWord;
3818 USHORT StatusWord;
3819 UCHAR TagWord;
3820 UCHAR Reserved1;
3821 USHORT ErrorOpcode;
3822 ULONG ErrorOffset;
3823 USHORT ErrorSelector;
3824 USHORT Reserved2;
3825 ULONG DataOffset;
3826 USHORT DataSelector;
3827 USHORT Reserved3;
3828 ULONG MxCsr;
3829 ULONG MxCsr_Mask;
3830 M128A FloatRegisters[8];
3831 M128A XmmRegisters[16];
3832 UCHAR Reserved4[96];
3833 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
3834
3835 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
3836 ULONG64 P1Home;
3837 ULONG64 P2Home;
3838 ULONG64 P3Home;
3839 ULONG64 P4Home;
3840 ULONG64 P5Home;
3841 ULONG64 P6Home;
3842
3843 /* Control flags */
3844 ULONG ContextFlags;
3845 ULONG MxCsr;
3846
3847 /* Segment */
3848 USHORT SegCs;
3849 USHORT SegDs;
3850 USHORT SegEs;
3851 USHORT SegFs;
3852 USHORT SegGs;
3853 USHORT SegSs;
3854 ULONG EFlags;
3855
3856 /* Debug */
3857 ULONG64 Dr0;
3858 ULONG64 Dr1;