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