1e7a48c6e170ccd14a6897c38c76bd6b950c10e2
[reactos.git] / reactos / include / ddk / ntddk.h
1 /*
2 * ntddk.h
3 *
4 * Windows NT Device Driver Kit
5 *
6 * This file is part of the ReactOS DDK package.
7 *
8 * Contributors:
9 * Amine Khaldi
10 * Timo Kreuzer (timo.kreuzer@reactos.org)
11 *
12 * THIS SOFTWARE IS NOT COPYRIGHTED
13 *
14 * This source code is offered for use in the public domain. You may
15 * use, modify or distribute it freely.
16 *
17 * This code is distributed in the hope that it will be useful but
18 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
19 * DISCLAIMED. This includes but is not limited to warranties of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 *
22 */
23
24 #pragma once
25
26 #define _NTDDK_
27
28 #if !defined(_NTHAL_) && !defined(_NTIFS_)
29 #define _NTDDK_INCLUDED_
30 #define _DDK_DRIVER_
31 #endif
32
33 /* Dependencies */
34
35 #define NT_INCLUDED
36 #define _CTYPE_DISABLE_MACROS
37
38 #include <wdm.h>
39 #include <excpt.h>
40 #include <ntdef.h>
41 #include <ntstatus.h>
42 #include <mce.h>
43 #include <bugcodes.h>
44 #include <ntiologc.h>
45
46 #include <stdarg.h> // FIXME
47 #include <basetyps.h> // FIXME
48
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 /* GUID and UUID */
55 #ifndef _NTLSA_IFS_
56 #ifndef _NTLSA_AUDIT_
57 #define _NTLSA_AUDIT_
58
59 #ifndef GUID_DEFINED
60 #include <guiddef.h>
61 #endif
62
63 #endif /* _NTLSA_AUDIT_ */
64 #endif /* _NTLSA_IFS_ */
65
66 typedef GUID UUID;
67
68 struct _LOADER_PARAMETER_BLOCK;
69 struct _CREATE_DISK;
70 struct _DRIVE_LAYOUT_INFORMATION_EX;
71 struct _SET_PARTITION_INFORMATION_EX;
72 struct _DISK_GEOMETRY_EX;
73
74 typedef struct _BUS_HANDLER *PBUS_HANDLER;
75 typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
76 #if defined(_NTHAL_INCLUDED_)
77 typedef struct _KAFFINITY_EX *PKAFFINITY_EX;
78 #endif
79 typedef struct _PEB *PPEB;
80
81 #ifndef _NTIMAGE_
82
83 typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
84 typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
85
86 #ifdef _WIN64
87 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
88 #else
89 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
90 #endif
91
92 #endif /* _NTIMAGE_ */
93
94 /******************************************************************************
95 * Executive Types *
96 ******************************************************************************/
97 typedef struct _ZONE_SEGMENT_HEADER {
98 SINGLE_LIST_ENTRY SegmentList;
99 PVOID Reserved;
100 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
101
102 typedef struct _ZONE_HEADER {
103 SINGLE_LIST_ENTRY FreeList;
104 SINGLE_LIST_ENTRY SegmentList;
105 ULONG BlockSize;
106 ULONG TotalSegmentSize;
107 } ZONE_HEADER, *PZONE_HEADER;
108
109 #define PROTECTED_POOL 0x80000000
110
111 /******************************************************************************
112 * Configuration Manager Types *
113 ******************************************************************************/
114
115 typedef struct _KEY_NAME_INFORMATION {
116 ULONG NameLength;
117 WCHAR Name[1];
118 } KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
119
120 typedef struct _KEY_CACHED_INFORMATION {
121 LARGE_INTEGER LastWriteTime;
122 ULONG TitleIndex;
123 ULONG SubKeys;
124 ULONG MaxNameLen;
125 ULONG Values;
126 ULONG MaxValueNameLen;
127 ULONG MaxValueDataLen;
128 ULONG NameLength;
129 } KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION;
130
131 typedef struct _KEY_VIRTUALIZATION_INFORMATION {
132 ULONG VirtualizationCandidate:1;
133 ULONG VirtualizationEnabled:1;
134 ULONG VirtualTarget:1;
135 ULONG VirtualStore:1;
136 ULONG VirtualSource:1;
137 ULONG Reserved:27;
138 } KEY_VIRTUALIZATION_INFORMATION, *PKEY_VIRTUALIZATION_INFORMATION;
139
140 #define CmResourceTypeMaximum 8
141
142 typedef struct _CM_PCCARD_DEVICE_DATA {
143 UCHAR Flags;
144 UCHAR ErrorCode;
145 USHORT Reserved;
146 ULONG BusData;
147 ULONG DeviceId;
148 ULONG LegacyBaseAddress;
149 UCHAR IRQMap[16];
150 } CM_PCCARD_DEVICE_DATA, *PCM_PCCARD_DEVICE_DATA;
151
152 /******************************************************************************
153 * I/O Manager Types *
154 ******************************************************************************/
155
156 /* DEVICE_OBJECT.Flags */
157 #define DO_DEVICE_HAS_NAME 0x00000040
158 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
159 #define DO_LONG_TERM_REQUESTS 0x00000200
160 #define DO_NEVER_LAST_DEVICE 0x00000400
161 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
162 #define DO_SUPPORTS_TRANSACTIONS 0x00040000
163 #define DO_FORCE_NEITHER_IO 0x00080000
164 #define DO_VOLUME_DEVICE_OBJECT 0x00100000
165 #define DO_SYSTEM_SYSTEM_PARTITION 0x00200000
166 #define DO_SYSTEM_CRITICAL_PARTITION 0x00400000
167 #define DO_DISALLOW_EXECUTE 0x00800000
168
169 #ifndef _ARC_DDK_
170 #define _ARC_DDK_
171 typedef enum _CONFIGURATION_TYPE {
172 ArcSystem,
173 CentralProcessor,
174 FloatingPointProcessor,
175 PrimaryIcache,
176 PrimaryDcache,
177 SecondaryIcache,
178 SecondaryDcache,
179 SecondaryCache,
180 EisaAdapter,
181 TcAdapter,
182 ScsiAdapter,
183 DtiAdapter,
184 MultiFunctionAdapter,
185 DiskController,
186 TapeController,
187 CdromController,
188 WormController,
189 SerialController,
190 NetworkController,
191 DisplayController,
192 ParallelController,
193 PointerController,
194 KeyboardController,
195 AudioController,
196 OtherController,
197 DiskPeripheral,
198 FloppyDiskPeripheral,
199 TapePeripheral,
200 ModemPeripheral,
201 MonitorPeripheral,
202 PrinterPeripheral,
203 PointerPeripheral,
204 KeyboardPeripheral,
205 TerminalPeripheral,
206 OtherPeripheral,
207 LinePeripheral,
208 NetworkPeripheral,
209 SystemMemory,
210 DockingInformation,
211 RealModeIrqRoutingTable,
212 RealModePCIEnumeration,
213 MaximumType
214 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
215 #endif /* !_ARC_DDK_ */
216
217 /*
218 ** IRP function codes
219 */
220
221 #define IRP_MN_QUERY_DIRECTORY 0x01
222 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
223
224 #define IRP_MN_USER_FS_REQUEST 0x00
225 #define IRP_MN_MOUNT_VOLUME 0x01
226 #define IRP_MN_VERIFY_VOLUME 0x02
227 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
228 #define IRP_MN_TRACK_LINK 0x04
229 #define IRP_MN_KERNEL_CALL 0x04
230
231 #define IRP_MN_LOCK 0x01
232 #define IRP_MN_UNLOCK_SINGLE 0x02
233 #define IRP_MN_UNLOCK_ALL 0x03
234 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
235
236 #define IRP_MN_FLUSH_AND_PURGE 0x01
237
238 #define IRP_MN_NORMAL 0x00
239 #define IRP_MN_DPC 0x01
240 #define IRP_MN_MDL 0x02
241 #define IRP_MN_COMPLETE 0x04
242 #define IRP_MN_COMPRESSED 0x08
243
244 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
245 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
246 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
247
248 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
249
250 #define IO_CHECK_CREATE_PARAMETERS 0x0200
251 #define IO_ATTACH_DEVICE 0x0400
252 #define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800
253
254 typedef NTSTATUS
255 (NTAPI *PIO_QUERY_DEVICE_ROUTINE)(
256 _In_ PVOID Context,
257 _In_ PUNICODE_STRING PathName,
258 _In_ INTERFACE_TYPE BusType,
259 _In_ ULONG BusNumber,
260 _In_ PKEY_VALUE_FULL_INFORMATION *BusInformation,
261 _In_ CONFIGURATION_TYPE ControllerType,
262 _In_ ULONG ControllerNumber,
263 _In_ PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
264 _In_ CONFIGURATION_TYPE PeripheralType,
265 _In_ ULONG PeripheralNumber,
266 _In_ PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
267
268 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
269 IoQueryDeviceIdentifier = 0,
270 IoQueryDeviceConfigurationData,
271 IoQueryDeviceComponentInformation,
272 IoQueryDeviceMaxData
273 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
274
275 typedef VOID
276 (NTAPI *PDRIVER_REINITIALIZE)(
277 _In_ struct _DRIVER_OBJECT *DriverObject,
278 _In_opt_ PVOID Context,
279 _In_ ULONG Count);
280
281 typedef struct _CONTROLLER_OBJECT {
282 CSHORT Type;
283 CSHORT Size;
284 PVOID ControllerExtension;
285 KDEVICE_QUEUE DeviceWaitQueue;
286 ULONG Spare1;
287 LARGE_INTEGER Spare2;
288 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
289
290 #define DRVO_REINIT_REGISTERED 0x00000008
291 #define DRVO_INITIALIZED 0x00000010
292 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
293 #define DRVO_LEGACY_RESOURCES 0x00000040
294
295 typedef struct _CONFIGURATION_INFORMATION {
296 ULONG DiskCount;
297 ULONG FloppyCount;
298 ULONG CdRomCount;
299 ULONG TapeCount;
300 ULONG ScsiPortCount;
301 ULONG SerialCount;
302 ULONG ParallelCount;
303 BOOLEAN AtDiskPrimaryAddressClaimed;
304 BOOLEAN AtDiskSecondaryAddressClaimed;
305 ULONG Version;
306 ULONG MediumChangerCount;
307 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
308
309 typedef struct _DISK_SIGNATURE {
310 ULONG PartitionStyle;
311 _ANONYMOUS_UNION union {
312 struct {
313 ULONG Signature;
314 ULONG CheckSum;
315 } Mbr;
316 struct {
317 GUID DiskId;
318 } Gpt;
319 } DUMMYUNIONNAME;
320 } DISK_SIGNATURE, *PDISK_SIGNATURE;
321
322 typedef struct _TXN_PARAMETER_BLOCK {
323 USHORT Length;
324 USHORT TxFsContext;
325 PVOID TransactionObject;
326 } TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK;
327
328 #define TXF_MINIVERSION_DEFAULT_VIEW (0xFFFE)
329
330 typedef struct _IO_DRIVER_CREATE_CONTEXT {
331 CSHORT Size;
332 struct _ECP_LIST *ExtraCreateParameter;
333 PVOID DeviceObjectHint;
334 PTXN_PARAMETER_BLOCK TxnParameters;
335 } IO_DRIVER_CREATE_CONTEXT, *PIO_DRIVER_CREATE_CONTEXT;
336
337 typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD {
338 USHORT Size;
339 USHORT Version;
340 PVOID Context;
341 PINTERFACE_REFERENCE InterfaceReference;
342 PINTERFACE_DEREFERENCE InterfaceDereference;
343 PGET_SET_DEVICE_DATA SetBusData;
344 PGET_SET_DEVICE_DATA GetBusData;
345 UCHAR CapabilityID;
346 } AGP_TARGET_BUS_INTERFACE_STANDARD, *PAGP_TARGET_BUS_INTERFACE_STANDARD;
347
348 _IRQL_requires_max_(PASSIVE_LEVEL)
349 _Must_inspect_result_
350 typedef NTSTATUS
351 (NTAPI *PGET_LOCATION_STRING)(
352 _Inout_opt_ PVOID Context,
353 _Outptr_
354 _At_(*LocationStrings,
355 _When_(return == 0, __drv_allocatesMem(Mem)))
356 PZZWSTR *LocationStrings);
357
358 typedef struct _PNP_LOCATION_INTERFACE {
359 USHORT Size;
360 USHORT Version;
361 PVOID Context;
362 PINTERFACE_REFERENCE InterfaceReference;
363 PINTERFACE_DEREFERENCE InterfaceDereference;
364 PGET_LOCATION_STRING GetLocationString;
365 } PNP_LOCATION_INTERFACE, *PPNP_LOCATION_INTERFACE;
366
367 typedef enum _ARBITER_ACTION {
368 ArbiterActionTestAllocation,
369 ArbiterActionRetestAllocation,
370 ArbiterActionCommitAllocation,
371 ArbiterActionRollbackAllocation,
372 ArbiterActionQueryAllocatedResources,
373 ArbiterActionWriteReservedResources,
374 ArbiterActionQueryConflict,
375 ArbiterActionQueryArbitrate,
376 ArbiterActionAddReserved,
377 ArbiterActionBootAllocation
378 } ARBITER_ACTION, *PARBITER_ACTION;
379
380 typedef struct _ARBITER_CONFLICT_INFO {
381 PDEVICE_OBJECT OwningObject;
382 ULONGLONG Start;
383 ULONGLONG End;
384 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
385
386 typedef struct _ARBITER_TEST_ALLOCATION_PARAMETERS {
387 _Inout_ PLIST_ENTRY ArbitrationList;
388 _In_ ULONG AllocateFromCount;
389 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
390 } ARBITER_TEST_ALLOCATION_PARAMETERS, *PARBITER_TEST_ALLOCATION_PARAMETERS;
391
392 typedef struct _ARBITER_RETEST_ALLOCATION_PARAMETERS {
393 _Inout_ PLIST_ENTRY ArbitrationList;
394 _In_ ULONG AllocateFromCount;
395 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
396 } ARBITER_RETEST_ALLOCATION_PARAMETERS, *PARBITER_RETEST_ALLOCATION_PARAMETERS;
397
398 typedef struct _ARBITER_BOOT_ALLOCATION_PARAMETERS {
399 _Inout_ PLIST_ENTRY ArbitrationList;
400 } ARBITER_BOOT_ALLOCATION_PARAMETERS, *PARBITER_BOOT_ALLOCATION_PARAMETERS;
401
402 typedef struct _ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS {
403 _Out_ PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
404 } ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS, *PARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS;
405
406 typedef struct _ARBITER_QUERY_CONFLICT_PARAMETERS {
407 _In_ PDEVICE_OBJECT PhysicalDeviceObject;
408 _In_ PIO_RESOURCE_DESCRIPTOR ConflictingResource;
409 _Out_ PULONG ConflictCount;
410 _Out_ PARBITER_CONFLICT_INFO *Conflicts;
411 } ARBITER_QUERY_CONFLICT_PARAMETERS, *PARBITER_QUERY_CONFLICT_PARAMETERS;
412
413 typedef struct _ARBITER_QUERY_ARBITRATE_PARAMETERS {
414 _In_ PLIST_ENTRY ArbitrationList;
415 } ARBITER_QUERY_ARBITRATE_PARAMETERS, *PARBITER_QUERY_ARBITRATE_PARAMETERS;
416
417 typedef struct _ARBITER_ADD_RESERVED_PARAMETERS {
418 _In_ PDEVICE_OBJECT ReserveDevice;
419 } ARBITER_ADD_RESERVED_PARAMETERS, *PARBITER_ADD_RESERVED_PARAMETERS;
420
421 typedef struct _ARBITER_PARAMETERS {
422 union {
423 ARBITER_TEST_ALLOCATION_PARAMETERS TestAllocation;
424 ARBITER_RETEST_ALLOCATION_PARAMETERS RetestAllocation;
425 ARBITER_BOOT_ALLOCATION_PARAMETERS BootAllocation;
426 ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS QueryAllocatedResources;
427 ARBITER_QUERY_CONFLICT_PARAMETERS QueryConflict;
428 ARBITER_QUERY_ARBITRATE_PARAMETERS QueryArbitrate;
429 ARBITER_ADD_RESERVED_PARAMETERS AddReserved;
430 } Parameters;
431 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
432
433 typedef enum _ARBITER_REQUEST_SOURCE {
434 ArbiterRequestUndefined = -1,
435 ArbiterRequestLegacyReported,
436 ArbiterRequestHalReported,
437 ArbiterRequestLegacyAssigned,
438 ArbiterRequestPnpDetected,
439 ArbiterRequestPnpEnumerated
440 } ARBITER_REQUEST_SOURCE;
441
442 typedef enum _ARBITER_RESULT {
443 ArbiterResultUndefined = -1,
444 ArbiterResultSuccess,
445 ArbiterResultExternalConflict,
446 ArbiterResultNullRequest
447 } ARBITER_RESULT;
448
449 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
450
451 typedef struct _ARBITER_LIST_ENTRY {
452 LIST_ENTRY ListEntry;
453 ULONG AlternativeCount;
454 PIO_RESOURCE_DESCRIPTOR Alternatives;
455 PDEVICE_OBJECT PhysicalDeviceObject;
456 ARBITER_REQUEST_SOURCE RequestSource;
457 ULONG Flags;
458 LONG_PTR WorkSpace;
459 INTERFACE_TYPE InterfaceType;
460 ULONG SlotNumber;
461 ULONG BusNumber;
462 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
463 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
464 ARBITER_RESULT Result;
465 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
466
467 typedef NTSTATUS
468 (NTAPI *PARBITER_HANDLER)(
469 _Inout_opt_ PVOID Context,
470 _In_ ARBITER_ACTION Action,
471 _Inout_ PARBITER_PARAMETERS Parameters);
472
473 #define ARBITER_PARTIAL 0x00000001
474
475 typedef struct _ARBITER_INTERFACE {
476 USHORT Size;
477 USHORT Version;
478 PVOID Context;
479 PINTERFACE_REFERENCE InterfaceReference;
480 PINTERFACE_DEREFERENCE InterfaceDereference;
481 PARBITER_HANDLER ArbiterHandler;
482 ULONG Flags;
483 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
484
485 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
486 TranslateChildToParent,
487 TranslateParentToChild
488 } RESOURCE_TRANSLATION_DIRECTION;
489
490 typedef NTSTATUS
491 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
492 _Inout_opt_ PVOID Context,
493 _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
494 _In_ RESOURCE_TRANSLATION_DIRECTION Direction,
495 _In_opt_ ULONG AlternativesCount,
496 _In_reads_opt_(AlternativesCount) IO_RESOURCE_DESCRIPTOR Alternatives[],
497 _In_ PDEVICE_OBJECT PhysicalDeviceObject,
498 _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
499
500 typedef NTSTATUS
501 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
502 _Inout_opt_ PVOID Context,
503 _In_ PIO_RESOURCE_DESCRIPTOR Source,
504 _In_ PDEVICE_OBJECT PhysicalDeviceObject,
505 _Out_ PULONG TargetCount,
506 _Out_writes_(*TargetCount) PIO_RESOURCE_DESCRIPTOR *Target);
507
508 typedef struct _TRANSLATOR_INTERFACE {
509 USHORT Size;
510 USHORT Version;
511 PVOID Context;
512 PINTERFACE_REFERENCE InterfaceReference;
513 PINTERFACE_DEREFERENCE InterfaceDereference;
514 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
515 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
516 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
517
518 typedef struct _PCI_AGP_CAPABILITY {
519 PCI_CAPABILITIES_HEADER Header;
520 USHORT Minor:4;
521 USHORT Major:4;
522 USHORT Rsvd1:8;
523 struct _PCI_AGP_STATUS {
524 ULONG Rate:3;
525 ULONG Agp3Mode:1;
526 ULONG FastWrite:1;
527 ULONG FourGB:1;
528 ULONG HostTransDisable:1;
529 ULONG Gart64:1;
530 ULONG ITA_Coherent:1;
531 ULONG SideBandAddressing:1;
532 ULONG CalibrationCycle:3;
533 ULONG AsyncRequestSize:3;
534 ULONG Rsvd1:1;
535 ULONG Isoch:1;
536 ULONG Rsvd2:6;
537 ULONG RequestQueueDepthMaximum:8;
538 } AGPStatus;
539 struct _PCI_AGP_COMMAND {
540 ULONG Rate:3;
541 ULONG Rsvd1:1;
542 ULONG FastWriteEnable:1;
543 ULONG FourGBEnable:1;
544 ULONG Rsvd2:1;
545 ULONG Gart64:1;
546 ULONG AGPEnable:1;
547 ULONG SBAEnable:1;
548 ULONG CalibrationCycle:3;
549 ULONG AsyncReqSize:3;
550 ULONG Rsvd3:8;
551 ULONG RequestQueueDepth:8;
552 } AGPCommand;
553 } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
554
555 typedef enum _EXTENDED_AGP_REGISTER {
556 IsochStatus,
557 AgpControl,
558 ApertureSize,
559 AperturePageSize,
560 GartLow,
561 GartHigh,
562 IsochCommand
563 } EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER;
564
565 typedef struct _PCI_AGP_ISOCH_STATUS {
566 ULONG ErrorCode:2;
567 ULONG Rsvd1:1;
568 ULONG Isoch_L:3;
569 ULONG Isoch_Y:2;
570 ULONG Isoch_N:8;
571 ULONG Rsvd2:16;
572 } PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS;
573
574 typedef struct _PCI_AGP_CONTROL {
575 ULONG Rsvd1:7;
576 ULONG GTLB_Enable:1;
577 ULONG AP_Enable:1;
578 ULONG CAL_Disable:1;
579 ULONG Rsvd2:22;
580 } PCI_AGP_CONTROL, *PPCI_AGP_CONTROL;
581
582 typedef struct _PCI_AGP_APERTURE_PAGE_SIZE {
583 USHORT PageSizeMask:11;
584 USHORT Rsvd1:1;
585 USHORT PageSizeSelect:4;
586 } PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE;
587
588 typedef struct _PCI_AGP_ISOCH_COMMAND {
589 USHORT Rsvd1:6;
590 USHORT Isoch_Y:2;
591 USHORT Isoch_N:8;
592 } PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND;
593
594 typedef struct PCI_AGP_EXTENDED_CAPABILITY {
595 PCI_AGP_ISOCH_STATUS IsochStatus;
596 PCI_AGP_CONTROL AgpControl;
597 USHORT ApertureSize;
598 PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize;
599 ULONG GartLow;
600 ULONG GartHigh;
601 PCI_AGP_ISOCH_COMMAND IsochCommand;
602 } PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY;
603
604 #define PCI_AGP_RATE_1X 0x1
605 #define PCI_AGP_RATE_2X 0x2
606 #define PCI_AGP_RATE_4X 0x4
607
608 #define PCIX_MODE_CONVENTIONAL_PCI 0x0
609 #define PCIX_MODE1_66MHZ 0x1
610 #define PCIX_MODE1_100MHZ 0x2
611 #define PCIX_MODE1_133MHZ 0x3
612 #define PCIX_MODE2_266_66MHZ 0x9
613 #define PCIX_MODE2_266_100MHZ 0xA
614 #define PCIX_MODE2_266_133MHZ 0xB
615 #define PCIX_MODE2_533_66MHZ 0xD
616 #define PCIX_MODE2_533_100MHZ 0xE
617 #define PCIX_MODE2_533_133MHZ 0xF
618
619 #define PCIX_VERSION_MODE1_ONLY 0x0
620 #define PCIX_VERSION_MODE2_ECC 0x1
621 #define PCIX_VERSION_DUAL_MODE_ECC 0x2
622
623 typedef struct _PCIX_BRIDGE_CAPABILITY {
624 PCI_CAPABILITIES_HEADER Header;
625 union {
626 _ANONYMOUS_STRUCT struct {
627 USHORT Bus64Bit:1;
628 USHORT Bus133MHzCapable:1;
629 USHORT SplitCompletionDiscarded:1;
630 USHORT UnexpectedSplitCompletion:1;
631 USHORT SplitCompletionOverrun:1;
632 USHORT SplitRequestDelayed:1;
633 USHORT BusModeFrequency:4;
634 USHORT Rsvd:2;
635 USHORT Version:2;
636 USHORT Bus266MHzCapable:1;
637 USHORT Bus533MHzCapable:1;
638 } DUMMYSTRUCTNAME;
639 USHORT AsUSHORT;
640 } SecondaryStatus;
641 union {
642 _ANONYMOUS_STRUCT struct {
643 ULONG FunctionNumber:3;
644 ULONG DeviceNumber:5;
645 ULONG BusNumber:8;
646 ULONG Device64Bit:1;
647 ULONG Device133MHzCapable:1;
648 ULONG SplitCompletionDiscarded:1;
649 ULONG UnexpectedSplitCompletion:1;
650 ULONG SplitCompletionOverrun:1;
651 ULONG SplitRequestDelayed:1;
652 ULONG Rsvd:7;
653 ULONG DIMCapable:1;
654 ULONG Device266MHzCapable:1;
655 ULONG Device533MHzCapable:1;
656 } DUMMYSTRUCTNAME;
657 ULONG AsULONG;
658 } BridgeStatus;
659 USHORT UpstreamSplitTransactionCapacity;
660 USHORT UpstreamSplitTransactionLimit;
661 USHORT DownstreamSplitTransactionCapacity;
662 USHORT DownstreamSplitTransactionLimit;
663 union {
664 _ANONYMOUS_STRUCT struct {
665 ULONG SelectSecondaryRegisters:1;
666 ULONG ErrorPresentInOtherBank:1;
667 ULONG AdditionalCorrectableError:1;
668 ULONG AdditionalUncorrectableError:1;
669 ULONG ErrorPhase:3;
670 ULONG ErrorCorrected:1;
671 ULONG Syndrome:8;
672 ULONG ErrorFirstCommand:4;
673 ULONG ErrorSecondCommand:4;
674 ULONG ErrorUpperAttributes:4;
675 ULONG ControlUpdateEnable:1;
676 ULONG Rsvd:1;
677 ULONG DisableSingleBitCorrection:1;
678 ULONG EccMode:1;
679 } DUMMYSTRUCTNAME;
680 ULONG AsULONG;
681 } EccControlStatus;
682 ULONG EccFirstAddress;
683 ULONG EccSecondAddress;
684 ULONG EccAttribute;
685 } PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY;
686
687 typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY {
688 PCI_CAPABILITIES_HEADER Header;
689 USHORT Reserved;
690 USHORT SubVendorID;
691 USHORT SubSystemID;
692 } PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY;
693
694 #define OSC_FIRMWARE_FAILURE 0x02
695 #define OSC_UNRECOGNIZED_UUID 0x04
696 #define OSC_UNRECOGNIZED_REVISION 0x08
697 #define OSC_CAPABILITIES_MASKED 0x10
698
699 #define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION 0x01
700
701 typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD {
702 union {
703 _ANONYMOUS_STRUCT struct {
704 ULONG ExtendedConfigOpRegions:1;
705 ULONG ActiveStatePowerManagement:1;
706 ULONG ClockPowerManagement:1;
707 ULONG SegmentGroups:1;
708 ULONG MessageSignaledInterrupts:1;
709 ULONG WindowsHardwareErrorArchitecture:1;
710 ULONG Reserved:26;
711 } DUMMYSTRUCTNAME;
712 ULONG AsULONG;
713 } u;
714 } PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD;
715
716 typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD {
717 union {
718 _ANONYMOUS_STRUCT struct {
719 ULONG ExpressNativeHotPlug:1;
720 ULONG ShpcNativeHotPlug:1;
721 ULONG ExpressNativePME:1;
722 ULONG ExpressAdvancedErrorReporting:1;
723 ULONG ExpressCapabilityStructure:1;
724 ULONG Reserved:27;
725 } DUMMYSTRUCTNAME;
726 ULONG AsULONG;
727 } u;
728 } PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD;
729
730 typedef enum _PCI_HARDWARE_INTERFACE {
731 PciConventional,
732 PciXMode1,
733 PciXMode2,
734 PciExpress
735 } PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE;
736
737 typedef enum {
738 BusWidth32Bits,
739 BusWidth64Bits
740 } PCI_BUS_WIDTH;
741
742 typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY {
743 PCI_HARDWARE_INTERFACE SecondaryInterface;
744 _ANONYMOUS_STRUCT struct {
745 BOOLEAN BusCapabilitiesFound;
746 ULONG CurrentSpeedAndMode;
747 ULONG SupportedSpeedsAndModes;
748 BOOLEAN DeviceIDMessagingCapable;
749 PCI_BUS_WIDTH SecondaryBusWidth;
750 } DUMMYSTRUCTNAME;
751 PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport;
752 PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest;
753 PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted;
754 } PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY;
755
756 typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER {
757 _ANONYMOUS_STRUCT struct {
758 USHORT CapabilityVersion:4;
759 USHORT DeviceType:4;
760 USHORT SlotImplemented:1;
761 USHORT InterruptMessageNumber:5;
762 USHORT Rsvd:2;
763 } DUMMYSTRUCTNAME;
764 USHORT AsUSHORT;
765 } PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER;
766
767 typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER {
768 _ANONYMOUS_STRUCT struct {
769 ULONG MaxPayloadSizeSupported:3;
770 ULONG PhantomFunctionsSupported:2;
771 ULONG ExtendedTagSupported:1;
772 ULONG L0sAcceptableLatency:3;
773 ULONG L1AcceptableLatency:3;
774 ULONG Undefined:3;
775 ULONG RoleBasedErrorReporting:1;
776 ULONG Rsvd1:2;
777 ULONG CapturedSlotPowerLimit:8;
778 ULONG CapturedSlotPowerLimitScale:2;
779 ULONG Rsvd2:4;
780 } DUMMYSTRUCTNAME;
781 ULONG AsULONG;
782 } PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER;
783
784 #define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07;
785
786 typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER {
787 _ANONYMOUS_STRUCT struct {
788 USHORT CorrectableErrorEnable:1;
789 USHORT NonFatalErrorEnable:1;
790 USHORT FatalErrorEnable:1;
791 USHORT UnsupportedRequestErrorEnable:1;
792 USHORT EnableRelaxedOrder:1;
793 USHORT MaxPayloadSize:3;
794 USHORT ExtendedTagEnable:1;
795 USHORT PhantomFunctionsEnable:1;
796 USHORT AuxPowerEnable:1;
797 USHORT NoSnoopEnable:1;
798 USHORT MaxReadRequestSize:3;
799 USHORT BridgeConfigRetryEnable:1;
800 } DUMMYSTRUCTNAME;
801 USHORT AsUSHORT;
802 } PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER;
803
804 #define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F;
805
806 typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER {
807 _ANONYMOUS_STRUCT struct {
808 USHORT CorrectableErrorDetected:1;
809 USHORT NonFatalErrorDetected:1;
810 USHORT FatalErrorDetected:1;
811 USHORT UnsupportedRequestDetected:1;
812 USHORT AuxPowerDetected:1;
813 USHORT TransactionsPending:1;
814 USHORT Rsvd:10;
815 } DUMMYSTRUCTNAME;
816 USHORT AsUSHORT;
817 } PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER;
818
819 typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER {
820 _ANONYMOUS_STRUCT struct {
821 ULONG MaximumLinkSpeed:4;
822 ULONG MaximumLinkWidth:6;
823 ULONG ActiveStatePMSupport:2;
824 ULONG L0sExitLatency:3;
825 ULONG L1ExitLatency:3;
826 ULONG ClockPowerManagement:1;
827 ULONG SurpriseDownErrorReportingCapable:1;
828 ULONG DataLinkLayerActiveReportingCapable:1;
829 ULONG Rsvd:3;
830 ULONG PortNumber:8;
831 } DUMMYSTRUCTNAME;
832 ULONG AsULONG;
833 } PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER;
834
835 typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER {
836 _ANONYMOUS_STRUCT struct {
837 USHORT ActiveStatePMControl:2;
838 USHORT Rsvd1:1;
839 USHORT ReadCompletionBoundary:1;
840 USHORT LinkDisable:1;
841 USHORT RetrainLink:1;
842 USHORT CommonClockConfig:1;
843 USHORT ExtendedSynch:1;
844 USHORT EnableClockPowerManagement:1;
845 USHORT Rsvd2:7;
846 } DUMMYSTRUCTNAME;
847 USHORT AsUSHORT;
848 } PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER;
849
850 typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER {
851 _ANONYMOUS_STRUCT struct {
852 USHORT LinkSpeed:4;
853 USHORT LinkWidth:6;
854 USHORT Undefined:1;
855 USHORT LinkTraining:1;
856 USHORT SlotClockConfig:1;
857 USHORT DataLinkLayerActive:1;
858 USHORT Rsvd:2;
859 } DUMMYSTRUCTNAME;
860 USHORT AsUSHORT;
861 } PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER;
862
863 typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER {
864 _ANONYMOUS_STRUCT struct {
865 ULONG AttentionButtonPresent:1;
866 ULONG PowerControllerPresent:1;
867 ULONG MRLSensorPresent:1;
868 ULONG AttentionIndicatorPresent:1;
869 ULONG PowerIndicatorPresent:1;
870 ULONG HotPlugSurprise:1;
871 ULONG HotPlugCapable:1;
872 ULONG SlotPowerLimit:8;
873 ULONG SlotPowerLimitScale:2;
874 ULONG ElectromechanicalLockPresent:1;
875 ULONG NoCommandCompletedSupport:1;
876 ULONG PhysicalSlotNumber:13;
877 } DUMMYSTRUCTNAME;
878 ULONG AsULONG;
879 } PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER;
880
881 typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER {
882 _ANONYMOUS_STRUCT struct {
883 USHORT AttentionButtonEnable:1;
884 USHORT PowerFaultDetectEnable:1;
885 USHORT MRLSensorEnable:1;
886 USHORT PresenceDetectEnable:1;
887 USHORT CommandCompletedEnable:1;
888 USHORT HotPlugInterruptEnable:1;
889 USHORT AttentionIndicatorControl:2;
890 USHORT PowerIndicatorControl:2;
891 USHORT PowerControllerControl:1;
892 USHORT ElectromechanicalLockControl:1;
893 USHORT DataLinkStateChangeEnable:1;
894 USHORT Rsvd:3;
895 } DUMMYSTRUCTNAME;
896 USHORT AsUSHORT;
897 } PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER;
898
899 typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER {
900 _ANONYMOUS_STRUCT struct {
901 USHORT AttentionButtonPressed:1;
902 USHORT PowerFaultDetected:1;
903 USHORT MRLSensorChanged:1;
904 USHORT PresenceDetectChanged:1;
905 USHORT CommandCompleted:1;
906 USHORT MRLSensorState:1;
907 USHORT PresenceDetectState:1;
908 USHORT ElectromechanicalLockEngaged:1;
909 USHORT DataLinkStateChanged:1;
910 USHORT Rsvd:7;
911 } DUMMYSTRUCTNAME;
912 USHORT AsUSHORT;
913 } PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER;
914
915 typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER {
916 _ANONYMOUS_STRUCT struct {
917 USHORT CorrectableSerrEnable:1;
918 USHORT NonFatalSerrEnable:1;
919 USHORT FatalSerrEnable:1;
920 USHORT PMEInterruptEnable:1;
921 USHORT CRSSoftwareVisibilityEnable:1;
922 USHORT Rsvd:11;
923 } DUMMYSTRUCTNAME;
924 USHORT AsUSHORT;
925 } PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER;
926
927 typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER {
928 _ANONYMOUS_STRUCT struct {
929 USHORT CRSSoftwareVisibility:1;
930 USHORT Rsvd:15;
931 } DUMMYSTRUCTNAME;
932 USHORT AsUSHORT;
933 } PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER;
934
935 typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER {
936 _ANONYMOUS_STRUCT struct {
937 ULONG PMERequestorId:16;
938 ULONG PMEStatus:1;
939 ULONG PMEPending:1;
940 ULONG Rsvd:14;
941 } DUMMYSTRUCTNAME;
942 ULONG AsULONG;
943 } PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER;
944
945 typedef struct _PCI_EXPRESS_CAPABILITY {
946 PCI_CAPABILITIES_HEADER Header;
947 PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities;
948 PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities;
949 PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl;
950 PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus;
951 PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities;
952 PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl;
953 PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus;
954 PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities;
955 PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl;
956 PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus;
957 PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl;
958 PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities;
959 PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus;
960 } PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY;
961
962 typedef enum {
963 MRLClosed = 0,
964 MRLOpen
965 } PCI_EXPRESS_MRL_STATE;
966
967 typedef enum {
968 SlotEmpty = 0,
969 CardPresent
970 } PCI_EXPRESS_CARD_PRESENCE;
971
972 typedef enum {
973 IndicatorOn = 1,
974 IndicatorBlink,
975 IndicatorOff
976 } PCI_EXPRESS_INDICATOR_STATE;
977
978 typedef enum {
979 PowerOn = 0,
980 PowerOff
981 } PCI_EXPRESS_POWER_STATE;
982
983 typedef enum {
984 L0sEntrySupport = 1,
985 L0sAndL1EntrySupport = 3
986 } PCI_EXPRESS_ASPM_SUPPORT;
987
988 typedef enum {
989 L0sAndL1EntryDisabled,
990 L0sEntryEnabled,
991 L1EntryEnabled,
992 L0sAndL1EntryEnabled
993 } PCI_EXPRESS_ASPM_CONTROL;
994
995 typedef enum {
996 L0s_Below64ns = 0,
997 L0s_64ns_128ns,
998 L0s_128ns_256ns,
999 L0s_256ns_512ns,
1000 L0s_512ns_1us,
1001 L0s_1us_2us,
1002 L0s_2us_4us,
1003 L0s_Above4us
1004 } PCI_EXPRESS_L0s_EXIT_LATENCY;
1005
1006 typedef enum {
1007 L1_Below1us = 0,
1008 L1_1us_2us,
1009 L1_2us_4us,
1010 L1_4us_8us,
1011 L1_8us_16us,
1012 L1_16us_32us,
1013 L1_32us_64us,
1014 L1_Above64us
1015 } PCI_EXPRESS_L1_EXIT_LATENCY;
1016
1017 typedef enum {
1018 PciExpressEndpoint = 0,
1019 PciExpressLegacyEndpoint,
1020 PciExpressRootPort = 4,
1021 PciExpressUpstreamSwitchPort,
1022 PciExpressDownstreamSwitchPort,
1023 PciExpressToPciXBridge,
1024 PciXToExpressBridge,
1025 PciExpressRootComplexIntegratedEndpoint,
1026 PciExpressRootComplexEventCollector
1027 } PCI_EXPRESS_DEVICE_TYPE;
1028
1029 typedef enum {
1030 MaxPayload128Bytes = 0,
1031 MaxPayload256Bytes,
1032 MaxPayload512Bytes,
1033 MaxPayload1024Bytes,
1034 MaxPayload2048Bytes,
1035 MaxPayload4096Bytes
1036 } PCI_EXPRESS_MAX_PAYLOAD_SIZE;
1037
1038 typedef union _PCI_EXPRESS_PME_REQUESTOR_ID {
1039 _ANONYMOUS_STRUCT struct {
1040 USHORT FunctionNumber:3;
1041 USHORT DeviceNumber:5;
1042 USHORT BusNumber:8;
1043 } DUMMYSTRUCTNAME;
1044 USHORT AsUSHORT;
1045 } PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID;
1046
1047 typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE {
1048 ResourceTypeSingle = 0,
1049 ResourceTypeRange,
1050 ResourceTypeExtendedCounterConfiguration,
1051 ResourceTypeOverflow,
1052 ResourceTypeMax
1053 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE;
1054
1055 typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR {
1056 PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type;
1057 ULONG Flags;
1058 union {
1059 ULONG CounterIndex;
1060 ULONG ExtendedRegisterAddress;
1061 struct {
1062 ULONG Begin;
1063 ULONG End;
1064 } Range;
1065 } u;
1066 } PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR;
1067
1068 typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST {
1069 ULONG Count;
1070 PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY];
1071 } PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST;
1072
1073 typedef VOID
1074 (NTAPI *PciPin2Line)(
1075 _In_ struct _BUS_HANDLER *BusHandler,
1076 _In_ struct _BUS_HANDLER *RootHandler,
1077 _In_ PCI_SLOT_NUMBER SlotNumber,
1078 _In_ PPCI_COMMON_CONFIG PciData);
1079
1080 typedef VOID
1081 (NTAPI *PciLine2Pin)(
1082 _In_ struct _BUS_HANDLER *BusHandler,
1083 _In_ struct _BUS_HANDLER *RootHandler,
1084 _In_ PCI_SLOT_NUMBER SlotNumber,
1085 _In_ PPCI_COMMON_CONFIG PciNewData,
1086 _In_ PPCI_COMMON_CONFIG PciOldData);
1087
1088 typedef VOID
1089 (NTAPI *PciReadWriteConfig)(
1090 _In_ struct _BUS_HANDLER *BusHandler,
1091 _In_ PCI_SLOT_NUMBER Slot,
1092 _In_reads_bytes_(Length) PVOID Buffer,
1093 _In_ ULONG Offset,
1094 _In_ ULONG Length);
1095
1096 #define PCI_DATA_TAG ' ICP'
1097 #define PCI_DATA_VERSION 1
1098
1099 typedef struct _PCIBUSDATA {
1100 ULONG Tag;
1101 ULONG Version;
1102 PciReadWriteConfig ReadConfig;
1103 PciReadWriteConfig WriteConfig;
1104 PciPin2Line Pin2Line;
1105 PciLine2Pin Line2Pin;
1106 PCI_SLOT_NUMBER ParentSlot;
1107 PVOID Reserved[4];
1108 } PCIBUSDATA, *PPCIBUSDATA;
1109
1110 #ifndef _PCIINTRF_X_
1111 #define _PCIINTRF_X_
1112
1113 typedef ULONG
1114 (NTAPI *PCI_READ_WRITE_CONFIG)(
1115 _In_ PVOID Context,
1116 _In_ ULONG BusOffset,
1117 _In_ ULONG Slot,
1118 _In_reads_bytes_(Length) PVOID Buffer,
1119 _In_ ULONG Offset,
1120 _In_ ULONG Length);
1121
1122 typedef VOID
1123 (NTAPI *PCI_PIN_TO_LINE)(
1124 _In_ PVOID Context,
1125 _In_ PPCI_COMMON_CONFIG PciData);
1126
1127 typedef VOID
1128 (NTAPI *PCI_LINE_TO_PIN)(
1129 _In_ PVOID Context,
1130 _In_ PPCI_COMMON_CONFIG PciNewData,
1131 _In_ PPCI_COMMON_CONFIG PciOldData);
1132
1133 typedef VOID
1134 (NTAPI *PCI_ROOT_BUS_CAPABILITY)(
1135 _In_ PVOID Context,
1136 _Out_ PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability);
1137
1138 typedef VOID
1139 (NTAPI *PCI_EXPRESS_WAKE_CONTROL)(
1140 _In_ PVOID Context,
1141 _In_ BOOLEAN EnableWake);
1142
1143 typedef struct _PCI_BUS_INTERFACE_STANDARD {
1144 USHORT Size;
1145 USHORT Version;
1146 PVOID Context;
1147 PINTERFACE_REFERENCE InterfaceReference;
1148 PINTERFACE_DEREFERENCE InterfaceDereference;
1149 PCI_READ_WRITE_CONFIG ReadConfig;
1150 PCI_READ_WRITE_CONFIG WriteConfig;
1151 PCI_PIN_TO_LINE PinToLine;
1152 PCI_LINE_TO_PIN LineToPin;
1153 PCI_ROOT_BUS_CAPABILITY RootBusCapability;
1154 PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl;
1155 } PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD;
1156
1157 #define PCI_BUS_INTERFACE_STANDARD_VERSION 1
1158
1159 #endif /* _PCIINTRF_X_ */
1160
1161 #if (NTDDI_VERSION >= NTDDI_WIN7)
1162
1163 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000
1164 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000
1165 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \
1166 (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \
1167 FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX)
1168
1169 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200
1170 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300
1171 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300
1172
1173 #else
1174
1175 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200
1176 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300
1177 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300
1178
1179 #define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL
1180 #define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL
1181 #define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK
1182
1183 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
1184
1185 #define FILE_CHARACTERISTICS_PROPAGATED (FILE_REMOVABLE_MEDIA | \
1186 FILE_READ_ONLY_DEVICE | \
1187 FILE_FLOPPY_DISKETTE | \
1188 FILE_WRITE_ONCE_MEDIA | \
1189 FILE_DEVICE_SECURE_OPEN)
1190
1191 typedef struct _FILE_ALIGNMENT_INFORMATION {
1192 ULONG AlignmentRequirement;
1193 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
1194
1195 typedef struct _FILE_NAME_INFORMATION {
1196 ULONG FileNameLength;
1197 WCHAR FileName[1];
1198 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
1199
1200
1201 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
1202 ULONG FileAttributes;
1203 ULONG ReparseTag;
1204 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
1205
1206 typedef struct _FILE_DISPOSITION_INFORMATION {
1207 BOOLEAN DeleteFile;
1208 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
1209
1210 typedef struct _FILE_END_OF_FILE_INFORMATION {
1211 LARGE_INTEGER EndOfFile;
1212 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
1213
1214 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
1215 LARGE_INTEGER ValidDataLength;
1216 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
1217
1218 typedef struct _FILE_FS_LABEL_INFORMATION {
1219 ULONG VolumeLabelLength;
1220 WCHAR VolumeLabel[1];
1221 } FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
1222
1223 typedef struct _FILE_FS_VOLUME_INFORMATION {
1224 LARGE_INTEGER VolumeCreationTime;
1225 ULONG VolumeSerialNumber;
1226 ULONG VolumeLabelLength;
1227 BOOLEAN SupportsObjects;
1228 WCHAR VolumeLabel[1];
1229 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
1230
1231 typedef struct _FILE_FS_SIZE_INFORMATION {
1232 LARGE_INTEGER TotalAllocationUnits;
1233 LARGE_INTEGER AvailableAllocationUnits;
1234 ULONG SectorsPerAllocationUnit;
1235 ULONG BytesPerSector;
1236 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
1237
1238 typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
1239 LARGE_INTEGER TotalAllocationUnits;
1240 LARGE_INTEGER CallerAvailableAllocationUnits;
1241 LARGE_INTEGER ActualAvailableAllocationUnits;
1242 ULONG SectorsPerAllocationUnit;
1243 ULONG BytesPerSector;
1244 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
1245
1246 typedef struct _FILE_FS_OBJECTID_INFORMATION {
1247 UCHAR ObjectId[16];
1248 UCHAR ExtendedInfo[48];
1249 } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
1250
1251 typedef union _FILE_SEGMENT_ELEMENT {
1252 PVOID64 Buffer;
1253 ULONGLONG Alignment;
1254 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
1255
1256 #define IOCTL_AVIO_ALLOCATE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
1257 #define IOCTL_AVIO_FREE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
1258 #define IOCTL_AVIO_MODIFY_STREAM CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
1259
1260 typedef enum _BUS_DATA_TYPE {
1261 ConfigurationSpaceUndefined = -1,
1262 Cmos,
1263 EisaConfiguration,
1264 Pos,
1265 CbusConfiguration,
1266 PCIConfiguration,
1267 VMEConfiguration,
1268 NuBusConfiguration,
1269 PCMCIAConfiguration,
1270 MPIConfiguration,
1271 MPSAConfiguration,
1272 PNPISAConfiguration,
1273 SgiInternalConfiguration,
1274 MaximumBusDataType
1275 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
1276
1277 /* Some Server 2003 DDK definitions */
1278 #define PCI_INT_ROUTE_INTRF_STANDARD_VER 1
1279
1280 typedef NTSTATUS
1281 (NTAPI *PLEGACY_DEVICE_DETECTION_HANDLER)(
1282 IN PVOID Context,
1283 IN INTERFACE_TYPE LegacyBusType,
1284 IN ULONG BusNumber,
1285 IN ULONG SlotNumber,
1286 OUT PDEVICE_OBJECT *PhysicalDeviceObject);
1287
1288 typedef struct _ROUTING_TOKEN {
1289 PVOID LinkNode;
1290 ULONG StaticVector;
1291 UCHAR Flags;
1292 } ROUTING_TOKEN, *PROUTING_TOKEN;
1293
1294 typedef NTSTATUS
1295 (NTAPI *PGET_INTERRUPT_ROUTING)(
1296 IN PDEVICE_OBJECT Pdo,
1297 OUT ULONG *Bus,
1298 OUT ULONG *PciSlot,
1299 OUT UCHAR *InterruptLine,
1300 OUT UCHAR *InterruptPin,
1301 OUT UCHAR *ClassCode,
1302 OUT UCHAR *SubClassCode,
1303 OUT PDEVICE_OBJECT *ParentPdo,
1304 OUT ROUTING_TOKEN *RoutingToken,
1305 OUT UCHAR *Flags);
1306
1307 typedef NTSTATUS
1308 (NTAPI *PSET_INTERRUPT_ROUTING_TOKEN)(
1309 IN PDEVICE_OBJECT Pdo,
1310 IN PROUTING_TOKEN RoutingToken);
1311
1312 typedef VOID
1313 (NTAPI *PUPDATE_INTERRUPT_LINE)(
1314 IN PDEVICE_OBJECT Pdo,
1315 IN UCHAR LineRegister);
1316
1317 typedef struct _INT_ROUTE_INTERFACE_STANDARD {
1318 USHORT Size;
1319 USHORT Version;
1320 PVOID Context;
1321 PINTERFACE_REFERENCE InterfaceReference;
1322 PINTERFACE_DEREFERENCE InterfaceDereference;
1323 PGET_INTERRUPT_ROUTING GetInterruptRouting;
1324 PSET_INTERRUPT_ROUTING_TOKEN SetInterruptRoutingToken;
1325 PUPDATE_INTERRUPT_LINE UpdateInterruptLine;
1326 } INT_ROUTE_INTERFACE_STANDARD, *PINT_ROUTE_INTERFACE_STANDARD;
1327
1328 typedef struct _LEGACY_DEVICE_DETECTION_INTERFACE {
1329 USHORT Size;
1330 USHORT Version;
1331 PVOID Context;
1332 PINTERFACE_REFERENCE InterfaceReference;
1333 PINTERFACE_DEREFERENCE InterfaceDereference;
1334 PLEGACY_DEVICE_DETECTION_HANDLER LegacyDeviceDetection;
1335 } LEGACY_DEVICE_DETECTION_INTERFACE, *PLEGACY_DEVICE_DETECTION_INTERFACE;
1336
1337 /* FIXME : These definitions don't exist in public headers */
1338
1339 #define PCI_CB_INTRF_VERSION 1
1340 #define PCI_PME_INTRF_STANDARD_VER 1
1341 #define PNP_LOCATION_INTERFACE_VERSION 1
1342
1343 DEFINE_GUID(GUID_PCI_CARDBUS_INTERFACE_PRIVATE, 0xcca82f31, 0x54d6, 0x11d1, 0x82, 0x24, 0x00, 0xa0, 0xc9, 0x32, 0x43, 0x85);
1344 DEFINE_GUID(GUID_PCI_PME_INTERFACE, 0xaac7e6ac, 0xbb0b, 0x11d2, 0xb4, 0x84, 0x00, 0xc0, 0x4f, 0x72, 0xde, 0x8b);
1345
1346 typedef NTSTATUS
1347 (NTAPI *PCARDBUSADD)(
1348 IN PDEVICE_OBJECT DeviceObject,
1349 IN OUT PVOID *DeviceContext);
1350
1351 typedef NTSTATUS
1352 (NTAPI *PCARDBUSDELETE)(
1353 IN PVOID DeviceContext);
1354
1355 typedef NTSTATUS
1356 (NTAPI *PCARDBUSPCIDISPATCH)(
1357 IN PVOID DeviceContext,
1358 IN PIRP Irp);
1359
1360 typedef VOID
1361 (NTAPI *PPME_SET_PME_ENABLE)(
1362 IN PDEVICE_OBJECT Pdo,
1363 IN BOOLEAN PmeEnable);
1364
1365 typedef VOID
1366 (NTAPI *PPME_CLEAR_PME_STATUS)(
1367 IN PDEVICE_OBJECT Pdo);
1368
1369 typedef VOID
1370 (NTAPI *PPME_GET_INFORMATION)(
1371 IN PDEVICE_OBJECT Pdo,
1372 OUT PBOOLEAN PmeCapable,
1373 OUT PBOOLEAN PmeStatus,
1374 OUT PBOOLEAN PmeEnable);
1375
1376 typedef struct _PCI_CARDBUS_INTERFACE_PRIVATE {
1377 USHORT Size;
1378 USHORT Version;
1379 PVOID Context;
1380 PINTERFACE_REFERENCE InterfaceReference;
1381 PINTERFACE_DEREFERENCE InterfaceDereference;
1382 PDRIVER_OBJECT DriverObject;
1383 PCARDBUSADD AddCardBus;
1384 PCARDBUSDELETE DeleteCardBus;
1385 PCARDBUSPCIDISPATCH DispatchPnp;
1386 } PCI_CARDBUS_INTERFACE_PRIVATE, *PPCI_CARDBUS_INTERFACE_PRIVATE;
1387
1388 typedef struct _PCI_PME_INTERFACE {
1389 USHORT Size;
1390 USHORT Version;
1391 PVOID Context;
1392 PINTERFACE_REFERENCE InterfaceReference;
1393 PINTERFACE_DEREFERENCE InterfaceDereference;
1394 PPME_GET_INFORMATION GetPmeInformation;
1395 PPME_CLEAR_PME_STATUS ClearPmeStatus;
1396 PPME_SET_PME_ENABLE UpdateEnable;
1397 } PCI_PME_INTERFACE, *PPCI_PME_INTERFACE;
1398
1399 /* Hardware Abstraction Layer Types */
1400
1401 typedef BOOLEAN
1402 (NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
1403 _In_ ULONG Columns,
1404 _In_ ULONG Rows);
1405
1406 typedef PBUS_HANDLER
1407 (FASTCALL *pHalHandlerForBus)(
1408 _In_ INTERFACE_TYPE InterfaceType,
1409 _In_ ULONG BusNumber);
1410
1411 typedef VOID
1412 (FASTCALL *pHalReferenceBusHandler)(
1413 _In_ PBUS_HANDLER BusHandler);
1414
1415 typedef enum _HAL_QUERY_INFORMATION_CLASS {
1416 HalInstalledBusInformation,
1417 HalProfileSourceInformation,
1418 HalInformationClassUnused1,
1419 HalPowerInformation,
1420 HalProcessorSpeedInformation,
1421 HalCallbackInformation,
1422 HalMapRegisterInformation,
1423 HalMcaLogInformation,
1424 HalFrameBufferCachingInformation,
1425 HalDisplayBiosInformation,
1426 HalProcessorFeatureInformation,
1427 HalNumaTopologyInterface,
1428 HalErrorInformation,
1429 HalCmcLogInformation,
1430 HalCpeLogInformation,
1431 HalQueryMcaInterface,
1432 HalQueryAMLIIllegalIOPortAddresses,
1433 HalQueryMaxHotPlugMemoryAddress,
1434 HalPartitionIpiInterface,
1435 HalPlatformInformation,
1436 HalQueryProfileSourceList,
1437 HalInitLogInformation,
1438 HalFrequencyInformation,
1439 HalProcessorBrandString,
1440 HalHypervisorInformation,
1441 HalPlatformTimerInformation,
1442 HalAcpiAuditInformation
1443 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
1444
1445 typedef enum _HAL_SET_INFORMATION_CLASS {
1446 HalProfileSourceInterval,
1447 HalProfileSourceInterruptHandler,
1448 HalMcaRegisterDriver,
1449 HalKernelErrorHandler,
1450 HalCmcRegisterDriver,
1451 HalCpeRegisterDriver,
1452 HalMcaLog,
1453 HalCmcLog,
1454 HalCpeLog,
1455 HalGenerateCmcInterrupt,
1456 HalProfileSourceTimerHandler,
1457 HalEnlightenment,
1458 HalProfileDpgoSourceInterruptHandler
1459 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
1460
1461 typedef NTSTATUS
1462 (NTAPI *pHalQuerySystemInformation)(
1463 _In_ HAL_QUERY_INFORMATION_CLASS InformationClass,
1464 _In_ ULONG BufferSize,
1465 _Inout_updates_bytes_to_(BufferSize, *ReturnedLength) PVOID Buffer,
1466 _Out_ PULONG ReturnedLength);
1467
1468 typedef NTSTATUS
1469 (NTAPI *pHalSetSystemInformation)(
1470 _In_ HAL_SET_INFORMATION_CLASS InformationClass,
1471 _In_ ULONG BufferSize,
1472 _In_ PVOID Buffer);
1473
1474 typedef VOID
1475 (FASTCALL *pHalExamineMBR)(
1476 _In_ PDEVICE_OBJECT DeviceObject,
1477 _In_ ULONG SectorSize,
1478 _In_ ULONG MBRTypeIdentifier,
1479 _Out_ PVOID *Buffer);
1480
1481 typedef NTSTATUS
1482 (FASTCALL *pHalIoReadPartitionTable)(
1483 _In_ PDEVICE_OBJECT DeviceObject,
1484 _In_ ULONG SectorSize,
1485 _In_ BOOLEAN ReturnRecognizedPartitions,
1486 _Out_ struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
1487
1488 typedef NTSTATUS
1489 (FASTCALL *pHalIoSetPartitionInformation)(
1490 _In_ PDEVICE_OBJECT DeviceObject,
1491 _In_ ULONG SectorSize,
1492 _In_ ULONG PartitionNumber,
1493 _In_ ULONG PartitionType);
1494
1495 typedef NTSTATUS
1496 (FASTCALL *pHalIoWritePartitionTable)(
1497 _In_ PDEVICE_OBJECT DeviceObject,
1498 _In_ ULONG SectorSize,
1499 _In_ ULONG SectorsPerTrack,
1500 _In_ ULONG NumberOfHeads,
1501 _In_ struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
1502
1503 typedef NTSTATUS
1504 (NTAPI *pHalQueryBusSlots)(
1505 _In_ PBUS_HANDLER BusHandler,
1506 _In_ ULONG BufferSize,
1507 _Out_ PULONG SlotNumbers,
1508 _Out_ PULONG ReturnedLength);
1509
1510 typedef NTSTATUS
1511 (NTAPI *pHalInitPnpDriver)(VOID);
1512
1513 typedef struct _PM_DISPATCH_TABLE {
1514 ULONG Signature;
1515 ULONG Version;
1516 PVOID Function[1];
1517 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
1518
1519 typedef NTSTATUS
1520 (NTAPI *pHalInitPowerManagement)(
1521 _In_ PPM_DISPATCH_TABLE PmDriverDispatchTable,
1522 _Out_ PPM_DISPATCH_TABLE *PmHalDispatchTable);
1523
1524 typedef struct _DMA_ADAPTER*
1525 (NTAPI *pHalGetDmaAdapter)(
1526 _In_ PVOID Context,
1527 _In_ struct _DEVICE_DESCRIPTION *DeviceDescriptor,
1528 _Out_ PULONG NumberOfMapRegisters);
1529
1530 typedef NTSTATUS
1531 (NTAPI *pHalGetInterruptTranslator)(
1532 _In_ INTERFACE_TYPE ParentInterfaceType,
1533 _In_ ULONG ParentBusNumber,
1534 _In_ INTERFACE_TYPE BridgeInterfaceType,
1535 _In_ USHORT Size,
1536 _In_ USHORT Version,
1537 _Out_ PTRANSLATOR_INTERFACE Translator,
1538 _Out_ PULONG BridgeBusNumber);
1539
1540 typedef NTSTATUS
1541 (NTAPI *pHalStartMirroring)(VOID);
1542
1543 typedef NTSTATUS
1544 (NTAPI *pHalEndMirroring)(
1545 _In_ ULONG PassNumber);
1546
1547 typedef NTSTATUS
1548 (NTAPI *pHalMirrorPhysicalMemory)(
1549 _In_ PHYSICAL_ADDRESS PhysicalAddress,
1550 _In_ LARGE_INTEGER NumberOfBytes);
1551
1552 typedef NTSTATUS
1553 (NTAPI *pHalMirrorVerify)(
1554 _In_ PHYSICAL_ADDRESS PhysicalAddress,
1555 _In_ LARGE_INTEGER NumberOfBytes);
1556
1557 typedef BOOLEAN
1558 (NTAPI *pHalTranslateBusAddress)(
1559 _In_ INTERFACE_TYPE InterfaceType,
1560 _In_ ULONG BusNumber,
1561 _In_ PHYSICAL_ADDRESS BusAddress,
1562 _Inout_ PULONG AddressSpace,
1563 _Out_ PPHYSICAL_ADDRESS TranslatedAddress);
1564
1565 typedef NTSTATUS
1566 (NTAPI *pHalAssignSlotResources)(
1567 _In_ PUNICODE_STRING RegistryPath,
1568 _In_opt_ PUNICODE_STRING DriverClassName,
1569 _In_ PDRIVER_OBJECT DriverObject,
1570 _In_ PDEVICE_OBJECT DeviceObject,
1571 _In_ INTERFACE_TYPE BusType,
1572 _In_ ULONG BusNumber,
1573 _In_ ULONG SlotNumber,
1574 _Inout_ PCM_RESOURCE_LIST *AllocatedResources);
1575
1576 typedef VOID
1577 (NTAPI *pHalHaltSystem)(VOID);
1578
1579 typedef BOOLEAN
1580 (NTAPI *pHalResetDisplay)(VOID);
1581
1582 typedef struct _MAP_REGISTER_ENTRY {
1583 PVOID MapRegister;
1584 BOOLEAN WriteToDevice;
1585 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
1586
1587 typedef UCHAR
1588 (NTAPI *pHalVectorToIDTEntry)(
1589 ULONG Vector);
1590
1591 typedef BOOLEAN
1592 (NTAPI *pHalFindBusAddressTranslation)(
1593 _In_ PHYSICAL_ADDRESS BusAddress,
1594 _Inout_ PULONG AddressSpace,
1595 _Out_ PPHYSICAL_ADDRESS TranslatedAddress,
1596 _Inout_ PULONG_PTR Context,
1597 _In_ BOOLEAN NextBus);
1598
1599 typedef VOID
1600 (NTAPI *pHalEndOfBoot)(VOID);
1601
1602 typedef PVOID
1603 (NTAPI *pHalGetAcpiTable)(
1604 _In_ ULONG Signature,
1605 _In_opt_ PCSTR OemId,
1606 _In_opt_ PCSTR OemTableId);
1607
1608 #if defined(_IA64_)
1609 typedef NTSTATUS
1610 (*pHalGetErrorCapList)(
1611 _Inout_ PULONG CapsListLength,
1612 _Inout_updates_bytes_(*CapsListLength) PUCHAR ErrorCapList);
1613
1614 typedef NTSTATUS
1615 (*pHalInjectError)(
1616 _In_ ULONG BufferLength,
1617 _In_reads_bytes_(BufferLength) PUCHAR Buffer);
1618 #endif
1619
1620 typedef VOID
1621 (NTAPI *PCI_ERROR_HANDLER_CALLBACK)(VOID);
1622
1623 typedef VOID
1624 (NTAPI *pHalSetPciErrorHandlerCallback)(
1625 _In_ PCI_ERROR_HANDLER_CALLBACK Callback);
1626
1627 #if 1 /* Not present in WDK 7600 */
1628 typedef VOID
1629 (FASTCALL *pHalIoAssignDriveLetters)(
1630 _In_ struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1631 _In_ PSTRING NtDeviceName,
1632 _Out_ PUCHAR NtSystemPath,
1633 _Out_ PSTRING NtSystemPathString);
1634 #endif
1635
1636 typedef struct {
1637 ULONG Version;
1638 pHalQuerySystemInformation HalQuerySystemInformation;
1639 pHalSetSystemInformation HalSetSystemInformation;
1640 pHalQueryBusSlots HalQueryBusSlots;
1641 ULONG Spare1;
1642 pHalExamineMBR HalExamineMBR;
1643 #if 1 /* Not present in WDK 7600 */
1644 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
1645 #endif
1646 pHalIoReadPartitionTable HalIoReadPartitionTable;
1647 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
1648 pHalIoWritePartitionTable HalIoWritePartitionTable;
1649 pHalHandlerForBus HalReferenceHandlerForBus;
1650 pHalReferenceBusHandler HalReferenceBusHandler;
1651 pHalReferenceBusHandler HalDereferenceBusHandler;
1652 pHalInitPnpDriver HalInitPnpDriver;
1653 pHalInitPowerManagement HalInitPowerManagement;
1654 pHalGetDmaAdapter HalGetDmaAdapter;
1655 pHalGetInterruptTranslator HalGetInterruptTranslator;
1656 pHalStartMirroring HalStartMirroring;
1657 pHalEndMirroring HalEndMirroring;
1658 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
1659 pHalEndOfBoot HalEndOfBoot;
1660 pHalMirrorVerify HalMirrorVerify;
1661 pHalGetAcpiTable HalGetCachedAcpiTable;
1662 pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback;
1663 #if defined(_IA64_)
1664 pHalGetErrorCapList HalGetErrorCapList;
1665 pHalInjectError HalInjectError;
1666 #endif
1667 } HAL_DISPATCH, *PHAL_DISPATCH;
1668
1669 #ifdef _NTSYSTEM_
1670 extern HAL_DISPATCH HalDispatchTable;
1671 #define HALDISPATCH (&HalDispatchTable)
1672 #else
1673 __CREATE_NTOS_DATA_IMPORT_ALIAS(HalDispatchTable)
1674 extern PHAL_DISPATCH HalDispatchTable;
1675 #define HALDISPATCH HalDispatchTable
1676 #endif
1677
1678 #define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */
1679 #define HalDispatchTableVersion HALDISPATCH->Version
1680 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
1681 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
1682 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
1683 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
1684 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
1685 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
1686 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
1687 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
1688 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
1689 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
1690 #define HalStartMirroring HALDISPATCH->HalStartMirroring
1691 #define HalEndMirroring HALDISPATCH->HalEndMirroring
1692 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
1693 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
1694 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
1695 #define HalGetCachedAcpiTable HALDISPATCH->HalGetCachedAcpiTable
1696 #define HalSetPciErrorHandlerCallback HALDISPATCH->HalSetPciErrorHandlerCallback
1697 #if defined(_IA64_)
1698 #define HalGetErrorCapList HALDISPATCH->HalGetErrorCapList
1699 #define HalInjectError HALDISPATCH->HalInjectError
1700 #endif
1701
1702 typedef struct _HAL_BUS_INFORMATION {
1703 INTERFACE_TYPE BusType;
1704 BUS_DATA_TYPE ConfigurationType;
1705 ULONG BusNumber;
1706 ULONG Reserved;
1707 } HAL_BUS_INFORMATION, *PHAL_BUS_INFORMATION;
1708
1709 typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
1710 KPROFILE_SOURCE Source;
1711 BOOLEAN Supported;
1712 ULONG Interval;
1713 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
1714
1715 typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX {
1716 KPROFILE_SOURCE Source;
1717 BOOLEAN Supported;
1718 ULONG_PTR Interval;
1719 ULONG_PTR DefInterval;
1720 ULONG_PTR MaxInterval;
1721 ULONG_PTR MinInterval;
1722 } HAL_PROFILE_SOURCE_INFORMATION_EX, *PHAL_PROFILE_SOURCE_INFORMATION_EX;
1723
1724 typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
1725 KPROFILE_SOURCE Source;
1726 ULONG_PTR Interval;
1727 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
1728
1729 typedef struct _HAL_PROFILE_SOURCE_LIST {
1730 KPROFILE_SOURCE Source;
1731 PWSTR Description;
1732 } HAL_PROFILE_SOURCE_LIST, *PHAL_PROFILE_SOURCE_LIST;
1733
1734 typedef enum _HAL_DISPLAY_BIOS_INFORMATION {
1735 HalDisplayInt10Bios,
1736 HalDisplayEmulatedBios,
1737 HalDisplayNoBios
1738 } HAL_DISPLAY_BIOS_INFORMATION, *PHAL_DISPLAY_BIOS_INFORMATION;
1739
1740 typedef struct _HAL_POWER_INFORMATION {
1741 ULONG TBD;
1742 } HAL_POWER_INFORMATION, *PHAL_POWER_INFORMATION;
1743
1744 typedef struct _HAL_PROCESSOR_SPEED_INFO {
1745 ULONG ProcessorSpeed;
1746 } HAL_PROCESSOR_SPEED_INFORMATION, *PHAL_PROCESSOR_SPEED_INFORMATION;
1747
1748 typedef struct _HAL_CALLBACKS {
1749 PCALLBACK_OBJECT SetSystemInformation;
1750 PCALLBACK_OBJECT BusCheck;
1751 } HAL_CALLBACKS, *PHAL_CALLBACKS;
1752
1753 typedef struct _HAL_PROCESSOR_FEATURE {
1754 ULONG UsableFeatureBits;
1755 } HAL_PROCESSOR_FEATURE;
1756
1757 typedef NTSTATUS
1758 (NTAPI *PHALIOREADWRITEHANDLER)(
1759 _In_ BOOLEAN fRead,
1760 _In_ ULONG dwAddr,
1761 _In_ ULONG dwSize,
1762 _Inout_ PULONG pdwData);
1763
1764 typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST {
1765 ULONG BadAddrBegin;
1766 ULONG BadAddrSize;
1767 ULONG OSVersionTrigger;
1768 PHALIOREADWRITEHANDLER IOHandler;
1769 } HAL_AMLI_BAD_IO_ADDRESS_LIST, *PHAL_AMLI_BAD_IO_ADDRESS_LIST;
1770
1771 #if defined(_X86_) || defined(_IA64_) || defined(_AMD64_)
1772
1773 typedef VOID
1774 (NTAPI *PHALMCAINTERFACELOCK)(VOID);
1775
1776 typedef VOID
1777 (NTAPI *PHALMCAINTERFACEUNLOCK)(VOID);
1778
1779 typedef NTSTATUS
1780 (NTAPI *PHALMCAINTERFACEREADREGISTER)(
1781 _In_ UCHAR BankNumber,
1782 _Inout_ PVOID Exception);
1783
1784 typedef struct _HAL_MCA_INTERFACE {
1785 PHALMCAINTERFACELOCK Lock;
1786 PHALMCAINTERFACEUNLOCK Unlock;
1787 PHALMCAINTERFACEREADREGISTER ReadRegister;
1788 } HAL_MCA_INTERFACE;
1789
1790 typedef enum {
1791 ApicDestinationModePhysical = 1,
1792 ApicDestinationModeLogicalFlat,
1793 ApicDestinationModeLogicalClustered,
1794 ApicDestinationModeUnknown
1795 } HAL_APIC_DESTINATION_MODE, *PHAL_APIC_DESTINATION_MODE;
1796
1797 #if defined(_AMD64_)
1798
1799 struct _KTRAP_FRAME;
1800 struct _KEXCEPTION_FRAME;
1801
1802 typedef ERROR_SEVERITY
1803 (NTAPI *PDRIVER_EXCPTN_CALLBACK)(
1804 _In_ PVOID Context,
1805 _In_ struct _KTRAP_FRAME *TrapFrame,
1806 _In_ struct _KEXCEPTION_FRAME *ExceptionFrame,
1807 _In_ PMCA_EXCEPTION Exception);
1808
1809 #endif
1810
1811 #if defined(_X86_) || defined(_IA64_)
1812 typedef
1813 #if defined(_IA64_)
1814 ERROR_SEVERITY
1815 #else
1816 VOID
1817 #endif
1818 (NTAPI *PDRIVER_EXCPTN_CALLBACK)(
1819 _In_ PVOID Context,
1820 _In_ PMCA_EXCEPTION BankLog);
1821 #endif
1822
1823 typedef PDRIVER_EXCPTN_CALLBACK PDRIVER_MCA_EXCEPTION_CALLBACK;
1824
1825 typedef struct _MCA_DRIVER_INFO {
1826 PDRIVER_MCA_EXCEPTION_CALLBACK ExceptionCallback;
1827 PKDEFERRED_ROUTINE DpcCallback;
1828 PVOID DeviceContext;
1829 } MCA_DRIVER_INFO, *PMCA_DRIVER_INFO;
1830
1831 typedef struct _HAL_ERROR_INFO {
1832 ULONG Version;
1833 ULONG InitMaxSize;
1834 ULONG McaMaxSize;
1835 ULONG McaPreviousEventsCount;
1836 ULONG McaCorrectedEventsCount;
1837 ULONG McaKernelDeliveryFails;
1838 ULONG McaDriverDpcQueueFails;
1839 ULONG McaReserved;
1840 ULONG CmcMaxSize;
1841 ULONG CmcPollingInterval;
1842 ULONG CmcInterruptsCount;
1843 ULONG CmcKernelDeliveryFails;
1844 ULONG CmcDriverDpcQueueFails;
1845 ULONG CmcGetStateFails;
1846 ULONG CmcClearStateFails;
1847 ULONG CmcReserved;
1848 ULONGLONG CmcLogId;
1849 ULONG CpeMaxSize;
1850 ULONG CpePollingInterval;
1851 ULONG CpeInterruptsCount;
1852 ULONG CpeKernelDeliveryFails;
1853 ULONG CpeDriverDpcQueueFails;
1854 ULONG CpeGetStateFails;
1855 ULONG CpeClearStateFails;
1856 ULONG CpeInterruptSources;
1857 ULONGLONG CpeLogId;
1858 ULONGLONG KernelReserved[4];
1859 } HAL_ERROR_INFO, *PHAL_ERROR_INFO;
1860
1861 #define HAL_MCE_INTERRUPTS_BASED ((ULONG)-1)
1862 #define HAL_MCE_DISABLED ((ULONG)0)
1863
1864 #define HAL_CMC_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED
1865 #define HAL_CMC_DISABLED HAL_MCE_DISABLED
1866
1867 #define HAL_CPE_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED
1868 #define HAL_CPE_DISABLED HAL_MCE_DISABLED
1869
1870 #define HAL_MCA_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED
1871 #define HAL_MCA_DISABLED HAL_MCE_DISABLED
1872
1873 typedef VOID
1874 (NTAPI *PDRIVER_CMC_EXCEPTION_CALLBACK)(
1875 _In_ PVOID Context,
1876 _In_ PCMC_EXCEPTION CmcLog);
1877
1878 typedef VOID
1879 (NTAPI *PDRIVER_CPE_EXCEPTION_CALLBACK)(
1880 _In_ PVOID Context,
1881 _In_ PCPE_EXCEPTION CmcLog);
1882
1883 typedef struct _CMC_DRIVER_INFO {
1884 PDRIVER_CMC_EXCEPTION_CALLBACK ExceptionCallback;
1885 PKDEFERRED_ROUTINE DpcCallback;
1886 PVOID DeviceContext;
1887 } CMC_DRIVER_INFO, *PCMC_DRIVER_INFO;
1888
1889 typedef struct _CPE_DRIVER_INFO {
1890 PDRIVER_CPE_EXCEPTION_CALLBACK ExceptionCallback;
1891 PKDEFERRED_ROUTINE DpcCallback;
1892 PVOID DeviceContext;
1893 } CPE_DRIVER_INFO, *PCPE_DRIVER_INFO;
1894
1895 #endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_)
1896
1897 #if defined(_IA64_)
1898
1899 typedef NTSTATUS
1900 (*HALSENDCROSSPARTITIONIPI)(
1901 _In_ USHORT ProcessorID,
1902 _In_ UCHAR HardwareVector);
1903
1904 typedef NTSTATUS
1905 (*HALRESERVECROSSPARTITIONINTERRUPTVECTOR)(
1906 _Out_ PULONG Vector,
1907 _Out_ PKIRQL Irql,
1908 _Inout_ PGROUP_AFFINITY Affinity,
1909 _Out_ PUCHAR HardwareVector);
1910
1911 typedef VOID
1912 (*HALFREECROSSPARTITIONINTERRUPTVECTOR)(
1913 _In_ ULONG Vector,
1914 _In_ PGROUP_AFFINITY Affinity);
1915
1916 typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE {
1917 HALSENDCROSSPARTITIONIPI HalSendCrossPartitionIpi;
1918 HALRESERVECROSSPARTITIONINTERRUPTVECTOR HalReserveCrossPartitionInterruptVector;
1919 HALFREECROSSPARTITIONINTERRUPTVECTOR HalFreeCrossPartitionInterruptVector;
1920 } HAL_CROSS_PARTITION_IPI_INTERFACE;
1921
1922 #define HAL_CROSS_PARTITION_IPI_INTERFACE_MINIMUM_SIZE \
1923 FIELD_OFFSET(HAL_CROSS_PARTITION_IPI_INTERFACE, \
1924 HalFreeCrossPartitionInterruptVector)
1925
1926 #endif /* defined(_IA64_) */
1927
1928 typedef struct _HAL_PLATFORM_INFORMATION {
1929 ULONG PlatformFlags;
1930 } HAL_PLATFORM_INFORMATION, *PHAL_PLATFORM_INFORMATION;
1931
1932 #define HAL_PLATFORM_DISABLE_WRITE_COMBINING 0x01L
1933 #define HAL_PLATFORM_DISABLE_PTCG 0x04L
1934 #define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L
1935 #define HAL_PLATFORM_ENABLE_WRITE_COMBINING_MMIO 0x10L
1936 #define HAL_PLATFORM_ACPI_TABLES_CACHED 0x20L
1937
1938 /******************************************************************************
1939 * Kernel Types *
1940 ******************************************************************************/
1941
1942 typedef struct _EXCEPTION_REGISTRATION_RECORD
1943 {
1944 struct _EXCEPTION_REGISTRATION_RECORD *Next;
1945 PEXCEPTION_ROUTINE Handler;
1946 } EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
1947
1948 typedef struct _NT_TIB {
1949 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1950 PVOID StackBase;
1951 PVOID StackLimit;
1952 PVOID SubSystemTib;
1953 _ANONYMOUS_UNION union {
1954 PVOID FiberData;
1955 ULONG Version;
1956 } DUMMYUNIONNAME;
1957 PVOID ArbitraryUserPointer;
1958 struct _NT_TIB *Self;
1959 } NT_TIB, *PNT_TIB;
1960
1961 typedef struct _NT_TIB32 {
1962 ULONG ExceptionList;
1963 ULONG StackBase;
1964 ULONG StackLimit;
1965 ULONG SubSystemTib;
1966 _ANONYMOUS_UNION union {
1967 ULONG FiberData;
1968 ULONG Version;
1969 } DUMMYUNIONNAME;
1970 ULONG ArbitraryUserPointer;
1971 ULONG Self;
1972 } NT_TIB32,*PNT_TIB32;
1973
1974 typedef struct _NT_TIB64 {
1975 ULONG64 ExceptionList;
1976 ULONG64 StackBase;
1977 ULONG64 StackLimit;
1978 ULONG64 SubSystemTib;
1979 _ANONYMOUS_UNION union {
1980 ULONG64 FiberData;
1981 ULONG Version;
1982 } DUMMYUNIONNAME;
1983 ULONG64 ArbitraryUserPointer;
1984 ULONG64 Self;
1985 } NT_TIB64,*PNT_TIB64;
1986
1987 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
1988 #define NX_SUPPORT_POLICY_ALWAYSON 1
1989 #define NX_SUPPORT_POLICY_OPTIN 2
1990 #define NX_SUPPORT_POLICY_OPTOUT 3
1991
1992 _IRQL_requires_same_
1993 _Function_class_(EXPAND_STACK_CALLOUT)
1994 typedef VOID
1995 (NTAPI EXPAND_STACK_CALLOUT)(
1996 _In_opt_ PVOID Parameter);
1997 typedef EXPAND_STACK_CALLOUT *PEXPAND_STACK_CALLOUT;
1998
1999 typedef VOID
2000 (NTAPI *PTIMER_APC_ROUTINE)(
2001 _In_ PVOID TimerContext,
2002 _In_ ULONG TimerLowValue,
2003 _In_ LONG TimerHighValue);
2004
2005 typedef enum _TIMER_SET_INFORMATION_CLASS {
2006 TimerSetCoalescableTimer,
2007 MaxTimerInfoClass
2008 } TIMER_SET_INFORMATION_CLASS;
2009
2010 #if (NTDDI_VERSION >= NTDDI_WIN7)
2011 typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO {
2012 _In_ LARGE_INTEGER DueTime;
2013 _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine;
2014 _In_opt_ PVOID TimerContext;
2015 _In_opt_ struct _COUNTED_REASON_CONTEXT *WakeContext;
2016 _In_opt_ ULONG Period;
2017 _In_ ULONG TolerableDelay;
2018 _Out_opt_ PBOOLEAN PreviousState;
2019 } TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO;
2020 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2021
2022 #define XSTATE_LEGACY_FLOATING_POINT 0
2023 #define XSTATE_LEGACY_SSE 1
2024 #define XSTATE_GSSE 2
2025
2026 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1LL << (XSTATE_LEGACY_FLOATING_POINT))
2027 #define XSTATE_MASK_LEGACY_SSE (1LL << (XSTATE_LEGACY_SSE))
2028 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
2029 #define XSTATE_MASK_GSSE (1LL << (XSTATE_GSSE))
2030
2031 #define MAXIMUM_XSTATE_FEATURES 64
2032
2033 typedef struct _XSTATE_FEATURE {
2034 ULONG Offset;
2035 ULONG Size;
2036 } XSTATE_FEATURE, *PXSTATE_FEATURE;
2037
2038 typedef struct _XSTATE_CONFIGURATION {
2039 ULONG64 EnabledFeatures;
2040 ULONG Size;
2041 ULONG OptimizedSave:1;
2042 XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES];
2043 } XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION;
2044
2045 #define MAX_WOW64_SHARED_ENTRIES 16
2046
2047 typedef struct _KUSER_SHARED_DATA {
2048 ULONG TickCountLowDeprecated;
2049 ULONG TickCountMultiplier;
2050 volatile KSYSTEM_TIME InterruptTime;
2051 volatile KSYSTEM_TIME SystemTime;
2052 volatile KSYSTEM_TIME TimeZoneBias;
2053 USHORT ImageNumberLow;
2054 USHORT ImageNumberHigh;
2055 WCHAR NtSystemRoot[260];
2056 ULONG MaxStackTraceDepth;
2057 ULONG CryptoExponent;
2058 ULONG TimeZoneId;
2059 ULONG LargePageMinimum;
2060 ULONG Reserved2[7];
2061 NT_PRODUCT_TYPE NtProductType;
2062 BOOLEAN ProductTypeIsValid;
2063 ULONG NtMajorVersion;
2064 ULONG NtMinorVersion;
2065 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
2066 ULONG Reserved1;
2067 ULONG Reserved3;
2068 volatile ULONG TimeSlip;
2069 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
2070 ULONG AltArchitecturePad[1];
2071 LARGE_INTEGER SystemExpirationDate;
2072 ULONG SuiteMask;
2073 BOOLEAN KdDebuggerEnabled;
2074 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
2075 UCHAR NXSupportPolicy;
2076 #endif
2077 volatile ULONG ActiveConsoleId;
2078 volatile ULONG DismountCount;
2079 ULONG ComPlusPackage;
2080 ULONG LastSystemRITEventTickCount;
2081 ULONG NumberOfPhysicalPages;
2082 BOOLEAN SafeBootMode;
2083 #if (NTDDI_VERSION >= NTDDI_WIN7)
2084 _ANONYMOUS_UNION union {
2085 UCHAR TscQpcData;
2086 _ANONYMOUS_STRUCT struct {
2087 UCHAR TscQpcEnabled:1;
2088 UCHAR TscQpcSpareFlag:1;
2089 UCHAR TscQpcShift:6;
2090 } DUMMYSTRUCTNAME;
2091 } DUMMYUNIONNAME;
2092 UCHAR TscQpcPad[2];
2093 #endif
2094 #if (NTDDI_VERSION >= NTDDI_VISTA)
2095 _ANONYMOUS_UNION union {
2096 ULONG SharedDataFlags;
2097 _ANONYMOUS_STRUCT struct {
2098 ULONG DbgErrorPortPresent:1;
2099 ULONG DbgElevationEnabled:1;
2100 ULONG DbgVirtEnabled:1;
2101 ULONG DbgInstallerDetectEnabled:1;
2102 ULONG DbgSystemDllRelocated:1;
2103 ULONG DbgDynProcessorEnabled:1;
2104 ULONG DbgSEHValidationEnabled:1;
2105 ULONG SpareBits:25;
2106 } DUMMYSTRUCTNAME2;
2107 } DUMMYUNIONNAME2;
2108 #else
2109 ULONG TraceLogging;
2110 #endif
2111 ULONG DataFlagsPad[1];
2112 ULONGLONG TestRetInstruction;
2113 ULONG SystemCall;
2114 ULONG SystemCallReturn;
2115 ULONGLONG SystemCallPad[3];
2116 _ANONYMOUS_UNION union {
2117 volatile KSYSTEM_TIME TickCount;
2118 volatile ULONG64 TickCountQuad;
2119 _ANONYMOUS_STRUCT struct {
2120 ULONG ReservedTickCountOverlay[3];
2121 ULONG TickCountPad[1];
2122 } DUMMYSTRUCTNAME;
2123 } DUMMYUNIONNAME3;
2124 ULONG Cookie;
2125 ULONG CookiePad[1];
2126 #if (NTDDI_VERSION >= NTDDI_WS03)
2127 LONGLONG ConsoleSessionForegroundProcessId;
2128 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
2129 #endif
2130 #if (NTDDI_VERSION >= NTDDI_VISTA)
2131 #if (NTDDI_VERSION >= NTDDI_WIN7)
2132 USHORT UserModeGlobalLogger[16];
2133 #else
2134 USHORT UserModeGlobalLogger[8];
2135 ULONG HeapTracingPid[2];
2136 ULONG CritSecTracingPid[2];
2137 #endif
2138 ULONG ImageFileExecutionOptions;
2139 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
2140 ULONG LangGenerationCount;
2141 #else
2142 /* 4 bytes padding */
2143 #endif
2144 ULONGLONG Reserved5;
2145 volatile ULONG64 InterruptTimeBias;
2146 #endif
2147 #if (NTDDI_VERSION >= NTDDI_WIN7)
2148 volatile ULONG64 TscQpcBias;
2149 volatile ULONG ActiveProcessorCount;
2150 volatile USHORT ActiveGroupCount;
2151 USHORT Reserved4;
2152 volatile ULONG AitSamplingValue;
2153 volatile ULONG AppCompatFlag;
2154 ULONGLONG SystemDllNativeRelocation;
2155 ULONG SystemDllWowRelocation;
2156 ULONG XStatePad[1];
2157 XSTATE_CONFIGURATION XState;
2158 #endif
2159 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
2160
2161 #if (NTDDI_VERSION >= NTDDI_VISTA)
2162 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
2163 #elif (NTDDI_VERSION >= NTDDI_WINXP)
2164 extern NTSYSAPI CCHAR KeNumberProcessors;
2165 #else
2166 extern PCCHAR KeNumberProcessors;
2167 #endif
2168
2169
2170 /******************************************************************************
2171 * Kernel Debugger Types *
2172 ******************************************************************************/
2173 typedef struct _DEBUG_DEVICE_ADDRESS {
2174 UCHAR Type;
2175 BOOLEAN Valid;
2176 UCHAR Reserved[2];
2177 PUCHAR TranslatedAddress;
2178 ULONG Length;
2179 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
2180
2181 typedef struct _DEBUG_MEMORY_REQUIREMENTS {
2182 PHYSICAL_ADDRESS Start;
2183 PHYSICAL_ADDRESS MaxEnd;
2184 PVOID VirtualAddress;
2185 ULONG Length;
2186 BOOLEAN Cached;
2187 BOOLEAN Aligned;
2188 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
2189
2190 typedef struct _DEBUG_DEVICE_DESCRIPTOR {
2191 ULONG Bus;
2192 ULONG Slot;
2193 USHORT Segment;
2194 USHORT VendorID;
2195 USHORT DeviceID;
2196 UCHAR BaseClass;
2197 UCHAR SubClass;
2198 UCHAR ProgIf;
2199 BOOLEAN Initialized;
2200 BOOLEAN Configured;
2201 DEBUG_DEVICE_ADDRESS BaseAddress[6];
2202 DEBUG_MEMORY_REQUIREMENTS Memory;
2203 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
2204
2205 typedef NTSTATUS
2206 (NTAPI *pKdSetupPciDeviceForDebugging)(
2207 _In_opt_ PVOID LoaderBlock,
2208 _Inout_ PDEBUG_DEVICE_DESCRIPTOR PciDevice);
2209
2210 typedef NTSTATUS
2211 (NTAPI *pKdReleasePciDeviceForDebugging)(
2212 _Inout_ PDEBUG_DEVICE_DESCRIPTOR PciDevice);
2213
2214 typedef PVOID
2215 (NTAPI *pKdGetAcpiTablePhase0)(
2216 _In_ struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2217 _In_ ULONG Signature);
2218
2219 typedef VOID
2220 (NTAPI *pKdCheckPowerButton)(VOID);
2221
2222 #if (NTDDI_VERSION >= NTDDI_VISTA)
2223 typedef PVOID
2224 (NTAPI *pKdMapPhysicalMemory64)(
2225 _In_ PHYSICAL_ADDRESS PhysicalAddress,
2226 _In_ ULONG NumberPages,
2227 _In_ BOOLEAN FlushCurrentTLB);
2228
2229 typedef VOID
2230 (NTAPI *pKdUnmapVirtualAddress)(
2231 _In_ PVOID VirtualAddress,
2232 _In_ ULONG NumberPages,
2233 _In_ BOOLEAN FlushCurrentTLB);
2234 #else
2235 typedef PVOID
2236 (NTAPI *pKdMapPhysicalMemory64)(
2237 _In_ PHYSICAL_ADDRESS PhysicalAddress,
2238 _In_ ULONG NumberPages);
2239
2240 typedef VOID
2241 (NTAPI *pKdUnmapVirtualAddress)(
2242 _In_ PVOID VirtualAddress,
2243 _In_ ULONG NumberPages);
2244 #endif
2245
2246 typedef ULONG
2247 (NTAPI *pKdGetPciDataByOffset)(
2248 _In_ ULONG BusNumber,
2249 _In_ ULONG SlotNumber,
2250 _Out_writes_bytes_(Length) PVOID Buffer,
2251 _In_ ULONG Offset,
2252 _In_ ULONG Length);
2253
2254 typedef ULONG
2255 (NTAPI *pKdSetPciDataByOffset)(
2256 _In_ ULONG BusNumber,
2257 _In_ ULONG SlotNumber,
2258 _In_reads_bytes_(Length) PVOID Buffer,
2259 _In_ ULONG Offset,
2260 _In_ ULONG Length);
2261 /******************************************************************************
2262 * Memory manager Types *
2263 ******************************************************************************/
2264
2265 typedef struct _PHYSICAL_MEMORY_RANGE {
2266 PHYSICAL_ADDRESS BaseAddress;
2267 LARGE_INTEGER NumberOfBytes;
2268 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
2269
2270 typedef NTSTATUS
2271 (NTAPI *PMM_ROTATE_COPY_CALLBACK_FUNCTION)(
2272 _In_ PMDL DestinationMdl,
2273 _In_ PMDL SourceMdl,
2274 _In_ PVOID Context);
2275
2276 typedef enum _MM_ROTATE_DIRECTION {
2277 MmToFrameBuffer,
2278 MmToFrameBufferNoCopy,
2279 MmToRegularMemory,
2280 MmToRegularMemoryNoCopy,
2281 MmMaximumRotateDirection
2282 } MM_ROTATE_DIRECTION, *PMM_ROTATE_DIRECTION;
2283
2284
2285 /******************************************************************************
2286 * Process Manager Types *
2287 ******************************************************************************/
2288
2289 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
2290 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
2291 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
2292 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
2293 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
2294
2295 typedef struct _QUOTA_LIMITS {
2296 SIZE_T PagedPoolLimit;
2297 SIZE_T NonPagedPoolLimit;
2298 SIZE_T MinimumWorkingSetSize;
2299 SIZE_T MaximumWorkingSetSize;
2300 SIZE_T PagefileLimit;
2301 LARGE_INTEGER TimeLimit;
2302 } QUOTA_LIMITS, *PQUOTA_LIMITS;
2303
2304 typedef union _RATE_QUOTA_LIMIT {
2305 ULONG RateData;
2306 _ANONYMOUS_STRUCT struct {
2307 ULONG RatePercent:7;
2308 ULONG Reserved0:25;
2309 } DUMMYSTRUCTNAME;
2310 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
2311
2312 typedef struct _QUOTA_LIMITS_EX {
2313 SIZE_T PagedPoolLimit;
2314 SIZE_T NonPagedPoolLimit;
2315 SIZE_T MinimumWorkingSetSize;
2316 SIZE_T MaximumWorkingSetSize;
2317 SIZE_T PagefileLimit;
2318 LARGE_INTEGER TimeLimit;
2319 SIZE_T WorkingSetLimit;
2320 SIZE_T Reserved2;
2321 SIZE_T Reserved3;
2322 SIZE_T Reserved4;
2323 ULONG Flags;
2324 RATE_QUOTA_LIMIT CpuRateLimit;
2325 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
2326
2327 typedef struct _IO_COUNTERS {
2328 ULONGLONG ReadOperationCount;
2329 ULONGLONG WriteOperationCount;
2330 ULONGLONG OtherOperationCount;
2331 ULONGLONG ReadTransferCount;
2332 ULONGLONG WriteTransferCount;
2333 ULONGLONG OtherTransferCount;
2334 } IO_COUNTERS, *PIO_COUNTERS;
2335
2336 typedef struct _VM_COUNTERS {
2337 SIZE_T PeakVirtualSize;
2338 SIZE_T VirtualSize;
2339 ULONG PageFaultCount;
2340 SIZE_T PeakWorkingSetSize;
2341 SIZE_T WorkingSetSize;
2342 SIZE_T QuotaPeakPagedPoolUsage;
2343 SIZE_T QuotaPagedPoolUsage;
2344 SIZE_T QuotaPeakNonPagedPoolUsage;
2345 SIZE_T QuotaNonPagedPoolUsage;
2346 SIZE_T PagefileUsage;
2347 SIZE_T PeakPagefileUsage;
2348 } VM_COUNTERS, *PVM_COUNTERS;
2349
2350 typedef struct _VM_COUNTERS_EX {
2351 SIZE_T PeakVirtualSize;
2352 SIZE_T VirtualSize;
2353 ULONG PageFaultCount;
2354 SIZE_T PeakWorkingSetSize;
2355 SIZE_T WorkingSetSize;
2356 SIZE_T QuotaPeakPagedPoolUsage;
2357 SIZE_T QuotaPagedPoolUsage;
2358 SIZE_T QuotaPeakNonPagedPoolUsage;
2359 SIZE_T QuotaNonPagedPoolUsage;
2360 SIZE_T PagefileUsage;
2361 SIZE_T PeakPagefileUsage;
2362 SIZE_T PrivateUsage;
2363 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
2364
2365 #define MAX_HW_COUNTERS 16
2366 #define THREAD_PROFILING_FLAG_DISPATCH 0x00000001
2367
2368 typedef enum _HARDWARE_COUNTER_TYPE {
2369 PMCCounter,
2370 MaxHardwareCounterType
2371 } HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE;
2372
2373 typedef struct _HARDWARE_COUNTER {
2374 HARDWARE_COUNTER_TYPE Type;
2375 ULONG Reserved;
2376 ULONG64 Index;
2377 } HARDWARE_COUNTER, *PHARDWARE_COUNTER;
2378
2379 typedef struct _POOLED_USAGE_AND_LIMITS {
2380 SIZE_T PeakPagedPoolUsage;
2381 SIZE_T PagedPoolUsage;
2382 SIZE_T PagedPoolLimit;
2383 SIZE_T PeakNonPagedPoolUsage;
2384 SIZE_T NonPagedPoolUsage;
2385 SIZE_T NonPagedPoolLimit;
2386 SIZE_T PeakPagefileUsage;
2387 SIZE_T PagefileUsage;
2388 SIZE_T PagefileLimit;
2389 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
2390
2391 typedef struct _PROCESS_ACCESS_TOKEN {
2392 HANDLE Token;
2393 HANDLE Thread;
2394 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
2395
2396 #define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL
2397 #define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1))
2398
2399 typedef struct _PROCESS_EXCEPTION_PORT {
2400 _In_ HANDLE ExceptionPortHandle;
2401 _Inout_ ULONG StateFlags;
2402 } PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT;
2403
2404 typedef VOID
2405 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
2406 _In_ HANDLE ParentId,
2407 _In_ HANDLE ProcessId,
2408 _In_ BOOLEAN Create);
2409
2410 typedef struct _PS_CREATE_NOTIFY_INFO {
2411 _In_ SIZE_T Size;
2412 _ANONYMOUS_UNION union {
2413 _In_ ULONG Flags;
2414 _ANONYMOUS_STRUCT struct {
2415 _In_ ULONG FileOpenNameAvailable:1;
2416 _In_ ULONG Reserved:31;
2417 } DUMMYSTRUCTNAME;
2418 } DUMMYUNIONNAME;
2419 _In_ HANDLE ParentProcessId;
2420 _In_ CLIENT_ID CreatingThreadId;
2421 _Inout_ struct _FILE_OBJECT *FileObject;
2422 _In_ PCUNICODE_STRING ImageFileName;
2423 _In_opt_ PCUNICODE_STRING CommandLine;
2424 _Inout_ NTSTATUS CreationStatus;
2425 } PS_CREATE_NOTIFY_INFO, *PPS_CREATE_NOTIFY_INFO;
2426
2427 typedef VOID
2428 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE_EX)(
2429 _Inout_ PEPROCESS Process,
2430 _In_ HANDLE ProcessId,
2431 _Inout_opt_ PPS_CREATE_NOTIFY_INFO CreateInfo);
2432
2433 typedef VOID
2434 (NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
2435 _In_ HANDLE ProcessId,
2436 _In_ HANDLE ThreadId,
2437 _In_ BOOLEAN Create);
2438
2439 #define IMAGE_ADDRESSING_MODE_32BIT 3
2440
2441 typedef struct _IMAGE_INFO {
2442 _ANONYMOUS_UNION union {
2443 ULONG Properties;
2444 _ANONYMOUS_STRUCT struct {
2445 ULONG ImageAddressingMode:8;
2446 ULONG SystemModeImage:1;
2447 ULONG ImageMappedToAllPids:1;
2448 ULONG ExtendedInfoPresent:1;
2449 ULONG Reserved:21;
2450 } DUMMYSTRUCTNAME;
2451 } DUMMYUNIONNAME;
2452 PVOID ImageBase;
2453 ULONG ImageSelector;
2454 SIZE_T ImageSize;
2455 ULONG ImageSectionNumber;
2456 } IMAGE_INFO, *PIMAGE_INFO;
2457
2458 typedef struct _IMAGE_INFO_EX {
2459 SIZE_T Size;
2460 IMAGE_INFO ImageInfo;
2461 struct _FILE_OBJECT *FileObject;
2462 } IMAGE_INFO_EX, *PIMAGE_INFO_EX;
2463
2464 typedef VOID
2465 (NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
2466 _In_ PUNICODE_STRING FullImageName,
2467 _In_ HANDLE ProcessId,
2468 _In_ PIMAGE_INFO ImageInfo);
2469
2470 #define THREAD_CSWITCH_PMU_DISABLE FALSE
2471 #define THREAD_CSWITCH_PMU_ENABLE TRUE
2472
2473 #define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001
2474
2475 #define PROCESS_HANDLE_TRACING_MAX_STACKS 16
2476
2477 typedef enum _PROCESSINFOCLASS {
2478 ProcessBasicInformation,
2479 ProcessQuotaLimits,
2480 ProcessIoCounters,
2481 ProcessVmCounters,
2482 ProcessTimes,
2483 ProcessBasePriority,
2484 ProcessRaisePriority,
2485 ProcessDebugPort,
2486 ProcessExceptionPort,
2487 ProcessAccessToken,
2488 ProcessLdtInformation,
2489 ProcessLdtSize,
2490 ProcessDefaultHardErrorMode,
2491 ProcessIoPortHandlers,
2492 ProcessPooledUsageAndLimits,
2493 ProcessWorkingSetWatch,
2494 ProcessUserModeIOPL,
2495 ProcessEnableAlignmentFaultFixup,
2496 ProcessPriorityClass,
2497 ProcessWx86Information,
2498 ProcessHandleCount,
2499 ProcessAffinityMask,
2500 ProcessPriorityBoost,
2501 ProcessDeviceMap,
2502 ProcessSessionInformation,
2503 ProcessForegroundInformation,
2504 ProcessWow64Information,
2505 ProcessImageFileName,
2506 ProcessLUIDDeviceMapsEnabled,
2507 ProcessBreakOnTermination,
2508 ProcessDebugObjectHandle,
2509 ProcessDebugFlags,
2510 ProcessHandleTracing,
2511 ProcessIoPriority,
2512 ProcessExecuteFlags,
2513 ProcessTlsInformation,
2514 ProcessCookie,
2515 ProcessImageInformation,
2516 ProcessCycleTime,
2517 ProcessPagePriority,
2518 ProcessInstrumentationCallback,
2519 ProcessThreadStackAllocation,
2520 ProcessWorkingSetWatchEx,
2521 ProcessImageFileNameWin32,
2522 ProcessImageFileMapping,
2523 ProcessAffinityUpdateMode,
2524 ProcessMemoryAllocationMode,
2525 ProcessGroupInformation,
2526 ProcessTokenVirtualizationEnabled,
2527 ProcessConsoleHostProcess,
2528 ProcessWindowInformation,
2529 MaxProcessInfoClass
2530 } PROCESSINFOCLASS;
2531
2532 typedef enum _THREADINFOCLASS {
2533 ThreadBasicInformation,
2534 ThreadTimes,
2535 ThreadPriority,
2536 ThreadBasePriority,
2537 ThreadAffinityMask,
2538 ThreadImpersonationToken,
2539 ThreadDescriptorTableEntry,
2540 ThreadEnableAlignmentFaultFixup,
2541 ThreadEventPair_Reusable,
2542 ThreadQuerySetWin32StartAddress,
2543 ThreadZeroTlsCell,
2544 ThreadPerformanceCount,
2545 ThreadAmILastThread,
2546 ThreadIdealProcessor,
2547 ThreadPriorityBoost,
2548 ThreadSetTlsArrayAddress,
2549 ThreadIsIoPending,
2550 ThreadHideFromDebugger,
2551 ThreadBreakOnTermination,
2552 ThreadSwitchLegacyState,
2553 ThreadIsTerminated,
2554 ThreadLastSystemCall,
2555 ThreadIoPriority,
2556 ThreadCycleTime,
2557 ThreadPagePriority,
2558 ThreadActualBasePriority,
2559 ThreadTebInformation,
2560 ThreadCSwitchMon,
2561 ThreadCSwitchPmu,
2562 ThreadWow64Context,
2563 ThreadGroupInformation,
2564 ThreadUmsInformation,
2565 ThreadCounterProfiling,
2566 ThreadIdealProcessorEx,
2567 MaxThreadInfoClass
2568 } THREADINFOCLASS;
2569
2570 typedef struct _PAGE_PRIORITY_INFORMATION {
2571 ULONG PagePriority;
2572 } PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION;
2573
2574 typedef struct _PROCESS_WS_WATCH_INFORMATION {
2575 PVOID FaultingPc;
2576 PVOID FaultingVa;
2577 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
2578
2579 typedef struct _PROCESS_BASIC_INFORMATION {
2580 NTSTATUS ExitStatus;
2581 struct _PEB *PebBaseAddress;
2582 ULONG_PTR AffinityMask;
2583 KPRIORITY BasePriority;
2584 ULONG_PTR UniqueProcessId;
2585 ULONG_PTR InheritedFromUniqueProcessId;
2586 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
2587
2588 typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION {
2589 SIZE_T Size;
2590 PROCESS_BASIC_INFORMATION BasicInfo;
2591 _ANONYMOUS_UNION union {
2592 ULONG Flags;
2593 _ANONYMOUS_STRUCT struct {
2594 ULONG IsProtectedProcess:1;
2595 ULONG IsWow64Process:1;
2596 ULONG IsProcessDeleting:1;
2597 ULONG IsCrossSessionCreate:1;
2598 ULONG SpareBits:28;
2599 } DUMMYSTRUCTNAME;
2600 } DUMMYUNIONNAME;
2601 } PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION;
2602
2603 typedef struct _PROCESS_DEVICEMAP_INFORMATION {
2604 _ANONYMOUS_UNION union {
2605 struct {
2606 HANDLE DirectoryHandle;
2607 } Set;
2608 struct {
2609 ULONG DriveMap;
2610 UCHAR DriveType[32];
2611 } Query;
2612 } DUMMYUNIONNAME;
2613 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
2614
2615 typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX {
2616 _ANONYMOUS_UNION union {
2617 struct {
2618 HANDLE DirectoryHandle;
2619 } Set;
2620 struct {
2621 ULONG DriveMap;
2622 UCHAR DriveType[32];
2623 } Query;
2624 } DUMMYUNIONNAME;
2625 ULONG Flags;
2626 } PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
2627
2628 typedef struct _PROCESS_SESSION_INFORMATION {
2629 ULONG SessionId;
2630 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
2631
2632 typedef struct _PROCESS_HANDLE_TRACING_ENABLE {
2633 ULONG Flags;
2634 } PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE;
2635
2636 typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX {
2637 ULONG Flags;
2638 ULONG TotalSlots;
2639 } PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX;
2640
2641 typedef struct _PROCESS_HANDLE_TRACING_ENTRY {
2642 HANDLE Handle;
2643 CLIENT_ID ClientId;
2644 ULONG Type;
2645 PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS];
2646 } PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY;
2647
2648 typedef struct _PROCESS_HANDLE_TRACING_QUERY {
2649 HANDLE Handle;
2650 ULONG TotalTraces;
2651 PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1];
2652 } PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY;
2653
2654 extern NTKERNELAPI PEPROCESS PsInitialSystemProcess;
2655
2656
2657 /******************************************************************************
2658 * Runtime Library Types *
2659 ******************************************************************************/
2660
2661
2662 #ifndef _RTL_RUN_ONCE_DEF
2663 #define _RTL_RUN_ONCE_DEF
2664
2665 #define RTL_RUN_ONCE_INIT {0}
2666
2667 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL
2668 #define RTL_RUN_ONCE_ASYNC 0x00000002UL
2669 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL
2670
2671 #define RTL_RUN_ONCE_CTX_RESERVED_BITS 2
2672
2673 #define RTL_HASH_ALLOCATED_HEADER 0x00000001
2674
2675 #define RTL_HASH_RESERVED_SIGNATURE 0
2676
2677 /* RtlVerifyVersionInfo() ComparisonType */
2678
2679 #define VER_EQUAL 1
2680 #define VER_GREATER 2
2681 #define VER_GREATER_EQUAL 3
2682 #define VER_LESS 4
2683 #define VER_LESS_EQUAL 5
2684 #define VER_AND 6
2685 #define VER_OR 7
2686
2687 #define VER_CONDITION_MASK 7
2688 #define VER_NUM_BITS_PER_CONDITION_MASK 3
2689
2690 /* RtlVerifyVersionInfo() TypeMask */
2691
2692 #define VER_MINORVERSION 0x0000001
2693 #define VER_MAJORVERSION 0x0000002
2694 #define VER_BUILDNUMBER 0x0000004
2695 #define VER_PLATFORMID 0x0000008
2696 #define VER_SERVICEPACKMINOR 0x0000010
2697 #define VER_SERVICEPACKMAJOR 0x0000020
2698 #define VER_SUITENAME 0x0000040
2699 #define VER_PRODUCT_TYPE 0x0000080
2700
2701 #define VER_NT_WORKSTATION 0x0000001
2702 #define VER_NT_DOMAIN_CONTROLLER 0x0000002
2703 #define VER_NT_SERVER 0x0000003
2704
2705 #define VER_PLATFORM_WIN32s 0
2706 #define VER_PLATFORM_WIN32_WINDOWS 1
2707 #define VER_PLATFORM_WIN32_NT 2
2708
2709 typedef union _RTL_RUN_ONCE {
2710 PVOID Ptr;
2711 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
2712
2713 _Function_class_(RTL_RUN_ONCE_INIT_FN)
2714 _IRQL_requires_same_
2715 typedef ULONG /* LOGICAL */
2716 (NTAPI *PRTL_RUN_ONCE_INIT_FN) (
2717 _Inout_ PRTL_RUN_ONCE RunOnce,
2718 _Inout_opt_ PVOID Parameter,
2719 _Inout_opt_ PVOID *Context);
2720
2721 #endif /* _RTL_RUN_ONCE_DEF */
2722
2723 typedef enum _TABLE_SEARCH_RESULT {
2724 TableEmptyTree,
2725 TableFoundNode,
2726 TableInsertAsLeft,
2727 TableInsertAsRight
2728 } TABLE_SEARCH_RESULT;
2729
2730 typedef enum _RTL_GENERIC_COMPARE_RESULTS {
2731 GenericLessThan,
2732 GenericGreaterThan,
2733 GenericEqual
2734 } RTL_GENERIC_COMPARE_RESULTS;
2735
2736 // Forwarder
2737 struct _RTL_AVL_TABLE;
2738
2739 _IRQL_requires_same_
2740 _Function_class_(RTL_AVL_COMPARE_ROUTINE)
2741 typedef RTL_GENERIC_COMPARE_RESULTS
2742 (NTAPI RTL_AVL_COMPARE_ROUTINE) (
2743 _In_ struct _RTL_AVL_TABLE *Table,
2744 _In_ PVOID FirstStruct,
2745 _In_ PVOID SecondStruct);
2746 typedef RTL_AVL_COMPARE_ROUTINE *PRTL_AVL_COMPARE_ROUTINE;
2747
2748 _IRQL_requires_same_
2749 _Function_class_(RTL_AVL_ALLOCATE_ROUTINE)
2750 __drv_allocatesMem(Mem)
2751 typedef PVOID
2752 (NTAPI RTL_AVL_ALLOCATE_ROUTINE) (
2753 _In_ struct _RTL_AVL_TABLE *Table,
2754 _In_ CLONG ByteSize);
2755 typedef RTL_AVL_ALLOCATE_ROUTINE *PRTL_AVL_ALLOCATE_ROUTINE;
2756
2757 _IRQL_requires_same_
2758 _Function_class_(RTL_AVL_FREE_ROUTINE)
2759 typedef VOID
2760 (NTAPI RTL_AVL_FREE_ROUTINE) (
2761 _In_ struct _RTL_AVL_TABLE *Table,
2762 _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer);
2763 typedef RTL_AVL_FREE_ROUTINE *PRTL_AVL_FREE_ROUTINE;
2764
2765 _IRQL_requires_same_
2766 _Function_class_(RTL_AVL_MATCH_FUNCTION)
2767 typedef NTSTATUS
2768 (NTAPI RTL_AVL_MATCH_FUNCTION) (
2769 _In_ struct _RTL_AVL_TABLE *Table,
2770 _In_ PVOID UserData,
2771 _In_ PVOID MatchData);
2772 typedef RTL_AVL_MATCH_FUNCTION *PRTL_AVL_MATCH_FUNCTION;
2773
2774 typedef struct _RTL_BALANCED_LINKS {
2775 struct _RTL_BALANCED_LINKS *Parent;
2776 struct _RTL_BALANCED_LINKS *LeftChild;
2777 struct _RTL_BALANCED_LINKS *RightChild;
2778 CHAR Balance;
2779 UCHAR Reserved[3];
2780 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
2781
2782 typedef struct _RTL_AVL_TABLE {
2783 RTL_BALANCED_LINKS BalancedRoot;
2784 PVOID OrderedPointer;
2785 ULONG WhichOrderedElement;
2786 ULONG NumberGenericTableElements;
2787 ULONG DepthOfTree;
2788 PRTL_BALANCED_LINKS RestartKey;
2789 ULONG DeleteCount;
2790 PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
2791 PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
2792 PRTL_AVL_FREE_ROUTINE FreeRoutine;
2793 PVOID TableContext;
2794 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
2795
2796 typedef struct _RTL_SPLAY_LINKS {
2797 struct _RTL_SPLAY_LINKS *Parent;
2798 struct _RTL_SPLAY_LINKS *LeftChild;
2799 struct _RTL_SPLAY_LINKS *RightChild;
2800 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
2801
2802 #ifndef RTL_USE_AVL_TABLES
2803
2804 struct _RTL_GENERIC_TABLE;
2805
2806 _IRQL_requires_same_
2807 _Function_class_(RTL_GENERIC_COMPARE_ROUTINE)
2808 typedef RTL_GENERIC_COMPARE_RESULTS
2809 (NTAPI RTL_GENERIC_COMPARE_ROUTINE) (
2810 _In_ struct _RTL_GENERIC_TABLE *Table,
2811 _In_ PVOID FirstStruct,
2812 _In_ PVOID SecondStruct);
2813 typedef RTL_GENERIC_COMPARE_ROUTINE *PRTL_GENERIC_COMPARE_ROUTINE;
2814
2815 _IRQL_requires_same_
2816 _Function_class_(RTL_GENERIC_ALLOCATE_ROUTINE)
2817 __drv_allocatesMem(Mem)
2818 typedef PVOID
2819 (NTAPI RTL_GENERIC_ALLOCATE_ROUTINE) (
2820 _In_ struct _RTL_GENERIC_TABLE *Table,
2821 _In_ CLONG ByteSize);
2822 typedef RTL_GENERIC_ALLOCATE_ROUTINE *PRTL_GENERIC_ALLOCATE_ROUTINE;
2823
2824 _IRQL_requires_same_
2825 _Function_class_(RTL_GENERIC_FREE_ROUTINE)
2826 typedef VOID
2827 (NTAPI RTL_GENERIC_FREE_ROUTINE) (
2828 _In_ struct _RTL_GENERIC_TABLE *Table,
2829 _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer);
2830 typedef RTL_GENERIC_FREE_ROUTINE *PRTL_GENERIC_FREE_ROUTINE;
2831
2832 typedef struct _RTL_GENERIC_TABLE {
2833 PRTL_SPLAY_LINKS TableRoot;
2834 LIST_ENTRY InsertOrderList;
2835 PLIST_ENTRY OrderedPointer;
2836 ULONG WhichOrderedElement;
2837 ULONG NumberGenericTableElements;
2838 PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine;
2839 PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine;
2840 PRTL_GENERIC_FREE_ROUTINE FreeRoutine;
2841 PVOID TableContext;
2842 } RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
2843
2844 #endif /* !RTL_USE_AVL_TABLES */
2845
2846 #ifdef RTL_USE_AVL_TABLES
2847
2848 #undef RTL_GENERIC_COMPARE_ROUTINE
2849 #undef PRTL_GENERIC_COMPARE_ROUTINE
2850 #undef RTL_GENERIC_ALLOCATE_ROUTINE
2851 #undef PRTL_GENERIC_ALLOCATE_ROUTINE
2852 #undef RTL_GENERIC_FREE_ROUTINE
2853 #undef PRTL_GENERIC_FREE_ROUTINE
2854 #undef RTL_GENERIC_TABLE
2855 #undef PRTL_GENERIC_TABLE
2856
2857 #define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE
2858 #define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE
2859 #define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE
2860 #define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE
2861 #define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE
2862 #define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE
2863 #define RTL_GENERIC_TABLE RTL_AVL_TABLE
2864 #define PRTL_GENERIC_TABLE PRTL_AVL_TABLE
2865
2866 #endif /* RTL_USE_AVL_TABLES */
2867
2868 #define RTL_HASH_ALLOCATED_HEADER 0x00000001
2869
2870 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY {
2871 LIST_ENTRY Linkage;
2872 ULONG_PTR Signature;
2873 } RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY;
2874
2875 typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT {
2876 PLIST_ENTRY ChainHead;
2877 PLIST_ENTRY PrevLinkage;
2878 ULONG_PTR Signature;
2879 } RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT;
2880
2881 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR {
2882 RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry;
2883 PLIST_ENTRY ChainHead;
2884 ULONG BucketIndex;
2885 } RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR;
2886
2887 typedef struct _RTL_DYNAMIC_HASH_TABLE {
2888 ULONG Flags;
2889 ULONG Shift;
2890 ULONG TableSize;
2891 ULONG Pivot;
2892 ULONG DivisorMask;
2893 ULONG NumEntries;
2894 ULONG NonEmptyBuckets;
2895 ULONG NumEnumerators;
2896 PVOID Directory;
2897 } RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE;
2898
2899 #define HASH_ENTRY_KEY(x) ((x)->Signature)
2900
2901 /******************************************************************************
2902 * Security Manager Types *
2903 ******************************************************************************/
2904 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
2905
2906
2907 typedef enum _WELL_KNOWN_SID_TYPE {
2908 WinNullSid = 0,
2909 WinWorldSid = 1,
2910 WinLocalSid = 2,
2911 WinCreatorOwnerSid = 3,
2912 WinCreatorGroupSid = 4,
2913 WinCreatorOwnerServerSid = 5,
2914 WinCreatorGroupServerSid = 6,
2915 WinNtAuthoritySid = 7,
2916 WinDialupSid = 8,
2917 WinNetworkSid = 9,
2918 WinBatchSid = 10,
2919 WinInteractiveSid = 11,
2920 WinServiceSid = 12,
2921 WinAnonymousSid = 13,
2922 WinProxySid = 14,
2923 WinEnterpriseControllersSid = 15,
2924 WinSelfSid = 16,
2925 WinAuthenticatedUserSid = 17,
2926 WinRestrictedCodeSid = 18,
2927 WinTerminalServerSid = 19,
2928 WinRemoteLogonIdSid = 20,
2929 WinLogonIdsSid = 21,
2930 WinLocalSystemSid = 22,
2931 WinLocalServiceSid = 23,
2932 WinNetworkServiceSid = 24,
2933 WinBuiltinDomainSid = 25,
2934 WinBuiltinAdministratorsSid = 26,
2935 WinBuiltinUsersSid = 27,
2936 WinBuiltinGuestsSid = 28,
2937 WinBuiltinPowerUsersSid = 29,
2938 WinBuiltinAccountOperatorsSid = 30,
2939 WinBuiltinSystemOperatorsSid = 31,
2940 WinBuiltinPrintOperatorsSid = 32,
2941 WinBuiltinBackupOperatorsSid = 33,
2942 WinBuiltinReplicatorSid = 34,
2943 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
2944 WinBuiltinRemoteDesktopUsersSid = 36,
2945 WinBuiltinNetworkConfigurationOperatorsSid = 37,
2946 WinAccountAdministratorSid = 38,
2947 WinAccountGuestSid = 39,
2948 WinAccountKrbtgtSid = 40,
2949 WinAccountDomainAdminsSid = 41,
2950 WinAccountDomainUsersSid = 42,
2951 WinAccountDomainGuestsSid = 43,
2952 WinAccountComputersSid = 44,
2953 WinAccountControllersSid = 45,
2954 WinAccountCertAdminsSid = 46,
2955 WinAccountSchemaAdminsSid = 47,
2956 WinAccountEnterpriseAdminsSid = 48,
2957 WinAccountPolicyAdminsSid = 49,
2958 WinAccountRasAndIasServersSid = 50,
2959 WinNTLMAuthenticationSid = 51,
2960 WinDigestAuthenticationSid = 52,
2961 WinSChannelAuthenticationSid = 53,
2962 WinThisOrganizationSid = 54,
2963 WinOtherOrganizationSid = 55,
2964 WinBuiltinIncomingForestTrustBuildersSid = 56,
2965 WinBuiltinPerfMonitoringUsersSid = 57,
2966 WinBuiltinPerfLoggingUsersSid = 58,
2967 WinBuiltinAuthorizationAccessSid = 59,
2968 WinBuiltinTerminalServerLicenseServersSid = 60,
2969 WinBuiltinDCOMUsersSid = 61,
2970 WinBuiltinIUsersSid = 62,
2971 WinIUserSid = 63,
2972 WinBuiltinCryptoOperatorsSid = 64,
2973 WinUntrustedLabelSid = 65,
2974 WinLowLabelSid = 66,
2975 WinMediumLabelSid = 67,
2976 WinHighLabelSid = 68,
2977 WinSystemLabelSid = 69,
2978 WinWriteRestrictedCodeSid = 70,
2979 WinCreatorOwnerRightsSid = 71,
2980 WinCacheablePrincipalsGroupSid = 72,
2981 WinNonCacheablePrincipalsGroupSid = 73,
2982 WinEnterpriseReadonlyControllersSid = 74,
2983 WinAccountReadonlyControllersSid = 75,
2984 WinBuiltinEventLogReadersGroup = 76,
2985 WinNewEnterpriseReadonlyControllersSid = 77,
2986 WinBuiltinCertSvcDComAccessGroup = 78,
2987 WinMediumPlusLabelSid = 79,
2988 WinLocalLogonSid = 80,
2989 WinConsoleLogonSid = 81,
2990 WinThisOrganizationCertificateSid = 82,
2991 } WELL_KNOWN_SID_TYPE;
2992
2993
2994 #if defined(_M_IX86)
2995
2996 #define PAUSE_PROCESSOR YieldProcessor();
2997
2998 #define KERNEL_STACK_SIZE 12288
2999 #define KERNEL_LARGE_STACK_SIZE 61440
3000 #define KERNEL_LARGE_STACK_COMMIT 12288
3001
3002 #define SIZE_OF_80387_REGISTERS 80
3003
3004 #if !defined(RC_INVOKED)
3005
3006 #define CONTEXT_i386 0x10000
3007 #define CONTEXT_i486 0x10000
3008 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
3009 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
3010 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
3011 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
3012 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
3013 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
3014
3015 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
3016 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
3017 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \
3018 CONTEXT_EXTENDED_REGISTERS)
3019
3020 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L)
3021
3022 #endif /* !defined(RC_INVOKED) */
3023
3024 typedef struct _FLOATING_SAVE_AREA {
3025 ULONG ControlWord;
3026 ULONG StatusWord;
3027 ULONG TagWord;
3028 ULONG ErrorOffset;
3029 ULONG ErrorSelector;
3030 ULONG DataOffset;
3031 ULONG DataSelector;
3032 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
3033 ULONG Cr0NpxState;
3034 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
3035
3036 #include "pshpack4.h"
3037 typedef struct _CONTEXT {
3038 ULONG ContextFlags;
3039 ULONG Dr0;
3040 ULONG Dr1;
3041 ULONG Dr2;
3042 ULONG Dr3;
3043 ULONG Dr6;
3044 ULONG Dr7;
3045 FLOATING_SAVE_AREA FloatSave;
3046 ULONG SegGs;
3047 ULONG SegFs;
3048 ULONG SegEs;
3049 ULONG SegDs;
3050 ULONG Edi;
3051 ULONG Esi;
3052 ULONG Ebx;
3053 ULONG Edx;
3054 ULONG Ecx;
3055 ULONG Eax;
3056 ULONG Ebp;
3057 ULONG Eip;
3058 ULONG SegCs;
3059 ULONG EFlags;
3060 ULONG Esp;
3061 ULONG SegSs;
3062 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
3063 } CONTEXT;
3064 #include "poppack.h"
3065
3066 #define KeGetPcr() PCR
3067
3068 #define PCR_MINOR_VERSION 1
3069 #define PCR_MAJOR_VERSION 1
3070
3071 typedef struct _KPCR {
3072 union {
3073 NT_TIB NtTib;
3074 struct {
3075 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
3076 PVOID Used_StackBase;
3077 PVOID Spare2;
3078 PVOID TssCopy;
3079 ULONG ContextSwitches;
3080 KAFFINITY SetMemberCopy;
3081 PVOID Used_Self;
3082 };
3083 };
3084 struct _KPCR *SelfPcr;
3085 struct _KPRCB *Prcb;
3086 KIRQL Irql;
3087 ULONG IRR;
3088 ULONG IrrActive;
3089 ULONG IDR;
3090 PVOID KdVersionBlock;
3091 struct _KIDTENTRY *IDT;
3092 struct _KGDTENTRY *GDT;
3093 struct _KTSS *TSS;
3094 USHORT MajorVersion;
3095 USHORT MinorVersion;
3096 KAFFINITY SetMember;
3097 ULONG StallScaleFactor;
3098 UCHAR SpareUnused;
3099 UCHAR Number;
3100 UCHAR Spare0;
3101 UCHAR SecondLevelCacheAssociativity;
3102 ULONG VdmAlert;
3103 ULONG KernelReserved[14];
3104 ULONG SecondLevelCacheSize;
3105 ULONG HalReserved[16];
3106 } KPCR, *PKPCR;
3107
3108 FORCEINLINE
3109 ULONG
3110 KeGetCurrentProcessorNumber(VOID)
3111 {
3112 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
3113 }
3114
3115
3116
3117
3118
3119
3120 extern NTKERNELAPI PVOID MmHighestUserAddress;
3121 extern NTKERNELAPI PVOID MmSystemRangeStart;
3122 extern NTKERNELAPI ULONG MmUserProbeAddress;
3123
3124 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3125 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3126 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
3127 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
3128 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
3129 #else
3130 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3131 #endif
3132 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3133 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
3134 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
3135 #if !defined (_X86PAE_)
3136 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
3137 #else
3138 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
3139 #endif
3140
3141 #elif defined(_M_AMD64)
3142
3143 #define PAUSE_PROCESSOR YieldProcessor();
3144
3145 #define KERNEL_STACK_SIZE 0x6000
3146 #define KERNEL_LARGE_STACK_SIZE 0x12000
3147 #define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE
3148
3149 #define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
3150
3151 #define EXCEPTION_READ_FAULT 0
3152 #define EXCEPTION_WRITE_FAULT 1
3153 #define EXCEPTION_EXECUTE_FAULT 8
3154
3155 #if !defined(RC_INVOKED)
3156
3157 #define CONTEXT_AMD64 0x100000
3158
3159 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
3160 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
3161 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
3162 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
3163 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
3164
3165 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
3166 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
3167
3168 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
3169
3170 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
3171 #define CONTEXT_SERVICE_ACTIVE 0x10000000
3172 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
3173 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
3174
3175 #endif /* !defined(RC_INVOKED) */
3176
3177 #define INITIAL_MXCSR 0x1f80
3178 #define INITIAL_FPCSR 0x027f
3179
3180 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
3181 ULONG64 P1Home;
3182 ULONG64 P2Home;
3183 ULONG64 P3Home;
3184 ULONG64 P4Home;
3185 ULONG64 P5Home;
3186 ULONG64 P6Home;
3187 ULONG ContextFlags;
3188 ULONG MxCsr;
3189 USHORT SegCs;
3190 USHORT SegDs;
3191 USHORT SegEs;
3192 USHORT SegFs;
3193 USHORT SegGs;
3194 USHORT SegSs;
3195 ULONG EFlags;
3196 ULONG64 Dr0;
3197 ULONG64 Dr1;
3198 ULONG64 Dr2;
3199 ULONG64 Dr3;
3200 ULONG64 Dr6;
3201 ULONG64 Dr7;
3202 ULONG64 Rax;
3203 ULONG64 Rcx;
3204 ULONG64 Rdx;
3205 ULONG64 Rbx;
3206 ULONG64 Rsp;
3207 ULONG64 Rbp;
3208 ULONG64 Rsi;
3209 ULONG64 Rdi;
3210 ULONG64 R8;
3211 ULONG64 R9;
3212 ULONG64 R10;
3213 ULONG64 R11;
3214 ULONG64 R12;
3215 ULONG64 R13;
3216 ULONG64 R14;
3217 ULONG64 R15;
3218 ULONG64 Rip;
3219 union {
3220 XMM_SAVE_AREA32 FltSave;
3221 struct {
3222 M128A Header[2];
3223 M128A Legacy[8];
3224 M128A Xmm0;
3225 M128A Xmm1;
3226 M128A Xmm2;
3227 M128A Xmm3;
3228 M128A Xmm4;
3229 M128A Xmm5;
3230 M128A Xmm6;
3231 M128A Xmm7;
3232 M128A Xmm8;
3233 M128A Xmm9;
3234 M128A Xmm10;
3235 M128A Xmm11;
3236 M128A Xmm12;
3237 M128A Xmm13;
3238 M128A Xmm14;
3239 M128A Xmm15;
3240 } DUMMYSTRUCTNAME;
3241 } DUMMYUNIONNAME;
3242 M128A VectorRegister[26];
3243 ULONG64 VectorControl;
3244 ULONG64 DebugControl;
3245 ULONG64 LastBranchToRip;
3246 ULONG64 LastBranchFromRip;
3247 ULONG64 LastExceptionToRip;
3248 ULONG64 LastExceptionFromRip;
3249 } CONTEXT;
3250
3251 #define PCR_MINOR_VERSION 1
3252 #define PCR_MAJOR_VERSION 1
3253
3254 typedef struct _KPCR
3255 {
3256 _ANONYMOUS_UNION union
3257 {
3258 NT_TIB NtTib;
3259 _ANONYMOUS_STRUCT struct
3260 {
3261 union _KGDTENTRY64 *GdtBase;
3262 struct _KTSS64 *TssBase;
3263 ULONG64 UserRsp;
3264 struct _KPCR *Self;
3265 struct _KPRCB *CurrentPrcb;
3266 PKSPIN_LOCK_QUEUE LockArray;
3267 PVOID Used_Self;
3268 };
3269 };
3270 union _KIDTENTRY64 *IdtBase;
3271 ULONG64 Unused[2];
3272 KIRQL Irql;
3273 UCHAR SecondLevelCacheAssociativity;
3274 UCHAR ObsoleteNumber;
3275 UCHAR Fill0;
3276 ULONG Unused0[3];
3277 USHORT MajorVersion;
3278 USHORT MinorVersion;
3279 ULONG StallScaleFactor;
3280 PVOID Unused1[3];
3281 ULONG KernelReserved[15];
3282 ULONG SecondLevelCacheSize;
3283 ULONG HalReserved[16];
3284 ULONG Unused2;
3285 PVOID KdVersionBlock;
3286 PVOID Unused3;
3287 ULONG PcrAlign1[24];
3288 } KPCR, *PKPCR;
3289
3290 FORCEINLINE
3291 PKPCR
3292 KeGetPcr(VOID)
3293 {
3294 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
3295 }
3296
3297 FORCEINLINE
3298 ULONG
3299 KeGetCurrentProcessorNumber(VOID)
3300 {
3301 return (ULONG)__readgsword(0x184);
3302 }
3303
3304
3305 #define PTI_SHIFT 12L
3306 #define PDI_SHIFT 21L
3307 #define PPI_SHIFT 30L
3308 #define PXI_SHIFT 39L
3309 #define PTE_PER_PAGE 512
3310 #define PDE_PER_PAGE 512
3311 #define PPE_PER_PAGE 512
3312 #define PXE_PER_PAGE 512
3313 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
3314 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
3315 #define PPI_MASK (PPE_PER_PAGE - 1)
3316 #define PXI_MASK (PXE_PER_PAGE - 1)
3317
3318 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
3319 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
3320 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
3321 #define PDE_BASE 0xFFFFF6FB40000000ULL
3322 #define PTE_BASE 0xFFFFF68000000000ULL
3323 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
3324 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
3325 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
3326 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
3327
3328 extern NTKERNELAPI PVOID MmHighestUserAddress;
3329 extern NTKERNELAPI PVOID MmSystemRangeStart;
3330 extern NTKERNELAPI ULONG64 MmUserProbeAddress;
3331
3332 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3333 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3334 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
3335 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
3336 extern ULONG64 _LOCAL_COPY_USER_PROBE_ADDRESS_;
3337 #else
3338 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3339 #endif
3340 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3341 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
3342
3343 #elif defined(_M_IA64)
3344
3345 #elif defined(_M_PPC)
3346
3347
3348 #elif defined(_M_MIPS)
3349
3350 #elif defined(_M_ARM)
3351
3352 #define PAUSE_PROCESSOR __yield();
3353
3354 #define KERNEL_STACK_SIZE 0x3000
3355 #define KERNEL_LARGE_STACK_SIZE 0xF000
3356 #define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE
3357
3358 #define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
3359
3360 #define EXCEPTION_READ_FAULT 0
3361 #define EXCEPTION_WRITE_FAULT 1
3362 #define EXCEPTION_EXECUTE_FAULT 8
3363
3364 /* The following flags control the contents of the CONTEXT structure. */
3365 #define CONTEXT_ARM 0x200000L
3366 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
3367 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
3368 #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x00000004L)
3369 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x00000008L)
3370 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
3371
3372 typedef struct _NEON128
3373 {
3374 ULONGLONG Low;
3375 LONGLONG High;
3376 } NEON128, *PNEON128;
3377
3378 #define ARM_MAX_BREAKPOINTS 8
3379 #define ARM_MAX_WATCHPOINTS 1
3380
3381 typedef struct _CONTEXT
3382 {
3383 /* The flags values within this flag control the contents of
3384 a CONTEXT record.
3385
3386 If the context record is used as an input parameter, then
3387 for each portion of the context record controlled by a flag
3388 whose value is set, it is assumed that that portion of the
3389 context record contains valid context. If the context record
3390 is being used to modify a thread's context, then only that
3391 portion of the threads context will be modified.
3392
3393 If the context record is used as an IN OUT parameter to capture
3394 the context of a thread, then only those portions of the thread's
3395 context corresponding to set flags will be returned.
3396
3397 The context record is never used as an OUT only parameter. */
3398 ULONG ContextFlags;
3399
3400 /* This section is specified/returned if the ContextFlags word contains
3401 the flag CONTEXT_INTEGER. */
3402 ULONG R0;
3403 ULONG R1;
3404 ULONG R2;
3405 ULONG R3;
3406 ULONG R4;
3407 ULONG R5;
3408 ULONG R6;
3409 ULONG R7;
3410 ULONG R8;
3411 ULONG R9;
3412 ULONG R10;
3413 ULONG R11;
3414 ULONG R12;
3415
3416 ULONG Sp;
3417 ULONG Lr;
3418 ULONG Pc;
3419 ULONG Cpsr;
3420
3421 /* Floating Point/NEON Registers */
3422 ULONG Fpscr;
3423 ULONG Padding;
3424 union
3425 {
3426 NEON128 Q[16];
3427 ULONGLONG D[32];
3428 ULONG S[32];
3429 } DUMMYUNIONNAME;
3430
3431 /* Debug registers */
3432 ULONG Bvr[ARM_MAX_BREAKPOINTS];
3433 ULONG Bcr[ARM_MAX_BREAKPOINTS];
3434 ULONG Wvr[ARM_MAX_WATCHPOINTS];
3435 ULONG Wcr[ARM_MAX_WATCHPOINTS];
3436
3437 ULONG Padding2[2];
3438 } CONTEXT;
3439
3440 #define PCR_MINOR_VERSION 1
3441 #define PCR_MAJOR_VERSION 1
3442
3443 typedef struct _KPCR
3444 {
3445 _ANONYMOUS_UNION union
3446 {
3447 NT_TIB NtTib;
3448 _ANONYMOUS_STRUCT struct
3449 {
3450 ULONG TibPad0[2];
3451 PVOID Spare1;
3452 struct _KPCR *Self;
3453 struct _KPRCB *CurrentPrcb;
3454 PKSPIN_LOCK_QUEUE LockArray;
3455 PVOID Used_Self;
3456 };
3457 };
3458 KIRQL CurrentIrql;
3459 UCHAR SecondLevelCacheAssociativity;
3460 ULONG Unused0[3];
3461 USHORT MajorVersion;
3462 USHORT MinorVersion;
3463 ULONG StallScaleFactor;
3464 PVOID Unused1[3];
3465 ULONG KernelReserved[15];
3466 ULONG SecondLevelCacheSize;
3467 _ANONYMOUS_UNION union
3468 {
3469 USHORT SoftwareInterruptPending; // Software Interrupt Pending Flag
3470 struct
3471 {
3472 UCHAR ApcInterrupt; // 0x01 if APC int pending
3473 UCHAR DispatchInterrupt; // 0x01 if dispatch int pending
3474 };
3475 };
3476 USHORT InterruptPad;
3477 ULONG HalReserved[32];
3478 PVOID KdVersionBlock;
3479 PVOID Unused3;
3480 ULONG PcrAlign1[8];
3481 } KPCR, *PKPCR;
3482
3483 #define CP15_PCR_RESERVED_MASK 0xFFF
3484 //#define KIPCR() ((ULONG_PTR)(_MoveFromCoprocessor(CP15_TPIDRPRW)) & ~CP15_PCR_RESERVED_MASK)
3485
3486 FORCEINLINE
3487 PKPCR
3488 KeGetPcr(
3489 VOID)
3490 {
3491 return (PKPCR)(_MoveFromCoprocessor(CP15_TPIDRPRW) & ~CP15_PCR_RESERVED_MASK);
3492 }
3493
3494 #if (NTDDI_VERSION < NTDDI_WIN7) || !defined(NT_PROCESSOR_GROUPS)
3495 FORCEINLINE
3496 ULONG
3497 KeGetCurrentProcessorNumber(
3498 VOID)
3499
3500 {
3501 return *((PUCHAR)KeGetPcr() + 0x580);
3502 }
3503 #endif /* (NTDDI_VERSION < NTDDI_WIN7) || !defined(NT_PROCESSOR_GROUPS) */
3504
3505
3506 #define PTI_SHIFT 12
3507 #define PDI_SHIFT 22
3508
3509 #define PDE_BASE 0xC0300000
3510 #define PTE_BASE 0xC0000000
3511 #define PDE_TOP 0xC0300FFF
3512 #define PTE_TOP 0xC03FFFFF
3513
3514 extern NTKERNELAPI PVOID MmHighestUserAddress;
3515 extern NTKERNELAPI PVOID MmSystemRangeStart;
3516 extern NTKERNELAPI ULONG MmUserProbeAddress;
3517
3518 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3519 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3520 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
3521 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
3522 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
3523 #else
3524 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3525 #endif
3526 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3527 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
3528 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
3529
3530 #else
3531 #error Unknown Architecture
3532 #endif
3533
3534 /******************************************************************************
3535 * Executive Functions *
3536 ******************************************************************************/
3537
3538 static __inline PVOID
3539 ExAllocateFromZone(
3540 IN PZONE_HEADER Zone)
3541 {
3542 PVOID Result = (PVOID)Zone->FreeList.Next;
3543 if (Zone->FreeList.Next)
3544 Zone->FreeList.Next = Zone->FreeList.Next->Next;
3545 return Result;
3546 }
3547
3548 static __inline PVOID
3549 ExFreeToZone(
3550 IN PZONE_HEADER Zone,
3551 IN PVOID Block)
3552 {
3553 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
3554 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
3555 return ((PSINGLE_LIST_ENTRY) Block)->Next;
3556 }
3557
3558 /*
3559 * PVOID
3560 * ExInterlockedAllocateFromZone(
3561 * IN PZONE_HEADER Zone,
3562 * IN PKSPIN_LOCK Lock)
3563 */
3564 #define ExInterlockedAllocateFromZone(Zone, Lock) \
3565 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
3566
3567 /* PVOID
3568 * ExInterlockedFreeToZone(
3569 * IN PZONE_HEADER Zone,
3570 * IN PVOID Block,
3571 * IN PKSPIN_LOCK Lock);
3572 */
3573 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
3574 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
3575
3576 /*
3577 * BOOLEAN
3578 * ExIsFullZone(
3579 * IN PZONE_HEADER Zone)
3580 */
3581 #define ExIsFullZone(Zone) \
3582 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
3583
3584 /* BOOLEAN
3585 * ExIsObjectInFirstZoneSegment(
3586 * IN PZONE_HEADER Zone,
3587 * IN PVOID Object);
3588 */
3589 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
3590 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
3591 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
3592 (Zone)->TotalSegmentSize)) )
3593
3594 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
3595 #define ExAcquireResourceShared ExAcquireResourceSharedLite
3596 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
3597 #define ExDeleteResource ExDeleteResourceLite
3598 #define ExInitializeResource ExInitializeResourceLite
3599 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
3600 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
3601 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
3602 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
3603
3604 #ifndef _M_IX86
3605 #define RESULT_ZERO 0
3606 #define RESULT_NEGATIVE 1
3607 #define RESULT_POSITIVE 2
3608 #endif
3609
3610 typedef enum _INTERLOCKED_RESULT {
3611 ResultNegative = RESULT_NEGATIVE,
3612 ResultZero = RESULT_ZERO,
3613 ResultPositive = RESULT_POSITIVE
3614 } INTERLOCKED_RESULT;
3615
3616 #ifdef _X86_
3617
3618 NTKERNELAPI
3619 INTERLOCKED_RESULT
3620 FASTCALL
3621 Exfi386InterlockedIncrementLong(
3622 _Inout_ _Interlocked_operand_ LONG volatile *Addend);
3623
3624 NTKERNELAPI
3625 INTERLOCKED_RESULT
3626 FASTCALL
3627 Exfi386InterlockedDecrementLong(
3628 _Inout_ _Interlocked_operand_ PLONG Addend);
3629
3630 NTKERNELAPI
3631 ULONG
3632 FASTCALL
3633 Exfi386InterlockedExchangeUlong(
3634 _Inout_ _Interlocked_operand_ PULONG Target,
3635 _In_ ULONG Value);
3636
3637 #endif
3638
3639
3640 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3641 NTKERNELAPI
3642 NTSTATUS
3643 NTAPI
3644 ExExtendZone(
3645 _Inout_ PZONE_HEADER Zone,
3646 _Inout_ PVOID Segment,
3647 _In_ ULONG SegmentSize);
3648
3649 NTKERNELAPI
3650 NTSTATUS
3651 NTAPI
3652 ExInitializeZone(
3653 _Out_ PZONE_HEADER Zone,
3654 _In_ ULONG BlockSize,
3655 _Inout_ PVOID InitialSegment,
3656 _In_ ULONG InitialSegmentSize);
3657
3658 _IRQL_requires_max_(DISPATCH_LEVEL)
3659 NTKERNELAPI
3660 NTSTATUS
3661 NTAPI
3662 ExInterlockedExtendZone(
3663 _Inout_ PZONE_HEADER Zone,
3664 _Inout_ PVOID Segment,
3665 _In_ ULONG SegmentSize,
3666 _Inout_ _Requires_lock_not_held_(*_Curr_) PKSPIN_LOCK Lock);
3667
3668 _IRQL_requires_max_(PASSIVE_LEVEL)
3669 NTKERNELAPI
3670 NTSTATUS
3671 NTAPI
3672 ExUuidCreate(
3673 _Out_ UUID *Uuid);
3674
3675 _IRQL_requires_max_(PASSIVE_LEVEL)
3676 NTKERNELAPI
3677 DECLSPEC_NORETURN
3678 VOID
3679 NTAPI
3680 ExRaiseAccessViolation(VOID);
3681
3682 _IRQL_requires_max_(PASSIVE_LEVEL)
3683 NTKERNELAPI
3684 DECLSPEC_NORETURN
3685 VOID
3686 NTAPI
3687 ExRaiseDatatypeMisalignment(VOID);
3688
3689 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3690
3691
3692 /* Hardware Abstraction Layer Functions */
3693
3694 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3695
3696 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
3697
3698 /* Nothing here */
3699
3700 #else /* USE_DMA_MACROS ... */
3701
3702 //DECLSPEC_DEPRECATED_DDK
3703 NTHALAPI
3704 VOID
3705 NTAPI
3706 IoFreeAdapterChannel(
3707 _In_ PADAPTER_OBJECT AdapterObject);
3708
3709 //DECLSPEC_DEPRECATED_DDK
3710 NTHALAPI
3711 BOOLEAN
3712 NTAPI
3713 IoFlushAdapterBuffers(
3714 _In_ PADAPTER_OBJECT AdapterObject,
3715 _In_ PMDL Mdl,
3716 _In_ PVOID MapRegisterBase,
3717 _In_ PVOID CurrentVa,
3718 _In_ ULONG Length,
3719 _In_ BOOLEAN WriteToDevice);
3720
3721 //DECLSPEC_DEPRECATED_DDK
3722 NTHALAPI
3723 VOID
3724 NTAPI
3725 IoFreeMapRegisters(
3726 _In_ PADAPTER_OBJECT AdapterObject,
3727 _In_ PVOID MapRegisterBase,
3728 _In_ ULONG NumberOfMapRegisters);
3729
3730 //DECLSPEC_DEPRECATED_DDK
3731 NTHALAPI
3732 PVOID
3733 NTAPI
3734 HalAllocateCommonBuffer(
3735 _In_ PADAPTER_OBJECT AdapterObject,
3736 _In_ ULONG Length,
3737 _Out_ PPHYSICAL_ADDRESS LogicalAddress,
3738 _In_ BOOLEAN CacheEnabled);
3739
3740 //DECLSPEC_DEPRECATED_DDK
3741 NTHALAPI
3742 VOID
3743 NTAPI
3744 HalFreeCommonBuffer(
3745 _In_ PADAPTER_OBJECT AdapterObject,
3746 _In_ ULONG Length,
3747 _In_ PHYSICAL_ADDRESS LogicalAddress,
3748 _In_ PVOID VirtualAddress,
3749 _In_ BOOLEAN CacheEnabled);
3750
3751 //DECLSPEC_DEPRECATED_DDK
3752 NTHALAPI
3753 ULONG
3754 NTAPI
3755 HalReadDmaCounter(
3756 _In_ PADAPTER_OBJECT AdapterObject);
3757
3758 NTHALAPI
3759 NTSTATUS
3760 NTAPI
3761 HalAllocateAdapterChannel(
3762 _In_ PADAPTER_OBJECT AdapterObject,
3763 _In_ PWAIT_CONTEXT_BLOCK Wcb,
3764 _In_ ULONG NumberOfMapRegisters,
3765 _In_ PDRIVER_CONTROL ExecutionRoutine);
3766
3767 #endif /* USE_DMA_MACROS ... */
3768
3769 #if !defined(NO_LEGACY_DRIVERS)
3770 NTHALAPI
3771 NTSTATUS
3772 NTAPI
3773 HalAssignSlotResources(
3774 _In_ PUNICODE_STRING RegistryPath,
3775 _In_opt_ PUNICODE_STRING DriverClassName,
3776 _In_ PDRIVER_OBJECT DriverObject,
3777 _In_ PDEVICE_OBJECT DeviceObject,
3778 _In_ INTERFACE_TYPE BusType,
3779 _In_ ULONG BusNumber,
3780 _In_ ULONG SlotNumber,
3781 _Inout_ PCM_RESOURCE_LIST *AllocatedResources);
3782
3783 _IRQL_requires_max_(PASSIVE_LEVEL)
3784 NTHALAPI
3785 ULONG
3786 NTAPI
3787 HalGetInterruptVector(
3788 _In_ INTERFACE_TYPE InterfaceType,
3789 _In_ ULONG BusNumber,
3790 _In_ ULONG BusInterruptLevel,
3791 _In_ ULONG BusInterruptVector,
3792 _Out_ PKIRQL Irql,
3793 _Out_ PKAFFINITY Affinity);
3794
3795 NTHALAPI
3796 ULONG
3797 NTAPI
3798 HalSetBusData(
3799 _In_ BUS_DATA_TYPE BusDataType,
3800 _In_ ULONG BusNumber,
3801 _In_ ULONG SlotNumber,
3802 _In_reads_bytes_(Length) PVOID Buffer,
3803 _In_ ULONG Length);
3804
3805 NTHALAPI
3806 ULONG
3807 NTAPI
3808 HalGetBusData(
3809 _In_ BUS_DATA_TYPE BusDataType,
3810 _In_ ULONG BusNumber,
3811 _In_ ULONG SlotNumber,
3812 _Out_writes_bytes_(Length) PVOID Buffer,
3813 _In_ ULONG Length);
3814
3815 NTHALAPI
3816 BOOLEAN
3817 NTAPI
3818 HalMakeBeep(
3819 _In_ ULONG Frequency);
3820 #endif /* !defined(NO_LEGACY_DRIVERS) */
3821
3822 _IRQL_requires_max_(PASSIVE_LEVEL)
3823 NTHALAPI
3824 PADAPTER_OBJECT
3825 NTAPI
3826 HalGetAdapter(
3827 _In_ PDEVICE_DESCRIPTION DeviceDescription,
3828 _Out_ PULONG NumberOfMapRegisters);
3829
3830 VOID
3831 NTAPI
3832 HalPutDmaAdapter(
3833 _In_ PADAPTER_OBJECT DmaAdapter);
3834
3835 NTHALAPI
3836 VOID
3837 NTAPI
3838 HalAcquireDisplayOwnership(
3839 _In_ PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
3840
3841 NTHALAPI
3842 ULONG
3843 NTAPI
3844 HalGetBusDataByOffset(
3845 _In_ BUS_DATA_TYPE BusDataType,
3846 _In_ ULONG BusNumber,
3847 _In_ ULONG SlotNumber,
3848 _Out_writes_bytes_(Length) PVOID Buffer,
3849 _In_ ULONG Offset,
3850 _In_ ULONG Length);
3851
3852 NTHALAPI
3853 ULONG
3854 NTAPI
3855 HalSetBusDataByOffset(
3856 _In_ BUS_DATA_TYPE BusDataType,
3857 _In_ ULONG BusNumber,
3858 _In_ ULONG SlotNumber,
3859 _In_reads_bytes_(Length) PVOID Buffer,
3860 _In_ ULONG Offset,
3861 _In_ ULONG Length);
3862
3863 NTHALAPI
3864 BOOLEAN
3865 NTAPI
3866 HalTranslateBusAddress(
3867 _In_ INTERFACE_TYPE InterfaceType,
3868 _In_ ULONG BusNumber,
3869 _In_ PHYSICAL_ADDRESS BusAddress,
3870 _Inout_ PULONG AddressSpace,
3871 _Out_ PPHYSICAL_ADDRESS TranslatedAddress);
3872
3873 NTHALAPI
3874 PVOID
3875 NTAPI
3876 HalAllocateCrashDumpRegisters(
3877 _In_ PADAPTER_OBJECT AdapterObject,
3878 _Inout_ PULONG NumberOfMapRegisters);
3879
3880 NTSTATUS
3881 NTAPI
3882 HalGetScatterGatherList(
3883 _In_ PADAPTER_OBJECT DmaAdapter,
3884 _In_ PDEVICE_OBJECT DeviceObject,
3885 _In_ PMDL Mdl,
3886 _In_ PVOID CurrentVa,
3887 _In_ ULONG Length,
3888 _In_ PDRIVER_LIST_CONTROL ExecutionRoutine,
3889 _In_ PVOID Context,
3890 _In_ BOOLEAN WriteToDevice);
3891
3892 VOID
3893 NTAPI
3894 HalPutScatterGatherList(
3895 _In_ PADAPTER_OBJECT DmaAdapter,
3896 _In_ PSCATTER_GATHER_LIST ScatterGather,
3897 _In_ BOOLEAN WriteToDevice);
3898
3899 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3900
3901 #if (NTDDI_VERSION >= NTDDI_WINXP)
3902 _IRQL_requires_max_(PASSIVE_LEVEL)
3903 NTKERNELAPI
3904 VOID
3905 FASTCALL
3906 HalExamineMBR(
3907 _In_ PDEVICE_OBJECT DeviceObject,
3908 _In_ ULONG SectorSize,
3909 _In_ ULONG MBRTypeIdentifier,
3910 _Out_ PVOID *Buffer);
3911 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3912
3913 #if (NTDDI_VERSION >= NTDDI_WIN7)
3914
3915 NTSTATUS
3916 NTAPI
3917 HalAllocateHardwareCounters(
3918 _In_reads_(GroupCount) PGROUP_AFFINITY GroupAffinty,
3919 _In_ ULONG GroupCount,
3920 _In_ PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList,
3921 _Out_ PHANDLE CounterSetHandle);
3922
3923 NTSTATUS
3924 NTAPI
3925 HalFreeHardwareCounters(
3926 _In_ HANDLE CounterSetHandle);
3927
3928 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3929
3930 #if defined(_IA64_)
3931 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3932 NTHALAPI
3933 ULONG
3934 NTAPI
3935 HalGetDmaAlignmentRequirement(VOID);
3936 #endif
3937 #endif /* defined(_IA64_) */
3938
3939 #if defined(_M_IX86) || defined(_M_AMD64)
3940 #define HalGetDmaAlignmentRequirement() 1L
3941 #endif
3942
3943 #if (NTDDI_VERSION >= NTDDI_WIN7)
3944
3945 typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR;
3946 typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD;
3947
3948 NTHALAPI
3949 VOID
3950 NTAPI
3951 HalBugCheckSystem(
3952 _In_ PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource,
3953 _In_ PWHEA_ERROR_RECORD ErrorRecord);
3954
3955 #else
3956
3957 typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD;
3958
3959 NTHALAPI
3960 VOID
3961 NTAPI
3962 HalBugCheckSystem(
3963 _In_ PWHEA_ERROR_RECORD ErrorRecord);
3964
3965 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3966
3967 /******************************************************************************
3968 * I/O Manager Functions *
3969 ******************************************************************************/
3970
3971 /*
3972 * VOID IoAssignArcName(
3973 * IN PUNICODE_STRING ArcName,
3974 * IN PUNICODE_STRING DeviceName);
3975 */
3976 #define IoAssignArcName(_ArcName, _DeviceName) ( \
3977 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
3978
3979 /*
3980 * VOID
3981 * IoDeassignArcName(
3982 * IN PUNICODE_STRING ArcName)
3983 */
3984 #define IoDeassignArcName IoDeleteSymbolicLink
3985
3986 FORCEINLINE
3987 VOID
3988 NTAPI
3989 IoInitializeDriverCreateContext(
3990 PIO_DRIVER_CREATE_CONTEXT DriverContext)
3991 {
3992 RtlZeroMemory(DriverContext, sizeof(IO_DRIVER_CREATE_CONTEXT));
3993 DriverContext->Size = sizeof(IO_DRIVER_CREATE_CONTEXT);
3994 }
3995
3996 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3997
3998 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
3999 _IRQL_requires_max_(DISPATCH_LEVEL)
4000 _IRQL_requires_min_(DISPATCH_LEVEL)
4001 NTKERNELAPI
4002 NTSTATUS
4003 NTAPI
4004 IoAllocateAdapterChannel(
4005 _In_ PADAPTER_OBJECT AdapterObject,
4006 _In_ PDEVICE_OBJECT DeviceObject,
4007 _In_ ULONG NumberOfMapRegisters,
4008 _In_ PDRIVER_CONTROL ExecutionRoutine,
4009 _In_ PVOID Context);
4010 #endif
4011
4012 #if !defined(DMA_MACROS_DEFINED)
4013 //DECLSPEC_DEPRECATED_DDK
4014 NTHALAPI
4015 PHYSICAL_ADDRESS
4016 NTAPI
4017 IoMapTransfer(
4018 _In_ PADAPTER_OBJECT AdapterObject,
4019 _In_ PMDL Mdl,
4020 _In_ PVOID MapRegisterBase,
4021 _In_ PVOID CurrentVa,
4022 _Inout_ PULONG Length,
4023 _In_ BOOLEAN WriteToDevice);
4024 #endif
4025
4026 _IRQL_requires_max_(DISPATCH_LEVEL)
4027 _IRQL_requires_min_(DISPATCH_LEVEL)
4028 NTKERNELAPI
4029 VOID
4030 NTAPI
4031 IoAllocateController(
4032 _In_ PCONTROLLER_OBJECT ControllerObject,
4033 _In_ PDEVICE_OBJECT DeviceObject,
4034 _In_ PDRIVER_CONTROL ExecutionRoutine,
4035 _In_opt_ PVOID Context);
4036
4037 _IRQL_requires_max_(PASSIVE_LEVEL)
4038 NTKERNELAPI
4039 PCONTROLLER_OBJECT
4040 NTAPI
4041 IoCreateController(
4042 _In_ ULONG Size);
4043
4044 _IRQL_requires_max_(PASSIVE_LEVEL)
4045 NTKERNELAPI
4046 VOID
4047 NTAPI
4048 IoDeleteController(
4049 _In_ PCONTROLLER_OBJECT ControllerObject);
4050
4051 _IRQL_requires_max_(DISPATCH_LEVEL)
4052 _IRQL_requires_min_(DISPATCH_LEVEL)
4053 NTKERNELAPI
4054 VOID
4055 NTAPI
4056 IoFreeController(
4057 _In_ PCONTROLLER_OBJECT ControllerObject);
4058
4059 _IRQL_requires_max_(PASSIVE_LEVEL)
4060 NTKERNELAPI
4061 PCONFIGURATION_INFORMATION
4062 NTAPI
4063 IoGetConfigurationInformation(VOID);
4064
4065 _IRQL_requires_max_(PASSIVE_LEVEL)
4066 NTKERNELAPI
4067 PDEVICE_OBJECT
4068 NTAPI
4069 IoGetDeviceToVerify(
4070 _In_ PETHREAD Thread);
4071
4072 NTKERNELAPI
4073 VOID
4074 NTAPI
4075 IoCancelFileOpen(
4076 _In_ PDEVICE_OBJECT DeviceObject,
4077 _In_ PFILE_OBJECT FileObject);
4078
4079 _IRQL_requires_max_(PASSIVE_LEVEL)
4080 NTKERNELAPI
4081 PGENERIC_MAPPING
4082 NTAPI
4083 IoGetFileObjectGenericMapping(VOID);
4084
4085 _IRQL_requires_max_(DISPATCH_LEVEL)
4086 NTKERNELAPI
4087 PIRP
4088 NTAPI
4089 IoMakeAssociatedIrp(
4090 _In_ PIRP Irp,
4091 _In_ CCHAR StackSize);
4092
4093 NTKERNELAPI
4094 NTSTATUS
4095 NTAPI
4096 IoQueryDeviceDescription(
4097 _In_opt_ PINTERFACE_TYPE BusType,
4098 _In_opt_ PULONG BusNumber,
4099 _In_opt_ PCONFIGURATION_TYPE ControllerType,
4100 _In_opt_ PULONG ControllerNumber,
4101 _In_opt_ PCONFIGURATION_TYPE PeripheralType,
4102 _In_opt_ PULONG PeripheralNumber,
4103 _In_ PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
4104 _Inout_opt_ PVOID Context);
4105
4106 _IRQL_requires_max_(APC_LEVEL)
4107 NTKERNELAPI
4108 VOID
4109 NTAPI
4110 IoRaiseHardError(
4111 _In_ PIRP Irp,
4112 _In_opt_ PVPB Vpb,
4113 _In_ PDEVICE_OBJECT RealDeviceObject);
4114
4115 _IRQL_requires_max_(APC_LEVEL)
4116 NTKERNELAPI
4117 BOOLEAN
4118 NTAPI
4119 IoRaiseInformationalHardError(
4120 _In_ NTSTATUS ErrorStatus,
4121 _In_opt_ PUNICODE_STRING String,
4122 _In_opt_ PKTHREAD Thread);
4123
4124 _IRQL_requires_max_(PASSIVE_LEVEL)
4125 NTKERNELAPI
4126 VOID
4127 NTAPI
4128 IoRegisterBootDriverReinitialization(
4129 _In_ PDRIVER_OBJECT DriverObject,
4130 _In_ PDRIVER_REINITIALIZE DriverReinitializationRoutine,
4131 _In_opt_ PVOID Context);
4132
4133 _IRQL_requires_max_(PASSIVE_LEVEL)
4134 NTKERNELAPI
4135 VOID
4136 NTAPI
4137 IoRegisterDriverReinitialization(
4138 _In_ PDRIVER_OBJECT DriverObject,
4139 _In_ PDRIVER_REINITIALIZE DriverReinitializationRoutine,
4140 _In_opt_ PVOID Context);
4141
4142 NTKERNELAPI
4143 NTSTATUS
4144 NTAPI
4145 IoAttachDeviceByPointer(
4146 _In_ PDEVICE_OBJECT SourceDevice,
4147 _In_ PDEVICE_OBJECT TargetDevice);
4148
4149 _IRQL_requires_max_(PASSIVE_LEVEL)
4150 _Must_inspect_result_
4151 NTKERNELAPI
4152 NTSTATUS
4153 NTAPI
4154 IoReportDetectedDevice(
4155 _In_ PDRIVER_OBJECT DriverObject,
4156 _In_ INTERFACE_TYPE LegacyBusType,
4157 _In_ ULONG BusNumber,
4158 _In_ ULONG SlotNumber,
4159 _In_opt_ PCM_RESOURCE_LIST ResourceList,
4160 _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements,
4161 _In_ BOOLEAN ResourceAssigned,
4162 _Inout_ PDEVICE_OBJECT *DeviceObject);
4163
4164 NTKERNELAPI
4165 NTSTATUS
4166 NTAPI
4167 IoReportResourceForDetection(
4168 _In_ PDRIVER_OBJECT DriverObject,
4169 _In_reads_bytes_opt_(DriverListSize) PCM_RESOURCE_LIST DriverList,
4170 _In_opt_ ULONG DriverListSize,
4171 _In_opt_ PDEVICE_OBJECT DeviceObject,
4172 _In_reads_bytes_opt_(DeviceListSize) PCM_RESOURCE_LIST DeviceList,
4173 _In_opt_ ULONG DeviceListSize,
4174 _Out_ PBOOLEAN ConflictDetected);
4175
4176 NTKERNELAPI
4177 NTSTATUS
4178 NTAPI
4179 IoReportResourceUsage(
4180 _In_opt_ PUNICODE_STRING DriverClassName,
4181 _In_ PDRIVER_OBJECT DriverObject,
4182 _In_reads_bytes_opt_(DriverListSize) PCM_RESOURCE_LIST DriverList,
4183 _In_opt_ ULONG DriverListSize,
4184 _In_opt_ PDEVICE_OBJECT DeviceObject,
4185 _In_reads_bytes_opt_(DeviceListSize) PCM_RESOURCE_LIST DeviceList,
4186 _In_opt_ ULONG DeviceListSize,
4187 _In_ BOOLEAN OverrideConflict,
4188 _Out_ PBOOLEAN ConflictDetected);
4189
4190 _IRQL_requires_max_(DISPATCH_LEVEL)
4191 NTKERNELAPI
4192 VOID
4193 NTAPI
4194 IoSetHardErrorOrVerifyDevice(
4195 _In_ PIRP Irp,
4196 _In_ PDEVICE_OBJECT DeviceObject);
4197
4198 NTKERNELAPI
4199 NTSTATUS
4200 NTAPI
4201 IoAssignResources(
4202 _In_ PUNICODE_STRING RegistryPath,
4203 _In_opt_ PUNICODE_STRING DriverClassName,
4204 _In_ PDRIVER_OBJECT DriverObject,
4205 _In_opt_ PDEVICE_OBJECT DeviceObject,
4206 _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
4207 _Inout_ PCM_RESOURCE_LIST *AllocatedResources);
4208
4209 _IRQL_requires_max_(DISPATCH_LEVEL)
4210 NTKERNELAPI
4211 BOOLEAN
4212 NTAPI
4213 IoSetThreadHardErrorMode(
4214 _In_ BOOLEAN EnableHardErrors);
4215
4216
4217 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
4218
4219 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
4220
4221 NTKERNELAPI
4222 BOOLEAN
4223 NTAPI
4224 IoIsFileOriginRemote(
4225 _In_ PFILE_OBJECT FileObject);
4226
4227 NTKERNELAPI
4228 NTSTATUS
4229 NTAPI
4230 IoSetFileOrigin(
4231 _In_ PFILE_OBJECT FileObject,
4232 _In_ BOOLEAN Remote);
4233
4234 #endif /* (NTDDI_VERSION >= NTDDI_WIN2KSP3) */
4235
4236 #if (NTDDI_VERSION >= NTDDI_WINXP)
4237
4238 _IRQL_requires_max_(PASSIVE_LEVEL)
4239 NTKERNELAPI
4240 NTSTATUS
4241 FASTCALL
4242 IoReadPartitionTable(
4243 _In_ PDEVICE_OBJECT DeviceObject,
4244 _In_ ULONG SectorSize,
4245 _In_ BOOLEAN ReturnRecognizedPartitions,
4246 _Out_ struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
4247
4248 _IRQL_requires_max_(PASSIVE_LEVEL)
4249 NTKERNELAPI
4250 NTSTATUS
4251 FASTCALL
4252 IoSetPartitionInformation(
4253 _In_ PDEVICE_OBJECT DeviceObject,
4254 _In_ ULONG SectorSize,
4255 _In_ ULONG PartitionNumber,
4256 _In_ ULONG PartitionType);
4257
4258 _IRQL_requires_max_(PASSIVE_LEVEL)
4259 NTKERNELAPI
4260 NTSTATUS
4261 FASTCALL
4262 IoWritePartitionTable(
4263 _In_ PDEVICE_OBJECT DeviceObject,
4264 _In_ ULONG SectorSize,
4265 _In_ ULONG SectorsPerTrack,
4266 _In_ ULONG NumberOfHeads,
4267 _In_ struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
4268
4269 NTKERNELAPI
4270 NTSTATUS
4271 NTAPI
4272 IoCreateDisk(
4273 _In_ PDEVICE_OBJECT DeviceObject,
4274 _In_opt_ struct _CREATE_DISK* Disk);
4275
4276 NTKERNELAPI
4277 NTSTATUS
4278 NTAPI
4279 IoReadDiskSignature(
4280 _In_ PDEVICE_OBJECT DeviceObject,
4281 _In_ ULONG BytesPerSector,
4282 _Out_ PDISK_SIGNATURE Signature);
4283
4284 _IRQL_requires_max_(PASSIVE_LEVEL)
4285 NTKERNELAPI
4286 NTSTATUS
4287 NTAPI
4288 IoReadPartitionTableEx(
4289 _In_ PDEVICE_OBJECT DeviceObject,
4290 _Out_ struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
4291
4292 _IRQL_requires_max_(PASSIVE_LEVEL)
4293 NTKERNELAPI
4294 NTSTATUS
4295 NTAPI
4296 IoSetPartitionInformationEx(
4297 _In_ PDEVICE_OBJECT DeviceObject,
4298 _In_ ULONG PartitionNumber,
4299 _In_ struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
4300
4301 NTKERNELAPI
4302 NTSTATUS
4303 NTAPI
4304 IoSetSystemPartition(
4305 _In_ PUNICODE_STRING VolumeNameString);
4306
4307 NTKERNELAPI
4308 NTSTATUS
4309 NTAPI
4310 IoVerifyPartitionTable(
4311 _In_ PDEVICE_OBJECT DeviceObject,
4312 _In_ BOOLEAN FixErrors);
4313
4314 NTKERNELAPI
4315 NTSTATUS
4316 NTAPI
4317 IoVolumeDeviceToDosName(
4318 _In_ PVOID VolumeDeviceObject,
4319 _Out_ _When_(return==0,
4320 _At_(DosName->Buffer, __drv_allocatesMem(Mem)))
4321 PUNICODE_STRING DosName);
4322
4323 _IRQL_requires_max_(PASSIVE_LEVEL)
4324 NTKERNELAPI
4325 NTSTATUS
4326 NTAPI
4327 IoWritePartitionTableEx(
4328 _In_ PDEVICE_OBJECT DeviceObject,
4329 _In_reads_(_Inexpressible_(FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[0])))
4330 struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout);
4331
4332 NTKERNELAPI
4333 NTSTATUS
4334 NTAPI
4335 IoCreateFileSpecifyDeviceObjectHint(
4336 _Out_ PHANDLE FileHandle,
4337 _In_ ACCESS_MASK DesiredAccess,
4338 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
4339 _Out_ PIO_STATUS_BLOCK IoStatusBlock,
4340 _In_opt_ PLARGE_INTEGER AllocationSize,
4341 _In_ ULONG FileAttributes,
4342 _In_ ULONG ShareAccess,
4343 _In_ ULONG Disposition,
4344 _In_ ULONG CreateOptions,
4345 _In_opt_ PVOID EaBuffer,
4346 _In_ ULONG EaLength,
4347 _In_ CREATE_FILE_TYPE CreateFileType,
4348 _In_opt_ PVOID InternalParameters,
4349 _In_ ULONG Options,
4350 _In_opt_ PVOID DeviceObject);
4351
4352 NTKERNELAPI
4353 NTSTATUS
4354 NTAPI
4355 IoAttachDeviceToDeviceStackSafe(
4356 _In_ PDEVICE_OBJECT SourceDevice,
4357 _In_ PDEVICE_OBJECT TargetDevice,
4358 _Outptr_ PDEVICE_OBJECT *AttachedToDeviceObject);
4359
4360
4361 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
4362
4363 #if (NTDDI_VERSION >= NTDDI_WS03)
4364 NTKERNELAPI
4365 IO_PAGING_PRIORITY
4366 FASTCALL
4367 IoGetPagingIoPriority(
4368 _In_ PIRP Irp);
4369
4370 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */
4371 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
4372
4373 BOOLEAN
4374 NTAPI
4375 IoTranslateBusAddress(
4376 _In_ INTERFACE_TYPE InterfaceType,
4377 _In_ ULONG BusNumber,
4378 _In_ PHYSICAL_ADDRESS BusAddress,
4379 _Inout_ PULONG AddressSpace,
4380 _Out_ PPHYSICAL_ADDRESS TranslatedAddress);
4381 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
4382
4383 #if (NTDDI_VERSION >= NTDDI_VISTA)
4384 NTKERNELAPI
4385 NTSTATUS
4386 NTAPI
4387 IoUpdateDiskGeometry(
4388 _In_ PDEVICE_OBJECT DeviceObject,
4389 _In_ struct _DISK_GEOMETRY_EX* OldDiskGeometry,
4390 _In_ struct _DISK_GEOMETRY_EX* NewDiskGeometry);
4391
4392 PTXN_PARAMETER_BLOCK
4393 NTAPI
4394 IoGetTransactionParameterBlock(
4395 _In_ PFILE_OBJECT FileObject);
4396
4397 NTKERNELAPI
4398 NTSTATUS
4399 NTAPI
4400 IoCreateFileEx(
4401 _Out_ PHANDLE FileHandle,
4402 _In_ ACCESS_MASK DesiredAccess,
4403 _In_ POBJECT_ATTRIBUTES ObjectAttributes,
4404 _Out_ PIO_STATUS_BLOCK IoStatusBlock,
4405 _In_opt_ PLARGE_INTEGER AllocationSize,
4406 _In_ ULONG FileAttributes,
4407 _In_ ULONG ShareAccess,
4408 _In_ ULONG Disposition,
4409 _In_ ULONG CreateOptions,
4410 _In_opt_ PVOID EaBuffer,
4411 _In_ ULONG EaLength,
4412 _In_ CREATE_FILE_TYPE CreateFileType,
4413 _In_opt_ PVOID InternalParameters,
4414 _In_ ULONG Options,
4415 _In_opt_ PIO_DRIVER_CREATE_CONTEXT DriverContext);
4416
4417 NTSTATUS
4418 NTAPI
4419 IoSetIrpExtraCreateParameter(
4420 _Inout_ PIRP Irp,
4421 _In_ struct _ECP_LIST *ExtraCreateParameter);
4422
4423 VOID
4424 NTAPI
4425 IoClearIrpExtraCreateParameter(
4426 _Inout_ PIRP Irp);
4427
4428 NTSTATUS
4429 NTAPI
4430 IoGetIrpExtraCreateParameter(
4431 _In_ PIRP Irp,
4432 _Outptr_result_maybenull_ struct _ECP_LIST **ExtraCreateParameter);
4433
4434 BOOLEAN
4435 NTAPI
4436 IoIsFileObjectIgnoringSharing(
4437 _In_ PFILE_OBJECT FileObject);
4438
4439 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
4440
4441 #if (NTDDI_VERSION >= NTDDI_WIN7)
4442
4443 NTSTATUS
4444 NTAPI
4445 IoSetFileObjectIgnoreSharing(
4446 _In_ PFILE_OBJECT FileObject);
4447
4448 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
4449
4450 /******************************************************************************
4451 * Kernel Debugger Functions *