- 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_OBJECT.Flags */
526
527 #define DO_DEVICE_HAS_NAME 0x00000040
528 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
529 #define DO_LONG_TERM_REQUESTS 0x00000200
530 #define DO_NEVER_LAST_DEVICE 0x00000400
531 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
532 #define DO_XIP 0x00020000
533
534 #define DRVO_REINIT_REGISTERED 0x00000008
535 #define DRVO_INITIALIZED 0x00000010
536 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
537 #define DRVO_LEGACY_RESOURCES 0x00000040
538
539 typedef enum _ARBITER_REQUEST_SOURCE {
540 ArbiterRequestUndefined = -1,
541 ArbiterRequestLegacyReported,
542 ArbiterRequestHalReported,
543 ArbiterRequestLegacyAssigned,
544 ArbiterRequestPnpDetected,
545 ArbiterRequestPnpEnumerated
546 } ARBITER_REQUEST_SOURCE;
547
548 typedef enum _ARBITER_RESULT {
549 ArbiterResultUndefined = -1,
550 ArbiterResultSuccess,
551 ArbiterResultExternalConflict,
552 ArbiterResultNullRequest
553 } ARBITER_RESULT;
554
555 typedef enum _ARBITER_ACTION {
556 ArbiterActionTestAllocation,
557 ArbiterActionRetestAllocation,
558 ArbiterActionCommitAllocation,
559 ArbiterActionRollbackAllocation,
560 ArbiterActionQueryAllocatedResources,
561 ArbiterActionWriteReservedResources,
562 ArbiterActionQueryConflict,
563 ArbiterActionQueryArbitrate,
564 ArbiterActionAddReserved,
565 ArbiterActionBootAllocation
566 } ARBITER_ACTION, *PARBITER_ACTION;
567
568 typedef struct _ARBITER_CONFLICT_INFO {
569 PDEVICE_OBJECT OwningObject;
570 ULONGLONG Start;
571 ULONGLONG End;
572 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
573
574 typedef struct _ARBITER_PARAMETERS {
575 union {
576 struct {
577 IN OUT PLIST_ENTRY ArbitrationList;
578 IN ULONG AllocateFromCount;
579 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
580 } TestAllocation;
581
582 struct {
583 IN OUT PLIST_ENTRY ArbitrationList;
584 IN ULONG AllocateFromCount;
585 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
586 } RetestAllocation;
587
588 struct {
589 IN OUT PLIST_ENTRY ArbitrationList;
590 } BootAllocation;
591
592 struct {
593 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
594 } QueryAllocatedResources;
595
596 struct {
597 IN PDEVICE_OBJECT PhysicalDeviceObject;
598 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
599 OUT PULONG ConflictCount;
600 OUT PARBITER_CONFLICT_INFO *Conflicts;
601 } QueryConflict;
602
603 struct {
604 IN PLIST_ENTRY ArbitrationList;
605 } QueryArbitrate;
606
607 struct {
608 IN PDEVICE_OBJECT ReserveDevice;
609 } AddReserved;
610 } Parameters;
611 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
612
613 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
614
615 typedef struct _ARBITER_LIST_ENTRY {
616 LIST_ENTRY ListEntry;
617 ULONG AlternativeCount;
618 PIO_RESOURCE_DESCRIPTOR Alternatives;
619 PDEVICE_OBJECT PhysicalDeviceObject;
620 ARBITER_REQUEST_SOURCE RequestSource;
621 ULONG Flags;
622 LONG_PTR WorkSpace;
623 INTERFACE_TYPE InterfaceType;
624 ULONG SlotNumber;
625 ULONG BusNumber;
626 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
627 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
628 ARBITER_RESULT Result;
629 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
630
631 typedef NTSTATUS
632 (DDKAPI *PARBITER_HANDLER)(
633 IN PVOID Context,
634 IN ARBITER_ACTION Action,
635 IN OUT PARBITER_PARAMETERS Parameters);
636
637 #define ARBITER_PARTIAL 0x00000001
638
639 typedef struct _ARBITER_INTERFACE {
640 USHORT Size;
641 USHORT Version;
642 PVOID Context;
643 PINTERFACE_REFERENCE InterfaceReference;
644 PINTERFACE_DEREFERENCE InterfaceDereference;
645 PARBITER_HANDLER ArbiterHandler;
646 ULONG Flags;
647 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
648
649 typedef enum _HAL_QUERY_INFORMATION_CLASS {
650 HalInstalledBusInformation,
651 HalProfileSourceInformation,
652 HalInformationClassUnused1,
653 HalPowerInformation,
654 HalProcessorSpeedInformation,
655 HalCallbackInformation,
656 HalMapRegisterInformation,
657 HalMcaLogInformation,
658 HalFrameBufferCachingInformation,
659 HalDisplayBiosInformation,
660 HalProcessorFeatureInformation,
661 HalNumaTopologyInterface,
662 HalErrorInformation,
663 HalCmcLogInformation,
664 HalCpeLogInformation,
665 HalQueryMcaInterface,
666 HalQueryAMLIIllegalIOPortAddresses,
667 HalQueryMaxHotPlugMemoryAddress,
668 HalPartitionIpiInterface,
669 HalPlatformInformation,
670 HalQueryProfileSourceList
671 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
672
673 typedef enum _HAL_SET_INFORMATION_CLASS {
674 HalProfileSourceInterval,
675 HalProfileSourceInterruptHandler,
676 HalMcaRegisterDriver,
677 HalKernelErrorHandler,
678 HalCmcRegisterDriver,
679 HalCpeRegisterDriver,
680 HalMcaLog,
681 HalCmcLog,
682 HalCpeLog,
683 HalGenerateCmcInterrupt
684 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
685
686 typedef struct _HAL_PROFILE_SOURCE_INTERVAL
687 {
688 KPROFILE_SOURCE Source;
689 ULONG_PTR Interval;
690 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
691
692 typedef struct _HAL_PROFILE_SOURCE_INFORMATION
693 {
694 KPROFILE_SOURCE Source;
695 BOOLEAN Supported;
696 ULONG Interval;
697 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
698
699 typedef struct _MAP_REGISTER_ENTRY
700 {
701 PVOID MapRegister;
702 BOOLEAN WriteToDevice;
703 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
704
705 typedef struct
706 {
707 UCHAR Type;
708 BOOLEAN Valid;
709 UCHAR Reserved[2];
710 PUCHAR TranslatedAddress;
711 ULONG Length;
712 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
713
714 typedef struct
715 {
716 PHYSICAL_ADDRESS Start;
717 PHYSICAL_ADDRESS MaxEnd;
718 PVOID VirtualAddress;
719 ULONG Length;
720 BOOLEAN Cached;
721 BOOLEAN Aligned;
722 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
723
724 typedef struct
725 {
726 ULONG Bus;
727 ULONG Slot;
728 USHORT VendorID;
729 USHORT DeviceID;
730 UCHAR BaseClass;
731 UCHAR SubClass;
732 UCHAR ProgIf;
733 BOOLEAN Initialized;
734 DEBUG_DEVICE_ADDRESS BaseAddress[6];
735 DEBUG_MEMORY_REQUIREMENTS Memory;
736 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
737
738 /* Function Type Defintions for Dispatch Functions */
739 struct _DEVICE_CONTROL_CONTEXT;
740
741 typedef VOID
742 (DDKAPI *PDEVICE_CONTROL_COMPLETION)(
743 IN struct _DEVICE_CONTROL_CONTEXT *ControlContext);
744
745 typedef struct _DEVICE_CONTROL_CONTEXT {
746 NTSTATUS Status;
747 PDEVICE_HANDLER_OBJECT DeviceHandler;
748 PDEVICE_OBJECT DeviceObject;
749 ULONG ControlCode;
750 PVOID Buffer;
751 PULONG BufferLength;
752 PVOID Context;
753 } DEVICE_CONTROL_CONTEXT, *PDEVICE_CONTROL_CONTEXT;
754
755 typedef struct _PM_DISPATCH_TABLE {
756 ULONG Signature;
757 ULONG Version;
758 PVOID Function[1];
759 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
760
761 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
762 TranslateChildToParent,
763 TranslateParentToChild
764 } RESOURCE_TRANSLATION_DIRECTION;
765
766 typedef NTSTATUS
767 (DDKAPI *PTRANSLATE_RESOURCE_HANDLER)(
768 IN PVOID Context,
769 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
770 IN RESOURCE_TRANSLATION_DIRECTION Direction,
771 IN ULONG AlternativesCount,
772 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
773 IN PDEVICE_OBJECT PhysicalDeviceObject,
774 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
775
776 typedef NTSTATUS
777 (DDKAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
778 IN PVOID Context,
779 IN PIO_RESOURCE_DESCRIPTOR Source,
780 IN PDEVICE_OBJECT PhysicalDeviceObject,
781 OUT PULONG TargetCount,
782 OUT PIO_RESOURCE_DESCRIPTOR *Target);
783
784 typedef struct _TRANSLATOR_INTERFACE {
785 USHORT Size;
786 USHORT Version;
787 PVOID Context;
788 PINTERFACE_REFERENCE InterfaceReference;
789 PINTERFACE_DEREFERENCE InterfaceDereference;
790 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
791 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
792 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
793
794 typedef NTSTATUS
795 (DDKAPI *pHalDeviceControl)(
796 IN PDEVICE_HANDLER_OBJECT DeviceHandler,
797 IN PDEVICE_OBJECT DeviceObject,
798 IN ULONG ControlCode,
799 IN OUT PVOID Buffer OPTIONAL,
800 IN OUT PULONG BufferLength OPTIONAL,
801 IN PVOID Context,
802 IN PDEVICE_CONTROL_COMPLETION CompletionRoutine);
803
804 typedef VOID
805 (FASTCALL *pHalExamineMBR)(
806 IN PDEVICE_OBJECT DeviceObject,
807 IN ULONG SectorSize,
808 IN ULONG MBRTypeIdentifier,
809 OUT PVOID *Buffer);
810
811 typedef VOID
812 (FASTCALL *pHalIoAssignDriveLetters)(
813 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
814 IN PSTRING NtDeviceName,
815 OUT PUCHAR NtSystemPath,
816 OUT PSTRING NtSystemPathString);
817
818 typedef NTSTATUS
819 (FASTCALL *pHalIoReadPartitionTable)(
820 IN PDEVICE_OBJECT DeviceObject,
821 IN ULONG SectorSize,
822 IN BOOLEAN ReturnRecognizedPartitions,
823 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
824
825 typedef NTSTATUS
826 (FASTCALL *pHalIoSetPartitionInformation)(
827 IN PDEVICE_OBJECT DeviceObject,
828 IN ULONG SectorSize,
829 IN ULONG PartitionNumber,
830 IN ULONG PartitionType);
831
832 typedef NTSTATUS
833 (FASTCALL *pHalIoWritePartitionTable)(
834 IN PDEVICE_OBJECT DeviceObject,
835 IN ULONG SectorSize,
836 IN ULONG SectorsPerTrack,
837 IN ULONG NumberOfHeads,
838 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
839
840 typedef PBUS_HANDLER
841 (FASTCALL *pHalHandlerForBus)(
842 IN INTERFACE_TYPE InterfaceType,
843 IN ULONG BusNumber);
844
845 typedef VOID
846 (FASTCALL *pHalReferenceBusHandler)(
847 IN PBUS_HANDLER BusHandler);
848
849 typedef NTSTATUS
850 (DDKAPI *pHalQuerySystemInformation)(
851 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
852 IN ULONG BufferSize,
853 IN OUT PVOID Buffer,
854 OUT PULONG ReturnedLength);
855
856 typedef NTSTATUS
857 (DDKAPI *pHalSetSystemInformation)(
858 IN HAL_SET_INFORMATION_CLASS InformationClass,
859 IN ULONG BufferSize,
860 IN PVOID Buffer);
861
862 typedef NTSTATUS
863 (DDKAPI *pHalQueryBusSlots)(
864 IN PBUS_HANDLER BusHandler,
865 IN ULONG BufferSize,
866 OUT PULONG SlotNumbers,
867 OUT PULONG ReturnedLength);
868
869 typedef NTSTATUS
870 (DDKAPI *pHalInitPnpDriver)(
871 VOID);
872
873 typedef NTSTATUS
874 (DDKAPI *pHalInitPowerManagement)(
875 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
876 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
877
878 typedef struct _DMA_ADAPTER*
879 (DDKAPI *pHalGetDmaAdapter)(
880 IN PVOID Context,
881 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
882 OUT PULONG NumberOfMapRegisters);
883
884 typedef NTSTATUS
885 (DDKAPI *pHalGetInterruptTranslator)(
886 IN INTERFACE_TYPE ParentInterfaceType,
887 IN ULONG ParentBusNumber,
888 IN INTERFACE_TYPE BridgeInterfaceType,
889 IN USHORT Size,
890 IN USHORT Version,
891 OUT PTRANSLATOR_INTERFACE Translator,
892 OUT PULONG BridgeBusNumber);
893
894 typedef NTSTATUS
895 (DDKAPI *pHalStartMirroring)(
896 VOID);
897
898 typedef NTSTATUS
899 (DDKAPI *pHalEndMirroring)(
900 IN ULONG PassNumber);
901
902 typedef NTSTATUS
903 (DDKAPI *pHalMirrorPhysicalMemory)(
904 IN PHYSICAL_ADDRESS PhysicalAddress,
905 IN LARGE_INTEGER NumberOfBytes);
906
907 typedef NTSTATUS
908 (DDKAPI *pHalMirrorVerify)(
909 IN PHYSICAL_ADDRESS PhysicalAddress,
910 IN LARGE_INTEGER NumberOfBytes);
911
912 typedef VOID
913 (DDKAPI *pHalEndOfBoot)(
914 VOID);
915
916 typedef
917 BOOLEAN
918 (DDKAPI *pHalTranslateBusAddress)(
919 IN INTERFACE_TYPE InterfaceType,
920 IN ULONG BusNumber,
921 IN PHYSICAL_ADDRESS BusAddress,
922 IN OUT PULONG AddressSpace,
923 OUT PPHYSICAL_ADDRESS TranslatedAddress
924 );
925
926 typedef
927 NTSTATUS
928 (DDKAPI *pHalAssignSlotResources)(
929 IN PUNICODE_STRING RegistryPath,
930 IN PUNICODE_STRING DriverClassName OPTIONAL,
931 IN PDRIVER_OBJECT DriverObject,
932 IN PDEVICE_OBJECT DeviceObject,
933 IN INTERFACE_TYPE BusType,
934 IN ULONG BusNumber,
935 IN ULONG SlotNumber,
936 IN OUT PCM_RESOURCE_LIST *AllocatedResources
937 );
938
939 typedef
940 VOID
941 (DDKAPI *pHalHaltSystem)(
942 VOID
943 );
944
945 typedef
946 BOOLEAN
947 (DDKAPI *pHalResetDisplay)(
948 VOID
949 );
950
951 typedef
952 UCHAR
953 (DDKAPI *pHalVectorToIDTEntry)(
954 ULONG Vector
955 );
956
957 typedef
958 BOOLEAN
959 (DDKAPI *pHalFindBusAddressTranslation)(
960 IN PHYSICAL_ADDRESS BusAddress,
961 IN OUT PULONG AddressSpace,
962 OUT PPHYSICAL_ADDRESS TranslatedAddress,
963 IN OUT PULONG_PTR Context,
964 IN BOOLEAN NextBus
965 );
966
967 typedef
968 NTSTATUS
969 (DDKAPI *pKdSetupPciDeviceForDebugging)(
970 IN PVOID LoaderBlock OPTIONAL,
971 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
972 );
973
974 typedef
975 NTSTATUS
976 (DDKAPI *pKdReleasePciDeviceForDebugging)(
977 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
978 );
979
980 typedef
981 PVOID
982 (DDKAPI *pKdGetAcpiTablePhase0)(
983 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
984 IN ULONG Signature
985 );
986
987 typedef
988 VOID
989 (DDKAPI *pKdCheckPowerButton)(
990 VOID
991 );
992
993 typedef
994 ULONG
995 (DDKAPI *pHalGetInterruptVector)(
996 IN INTERFACE_TYPE InterfaceType,
997 IN ULONG BusNumber,
998 IN ULONG BusInterruptLevel,
999 IN ULONG BusInterruptVector,
1000 OUT PKIRQL Irql,
1001 OUT PKAFFINITY Affinity
1002 );
1003
1004 typedef
1005 NTSTATUS
1006 (DDKAPI *pHalGetVectorInput)(
1007 IN ULONG Vector,
1008 IN KAFFINITY Affinity,
1009 OUT PULONG Input,
1010 OUT PKINTERRUPT_POLARITY Polarity
1011 );
1012
1013 typedef
1014 PVOID
1015 (DDKAPI *pKdMapPhysicalMemory64)(
1016 IN PHYSICAL_ADDRESS PhysicalAddress,
1017 IN ULONG NumberPages
1018 );
1019
1020 typedef
1021 VOID
1022 (DDKAPI *pKdUnmapVirtualAddress)(
1023 IN PVOID VirtualAddress,
1024 IN ULONG NumberPages
1025 );
1026
1027 typedef
1028 ULONG
1029 (DDKAPI *pKdGetPciDataByOffset)(
1030 IN ULONG BusNumber,
1031 IN ULONG SlotNumber,
1032 OUT PVOID Buffer,
1033 IN ULONG Offset,
1034 IN ULONG Length
1035 );
1036
1037 typedef
1038 ULONG
1039 (DDKAPI *pKdSetPciDataByOffset)(
1040 IN ULONG BusNumber,
1041 IN ULONG SlotNumber,
1042 IN PVOID Buffer,
1043 IN ULONG Offset,
1044 IN ULONG Length
1045 );
1046
1047 typedef BOOLEAN
1048 (DDKAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
1049 ULONG Columns, ULONG Rows);
1050
1051 typedef struct {
1052 ULONG Version;
1053 pHalQuerySystemInformation HalQuerySystemInformation;
1054 pHalSetSystemInformation HalSetSystemInformation;
1055 pHalQueryBusSlots HalQueryBusSlots;
1056 ULONG Spare1;
1057 pHalExamineMBR HalExamineMBR;
1058 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
1059 pHalIoReadPartitionTable HalIoReadPartitionTable;
1060 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
1061 pHalIoWritePartitionTable HalIoWritePartitionTable;
1062 pHalHandlerForBus HalReferenceHandlerForBus;
1063 pHalReferenceBusHandler HalReferenceBusHandler;
1064 pHalReferenceBusHandler HalDereferenceBusHandler;
1065 pHalInitPnpDriver HalInitPnpDriver;
1066 pHalInitPowerManagement HalInitPowerManagement;
1067 pHalGetDmaAdapter HalGetDmaAdapter;
1068 pHalGetInterruptTranslator HalGetInterruptTranslator;
1069 pHalStartMirroring HalStartMirroring;
1070 pHalEndMirroring HalEndMirroring;
1071 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
1072 pHalEndOfBoot HalEndOfBoot;
1073 pHalMirrorVerify HalMirrorVerify;
1074 } HAL_DISPATCH, *PHAL_DISPATCH;
1075
1076 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTHAL_)
1077 extern NTSYSAPI PHAL_DISPATCH HalDispatchTable;
1078 #define HALDISPATCH ((PHAL_DISPATCH)&HalDispatchTable)
1079 #else
1080 extern __declspec(dllexport) HAL_DISPATCH HalDispatchTable;
1081 #define HALDISPATCH (&HalDispatchTable)
1082 #endif
1083
1084 #define HAL_DISPATCH_VERSION 3
1085 #define HalDispatchTableVersion HALDISPATCH->Version
1086 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
1087 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
1088 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
1089 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
1090 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
1091 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
1092 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
1093 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
1094 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
1095 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
1096 #define HalStartMirroring HALDISPATCH->HalStartMirroring
1097 #define HalEndMirroring HALDISPATCH->HalEndMirroring
1098 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
1099 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
1100 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
1101
1102 typedef struct _FILE_ALIGNMENT_INFORMATION {
1103 ULONG AlignmentRequirement;
1104 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
1105
1106 typedef struct _FILE_NAME_INFORMATION {
1107 ULONG FileNameLength;
1108 WCHAR FileName[1];
1109 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
1110
1111
1112 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
1113 ULONG FileAttributes;
1114 ULONG ReparseTag;
1115 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
1116
1117 typedef struct _FILE_DISPOSITION_INFORMATION {
1118 BOOLEAN DeleteFile;
1119 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
1120
1121 typedef struct _FILE_END_OF_FILE_INFORMATION {
1122 LARGE_INTEGER EndOfFile;
1123 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
1124
1125 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
1126 LARGE_INTEGER ValidDataLength;
1127 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
1128
1129 typedef union _FILE_SEGMENT_ELEMENT {
1130 PVOID64 Buffer;
1131 ULONGLONG Alignment;
1132 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
1133
1134 typedef BOOLEAN
1135 (DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
1136 IN struct _FILE_OBJECT *FileObject,
1137 IN PLARGE_INTEGER FileOffset,
1138 IN ULONG Length,
1139 IN BOOLEAN Wait,
1140 IN ULONG LockKey,
1141 IN BOOLEAN CheckForReadOperation,
1142 OUT PIO_STATUS_BLOCK IoStatus,
1143 IN struct _DEVICE_OBJECT *DeviceObject);
1144
1145 typedef BOOLEAN
1146 (DDKAPI *PFAST_IO_READ)(
1147 IN struct _FILE_OBJECT *FileObject,
1148 IN PLARGE_INTEGER FileOffset,
1149 IN ULONG Length,
1150 IN BOOLEAN Wait,
1151 IN ULONG LockKey,
1152 OUT PVOID Buffer,
1153 OUT PIO_STATUS_BLOCK IoStatus,
1154 IN struct _DEVICE_OBJECT *DeviceObject);
1155
1156 typedef BOOLEAN
1157 (DDKAPI *PFAST_IO_WRITE)(
1158 IN struct _FILE_OBJECT *FileObject,
1159 IN PLARGE_INTEGER FileOffset,
1160 IN ULONG Length,
1161 IN BOOLEAN Wait,
1162 IN ULONG LockKey,
1163 IN PVOID Buffer,
1164 OUT PIO_STATUS_BLOCK IoStatus,
1165 IN struct _DEVICE_OBJECT *DeviceObject);
1166
1167 typedef BOOLEAN
1168 (DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
1169 IN struct _FILE_OBJECT *FileObject,
1170 IN BOOLEAN Wait,
1171 OUT PFILE_BASIC_INFORMATION Buffer,
1172 OUT PIO_STATUS_BLOCK IoStatus,
1173 IN struct _DEVICE_OBJECT *DeviceObject);
1174
1175 typedef BOOLEAN
1176 (DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
1177 IN struct _FILE_OBJECT *FileObject,
1178 IN BOOLEAN Wait,
1179 OUT PFILE_STANDARD_INFORMATION Buffer,
1180 OUT PIO_STATUS_BLOCK IoStatus,
1181 IN struct _DEVICE_OBJECT *DeviceObject);
1182
1183 typedef BOOLEAN
1184 (DDKAPI *PFAST_IO_LOCK)(
1185 IN struct _FILE_OBJECT *FileObject,
1186 IN PLARGE_INTEGER FileOffset,
1187 IN PLARGE_INTEGER Length,
1188 PEPROCESS ProcessId,
1189 ULONG Key,
1190 BOOLEAN FailImmediately,
1191 BOOLEAN ExclusiveLock,
1192 OUT PIO_STATUS_BLOCK IoStatus,
1193 IN struct _DEVICE_OBJECT *DeviceObject);
1194
1195 typedef BOOLEAN
1196 (DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
1197 IN struct _FILE_OBJECT *FileObject,
1198 IN PLARGE_INTEGER FileOffset,
1199 IN PLARGE_INTEGER Length,
1200 PEPROCESS ProcessId,
1201 ULONG Key,
1202 OUT PIO_STATUS_BLOCK IoStatus,
1203 IN struct _DEVICE_OBJECT *DeviceObject);
1204
1205 typedef BOOLEAN
1206 (DDKAPI *PFAST_IO_UNLOCK_ALL)(
1207 IN struct _FILE_OBJECT *FileObject,
1208 PEPROCESS ProcessId,
1209 OUT PIO_STATUS_BLOCK IoStatus,
1210 IN struct _DEVICE_OBJECT *DeviceObject);
1211
1212 typedef BOOLEAN
1213 (DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
1214 IN struct _FILE_OBJECT *FileObject,
1215 PVOID ProcessId,
1216 ULONG Key,
1217 OUT PIO_STATUS_BLOCK IoStatus,
1218 IN struct _DEVICE_OBJECT *DeviceObject);
1219
1220 typedef BOOLEAN
1221 (DDKAPI *PFAST_IO_DEVICE_CONTROL)(
1222 IN struct _FILE_OBJECT *FileObject,
1223 IN BOOLEAN Wait,
1224 IN PVOID InputBuffer OPTIONAL,
1225 IN ULONG InputBufferLength,
1226 OUT PVOID OutputBuffer OPTIONAL,
1227 IN ULONG OutputBufferLength,
1228 IN ULONG IoControlCode,
1229 OUT PIO_STATUS_BLOCK IoStatus,
1230 IN struct _DEVICE_OBJECT *DeviceObject);
1231
1232 typedef VOID
1233 (DDKAPI *PFAST_IO_ACQUIRE_FILE)(
1234 IN struct _FILE_OBJECT *FileObject);
1235
1236 typedef VOID
1237 (DDKAPI *PFAST_IO_RELEASE_FILE)(
1238 IN struct _FILE_OBJECT *FileObject);
1239
1240 typedef VOID
1241 (DDKAPI *PFAST_IO_DETACH_DEVICE)(
1242 IN struct _DEVICE_OBJECT *SourceDevice,
1243 IN struct _DEVICE_OBJECT *TargetDevice);
1244
1245 typedef BOOLEAN
1246 (DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
1247 IN struct _FILE_OBJECT *FileObject,
1248 IN BOOLEAN Wait,
1249 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
1250 OUT struct _IO_STATUS_BLOCK *IoStatus,
1251 IN struct _DEVICE_OBJECT *DeviceObject);
1252
1253 typedef NTSTATUS
1254 (DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
1255 IN struct _FILE_OBJECT *FileObject,
1256 IN PLARGE_INTEGER EndingOffset,
1257 OUT struct _ERESOURCE **ResourceToRelease,
1258 IN struct _DEVICE_OBJECT *DeviceObject);
1259
1260 typedef BOOLEAN
1261 (DDKAPI *PFAST_IO_MDL_READ)(
1262 IN struct _FILE_OBJECT *FileObject,
1263 IN PLARGE_INTEGER FileOffset,
1264 IN ULONG Length,
1265 IN ULONG LockKey,
1266 OUT PMDL *MdlChain,
1267 OUT PIO_STATUS_BLOCK IoStatus,
1268 IN struct _DEVICE_OBJECT *DeviceObject);
1269
1270 typedef BOOLEAN
1271 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
1272 IN struct _FILE_OBJECT *FileObject,
1273 IN PMDL MdlChain,
1274 IN struct _DEVICE_OBJECT *DeviceObject);
1275
1276 typedef BOOLEAN
1277 (DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
1278 IN struct _FILE_OBJECT *FileObject,
1279 IN PLARGE_INTEGER FileOffset,
1280 IN ULONG Length,
1281 IN ULONG LockKey,
1282 OUT PMDL *MdlChain,
1283 OUT PIO_STATUS_BLOCK IoStatus,
1284 IN struct _DEVICE_OBJECT *DeviceObject);
1285
1286 typedef BOOLEAN
1287 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
1288 IN struct _FILE_OBJECT *FileObject,
1289 IN PLARGE_INTEGER FileOffset,
1290 IN PMDL MdlChain,
1291 IN struct _DEVICE_OBJECT *DeviceObject);
1292
1293 typedef BOOLEAN
1294 (DDKAPI *PFAST_IO_READ_COMPRESSED)(
1295 IN struct _FILE_OBJECT *FileObject,
1296 IN PLARGE_INTEGER FileOffset,
1297 IN ULONG Length,
1298 IN ULONG LockKey,
1299 OUT PVOID Buffer,
1300 OUT PMDL *MdlChain,
1301 OUT PIO_STATUS_BLOCK IoStatus,
1302 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1303 IN ULONG CompressedDataInfoLength,
1304 IN struct _DEVICE_OBJECT *DeviceObject);
1305
1306 typedef BOOLEAN
1307 (DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
1308 IN struct _FILE_OBJECT *FileObject,
1309 IN PLARGE_INTEGER FileOffset,
1310 IN ULONG Length,
1311 IN ULONG LockKey,
1312 IN PVOID Buffer,
1313 OUT PMDL *MdlChain,
1314 OUT PIO_STATUS_BLOCK IoStatus,
1315 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1316 IN ULONG CompressedDataInfoLength,
1317 IN struct _DEVICE_OBJECT *DeviceObject);
1318
1319 typedef BOOLEAN
1320 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
1321 IN struct _FILE_OBJECT *FileObject,
1322 IN PMDL MdlChain,
1323 IN struct _DEVICE_OBJECT *DeviceObject);
1324
1325 typedef BOOLEAN
1326 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
1327 IN struct _FILE_OBJECT *FileObject,
1328 IN PLARGE_INTEGER FileOffset,
1329 IN PMDL MdlChain,
1330 IN struct _DEVICE_OBJECT *DeviceObject);
1331
1332 typedef BOOLEAN
1333 (DDKAPI *PFAST_IO_QUERY_OPEN)(
1334 IN struct _IRP *Irp,
1335 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
1336 IN struct _DEVICE_OBJECT *DeviceObject);
1337
1338 typedef NTSTATUS
1339 (DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
1340 IN struct _FILE_OBJECT *FileObject,
1341 IN struct _ERESOURCE *ResourceToRelease,
1342 IN struct _DEVICE_OBJECT *DeviceObject);
1343
1344 typedef NTSTATUS
1345 (DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
1346 IN struct _FILE_OBJECT *FileObject,
1347 IN struct _DEVICE_OBJECT *DeviceObject);
1348
1349 typedef NTSTATUS
1350 (DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
1351 IN struct _FILE_OBJECT *FileObject,
1352 IN struct _DEVICE_OBJECT *DeviceObject);
1353
1354 typedef struct _FAST_IO_DISPATCH {
1355 ULONG SizeOfFastIoDispatch;
1356 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
1357 PFAST_IO_READ FastIoRead;
1358 PFAST_IO_WRITE FastIoWrite;
1359 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
1360 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
1361 PFAST_IO_LOCK FastIoLock;
1362 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
1363 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
1364 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
1365 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
1366 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
1367 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
1368 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
1369 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
1370 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
1371 PFAST_IO_MDL_READ MdlRead;
1372 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
1373 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
1374 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
1375 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
1376 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
1377 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
1378 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
1379 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
1380 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
1381 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
1382 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
1383 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
1384
1385 typedef struct _SECTION_OBJECT_POINTERS {
1386 PVOID DataSectionObject;
1387 PVOID SharedCacheMap;
1388 PVOID ImageSectionObject;
1389 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
1390
1391 typedef struct _IO_COMPLETION_CONTEXT {
1392 PVOID Port;
1393 PVOID Key;
1394 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
1395
1396 /* FILE_OBJECT.Flags */
1397
1398 #define FO_FILE_OPEN 0x00000001
1399 #define FO_SYNCHRONOUS_IO 0x00000002
1400 #define FO_ALERTABLE_IO 0x00000004
1401 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
1402 #define FO_WRITE_THROUGH 0x00000010
1403 #define FO_SEQUENTIAL_ONLY 0x00000020
1404 #define FO_CACHE_SUPPORTED 0x00000040
1405 #define FO_NAMED_PIPE 0x00000080
1406 #define FO_STREAM_FILE 0x00000100
1407 #define FO_MAILSLOT 0x00000200
1408 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
1409 #define FO_DIRECT_DEVICE_OPEN 0x00000800
1410 #define FO_FILE_MODIFIED 0x00001000
1411 #define FO_FILE_SIZE_CHANGED 0x00002000
1412 #define FO_CLEANUP_COMPLETE 0x00004000
1413 #define FO_TEMPORARY_FILE 0x00008000
1414 #define FO_DELETE_ON_CLOSE 0x00010000
1415 #define FO_OPENED_CASE_SENSITIVE 0x00020000
1416 #define FO_HANDLE_CREATED 0x00040000
1417 #define FO_FILE_FAST_IO_READ 0x00080000
1418 #define FO_RANDOM_ACCESS 0x00100000
1419 #define FO_FILE_OPEN_CANCELLED 0x00200000
1420 #define FO_VOLUME_OPEN 0x00400000
1421 #define FO_REMOTE_ORIGIN 0x01000000
1422
1423 typedef struct _FILE_OBJECT
1424 {
1425 CSHORT Type;
1426 CSHORT Size;
1427 PDEVICE_OBJECT DeviceObject;
1428 PVPB Vpb;
1429 PVOID FsContext;
1430 PVOID FsContext2;
1431 PSECTION_OBJECT_POINTERS SectionObjectPointer;
1432 PVOID PrivateCacheMap;
1433 NTSTATUS FinalStatus;
1434 struct _FILE_OBJECT *RelatedFileObject;
1435 BOOLEAN LockOperation;
1436 BOOLEAN DeletePending;
1437 BOOLEAN ReadAccess;
1438 BOOLEAN WriteAccess;
1439 BOOLEAN DeleteAccess;
1440 BOOLEAN SharedRead;
1441 BOOLEAN SharedWrite;
1442 BOOLEAN SharedDelete;
1443 ULONG Flags;
1444 UNICODE_STRING FileName;
1445 LARGE_INTEGER CurrentByteOffset;
1446 volatile ULONG Waiters;
1447 volatile ULONG Busy;
1448 PVOID LastLock;
1449 KEVENT Lock;
1450 KEVENT Event;
1451 volatile PIO_COMPLETION_CONTEXT CompletionContext;
1452 KSPIN_LOCK IrpListLock;
1453 LIST_ENTRY IrpList;
1454 volatile PVOID FileObjectExtension;
1455 } FILE_OBJECT;
1456 typedef struct _FILE_OBJECT *PFILE_OBJECT;
1457
1458 typedef enum _SECURITY_OPERATION_CODE {
1459 SetSecurityDescriptor,
1460 QuerySecurityDescriptor,
1461 DeleteSecurityDescriptor,
1462 AssignSecurityDescriptor
1463 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
1464
1465 #define INITIAL_PRIVILEGE_COUNT 3
1466
1467 typedef struct _INITIAL_PRIVILEGE_SET {
1468 ULONG PrivilegeCount;
1469 ULONG Control;
1470 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
1471 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
1472
1473 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
1474 #define SE_CREATE_TOKEN_PRIVILEGE 2
1475 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
1476 #define SE_LOCK_MEMORY_PRIVILEGE 4
1477 #define SE_INCREASE_QUOTA_PRIVILEGE 5
1478 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
1479 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
1480 #define SE_TCB_PRIVILEGE 7
1481 #define SE_SECURITY_PRIVILEGE 8
1482 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
1483 #define SE_LOAD_DRIVER_PRIVILEGE 10
1484 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
1485 #define SE_SYSTEMTIME_PRIVILEGE 12
1486 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
1487 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
1488 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
1489 #define SE_CREATE_PERMANENT_PRIVILEGE 16
1490 #define SE_BACKUP_PRIVILEGE 17
1491 #define SE_RESTORE_PRIVILEGE 18
1492 #define SE_SHUTDOWN_PRIVILEGE 19
1493 #define SE_DEBUG_PRIVILEGE 20
1494 #define SE_AUDIT_PRIVILEGE 21
1495 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
1496 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
1497 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
1498 #define SE_UNDOCK_PRIVILEGE 25
1499 #define SE_SYNC_AGENT_PRIVILEGE 26
1500 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
1501 #define SE_MANAGE_VOLUME_PRIVILEGE 28
1502 #define SE_IMPERSONATE_PRIVILEGE 29
1503 #define SE_CREATE_GLOBAL_PRIVILEGE 30
1504 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_GLOBAL_PRIVILEGE
1505
1506 typedef struct _SECURITY_SUBJECT_CONTEXT {
1507 PACCESS_TOKEN ClientToken;
1508 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
1509 PACCESS_TOKEN PrimaryToken;
1510 PVOID ProcessAuditId;
1511 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
1512
1513 #include <pshpack4.h>
1514 typedef struct _ACCESS_STATE {
1515 LUID OperationID;
1516 BOOLEAN SecurityEvaluated;
1517 BOOLEAN GenerateAudit;
1518 BOOLEAN GenerateOnClose;
1519 BOOLEAN PrivilegesAllocated;
1520 ULONG Flags;
1521 ACCESS_MASK RemainingDesiredAccess;
1522 ACCESS_MASK PreviouslyGrantedAccess;
1523 ACCESS_MASK OriginalDesiredAccess;
1524 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
1525 PSECURITY_DESCRIPTOR SecurityDescriptor;
1526 PVOID AuxData;
1527 union {
1528 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
1529 PRIVILEGE_SET PrivilegeSet;
1530 } Privileges;
1531
1532 BOOLEAN AuditPrivileges;
1533 UNICODE_STRING ObjectName;
1534 UNICODE_STRING ObjectTypeName;
1535 } ACCESS_STATE, *PACCESS_STATE;
1536 #include <poppack.h>
1537
1538 typedef struct _IO_SECURITY_CONTEXT {
1539 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
1540 PACCESS_STATE AccessState;
1541 ACCESS_MASK DesiredAccess;
1542 ULONG FullCreateOptions;
1543 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
1544
1545 #define IO_TYPE_ADAPTER 1
1546 #define IO_TYPE_CONTROLLER 2
1547 #define IO_TYPE_DEVICE 3
1548 #define IO_TYPE_DRIVER 4
1549 #define IO_TYPE_FILE 5
1550 #define IO_TYPE_IRP 6
1551 #define IO_TYPE_MASTER_ADAPTER 7
1552 #define IO_TYPE_OPEN_PACKET 8
1553 #define IO_TYPE_TIMER 9
1554 #define IO_TYPE_VPB 10
1555 #define IO_TYPE_ERROR_LOG 11
1556 #define IO_TYPE_ERROR_MESSAGE 12
1557 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
1558
1559 #define IO_TYPE_CSQ_IRP_CONTEXT 1
1560 #define IO_TYPE_CSQ 2
1561
1562 struct _IO_CSQ;
1563
1564 typedef struct _IO_CSQ_IRP_CONTEXT {
1565 ULONG Type;
1566 struct _IRP *Irp;
1567 struct _IO_CSQ *Csq;
1568 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
1569
1570 typedef VOID
1571 (DDKAPI *PIO_CSQ_INSERT_IRP)(
1572 IN struct _IO_CSQ *Csq,
1573 IN PIRP Irp);
1574
1575 typedef VOID
1576 (DDKAPI *PIO_CSQ_REMOVE_IRP)(
1577 IN struct _IO_CSQ *Csq,
1578 IN PIRP Irp);
1579
1580 typedef PIRP
1581 (DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)(
1582 IN struct _IO_CSQ *Csq,
1583 IN PIRP Irp,
1584 IN PVOID PeekContext);
1585
1586 typedef VOID
1587 (DDKAPI *PIO_CSQ_ACQUIRE_LOCK)(
1588 IN struct _IO_CSQ *Csq,
1589 OUT PKIRQL Irql);
1590
1591 typedef VOID
1592 (DDKAPI *PIO_CSQ_RELEASE_LOCK)(
1593 IN struct _IO_CSQ *Csq,
1594 IN KIRQL Irql);
1595
1596 typedef VOID
1597 (DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
1598 IN struct _IO_CSQ *Csq,
1599 IN PIRP Irp);
1600
1601 typedef struct _IO_CSQ {
1602 ULONG Type;
1603 PIO_CSQ_INSERT_IRP CsqInsertIrp;
1604 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
1605 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
1606 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
1607 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
1608 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
1609 PVOID ReservePointer;
1610 } IO_CSQ, *PIO_CSQ;
1611
1612 #if !defined(_ALPHA_)
1613 #include <pshpack4.h>
1614 #endif
1615 typedef struct _IO_STACK_LOCATION {
1616 UCHAR MajorFunction;
1617 UCHAR MinorFunction;
1618 UCHAR Flags;
1619 UCHAR Control;
1620 union {
1621 struct {
1622 PIO_SECURITY_CONTEXT SecurityContext;
1623 ULONG Options;
1624 USHORT POINTER_ALIGNMENT FileAttributes;
1625 USHORT ShareAccess;
1626 ULONG POINTER_ALIGNMENT EaLength;
1627 } Create;
1628 struct {
1629 ULONG Length;
1630 ULONG POINTER_ALIGNMENT Key;
1631 LARGE_INTEGER ByteOffset;
1632 } Read;
1633 struct {
1634 ULONG Length;
1635 ULONG POINTER_ALIGNMENT Key;
1636 LARGE_INTEGER ByteOffset;
1637 } Write;
1638 struct {
1639 ULONG Length;
1640 PUNICODE_STRING FileName;
1641 FILE_INFORMATION_CLASS FileInformationClass;
1642 ULONG FileIndex;
1643 } QueryDirectory;
1644 struct {
1645 ULONG Length;
1646 ULONG CompletionFilter;
1647 } NotifyDirectory;
1648 struct {
1649 ULONG Length;
1650 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
1651 } QueryFile;
1652 struct {
1653 ULONG Length;
1654 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
1655 PFILE_OBJECT FileObject;
1656 _ANONYMOUS_UNION union {
1657 _ANONYMOUS_STRUCT struct {
1658 BOOLEAN ReplaceIfExists;
1659 BOOLEAN AdvanceOnly;
1660 } DUMMYSTRUCTNAME;
1661 ULONG ClusterCount;
1662 HANDLE DeleteHandle;
1663 } DUMMYUNIONNAME;
1664 } SetFile;
1665 struct {
1666 ULONG Length;
1667 PVOID EaList;
1668 ULONG EaListLength;
1669 ULONG EaIndex;
1670 } QueryEa;
1671 struct {
1672 ULONG Length;
1673 } SetEa;
1674 struct {
1675 ULONG Length;
1676 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
1677 } QueryVolume;
1678 struct {
1679 ULONG Length;
1680 FS_INFORMATION_CLASS FsInformationClass;
1681 } SetVolume;
1682 struct {
1683 ULONG OutputBufferLength;
1684 ULONG InputBufferLength;
1685 ULONG FsControlCode;
1686 PVOID Type3InputBuffer;
1687 } FileSystemControl;
1688 struct {
1689 PLARGE_INTEGER Length;
1690 ULONG Key;
1691 LARGE_INTEGER ByteOffset;
1692 } LockControl;
1693 struct {
1694 ULONG OutputBufferLength;
1695 ULONG POINTER_ALIGNMENT InputBufferLength;
1696 ULONG POINTER_ALIGNMENT IoControlCode;
1697 PVOID Type3InputBuffer;
1698 } DeviceIoControl;
1699 struct {
1700 SECURITY_INFORMATION SecurityInformation;
1701 ULONG POINTER_ALIGNMENT Length;
1702 } QuerySecurity;
1703 struct {
1704 SECURITY_INFORMATION SecurityInformation;
1705 PSECURITY_DESCRIPTOR SecurityDescriptor;
1706 } SetSecurity;
1707 struct {
1708 PVPB Vpb;
1709 PDEVICE_OBJECT DeviceObject;
1710 } MountVolume;
1711 struct {
1712 PVPB Vpb;
1713 PDEVICE_OBJECT DeviceObject;
1714 } VerifyVolume;
1715 struct {
1716 struct _SCSI_REQUEST_BLOCK *Srb;
1717 } Scsi;
1718 struct {
1719 ULONG Length;
1720 PSID StartSid;
1721 struct _FILE_GET_QUOTA_INFORMATION *SidList;
1722 ULONG SidListLength;
1723 } QueryQuota;
1724 struct {
1725 ULONG Length;
1726 } SetQuota;
1727 struct {
1728 DEVICE_RELATION_TYPE Type;
1729 } QueryDeviceRelations;
1730 struct {
1731 CONST GUID *InterfaceType;
1732 USHORT Size;
1733 USHORT Version;
1734 PINTERFACE Interface;
1735 PVOID InterfaceSpecificData;
1736 } QueryInterface;
1737 struct {
1738 PDEVICE_CAPABILITIES Capabilities;
1739 } DeviceCapabilities;
1740 struct {
1741 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
1742 } FilterResourceRequirements;
1743 struct {
1744 ULONG WhichSpace;
1745 PVOID Buffer;
1746 ULONG Offset;
1747 ULONG POINTER_ALIGNMENT Length;
1748 } ReadWriteConfig;
1749 struct {
1750 BOOLEAN Lock;
1751 } SetLock;
1752 struct {
1753 BUS_QUERY_ID_TYPE IdType;
1754 } QueryId;
1755 struct {
1756 DEVICE_TEXT_TYPE DeviceTextType;
1757 LCID POINTER_ALIGNMENT LocaleId;
1758 } QueryDeviceText;
1759 struct {
1760 BOOLEAN InPath;
1761 BOOLEAN Reserved[3];
1762 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
1763 } UsageNotification;
1764 struct {
1765 SYSTEM_POWER_STATE PowerState;
1766 } WaitWake;
1767 struct {
1768 PPOWER_SEQUENCE PowerSequence;
1769 } PowerSequence;
1770 struct {
1771 ULONG SystemContext;
1772 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
1773 POWER_STATE POINTER_ALIGNMENT State;
1774 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
1775 } Power;
1776 struct {
1777 PCM_RESOURCE_LIST AllocatedResources;
1778 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
1779 } StartDevice;
1780 struct {
1781 ULONG_PTR ProviderId;
1782 PVOID DataPath;
1783 ULONG BufferSize;
1784 PVOID Buffer;
1785 } WMI;
1786 struct {
1787 PVOID Argument1;
1788 PVOID Argument2;
1789 PVOID Argument3;
1790 PVOID Argument4;
1791 } Others;
1792 } Parameters;
1793 PDEVICE_OBJECT DeviceObject;
1794 PFILE_OBJECT FileObject;
1795 PIO_COMPLETION_ROUTINE CompletionRoutine;
1796 PVOID Context;
1797 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
1798 #if !defined(_ALPHA_)
1799 #include <poppack.h>
1800 #endif
1801
1802 /* IO_STACK_LOCATION.Control */
1803
1804 #define SL_PENDING_RETURNED 0x01
1805 #define SL_ERROR_RETURNED 0x02
1806 #define SL_INVOKE_ON_CANCEL 0x20
1807 #define SL_INVOKE_ON_SUCCESS 0x40
1808 #define SL_INVOKE_ON_ERROR 0x80
1809
1810 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
1811
1812 #define PCI_WHICHSPACE_CONFIG 0x0
1813 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
1814
1815 typedef enum _KEY_INFORMATION_CLASS {
1816 KeyBasicInformation,
1817 KeyNodeInformation,
1818 KeyFullInformation,
1819 KeyNameInformation,
1820 KeyCachedInformation,
1821 KeyFlagsInformation
1822 } KEY_INFORMATION_CLASS;
1823
1824 typedef struct _KEY_BASIC_INFORMATION {
1825 LARGE_INTEGER LastWriteTime;
1826 ULONG TitleIndex;
1827 ULONG NameLength;
1828 WCHAR Name[1];
1829 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
1830
1831 typedef struct _KEY_FULL_INFORMATION {
1832 LARGE_INTEGER LastWriteTime;
1833 ULONG TitleIndex;
1834 ULONG ClassOffset;
1835 ULONG ClassLength;
1836 ULONG SubKeys;
1837 ULONG MaxNameLen;
1838 ULONG MaxClassLen;
1839 ULONG Values;
1840 ULONG MaxValueNameLen;
1841 ULONG MaxValueDataLen;
1842 WCHAR Class[1];
1843 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
1844
1845 typedef struct _KEY_NODE_INFORMATION {
1846 LARGE_INTEGER LastWriteTime;
1847 ULONG TitleIndex;
1848 ULONG ClassOffset;
1849 ULONG ClassLength;
1850 ULONG NameLength;
1851 WCHAR Name[1];
1852 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
1853
1854 typedef struct _KEY_VALUE_BASIC_INFORMATION {
1855 ULONG TitleIndex;
1856 ULONG Type;
1857 ULONG NameLength;
1858 WCHAR Name[1];
1859 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
1860
1861 typedef struct _KEY_VALUE_FULL_INFORMATION {
1862 ULONG TitleIndex;
1863 ULONG Type;
1864 ULONG DataOffset;
1865 ULONG DataLength;
1866 ULONG NameLength;
1867 WCHAR Name[1];
1868 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
1869
1870 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
1871 ULONG TitleIndex;
1872 ULONG Type;
1873 ULONG DataLength;
1874 UCHAR Data[1];
1875 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
1876
1877 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
1878 ULONG Type;
1879 ULONG DataLength;
1880 UCHAR Data[1];
1881 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
1882
1883 typedef struct _KEY_VALUE_ENTRY {
1884 PUNICODE_STRING ValueName;
1885 ULONG DataLength;
1886 ULONG DataOffset;
1887 ULONG Type;
1888 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
1889
1890 typedef enum _KEY_VALUE_INFORMATION_CLASS {
1891 KeyValueBasicInformation,
1892 KeyValueFullInformation,
1893 KeyValuePartialInformation,
1894 KeyValueFullInformationAlign64,
1895 KeyValuePartialInformationAlign64
1896 } KEY_VALUE_INFORMATION_CLASS;
1897
1898 typedef struct _KEY_WRITE_TIME_INFORMATION {
1899 LARGE_INTEGER LastWriteTime;
1900 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
1901
1902 typedef struct _KEY_USER_FLAGS_INFORMATION {
1903 ULONG UserFlags;
1904 } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
1905
1906 typedef enum _KEY_SET_INFORMATION_CLASS {
1907 KeyWriteTimeInformation,
1908 KeyUserFlagsInformation,
1909 MaxKeySetInfoClass
1910 } KEY_SET_INFORMATION_CLASS;
1911
1912 /* KEY_VALUE_Xxx.Type */
1913
1914 #define REG_NONE 0
1915 #define REG_SZ 1
1916 #define REG_EXPAND_SZ 2
1917 #define REG_BINARY 3
1918 #define REG_DWORD 4
1919 #define REG_DWORD_LITTLE_ENDIAN 4
1920 #define REG_DWORD_BIG_ENDIAN 5
1921 #define REG_LINK 6
1922 #define REG_MULTI_SZ 7
1923 #define REG_RESOURCE_LIST 8
1924 #define REG_FULL_RESOURCE_DESCRIPTOR 9
1925 #define REG_RESOURCE_REQUIREMENTS_LIST 10
1926 #define REG_QWORD 11
1927 #define REG_QWORD_LITTLE_ENDIAN 11
1928
1929 #define PCI_TYPE0_ADDRESSES 6
1930 #define PCI_TYPE1_ADDRESSES 2
1931 #define PCI_TYPE2_ADDRESSES 5
1932
1933 typedef struct _PCI_COMMON_CONFIG {
1934 USHORT VendorID;
1935 USHORT DeviceID;
1936 USHORT Command;
1937 USHORT Status;
1938 UCHAR RevisionID;
1939 UCHAR ProgIf;
1940 UCHAR SubClass;
1941 UCHAR BaseClass;
1942 UCHAR CacheLineSize;
1943 UCHAR LatencyTimer;
1944 UCHAR HeaderType;
1945 UCHAR BIST;
1946 union {
1947 struct _PCI_HEADER_TYPE_0 {
1948 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
1949 ULONG CIS;
1950 USHORT SubVendorID;
1951 USHORT SubSystemID;
1952 ULONG ROMBaseAddress;
1953 UCHAR CapabilitiesPtr;
1954 UCHAR Reserved1[3];
1955 ULONG Reserved2;
1956 UCHAR InterruptLine;
1957 UCHAR InterruptPin;
1958 UCHAR MinimumGrant;
1959 UCHAR MaximumLatency;
1960 } type0;
1961 struct _PCI_HEADER_TYPE_1 {
1962 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
1963 UCHAR PrimaryBus;
1964 UCHAR SecondaryBus;
1965 UCHAR SubordinateBus;
1966 UCHAR SecondaryLatency;
1967 UCHAR IOBase;
1968 UCHAR IOLimit;
1969 USHORT SecondaryStatus;
1970 USHORT MemoryBase;
1971 USHORT MemoryLimit;
1972 USHORT PrefetchBase;
1973 USHORT PrefetchLimit;
1974 ULONG PrefetchBaseUpper32;
1975 ULONG PrefetchLimitUpper32;
1976 USHORT IOBaseUpper16;
1977 USHORT IOLimitUpper16;
1978 UCHAR CapabilitiesPtr;
1979 UCHAR Reserved1[3];
1980 ULONG ROMBaseAddress;
1981 UCHAR InterruptLine;
1982 UCHAR InterruptPin;
1983 USHORT BridgeControl;
1984 } type1;
1985 struct _PCI_HEADER_TYPE_2 {
1986 ULONG SocketRegistersBaseAddress;
1987 UCHAR CapabilitiesPtr;
1988 UCHAR Reserved;
1989 USHORT SecondaryStatus;
1990 UCHAR PrimaryBus;
1991 UCHAR SecondaryBus;
1992 UCHAR SubordinateBus;
1993 UCHAR SecondaryLatency;
1994 struct {
1995 ULONG Base;
1996 ULONG Limit;
1997 } Range[PCI_TYPE2_ADDRESSES - 1];
1998 UCHAR InterruptLine;
1999 UCHAR InterruptPin;
2000 USHORT BridgeControl;
2001 } type2;
2002 } u;
2003 UCHAR DeviceSpecific[192];
2004 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
2005
2006 /* PCI_COMMON_CONFIG.Command */
2007
2008 #define PCI_ENABLE_IO_SPACE 0x0001
2009 #define PCI_ENABLE_MEMORY_SPACE 0x0002
2010 #define PCI_ENABLE_BUS_MASTER 0x0004
2011 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
2012 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
2013 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
2014 #define PCI_ENABLE_PARITY 0x0040
2015 #define PCI_ENABLE_WAIT_CYCLE 0x0080
2016 #define PCI_ENABLE_SERR 0x0100
2017 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
2018
2019 /* PCI_COMMON_CONFIG.Status */
2020
2021 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
2022 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
2023 #define PCI_STATUS_UDF_SUPPORTED 0x0040
2024 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
2025 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
2026 #define PCI_STATUS_DEVSEL 0x0600
2027 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
2028 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
2029 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
2030 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
2031 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
2032
2033 /* PCI_COMMON_CONFIG.HeaderType */
2034
2035 #define PCI_MULTIFUNCTION 0x80
2036 #define PCI_DEVICE_TYPE 0x00
2037 #define PCI_BRIDGE_TYPE 0x01
2038 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
2039
2040 #define PCI_CONFIGURATION_TYPE(PciData) \
2041 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
2042
2043 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
2044 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
2045
2046 /* PCI device classes */
2047
2048 #define PCI_CLASS_PRE_20 0x00
2049 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
2050 #define PCI_CLASS_NETWORK_CTLR 0x02
2051 #define PCI_CLASS_DISPLAY_CTLR 0x03
2052 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
2053 #define PCI_CLASS_MEMORY_CTLR 0x05
2054 #define PCI_CLASS_BRIDGE_DEV 0x06
2055 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
2056 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
2057 #define PCI_CLASS_INPUT_DEV 0x09
2058 #define PCI_CLASS_DOCKING_STATION 0x0a
2059 #define PCI_CLASS_PROCESSOR 0x0b
2060 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
2061
2062 /* PCI device subclasses for class 0 */
2063
2064 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
2065 #define PCI_SUBCLASS_PRE_20_VGA 0x01
2066
2067 /* PCI device subclasses for class 1 (mass storage controllers)*/
2068
2069 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
2070 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
2071 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
2072 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
2073 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
2074 #define PCI_SUBCLASS_MSC_OTHER 0x80
2075
2076 /* PCI device subclasses for class 2 (network controllers)*/
2077
2078 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
2079 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
2080 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
2081 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
2082 #define PCI_SUBCLASS_NET_OTHER 0x80
2083
2084 /* PCI device subclasses for class 3 (display controllers)*/
2085
2086 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
2087 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
2088 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
2089 #define PCI_SUBCLASS_VID_OTHER 0x80
2090
2091 /* PCI device subclasses for class 4 (multimedia device)*/
2092
2093 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
2094 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
2095 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
2096 #define PCI_SUBCLASS_MM_OTHER 0x80
2097
2098 /* PCI device subclasses for class 5 (memory controller)*/
2099
2100 #define PCI_SUBCLASS_MEM_RAM 0x00
2101 #define PCI_SUBCLASS_MEM_FLASH 0x01
2102 #define PCI_SUBCLASS_MEM_OTHER 0x80
2103
2104 /* PCI device subclasses for class 6 (bridge device)*/
2105
2106 #define PCI_SUBCLASS_BR_HOST 0x00
2107 #define PCI_SUBCLASS_BR_ISA 0x01
2108 #define PCI_SUBCLASS_BR_EISA 0x02
2109 #define PCI_SUBCLASS_BR_MCA 0x03
2110 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
2111 #define PCI_SUBCLASS_BR_PCMCIA 0x05
2112 #define PCI_SUBCLASS_BR_NUBUS 0x06
2113 #define PCI_SUBCLASS_BR_CARDBUS 0x07
2114 #define PCI_SUBCLASS_BR_OTHER 0x80
2115
2116 /* PCI device subclasses for class C (serial bus controller)*/
2117
2118 #define PCI_SUBCLASS_SB_IEEE1394 0x00
2119 #define PCI_SUBCLASS_SB_ACCESS 0x01
2120 #define PCI_SUBCLASS_SB_SSA 0x02
2121 #define PCI_SUBCLASS_SB_USB 0x03
2122 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
2123 #define PCI_SUBCLASS_SB_SMBUS 0x05
2124
2125 #define PCI_MAX_DEVICES 32
2126 #define PCI_MAX_FUNCTION 8
2127 #define PCI_MAX_BRIDGE_NUMBER 0xFF
2128 #define PCI_INVALID_VENDORID 0xFFFF
2129 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
2130
2131 #define PCI_ADDRESS_MEMORY_SPACE 0x00000000
2132 #define PCI_ADDRESS_IO_SPACE 0x00000001
2133 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
2134 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
2135 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
2136 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
2137 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
2138
2139 #define PCI_TYPE_32BIT 0
2140 #define PCI_TYPE_20BIT 2
2141 #define PCI_TYPE_64BIT 4
2142
2143 typedef struct _PCI_SLOT_NUMBER {
2144 union {
2145 struct {
2146 ULONG DeviceNumber : 5;
2147 ULONG FunctionNumber : 3;
2148 ULONG Reserved : 24;
2149 } bits;
2150 ULONG AsULONG;
2151 } u;
2152 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
2153
2154 #define POOL_COLD_ALLOCATION 256
2155 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8
2156 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16
2157
2158 typedef struct _OSVERSIONINFOA {
2159 ULONG dwOSVersionInfoSize;
2160 ULONG dwMajorVersion;
2161 ULONG dwMinorVersion;
2162 ULONG dwBuildNumber;
2163 ULONG dwPlatformId;
2164 CHAR szCSDVersion[128];
2165 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
2166
2167 typedef struct _OSVERSIONINFOW {
2168 ULONG dwOSVersionInfoSize;
2169 ULONG dwMajorVersion;
2170 ULONG dwMinorVersion;
2171 ULONG dwBuildNumber;
2172 ULONG dwPlatformId;
2173 WCHAR szCSDVersion[128];
2174 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
2175
2176 #ifdef UNICODE
2177 typedef OSVERSIONINFOW OSVERSIONINFO;
2178 typedef POSVERSIONINFOW POSVERSIONINFO;
2179 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
2180 #else
2181 typedef OSVERSIONINFOA OSVERSIONINFO;
2182 typedef POSVERSIONINFOA POSVERSIONINFO;
2183 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
2184 #endif // UNICODE
2185
2186 typedef struct _OSVERSIONINFOEXA {
2187 ULONG dwOSVersionInfoSize;
2188 ULONG dwMajorVersion;
2189 ULONG dwMinorVersion;
2190 ULONG dwBuildNumber;
2191 ULONG dwPlatformId;
2192 CHAR szCSDVersion[128];
2193 USHORT wServicePackMajor;
2194 USHORT wServicePackMinor;
2195 USHORT wSuiteMask;
2196 UCHAR wProductType;
2197 UCHAR wReserved;
2198 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
2199
2200 typedef struct _OSVERSIONINFOEXW {
2201 ULONG dwOSVersionInfoSize;
2202 ULONG dwMajorVersion;
2203 ULONG dwMinorVersion;
2204 ULONG dwBuildNumber;
2205 ULONG dwPlatformId;
2206 WCHAR szCSDVersion[128];
2207 USHORT wServicePackMajor;
2208 USHORT wServicePackMinor;
2209 USHORT wSuiteMask;
2210 UCHAR wProductType;
2211 UCHAR wReserved;
2212 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
2213
2214 #ifdef UNICODE
2215 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
2216 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
2217 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
2218 #else
2219 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
2220 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
2221 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
2222 #endif // UNICODE
2223
2224 NTSYSAPI
2225 ULONGLONG
2226 DDKAPI
2227 VerSetConditionMask(
2228 IN ULONGLONG ConditionMask,
2229 IN ULONG TypeMask,
2230 IN UCHAR Condition);
2231
2232 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
2233 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
2234 (TypeBitMask), (ComparisonType)))
2235
2236 /* RtlVerifyVersionInfo() TypeMask */
2237
2238 #define VER_MINORVERSION 0x0000001
2239 #define VER_MAJORVERSION 0x0000002
2240 #define VER_BUILDNUMBER 0x0000004
2241 #define VER_PLATFORMID 0x0000008
2242 #define VER_SERVICEPACKMINOR 0x0000010
2243 #define VER_SERVICEPACKMAJOR 0x0000020
2244 #define VER_SUITENAME 0x0000040
2245 #define VER_PRODUCT_TYPE 0x0000080
2246
2247 /* RtlVerifyVersionInfo() ComparisonType */
2248
2249 #define VER_EQUAL 1
2250 #define VER_GREATER 2
2251 #define VER_GREATER_EQUAL 3
2252 #define VER_LESS 4
2253 #define VER_LESS_EQUAL 5
2254 #define VER_AND 6
2255 #define VER_OR 7
2256
2257 #define VER_CONDITION_MASK 7
2258 #define VER_NUM_BITS_PER_CONDITION_MASK 3
2259
2260 struct _RTL_RANGE;
2261
2262 typedef BOOLEAN
2263 (NTAPI *PRTL_CONFLICT_RANGE_CALLBACK) (
2264 PVOID Context,
2265 struct _RTL_RANGE *Range
2266 );
2267
2268 typedef enum _EVENT_TYPE {
2269 NotificationEvent,
2270 SynchronizationEvent
2271 } EVENT_TYPE;
2272
2273 typedef enum _KWAIT_REASON {
2274 Executive,
2275 FreePage,
2276 PageIn,
2277 PoolAllocation,
2278 DelayExecution,
2279 Suspended,
2280 UserRequest,
2281 WrExecutive,
2282 WrFreePage,
2283 WrPageIn,
2284 WrPoolAllocation,
2285 WrDelayExecution,
2286 WrSuspended,
2287 WrUserRequest,
2288 WrEventPair,
2289 WrQueue,
2290 WrLpcReceive,
2291 WrLpcReply,
2292 WrVirtualMemory,
2293 WrPageOut,
2294 WrRendezvous,
2295 Spare2,
2296 WrGuardedMutex,
2297 Spare4,
2298 Spare5,
2299 Spare6,
2300 WrKernel,
2301 WrResource,
2302 WrPushLock,
2303 WrMutex,
2304 WrQuantumEnd,
2305 WrDispatchInt,
2306 WrPreempted,
2307 WrYieldExecution,
2308 MaximumWaitReason
2309 } KWAIT_REASON;
2310
2311 typedef struct _KWAIT_BLOCK {
2312 LIST_ENTRY WaitListEntry;
2313 struct _KTHREAD * RESTRICTED_POINTER Thread;
2314 PVOID Object;
2315 struct _KWAIT_BLOCK * RESTRICTED_POINTER NextWaitBlock;
2316 USHORT WaitKey;
2317 UCHAR WaitType;
2318 UCHAR SpareByte;
2319 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
2320
2321 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
2322
2323 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
2324 BOOLEAN Removed;
2325 BOOLEAN Reserved[3];
2326 volatile LONG IoCount;
2327 KEVENT RemoveEvent;
2328 } IO_REMOVE_LOCK_COMMON_BLOCK;
2329
2330 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
2331 LONG Signature;
2332 LONG HighWatermark;
2333 LONGLONG MaxLockedTicks;
2334 LONG AllocateTag;
2335 LIST_ENTRY LockList;
2336 KSPIN_LOCK Spin;
2337 volatile LONG LowMemoryCount;
2338 ULONG Reserved1[4];
2339 PVOID Reserved2;
2340 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
2341 } IO_REMOVE_LOCK_DBG_BLOCK;
2342
2343 typedef struct _IO_REMOVE_LOCK {
2344 IO_REMOVE_LOCK_COMMON_BLOCK Common;
2345 #if DBG
2346 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
2347 #endif
2348 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
2349
2350 typedef struct _IO_WORKITEM *PIO_WORKITEM;
2351
2352 typedef VOID
2353 (DDKAPI IO_WORKITEM_ROUTINE)(
2354 IN PDEVICE_OBJECT DeviceObject,
2355 IN PVOID Context);
2356 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
2357
2358 typedef struct _SHARE_ACCESS {
2359 ULONG OpenCount;
2360 ULONG Readers;
2361 ULONG Writers;
2362 ULONG Deleters;
2363 ULONG SharedRead;
2364 ULONG SharedWrite;
2365 ULONG SharedDelete;
2366 } SHARE_ACCESS, *PSHARE_ACCESS;
2367
2368 typedef enum _KINTERRUPT_MODE {
2369 LevelSensitive,
2370 Latched
2371 } KINTERRUPT_MODE;
2372
2373 #define THREAD_WAIT_OBJECTS 3
2374
2375 typedef VOID
2376 (DDKAPI *PKINTERRUPT_ROUTINE)(
2377 VOID);
2378
2379 typedef enum _CREATE_FILE_TYPE {
2380 CreateFileTypeNone,
2381 CreateFileTypeNamedPipe,
2382 CreateFileTypeMailslot
2383 } CREATE_FILE_TYPE;
2384
2385 typedef struct _CONFIGURATION_INFORMATION {
2386 ULONG DiskCount;
2387 ULONG FloppyCount;
2388 ULONG CdRomCount;
2389 ULONG TapeCount;
2390 ULONG ScsiPortCount;
2391 ULONG SerialCount;
2392 ULONG ParallelCount;
2393 BOOLEAN AtDiskPrimaryAddressClaimed;
2394 BOOLEAN AtDiskSecondaryAddressClaimed;
2395 ULONG Version;
2396 ULONG MediumChangerCount;
2397 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
2398
2399 typedef enum _CONFIGURATION_TYPE {
2400 ArcSystem,
2401 CentralProcessor,
2402 FloatingPointProcessor,
2403 PrimaryIcache,
2404 PrimaryDcache,
2405 SecondaryIcache,
2406 SecondaryDcache,
2407 SecondaryCache,
2408 EisaAdapter,
2409 TcAdapter,
2410 ScsiAdapter,
2411 DtiAdapter,
2412 MultiFunctionAdapter,
2413 DiskController,
2414 TapeController,
2415 CdromController,
2416 WormController,
2417 SerialController,
2418 NetworkController,
2419 DisplayController,
2420 ParallelController,
2421 PointerController,
2422 KeyboardController,
2423 AudioController,
2424 OtherController,
2425 DiskPeripheral,
2426 FloppyDiskPeripheral,
2427 TapePeripheral,
2428 ModemPeripheral,
2429 MonitorPeripheral,
2430 PrinterPeripheral,
2431 PointerPeripheral,
2432 KeyboardPeripheral,
2433 TerminalPeripheral,
2434 OtherPeripheral,
2435 LinePeripheral,
2436 NetworkPeripheral,
2437 SystemMemory,
2438 DockingInformation,
2439 RealModeIrqRoutingTable,
2440 RealModePCIEnumeration,
2441 MaximumType
2442 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
2443
2444 #define IO_FORCE_ACCESS_CHECK 0x001
2445 #define IO_NO_PARAMETER_CHECKING 0x100
2446
2447 #define IO_REPARSE 0x0
2448 #define IO_REMOUNT 0x1
2449
2450 typedef NTSTATUS
2451 (DDKAPI *PIO_QUERY_DEVICE_ROUTINE)(
2452 IN PVOID Context,
2453 IN PUNICODE_STRING PathName,
2454 IN INTERFACE_TYPE BusType,
2455 IN ULONG BusNumber,
2456 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
2457 IN CONFIGURATION_TYPE ControllerType,
2458 IN ULONG ControllerNumber,
2459 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
2460 IN CONFIGURATION_TYPE PeripheralType,
2461 IN ULONG PeripheralNumber,
2462 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
2463
2464 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
2465 IoQueryDeviceIdentifier = 0,
2466 IoQueryDeviceConfigurationData,
2467 IoQueryDeviceComponentInformation,
2468 IoQueryDeviceMaxData
2469 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
2470
2471 typedef enum _KBUGCHECK_CALLBACK_REASON {
2472 KbCallbackInvalid,
2473 KbCallbackReserved1,
2474 KbCallbackSecondaryDumpData,
2475 KbCallbackDumpIo,
2476 } KBUGCHECK_CALLBACK_REASON;
2477
2478 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
2479
2480 typedef VOID
2481 (DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)(
2482 IN KBUGCHECK_CALLBACK_REASON Reason,
2483 IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
2484 IN OUT PVOID ReasonSpecificData,
2485 IN ULONG ReasonSpecificDataLength);
2486
2487 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
2488 LIST_ENTRY Entry;
2489 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
2490 PUCHAR Component;
2491 ULONG_PTR Checksum;
2492 KBUGCHECK_CALLBACK_REASON Reason;
2493 UCHAR State;
2494 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
2495
2496 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
2497 BufferEmpty,
2498 BufferInserted,
2499 BufferStarted,
2500 BufferFinished,
2501 BufferIncomplete
2502 } KBUGCHECK_BUFFER_DUMP_STATE;
2503
2504 typedef VOID
2505 (DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)(
2506 IN PVOID Buffer,
2507 IN ULONG Length);
2508
2509 typedef struct _KBUGCHECK_CALLBACK_RECORD {
2510 LIST_ENTRY Entry;
2511 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
2512 PVOID Buffer;
2513 ULONG Length;
2514 PUCHAR Component;
2515 ULONG_PTR Checksum;
2516 UCHAR State;
2517 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
2518
2519 typedef BOOLEAN
2520 (DDKAPI *PNMI_CALLBACK)(
2521 IN PVOID Context,
2522 IN BOOLEAN Handled);
2523
2524 /*
2525 * VOID
2526 * KeInitializeCallbackRecord(
2527 * IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
2528 */
2529 #define KeInitializeCallbackRecord(CallbackRecord) \
2530 CallbackRecord->State = BufferEmpty;
2531
2532 typedef enum _KDPC_IMPORTANCE {
2533 LowImportance,
2534 MediumImportance,
2535 HighImportance
2536 } KDPC_IMPORTANCE;
2537
2538 typedef enum _MEMORY_CACHING_TYPE_ORIG {
2539 MmFrameBufferCached = 2
2540 } MEMORY_CACHING_TYPE_ORIG;
2541
2542 typedef enum _MEMORY_CACHING_TYPE {
2543 MmNonCached = FALSE,
2544 MmCached = TRUE,
2545 MmWriteCombined = MmFrameBufferCached,
2546 MmHardwareCoherentCached,
2547 MmNonCachedUnordered,
2548 MmUSWCCached,
2549 MmMaximumCacheType
2550 } MEMORY_CACHING_TYPE;
2551
2552 typedef enum _MM_PAGE_PRIORITY {
2553 LowPagePriority,
2554 NormalPagePriority = 16,
2555 HighPagePriority = 32
2556 } MM_PAGE_PRIORITY;
2557
2558 typedef enum _LOCK_OPERATION {
2559 IoReadAccess,
2560 IoWriteAccess,
2561 IoModifyAccess
2562 } LOCK_OPERATION;
2563
2564 #define FLUSH_MULTIPLE_MAXIMUM 32
2565
2566 typedef enum _MM_SYSTEM_SIZE {
2567 MmSmallSystem,
2568 MmMediumSystem,
2569 MmLargeSystem
2570 } MM_SYSTEMSIZE;
2571
2572 typedef struct _OBJECT_HANDLE_INFORMATION {
2573 ULONG HandleAttributes;
2574 ACCESS_MASK GrantedAccess;
2575 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
2576
2577 typedef struct _CLIENT_ID {
2578 HANDLE UniqueProcess;
2579 HANDLE UniqueThread;
2580 } CLIENT_ID, *PCLIENT_ID;
2581
2582 typedef VOID
2583 (DDKAPI *PKSTART_ROUTINE)(
2584 IN PVOID StartContext);
2585
2586 typedef VOID
2587 (DDKAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
2588 IN HANDLE ParentId,
2589 IN HANDLE ProcessId,
2590 IN BOOLEAN Create);
2591
2592 typedef VOID
2593 (DDKAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
2594 IN HANDLE ProcessId,
2595 IN HANDLE ThreadId,
2596 IN BOOLEAN Create);
2597
2598 typedef struct _IMAGE_INFO {
2599 _ANONYMOUS_UNION union {
2600 ULONG Properties;
2601 _ANONYMOUS_STRUCT struct {
2602 ULONG ImageAddressingMode : 8;
2603 ULONG SystemModeImage : 1;
2604 ULONG ImageMappedToAllPids : 1;
2605 ULONG Reserved : 22;
2606 } DUMMYSTRUCTNAME;
2607 } DUMMYUNIONNAME;
2608 PVOID ImageBase;
2609 ULONG ImageSelector;
2610 SIZE_T ImageSize;
2611 ULONG ImageSectionNumber;
2612 } IMAGE_INFO, *PIMAGE_INFO;
2613
2614 #define IMAGE_ADDRESSING_MODE_32BIT 3
2615
2616 typedef VOID
2617 (DDKAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
2618 IN PUNICODE_STRING FullImageName,
2619 IN HANDLE ProcessId,
2620 IN PIMAGE_INFO ImageInfo);
2621
2622 #pragma pack(push,4)
2623 typedef enum _BUS_DATA_TYPE {
2624 ConfigurationSpaceUndefined = -1,
2625 Cmos,
2626 EisaConfiguration,
2627 Pos,
2628 CbusConfiguration,
2629 PCIConfiguration,
2630 VMEConfiguration,
2631 NuBusConfiguration,
2632 PCMCIAConfiguration,
2633 MPIConfiguration,
2634 MPSAConfiguration,
2635 PNPISAConfiguration,
2636 SgiInternalConfiguration,
2637 MaximumBusDataType
2638 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
2639 #pragma pack(pop)
2640
2641 typedef struct _NT_TIB {
2642 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2643 PVOID StackBase;
2644 PVOID StackLimit;
2645 PVOID SubSystemTib;
2646 _ANONYMOUS_UNION union {
2647 PVOID FiberData;
2648 ULONG Version;
2649 } DUMMYUNIONNAME;
2650 PVOID ArbitraryUserPointer;
2651 struct _NT_TIB *Self;
2652 } NT_TIB, *PNT_TIB;
2653
2654 typedef struct _NT_TIB32 {
2655 ULONG ExceptionList;
2656 ULONG StackBase;
2657 ULONG StackLimit;
2658 ULONG SubSystemTib;
2659 __GNU_EXTENSION union {
2660 ULONG FiberData;
2661 ULONG Version;
2662 };
2663 ULONG ArbitraryUserPointer;
2664 ULONG Self;
2665 } NT_TIB32,*PNT_TIB32;
2666
2667 typedef struct _NT_TIB64 {
2668 ULONG64 ExceptionList;
2669 ULONG64 StackBase;
2670 ULONG64 StackLimit;
2671 ULONG64 SubSystemTib;
2672 __GNU_EXTENSION union {
2673 ULONG64 FiberData;
2674 ULONG Version;
2675 };
2676 ULONG64 ArbitraryUserPointer;
2677 ULONG64 Self;
2678 } NT_TIB64,*PNT_TIB64;
2679
2680 typedef enum _PROCESSINFOCLASS {
2681 ProcessBasicInformation,
2682 ProcessQuotaLimits,
2683 ProcessIoCounters,
2684 ProcessVmCounters,
2685 ProcessTimes,
2686 ProcessBasePriority,
2687 ProcessRaisePriority,
2688 ProcessDebugPort,
2689 ProcessExceptionPort,
2690 ProcessAccessToken,
2691 ProcessLdtInformation,
2692 ProcessLdtSize,
2693 ProcessDefaultHardErrorMode,
2694 ProcessIoPortHandlers,
2695 ProcessPooledUsageAndLimits,
2696 ProcessWorkingSetWatch,
2697 ProcessUserModeIOPL,
2698 ProcessEnableAlignmentFaultFixup,
2699 ProcessPriorityClass,
2700 ProcessWx86Information,
2701 ProcessHandleCount,
2702 ProcessAffinityMask,
2703 ProcessPriorityBoost,
2704 ProcessDeviceMap,
2705 ProcessSessionInformation,
2706 ProcessForegroundInformation,
2707 ProcessWow64Information,
2708 ProcessImageFileName,
2709 ProcessLUIDDeviceMapsEnabled,
2710 ProcessBreakOnTermination,
2711 ProcessDebugObjectHandle,
2712 ProcessDebugFlags,
2713 ProcessHandleTracing,
2714 ProcessIoPriority,
2715 ProcessExecuteFlags,
2716 ProcessTlsInformation,
2717 ProcessCookie,
2718 ProcessImageInformation,
2719 ProcessCycleTime,
2720 ProcessPagePriority,
2721 ProcessInstrumentationCallback,
2722 MaxProcessInfoClass
2723 } PROCESSINFOCLASS;
2724
2725 typedef enum _THREADINFOCLASS {
2726 ThreadBasicInformation,
2727 ThreadTimes,
2728 ThreadPriority,
2729 ThreadBasePriority,
2730 ThreadAffinityMask,
2731 ThreadImpersonationToken,
2732 ThreadDescriptorTableEntry,
2733 ThreadEnableAlignmentFaultFixup,
2734 ThreadEventPair_Reusable,
2735 ThreadQuerySetWin32StartAddress,
2736 ThreadZeroTlsCell,
2737 ThreadPerformanceCount,
2738 ThreadAmILastThread,
2739 ThreadIdealProcessor,
2740 ThreadPriorityBoost,
2741 ThreadSetTlsArrayAddress,
2742 ThreadIsIoPending,
2743 ThreadHideFromDebugger,
2744 ThreadBreakOnTermination,
2745 ThreadSwitchLegacyState,
2746 ThreadIsTerminated,
2747 ThreadLastSystemCall,
2748 ThreadIoPriority,
2749 ThreadCycleTime,
2750 ThreadPagePriority,
2751 ThreadActualBasePriority,
2752 MaxThreadInfoClass
2753 } THREADINFOCLASS;
2754
2755 typedef struct _PROCESS_BASIC_INFORMATION
2756 {
2757 NTSTATUS ExitStatus;
2758 struct _PEB *PebBaseAddress;
2759 ULONG_PTR AffinityMask;
2760 KPRIORITY BasePriority;
2761 ULONG_PTR UniqueProcessId;
2762 ULONG_PTR InheritedFromUniqueProcessId;
2763 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
2764
2765 typedef struct _PROCESS_WS_WATCH_INFORMATION
2766 {
2767 PVOID FaultingPc;
2768 PVOID FaultingVa;
2769 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
2770
2771 typedef struct _PROCESS_DEVICEMAP_INFORMATION
2772 {
2773 __GNU_EXTENSION union
2774 {
2775 struct
2776 {
2777 HANDLE DirectoryHandle;
2778 } Set;
2779 struct
2780 {
2781 ULONG DriveMap;
2782 UCHAR DriveType[32];
2783 } Query;
2784 };
2785 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
2786
2787 typedef struct _KERNEL_USER_TIMES
2788 {
2789 LARGE_INTEGER CreateTime;
2790 LARGE_INTEGER ExitTime;
2791 LARGE_INTEGER KernelTime;
2792 LARGE_INTEGER UserTime;
2793 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
2794
2795 typedef struct _PROCESS_ACCESS_TOKEN
2796 {
2797 HANDLE Token;
2798 HANDLE Thread;
2799 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
2800
2801 typedef struct _PROCESS_SESSION_INFORMATION
2802 {
2803 ULONG SessionId;
2804 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
2805
2806 typedef VOID
2807 (DDKAPI *PREQUEST_POWER_COMPLETE)(
2808 IN PDEVICE_OBJECT DeviceObject,
2809 IN UCHAR MinorFunction,
2810 IN POWER_STATE PowerState,
2811 IN PVOID Context,
2812 IN PIO_STATUS_BLOCK IoStatus);
2813
2814 typedef enum _TRACE_INFORMATION_CLASS {
2815 TraceIdClass,
2816 TraceHandleClass,
2817 TraceEnableFlagsClass,
2818 TraceEnableLevelClass,
2819 GlobalLoggerHandleClass,
2820 EventLoggerHandleClass,
2821 AllLoggerHandlesClass,
2822 TraceHandleByNameClass
2823 } TRACE_INFORMATION_CLASS;
2824
2825 typedef enum _REG_NOTIFY_CLASS
2826 {
2827 RegNtDeleteKey,
2828 RegNtPreDeleteKey = RegNtDeleteKey,
2829 RegNtSetValueKey,
2830 RegNtPreSetValueKey = RegNtSetValueKey,
2831 RegNtDeleteValueKey,
2832 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
2833 RegNtSetInformationKey,
2834 RegNtPreSetInformationKey = RegNtSetInformationKey,
2835 RegNtRenameKey,
2836 RegNtPreRenameKey = RegNtRenameKey,
2837 RegNtEnumerateKey,
2838 RegNtPreEnumerateKey = RegNtEnumerateKey,
2839 RegNtEnumerateValueKey,
2840 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
2841 RegNtQueryKey,
2842 RegNtPreQueryKey = RegNtQueryKey,
2843 RegNtQueryValueKey,
2844 RegNtPreQueryValueKey = RegNtQueryValueKey,
2845 RegNtQueryMultipleValueKey,
2846 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
2847 RegNtPreCreateKey,
2848 RegNtPostCreateKey,
2849 RegNtPreOpenKey,
2850 RegNtPostOpenKey,
2851 RegNtKeyHandleClose,
2852 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
2853 RegNtPostDeleteKey,
2854 RegNtPostSetValueKey,
2855 RegNtPostDeleteValueKey,
2856 RegNtPostSetInformationKey,
2857 RegNtPostRenameKey,
2858 RegNtPostEnumerateKey,
2859 RegNtPostEnumerateValueKey,
2860 RegNtPostQueryKey,
2861 RegNtPostQueryValueKey,
2862 RegNtPostQueryMultipleValueKey,
2863 RegNtPostKeyHandleClose,
2864 RegNtPreCreateKeyEx,
2865 RegNtPostCreateKeyEx,
2866 RegNtPreOpenKeyEx,
2867 RegNtPostOpenKeyEx
2868 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
2869
2870 typedef NTSTATUS
2871 (NTAPI *PEX_CALLBACK_FUNCTION)(
2872 IN PVOID CallbackContext,
2873 IN PVOID Argument1,
2874 IN PVOID Argument2
2875 );
2876
2877 typedef struct _REG_DELETE_KEY_INFORMATION
2878 {
2879 PVOID Object;
2880 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION;
2881
2882 typedef struct _REG_SET_VALUE_KEY_INFORMATION
2883 {
2884 PVOID Object;
2885 PUNICODE_STRING ValueName;
2886 ULONG TitleIndex;
2887 ULONG Type;
2888 PVOID Data;
2889 ULONG DataSize;
2890 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
2891
2892 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION
2893 {
2894 PVOID Object;
2895 PUNICODE_STRING ValueName;
2896 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
2897
2898 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION
2899 {
2900 PVOID Object;
2901 KEY_SET_INFORMATION_CLASS KeySetInformationClass;
2902 PVOID KeySetInformation;
2903 ULONG KeySetInformationLength;
2904 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
2905
2906 typedef struct _REG_ENUMERATE_KEY_INFORMATION
2907 {
2908 PVOID Object;
2909 ULONG Index;
2910 KEY_INFORMATION_CLASS KeyInformationClass;
2911 PVOID KeyInformation;
2912 ULONG Length;
2913 PULONG ResultLength;
2914 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
2915
2916 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION
2917 {
2918 PVOID Object;
2919 ULONG Index;
2920 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
2921 PVOID KeyValueInformation;
2922 ULONG Length;
2923 PULONG ResultLength;
2924 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
2925
2926 typedef struct _REG_QUERY_KEY_INFORMATION
2927 {
2928 PVOID Object;
2929 KEY_INFORMATION_CLASS KeyInformationClass;
2930 PVOID KeyInformation;
2931 ULONG Length;
2932 PULONG ResultLength;
2933 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
2934
2935 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION
2936 {
2937 PVOID Object;
2938 PUNICODE_STRING ValueName;
2939 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
2940 PVOID KeyValueInformation;
2941 ULONG Length;
2942 PULONG ResultLength;
2943 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
2944
2945 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION
2946 {
2947 PVOID Object;
2948 PKEY_VALUE_ENTRY ValueEntries;
2949 ULONG EntryCount;
2950 PVOID ValueBuffer;
2951 PULONG BufferLength;
2952 PULONG RequiredBufferLength;
2953 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
2954
2955 typedef struct _REG_PRE_CREATE_KEY_INFORMATION
2956 {
2957 PUNICODE_STRING CompleteName;
2958 } REG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_CREATE_KEY_INFORMATION;
2959
2960 typedef struct _REG_POST_CREATE_KEY_INFORMATION
2961 {
2962 PUNICODE_STRING CompleteName;
2963 PVOID Object;
2964 NTSTATUS Status;
2965 } REG_POST_CREATE_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION;
2966
2967 typedef struct _REG_PRE_OPEN_KEY_INFORMATION
2968 {
2969 PUNICODE_STRING CompleteName;
2970 } REG_PRE_OPEN_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;
2971
2972 typedef struct _REG_POST_OPEN_KEY_INFORMATION
2973 {
2974 PUNICODE_STRING CompleteName;
2975 PVOID Object;
2976 NTSTATUS Status;
2977 } REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
2978
2979 typedef struct _REG_POST_OPERATION_INFORMATION
2980 {
2981 PVOID Object;
2982 NTSTATUS Status;
2983 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
2984
2985 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION
2986 {
2987 PVOID Object;
2988 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
2989
2990 /*
2991 ** Storage structures
2992 */
2993 typedef enum _PARTITION_STYLE {
2994 PARTITION_STYLE_MBR,
2995 PARTITION_STYLE_GPT,
2996 PARTITION_STYLE_RAW
2997 } PARTITION_STYLE;
2998
2999 typedef struct _CREATE_DISK_MBR {
3000 ULONG Signature;
3001 } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
3002
3003 typedef struct _CREATE_DISK_GPT {
3004 GUID DiskId;
3005 ULONG MaxPartitionCount;
3006 } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
3007
3008 typedef struct _CREATE_DISK {
3009 PARTITION_STYLE PartitionStyle;
3010 _ANONYMOUS_UNION union {
3011 CREATE_DISK_MBR Mbr;
3012 CREATE_DISK_GPT Gpt;
3013 } DUMMYUNIONNAME;
3014 } CREATE_DISK, *PCREATE_DISK;
3015
3016 typedef struct _DISK_SIGNATURE {
3017 ULONG PartitionStyle;
3018 _ANONYMOUS_UNION union {
3019 struct {
3020 ULONG Signature;
3021 ULONG CheckSum;
3022 } Mbr;
3023 struct {
3024 GUID DiskId;
3025 } Gpt;
3026 } DUMMYUNIONNAME;
3027 } DISK_SIGNATURE, *PDISK_SIGNATURE;
3028
3029 typedef VOID
3030 (FASTCALL*PTIME_UPDATE_NOTIFY_ROUTINE)(
3031 IN HANDLE ThreadId,
3032 IN KPROCESSOR_MODE Mode);
3033
3034 #define DBG_STATUS_CONTROL_C 1
3035 #define DBG_STATUS_SYSRQ 2
3036 #define DBG_STATUS_BUGCHECK_FIRST 3
3037 #define DBG_STATUS_BUGCHECK_SECOND 4
3038 #define DBG_STATUS_FATAL 5
3039 #define DBG_STATUS_DEBUG_CONTROL 6
3040 #define DBG_STATUS_WORKER 7
3041
3042 typedef struct _PHYSICAL_MEMORY_RANGE {
3043 PHYSICAL_ADDRESS BaseAddress;
3044 LARGE_INTEGER NumberOfBytes;
3045 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
3046
3047 typedef ULONG_PTR
3048 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
3049 IN PVOID Context);
3050
3051 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
3052 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
3053 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
3054 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
3055
3056 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
3057 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
3058 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
3059 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
3060 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
3061
3062 #define HASH_STRING_ALGORITHM_DEFAULT 0
3063 #define HASH_STRING_ALGORITHM_X65599 1
3064 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
3065
3066 typedef VOID
3067 (DDKAPI *PTIMER_APC_ROUTINE)(
3068 IN PVOID TimerContext,
3069 IN ULONG TimerLowValue,
3070 IN LONG TimerHighValue);
3071
3072
3073
3074 /*
3075 ** WMI structures
3076 */
3077
3078 typedef VOID
3079 (DDKAPI *WMI_NOTIFICATION_CALLBACK)(
3080 PVOID Wnode,
3081 PVOID Context);
3082
3083
3084 /*
3085 ** Architecture specific structures
3086 */
3087 #define PCR_MINOR_VERSION 1
3088 #define PCR_MAJOR_VERSION 1
3089
3090 #ifdef _X86_
3091
3092 #define SIZE_OF_80387_REGISTERS 80
3093 #define CONTEXT_i386 0x10000
3094 #define CONTEXT_i486 0x10000
3095 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
3096 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
3097 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
3098 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
3099 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
3100 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
3101 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
3102 #define MAXIMUM_SUPPORTED_EXTENSION 512
3103
3104 typedef struct _FLOATING_SAVE_AREA {
3105 ULONG ControlWord;
3106 ULONG StatusWord;
3107 ULONG TagWord;
3108 ULONG ErrorOffset;
3109 ULONG ErrorSelector;
3110 ULONG DataOffset;
3111 ULONG DataSelector;
3112 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
3113 ULONG Cr0NpxState;
3114 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
3115
3116 typedef struct _CONTEXT {
3117 ULONG ContextFlags;
3118 ULONG Dr0;
3119 ULONG Dr1;
3120 ULONG Dr2;
3121 ULONG Dr3;
3122 ULONG Dr6;
3123 ULONG Dr7;
3124 FLOATING_SAVE_AREA FloatSave;
3125 ULONG SegGs;
3126 ULONG SegFs;
3127 ULONG SegEs;
3128 ULONG SegDs;
3129 ULONG Edi;
3130 ULONG Esi;
3131 ULONG Ebx;
3132 ULONG Edx;
3133 ULONG Ecx;
3134 ULONG Eax;
3135 ULONG Ebp;
3136 ULONG Eip;
3137 ULONG SegCs;
3138 ULONG EFlags;
3139 ULONG Esp;
3140 ULONG SegSs;
3141 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
3142 } CONTEXT;
3143
3144 //
3145 // Used to contain PFNs and PFN counts
3146 //
3147 typedef ULONG PFN_COUNT;
3148 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
3149 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
3150
3151 #define PASSIVE_LEVEL 0
3152 #define LOW_LEVEL 0
3153 #define APC_LEVEL 1
3154 #define DISPATCH_LEVEL 2
3155 #define PROFILE_LEVEL 27
3156 #define CLOCK1_LEVEL 28
3157 #define CLOCK2_LEVEL 28
3158 #define IPI_LEVEL 29
3159 #define POWER_LEVEL 30
3160 #define HIGH_LEVEL 31
3161
3162 typedef struct _KPCR_TIB {
3163 PVOID ExceptionList; /* 00 */
3164 PVOID StackBase; /* 04 */
3165 PVOID StackLimit; /* 08 */
3166 PVOID SubSystemTib; /* 0C */
3167 _ANONYMOUS_UNION union {
3168 PVOID FiberData; /* 10 */
3169 ULONG Version; /* 10 */
3170 } DUMMYUNIONNAME;
3171 PVOID ArbitraryUserPointer; /* 14 */
3172 struct _KPCR_TIB *Self; /* 18 */
3173 } KPCR_TIB, *PKPCR_TIB; /* 1C */
3174
3175 typedef struct _KPCR {
3176 KPCR_TIB Tib; /* 00 */
3177 struct _KPCR *Self; /* 1C */
3178 struct _KPRCB *Prcb; /* 20 */
3179 KIRQL Irql; /* 24 */
3180 ULONG IRR; /* 28 */
3181 ULONG IrrActive; /* 2C */
3182 ULONG IDR; /* 30 */
3183 PVOID KdVersionBlock; /* 34 */
3184 PUSHORT IDT; /* 38 */
3185 PUSHORT GDT; /* 3C */
3186 struct _KTSS *TSS; /* 40 */
3187 USHORT MajorVersion; /* 44 */
3188 USHORT MinorVersion; /* 46 */
3189 KAFFINITY SetMember; /* 48 */
3190 ULONG StallScaleFactor; /* 4C */
3191 UCHAR SpareUnused; /* 50 */
3192 UCHAR Number; /* 51 */
3193 UCHAR Spare0;
3194 UCHAR SecondLevelCacheAssociativity;
3195 ULONG VdmAlert;
3196 ULONG KernelReserved[14]; // For use by the kernel
3197 ULONG SecondLevelCacheSize;
3198 ULONG HalReserved[16]; // For use by Hal
3199 } KPCR, *PKPCR; /* 54 */
3200
3201 #define KeGetPcr() PCR
3202
3203 typedef struct _KFLOATING_SAVE {
3204 ULONG ControlWord;
3205 ULONG StatusWord;
3206 ULONG ErrorOffset;
3207 ULONG ErrorSelector;
3208 ULONG DataOffset;
3209 ULONG DataSelector;
3210 ULONG Cr0NpxState;
3211 ULONG Spare1;
3212 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3213
3214 FORCEINLINE
3215 ULONG
3216 KeGetCurrentProcessorNumber(VOID)
3217 {
3218 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
3219 }
3220
3221 NTHALAPI
3222 KIRQL
3223 DDKAPI
3224 KeGetCurrentIrql(
3225 VOID);
3226
3227 NTKERNELAPI
3228 PRKTHREAD
3229 NTAPI
3230 KeGetCurrentThread(
3231 VOID);
3232
3233 #define KI_USER_SHARED_DATA 0xffdf0000
3234
3235 #define PAGE_SIZE 0x1000
3236 #define PAGE_SHIFT 12L
3237
3238 #define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA)
3239
3240 extern NTKERNELAPI PVOID MmHighestUserAddress;
3241 extern NTKERNELAPI PVOID MmSystemRangeStart;
3242 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
3243
3244 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3245 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3246 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3247 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3248 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
3249
3250 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
3251 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
3252
3253 #elif defined(__x86_64__)
3254
3255 #define CONTEXT_AMD64 0x100000
3256 #if !defined(RC_INVOKED)
3257 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
3258 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
3259 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
3260 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
3261 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
3262
3263 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
3264 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
3265
3266 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
3267 #define CONTEXT_SERVICE_ACTIVE 0x10000000
3268 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
3269 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
3270 #endif
3271
3272 typedef struct DECLSPEC_ALIGN(16) _M128A {
3273 ULONGLONG Low;
3274 LONGLONG High;
3275 } M128A, *PM128A;
3276
3277 typedef struct _XMM_SAVE_AREA32 {
3278 USHORT ControlWord;
3279 USHORT StatusWord;
3280 UCHAR TagWord;
3281 UCHAR Reserved1;
3282 USHORT ErrorOpcode;
3283 ULONG ErrorOffset;
3284 USHORT ErrorSelector;
3285 USHORT Reserved2;
3286 ULONG DataOffset;
3287 USHORT DataSelector;
3288 USHORT Reserved3;
3289 ULONG MxCsr;
3290 ULONG MxCsr_Mask;
3291 M128A FloatRegisters[8];
3292 M128A XmmRegisters[16];
3293 UCHAR Reserved4[96];
3294 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
3295
3296 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
3297 ULONG64 P1Home;
3298 ULONG64 P2Home;
3299 ULONG64 P3Home;
3300 ULONG64 P4Home;
3301 ULONG64 P5Home;
3302 ULONG64 P6Home;
3303
3304 /* Control flags */
3305 ULONG ContextFlags;
3306 ULONG MxCsr;
3307
3308 /* Segment */
3309 USHORT SegCs;
3310 USHORT SegDs;
3311 USHORT SegEs;
3312 USHORT SegFs;
3313 USHORT SegGs;
3314 USHORT SegSs;
3315 ULONG EFlags;
3316
3317 /* Debug */
3318 ULONG64 Dr0;
3319 ULONG64 Dr1;
3320 ULONG64 Dr2;
3321 ULONG64 Dr3;
3322 ULONG64 Dr6;
3323 ULONG64 Dr7;
3324
3325 /* Integer */
3326 ULONG64 Rax;
3327 ULONG64 Rcx;
3328 ULONG64 Rdx;
3329 ULONG64 Rbx;
3330 ULONG64 Rsp;
3331 ULONG64 Rbp;
3332 ULONG64 Rsi;
3333 ULONG64 Rdi;
3334 ULONG64 R8;
3335 ULONG64 R9;
3336 ULONG64 R10;
3337 ULONG64 R11;
3338 ULONG64 R12;
3339 ULONG64 R13;
3340 ULONG64 R14;
3341 ULONG64 R15;
3342
3343 /* Counter */
3344 ULONG64 Rip;
3345
3346 /* Floating point */
3347 union {
3348 XMM_SAVE_AREA32 FltSave;
3349 struct {
3350 M128A Header[2];
3351 M128A Legacy[8];
3352 M128A Xmm0;
3353 M128A Xmm1;
3354 M128A Xmm2;
3355 M128A Xmm3;
3356 M128A Xmm4;
3357 M128A Xmm5;
3358 M128A Xmm6;
3359 M128A Xmm7;
3360 M128A Xmm8;
3361 M128A Xmm9;
3362 M128A Xmm10;
3363 M128A Xmm11;
3364 M128A Xmm12;
3365 M128A Xmm13;
3366 M128A Xmm14;
3367 M128A Xmm15;
3368 } DUMMYSTRUCTNAME;
3369 } DUMMYUNIONNAME;
3370
3371 /* Vector */
3372 M128A VectorRegister[26];
3373 ULONG64 VectorControl;
3374
3375 /* Debug control */
3376 ULONG64 DebugControl;
3377 ULONG64 LastBranchToRip;
3378 ULONG64 LastBranchFromRip;
3379 ULONG64 LastExceptionToRip;
3380 ULONG64 LastExceptionFromRip;
3381 } CONTEXT;
3382
3383 //
3384 // Used to contain PFNs and PFN counts
3385 //
3386 typedef ULONG PFN_COUNT;
3387 typedef ULONG64 PFN_NUMBER, *PPFN_NUMBER;
3388 typedef LONG64 SPFN_NUMBER, *PSPFN_NUMBER;
3389
3390 #define PASSIVE_LEVEL 0
3391 #define LOW_LEVEL 0
3392 #define APC_LEVEL 1
3393 #define DISPATCH_LEVEL 2
3394 #define CLOCK_LEVEL 13
3395 #define IPI_LEVEL 14
3396 #define POWER_LEVEL 14
3397 #define PROFILE_LEVEL 15
3398 #define HIGH_LEVEL 15
3399
3400 #define PAGE_SIZE 0x1000
3401 #define PAGE_SHIFT 12L
3402 #define PTI_SHIFT 12L
3403 #define PDI_SHIFT 21L
3404 #define PPI_SHIFT 30L
3405 #define PXI_SHIFT 39L
3406 #define PTE_PER_PAGE 512
3407 #define PDE_PER_PAGE 512
3408 #define PPE_PER_PAGE 512
3409 #define PXE_PER_PAGE 512
3410 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
3411 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
3412 #define PPI_MASK (PPE_PER_PAGE - 1)
3413 #define PXI_MASK (PXE_PER_PAGE - 1)
3414
3415 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
3416 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
3417 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
3418 #define PDE_BASE 0xFFFFF6FB40000000ULL
3419 #define PTE_BASE 0xFFFFF68000000000ULL
3420 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
3421 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
3422 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
3423 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
3424
3425 extern NTKERNELAPI PVOID MmHighestUserAddress;
3426 extern NTKERNELAPI PVOID MmSystemRangeStart;
3427 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
3428
3429 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3430 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3431 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3432 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3433 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
3434 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
3435
3436 #define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA)
3437 #define SharedInterruptTime (&SharedUserData->InterruptTime)
3438 #define SharedSystemTime (&SharedUserData->SystemTime)
3439 #define SharedTickCount (&SharedUserData->TickCount)
3440
3441 #define KeQueryInterruptTime() \
3442 (*(volatile ULONG64*)SharedInterruptTime)
3443 #define KeQuerySystemTime(CurrentCount) \
3444 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
3445 #define KeQueryTickCount(CurrentCount) \
3446 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
3447
3448 typedef struct _KPCR
3449 {
3450 __GNU_EXTENSION union
3451 {
3452 NT_TIB NtTib;
3453 __GNU_EXTENSION struct
3454 {
3455 union _KGDTENTRY64 *GdtBase;
3456 struct _KTSS64 *TssBase;
3457 ULONG64 UserRsp;
3458 struct _KPCR *Self;
3459 struct _KPRCB *CurrentPrcb;
3460 PKSPIN_LOCK_QUEUE LockArray;
3461 PVOID Used_Self;
3462 };
3463 };
3464 union _KIDTENTRY64 *IdtBase;
3465 ULONG64 Unused[2];
3466 KIRQL Irql;
3467 UCHAR SecondLevelCacheAssociativity;
3468 UCHAR ObsoleteNumber;
3469 UCHAR Fill0;
3470 ULONG Unused0[3];
3471 USHORT MajorVersion;
3472 USHORT MinorVersion;
3473 ULONG StallScaleFactor;
3474 PVOID Unused1[3];
3475 ULONG KernelReserved[15];
3476 ULONG SecondLevelCacheSize;
3477 ULONG HalReserved[16];
3478 ULONG Unused2;
3479 PVOID KdVersionBlock;
3480 PVOID Unused3;
3481 ULONG PcrAlign1[24];
3482 } KPCR, *PKPCR;
3483
3484 typedef struct _KFLOATING_SAVE {
3485 ULONG Dummy;
3486 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3487
3488 NTKERNELAPI
3489 PRKTHREAD
3490 NTAPI
3491 KeGetCurrentThread(
3492 VOID);
3493
3494 FORCEINLINE
3495 PKPCR
3496 KeGetPcr(VOID)
3497 {
3498 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
3499 }
3500
3501 FORCEINLINE
3502 ULONG
3503 KeGetCurrentProcessorNumber(VOID)
3504 {
3505 return (ULONG)__readgsword(0x184);
3506 }
3507
3508 #elif defined(__PowerPC__)
3509
3510 //
3511 // Used to contain PFNs and PFN counts
3512 //
3513 typedef ULONG PFN_COUNT;
3514 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
3515 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
3516
3517 #define PASSIVE_LEVEL 0
3518 #define LOW_LEVEL 0
3519 #define APC_LEVEL 1
3520 #define DISPATCH_LEVEL 2
3521 #define PROFILE_LEVEL 27
3522 #define CLOCK1_LEVEL 28
3523 #define CLOCK2_LEVEL 28
3524 #define IPI_LEVEL 29
3525 #define POWER_LEVEL 30
3526 #define HIGH_LEVEL 31
3527
3528 typedef struct _KFLOATING_SAVE {
3529 ULONG Dummy;
3530 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3531
3532 typedef struct _KPCR_TIB {
3533 PVOID ExceptionList; /* 00 */
3534 PVOID StackBase; /* 04 */
3535 PVOID StackLimit; /* 08 */
3536 PVOID SubSystemTib; /* 0C */
3537 _ANONYMOUS_UNION union {
3538 PVOID FiberData; /* 10 */
3539 ULONG Version; /* 10 */
3540 } DUMMYUNIONNAME;
3541 PVOID ArbitraryUserPointer; /* 14 */
3542 struct _KPCR_TIB *Self; /* 18 */
3543 } KPCR_TIB, *PKPCR_TIB; /* 1C */
3544
3545 #define PCR_MINOR_VERSION 1
3546 #define PCR_MAJOR_VERSION 1
3547
3548 typedef struct _KPCR {
3549 KPCR_TIB Tib; /* 00 */
3550 struct _KPCR *Self; /* 1C */
3551 struct _KPRCB *Prcb; /* 20 */
3552 KIRQL Irql; /* 24 */
3553 ULONG IRR; /* 28 */
3554 ULONG IrrActive; /* 2C */
3555 ULONG IDR; /* 30 */
3556 PVOID KdVersionBlock; /* 34 */
3557 PUSHORT IDT; /* 38 */
3558 PUSHORT GDT; /* 3C */
3559 struct _KTSS *TSS; /* 40 */
3560 USHORT MajorVersion; /* 44 */
3561 USHORT MinorVersion; /* 46 */
3562 KAFFINITY SetMember; /* 48 */
3563 ULONG StallScaleFactor; /* 4C */
3564 UCHAR SpareUnused; /* 50 */
3565 UCHAR Number; /* 51 */
3566 } KPCR, *PKPCR; /* 54 */
3567
3568 #define KeGetPcr() PCR
3569
3570 static __inline
3571 ULONG
3572 DDKAPI
3573 KeGetCurrentProcessorNumber(VOID)
3574 {
3575 ULONG Number;
3576 __asm__ __volatile__ (
3577 "lwz %0, %c1(12)\n"
3578 : "=r" (Number)
3579 : "i" (FIELD_OFFSET(KPCR, Number))
3580 );
3581 return Number;
3582 }
3583
3584 #elif defined(_MIPS_)
3585
3586 #error MIPS Headers are totally incorrect
3587
3588 //
3589 // Used to contain PFNs and PFN counts
3590 //
3591 typedef ULONG PFN_COUNT;
3592 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
3593 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
3594
3595 #define PASSIVE_LEVEL 0
3596 #define APC_LEVEL 1
3597 #define DISPATCH_LEVEL 2
3598 #define PROFILE_LEVEL 27
3599 #define IPI_LEVEL 29
3600 #define HIGH_LEVEL 31
3601
3602 typedef struct _KPCR {
3603 struct _KPRCB *Prcb; /* 20 */
3604 KIRQL Irql; /* 24 */
3605 ULONG IRR; /* 28 */
3606 ULONG IDR; /* 30 */
3607 } KPCR, *PKPCR;
3608
3609 #define KeGetPcr() PCR
3610
3611 typedef struct _KFLOATING_SAVE {
3612 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3613
3614 static __inline
3615 ULONG
3616 DDKAPI
3617 KeGetCurrentProcessorNumber(VOID)
3618 {
3619 return 0;
3620 }
3621
3622 #elif defined(_M_ARM)
3623
3624 //
3625 // NT-ARM is not documented, need DDK-ARM
3626 //
3627 #include <armddk.h>
3628
3629 #else
3630 #error Unknown architecture
3631 #endif
3632
3633 #define MM_DONT_ZERO_ALLOCATION 0x00000001
3634 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
3635
3636
3637 #define EFLAG_SIGN 0x8000
3638 #define EFLAG_ZERO 0x4000
3639 #define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO)
3640
3641 #define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
3642 #define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
3643 #define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
3644
3645 typedef enum _INTERLOCKED_RESULT {
3646 ResultNegative = RESULT_NEGATIVE,
3647 ResultZero = RESULT_ZERO,
3648 ResultPositive = RESULT_POSITIVE
3649 } INTERLOCKED_RESULT;
3650
3651 typedef VOID
3652 (NTAPI *PciPin2Line)(
3653 IN struct _BUS_HANDLER *BusHandler,
3654 IN struct _BUS_HANDLER *RootHandler,
3655 IN PCI_SLOT_NUMBER SlotNumber,
3656 IN PPCI_COMMON_CONFIG PciData
3657 );
3658
3659 typedef VOID
3660 (NTAPI *PciLine2Pin)(
3661 IN struct _BUS_HANDLER *BusHandler,
3662 IN struct _BUS_HANDLER *RootHandler,
3663 IN PCI_SLOT_NUMBER SlotNumber,
3664 IN PPCI_COMMON_CONFIG PciNewData,
3665 IN PPCI_COMMON_CONFIG PciOldData
3666 );
3667
3668 typedef VOID
3669 (NTAPI *PciReadWriteConfig)(
3670 IN struct _BUS_HANDLER *BusHandler,
3671 IN PCI_SLOT_NUMBER Slot,
3672 IN PVOID Buffer,
3673 IN ULONG Offset,
3674 IN ULONG Length
3675 );
3676
3677 #define PCI_DATA_TAG ' ICP'
3678 #define PCI_DATA_VERSION 1
3679
3680 typedef struct _PCIBUSDATA
3681 {
3682 ULONG Tag;
3683 ULONG Version;
3684 PciReadWriteConfig ReadConfig;
3685 PciReadWriteConfig WriteConfig;
3686 PciPin2Line Pin2Line;
3687 PciLine2Pin Line2Pin;
3688 PCI_SLOT_NUMBER ParentSlot;
3689 PVOID Reserved[4];
3690 } PCIBUSDATA, *PPCIBUSDATA;
3691
3692
3693 /** SPINLOCK FUNCTIONS ********************************************************/
3694
3695 NTKERNELAPI
3696 BOOLEAN
3697 FASTCALL
3698 KeTryToAcquireSpinLockAtDpcLevel(
3699 IN OUT PKSPIN_LOCK SpinLock
3700 );
3701
3702 NTKERNELAPI
3703 BOOLEAN
3704 FASTCALL
3705 KeTestSpinLock(
3706 IN PKSPIN_LOCK SpinLock
3707 );
3708
3709 #if defined (_X86_)
3710
3711 #if defined(WIN9X_COMPAT_SPINLOCK)
3712
3713 NTKERNELAPI
3714 VOID
3715 NTAPI
3716 KeInitializeSpinLock(
3717 IN PKSPIN_LOCK SpinLock
3718 );
3719
3720 #else
3721
3722 FORCEINLINE
3723 VOID
3724 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
3725 {
3726 /* Clear the lock */
3727 *SpinLock = 0;
3728 }
3729
3730 #endif
3731
3732 NTHALAPI
3733 KIRQL
3734 FASTCALL
3735 KfAcquireSpinLock(
3736 IN PKSPIN_LOCK SpinLock);
3737
3738 NTHALAPI
3739 VOID
3740 FASTCALL
3741 KfReleaseSpinLock(
3742 IN PKSPIN_LOCK SpinLock,
3743 IN KIRQL NewIrql);
3744
3745 NTKERNELAPI
3746 VOID
3747 FASTCALL
3748 KefAcquireSpinLockAtDpcLevel(
3749 IN PKSPIN_LOCK SpinLock);
3750
3751 NTKERNELAPI
3752 VOID
3753 FASTCALL
3754 KefReleaseSpinLockFromDpcLevel(
3755 IN PKSPIN_LOCK SpinLock);
3756
3757 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
3758 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
3759 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
3760 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
3761
3762 #define KeGetDcacheFillSize() 1L
3763
3764 #elif defined(_M_ARM) // !defined (_X86_)
3765
3766 FORCEINLINE
3767 VOID
3768 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
3769 {
3770 /* Clear the lock */
3771 *SpinLock = 0;
3772 }
3773
3774 NTHALAPI
3775 KIRQL
3776 FASTCALL
3777 KfAcquireSpinLock(
3778 IN PKSPIN_LOCK SpinLock);
3779
3780 NTHALAPI
3781 VOID
3782 FASTCALL
3783 KfReleaseSpinLock(
3784 IN PKSPIN_LOCK SpinLock,
3785 IN KIRQL NewIrql);
3786
3787
3788 NTKERNELAPI
3789 VOID
3790 FASTCALL
3791 KefAcquireSpinLockAtDpcLevel(
3792 IN PKSPIN_LOCK SpinLock);
3793
3794 NTKERNELAPI
3795 VOID
3796 FASTCALL
3797 KefReleaseSpinLockFromDpcLevel(
3798 IN PKSPIN_LOCK SpinLock);
3799
3800
3801 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
3802 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
3803 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
3804 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
3805
3806 NTKERNELAPI
3807 VOID
3808 NTAPI
3809 KeInitializeSpinLock(
3810 IN PKSPIN_LOCK SpinLock);
3811
3812 #else
3813
3814 FORCEINLINE
3815 VOID
3816 NTAPI
3817 KeInitializeSpinLock(
3818 PKSPIN_LOCK SpinLock)
3819 {
3820 *SpinLock = 0;
3821 }
3822
3823 NTKERNELAPI
3824 VOID
3825 KeReleaseSpinLock(
3826 IN PKSPIN_LOCK SpinLock,
3827 IN KIRQL NewIrql);
3828
3829 NTKERNELAPI
3830 VOID
3831 KeAcquireSpinLockAtDpcLevel(
3832 IN PKSPIN_LOCK SpinLock);
3833
3834 NTKERNELAPI
3835 VOID
3836 KeReleaseSpinLockFromDpcLevel(
3837 IN PKSPIN_LOCK SpinLock);
3838
3839 NTKERNELAPI
3840 KIRQL
3841 KeAcquireSpinLockRaiseToDpc(
3842 IN PKSPIN_LOCK SpinLock);
3843
3844 #define KeAcquireSpinLock(SpinLock, OldIrql) \
3845 *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
3846
3847 #endif // !defined (_X86_)
3848
3849 /*
3850 ** Utillity functions
3851 */
3852
3853 #define ARGUMENT_PRESENT(ArgumentPointer) \
3854 ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
3855
3856 /*
3857 * ULONG
3858 * BYTE_OFFSET(
3859 * IN PVOID Va)
3860 */
3861 #define BYTE_OFFSET(Va) \
3862 ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
3863
3864 /*
3865 * ULONG
3866 * BYTES_TO_PAGES(
3867 * IN ULONG Size)
3868 */
3869 #define BYTES_TO_PAGES(Size) \
3870 ((ULONG) ((ULONG_PTR) (Size) >> PAGE_SHIFT) + (((ULONG) (Size) & (PAGE_SIZE - 1)) != 0))
3871
3872 /*
3873 * PVOID
3874 * PAGE_ALIGN(
3875 * IN PVOID Va)
3876 */
3877 #define PAGE_ALIGN(Va) \
3878 ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE