Sync with trunk (48237)
[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 *PEXPAND_STACK_CALLOUT)(
1912 IN PVOID Parameter OPTIONAL);
1913
1914 typedef VOID
1915 (NTAPI *PTIMER_APC_ROUTINE)(
1916 IN PVOID TimerContext,
1917 IN ULONG TimerLowValue,
1918 IN LONG TimerHighValue);
1919
1920 typedef enum _TIMER_SET_INFORMATION_CLASS {
1921 TimerSetCoalescableTimer,
1922 MaxTimerInfoClass
1923 } TIMER_SET_INFORMATION_CLASS;
1924
1925 #if (NTDDI_VERSION >= NTDDI_WIN7)
1926 typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO {
1927 IN LARGE_INTEGER DueTime;
1928 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL;
1929 IN PVOID TimerContext OPTIONAL;
1930 IN struct _COUNTED_REASON_CONTEXT *WakeContext OPTIONAL;
1931 IN ULONG Period OPTIONAL;
1932 IN ULONG TolerableDelay;
1933 OUT PBOOLEAN PreviousState OPTIONAL;
1934 } TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO;
1935 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
1936
1937 #define XSTATE_LEGACY_FLOATING_POINT 0
1938 #define XSTATE_LEGACY_SSE 1
1939 #define XSTATE_GSSE 2
1940
1941 #define XSTATE_MASK_LEGACY_FLOATING_POINT (1i64 << (XSTATE_LEGACY_FLOATING_POINT))
1942 #define XSTATE_MASK_LEGACY_SSE (1i64 << (XSTATE_LEGACY_SSE))
1943 #define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE)
1944 #define XSTATE_MASK_GSSE (1i64 << (XSTATE_GSSE))
1945
1946 #define MAXIMUM_XSTATE_FEATURES 64
1947
1948 typedef struct _XSTATE_FEATURE {
1949 ULONG Offset;
1950 ULONG Size;
1951 } XSTATE_FEATURE, *PXSTATE_FEATURE;
1952
1953 typedef struct _XSTATE_CONFIGURATION {
1954 ULONG64 EnabledFeatures;
1955 ULONG Size;
1956 ULONG OptimizedSave:1;
1957 XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES];
1958 } XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION;
1959
1960 #define MAX_WOW64_SHARED_ENTRIES 16
1961
1962 typedef struct _KUSER_SHARED_DATA {
1963 ULONG TickCountLowDeprecated;
1964 ULONG TickCountMultiplier;
1965 volatile KSYSTEM_TIME InterruptTime;
1966 volatile KSYSTEM_TIME SystemTime;
1967 volatile KSYSTEM_TIME TimeZoneBias;
1968 USHORT ImageNumberLow;
1969 USHORT ImageNumberHigh;
1970 WCHAR NtSystemRoot[260];
1971 ULONG MaxStackTraceDepth;
1972 ULONG CryptoExponent;
1973 ULONG TimeZoneId;
1974 ULONG LargePageMinimum;
1975 ULONG Reserved2[7];
1976 NT_PRODUCT_TYPE NtProductType;
1977 BOOLEAN ProductTypeIsValid;
1978 ULONG NtMajorVersion;
1979 ULONG NtMinorVersion;
1980 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
1981 ULONG Reserved1;
1982 ULONG Reserved3;
1983 volatile ULONG TimeSlip;
1984 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
1985 ULONG AltArchitecturePad[1];
1986 LARGE_INTEGER SystemExpirationDate;
1987 ULONG SuiteMask;
1988 BOOLEAN KdDebuggerEnabled;
1989 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
1990 UCHAR NXSupportPolicy;
1991 #endif
1992 volatile ULONG ActiveConsoleId;
1993 volatile ULONG DismountCount;
1994 ULONG ComPlusPackage;
1995 ULONG LastSystemRITEventTickCount;
1996 ULONG NumberOfPhysicalPages;
1997 BOOLEAN SafeBootMode;
1998 #if (NTDDI_VERSION >= NTDDI_WIN7)
1999 _ANONYMOUS_UNION union {
2000 UCHAR TscQpcData;
2001 _ANONYMOUS_STRUCT struct {
2002 UCHAR TscQpcEnabled:1;
2003 UCHAR TscQpcSpareFlag:1;
2004 UCHAR TscQpcShift:6;
2005 } DUMMYSTRUCTNAME;
2006 } DUMMYUNIONNAME;
2007 UCHAR TscQpcPad[2];
2008 #endif
2009 #if (NTDDI_VERSION >= NTDDI_VISTA)
2010 _ANONYMOUS_UNION union {
2011 ULONG SharedDataFlags;
2012 _ANONYMOUS_STRUCT struct {
2013 ULONG DbgErrorPortPresent:1;
2014 ULONG DbgElevationEnabled:1;
2015 ULONG DbgVirtEnabled:1;
2016 ULONG DbgInstallerDetectEnabled:1;
2017 ULONG DbgSystemDllRelocated:1;
2018 ULONG DbgDynProcessorEnabled:1;
2019 ULONG DbgSEHValidationEnabled:1;
2020 ULONG SpareBits:25;
2021 } DUMMYSTRUCTNAME2;
2022 } DUMMYUNIONNAME2;
2023 #else
2024 ULONG TraceLogging;
2025 #endif
2026 ULONG DataFlagsPad[1];
2027 ULONGLONG TestRetInstruction;
2028 ULONG SystemCall;
2029 ULONG SystemCallReturn;
2030 ULONGLONG SystemCallPad[3];
2031 _ANONYMOUS_UNION union {
2032 volatile KSYSTEM_TIME TickCount;
2033 volatile ULONG64 TickCountQuad;
2034 _ANONYMOUS_STRUCT struct {
2035 ULONG ReservedTickCountOverlay[3];
2036 ULONG TickCountPad[1];
2037 } DUMMYSTRUCTNAME;
2038 } DUMMYUNIONNAME3;
2039 ULONG Cookie;
2040 ULONG CookiePad[1];
2041 #if (NTDDI_VERSION >= NTDDI_WS03)
2042 LONGLONG ConsoleSessionForegroundProcessId;
2043 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
2044 #endif
2045 #if (NTDDI_VERSION >= NTDDI_VISTA)
2046 #if (NTDDI_VERSION >= NTDDI_WIN7)
2047 USHORT UserModeGlobalLogger[16];
2048 #else
2049 USHORT UserModeGlobalLogger[8];
2050 ULONG HeapTracingPid[2];
2051 ULONG CritSecTracingPid[2];
2052 #endif
2053 ULONG ImageFileExecutionOptions;
2054 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
2055 ULONG LangGenerationCount;
2056 #else
2057 /* 4 bytes padding */
2058 #endif
2059 ULONGLONG Reserved5;
2060 volatile ULONG64 InterruptTimeBias;
2061 #endif
2062 #if (NTDDI_VERSION >= NTDDI_WIN7)
2063 volatile ULONG64 TscQpcBias;
2064 volatile ULONG ActiveProcessorCount;
2065 volatile USHORT ActiveGroupCount;
2066 USHORT Reserved4;
2067 volatile ULONG AitSamplingValue;
2068 volatile ULONG AppCompatFlag;
2069 ULONGLONG SystemDllNativeRelocation;
2070 ULONG SystemDllWowRelocation;
2071 ULONG XStatePad[1];
2072 XSTATE_CONFIGURATION XState;
2073 #endif
2074 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
2075
2076 #if (NTDDI_VERSION >= NTDDI_VISTA)
2077 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
2078 #elif (NTDDI_VERSION >= NTDDI_WINXP)
2079 extern NTSYSAPI CCHAR KeNumberProcessors;
2080 #else
2081 extern PCCHAR KeNumberProcessors;
2082 #endif
2083
2084
2085 /******************************************************************************
2086 * Kernel Debugger Types *
2087 ******************************************************************************/
2088 typedef struct _DEBUG_DEVICE_ADDRESS {
2089 UCHAR Type;
2090 BOOLEAN Valid;
2091 UCHAR Reserved[2];
2092 PUCHAR TranslatedAddress;
2093 ULONG Length;
2094 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
2095
2096 typedef struct _DEBUG_MEMORY_REQUIREMENTS {
2097 PHYSICAL_ADDRESS Start;
2098 PHYSICAL_ADDRESS MaxEnd;
2099 PVOID VirtualAddress;
2100 ULONG Length;
2101 BOOLEAN Cached;
2102 BOOLEAN Aligned;
2103 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
2104
2105 typedef struct _DEBUG_DEVICE_DESCRIPTOR {
2106 ULONG Bus;
2107 ULONG Slot;
2108 USHORT Segment;
2109 USHORT VendorID;
2110 USHORT DeviceID;
2111 UCHAR BaseClass;
2112 UCHAR SubClass;
2113 UCHAR ProgIf;
2114 BOOLEAN Initialized;
2115 BOOLEAN Configured;
2116 DEBUG_DEVICE_ADDRESS BaseAddress[6];
2117 DEBUG_MEMORY_REQUIREMENTS Memory;
2118 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
2119
2120 typedef NTSTATUS
2121 (NTAPI *pKdSetupPciDeviceForDebugging)(
2122 IN PVOID LoaderBlock OPTIONAL,
2123 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
2124
2125 typedef NTSTATUS
2126 (NTAPI *pKdReleasePciDeviceForDebugging)(
2127 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
2128
2129 typedef PVOID
2130 (NTAPI *pKdGetAcpiTablePhase0)(
2131 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2132 IN ULONG Signature);
2133
2134 typedef VOID
2135 (NTAPI *pKdCheckPowerButton)(
2136 VOID);
2137
2138 #if (NTDDI_VERSION >= NTDDI_VISTA)
2139 typedef PVOID
2140 (NTAPI *pKdMapPhysicalMemory64)(
2141 IN PHYSICAL_ADDRESS PhysicalAddress,
2142 IN ULONG NumberPages,
2143 IN BOOLEAN FlushCurrentTLB);
2144
2145 typedef VOID
2146 (NTAPI *pKdUnmapVirtualAddress)(
2147 IN PVOID VirtualAddress,
2148 IN ULONG NumberPages,
2149 IN BOOLEAN FlushCurrentTLB);
2150 #else
2151 typedef PVOID
2152 (NTAPI *pKdMapPhysicalMemory64)(
2153 IN PHYSICAL_ADDRESS PhysicalAddress,
2154 IN ULONG NumberPages);
2155
2156 typedef VOID
2157 (NTAPI *pKdUnmapVirtualAddress)(
2158 IN PVOID VirtualAddress,
2159 IN ULONG NumberPages);
2160 #endif
2161
2162 typedef ULONG
2163 (NTAPI *pKdGetPciDataByOffset)(
2164 IN ULONG BusNumber,
2165 IN ULONG SlotNumber,
2166 OUT PVOID Buffer,
2167 IN ULONG Offset,
2168 IN ULONG Length);
2169
2170 typedef ULONG
2171 (NTAPI *pKdSetPciDataByOffset)(
2172 IN ULONG BusNumber,
2173 IN ULONG SlotNumber,
2174 IN PVOID Buffer,
2175 IN ULONG Offset,
2176 IN ULONG Length);
2177 /******************************************************************************
2178 * Memory manager Types *
2179 ******************************************************************************/
2180
2181 typedef struct _PHYSICAL_MEMORY_RANGE {
2182 PHYSICAL_ADDRESS BaseAddress;
2183 LARGE_INTEGER NumberOfBytes;
2184 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
2185
2186 typedef NTSTATUS
2187 (NTAPI *PMM_ROTATE_COPY_CALLBACK_FUNCTION)(
2188 IN PMDL DestinationMdl,
2189 IN PMDL SourceMdl,
2190 IN PVOID Context);
2191
2192 typedef enum _MM_ROTATE_DIRECTION {
2193 MmToFrameBuffer,
2194 MmToFrameBufferNoCopy,
2195 MmToRegularMemory,
2196 MmToRegularMemoryNoCopy,
2197 MmMaximumRotateDirection
2198 } MM_ROTATE_DIRECTION, *PMM_ROTATE_DIRECTION;
2199
2200
2201 /******************************************************************************
2202 * Process Manager Types *
2203 ******************************************************************************/
2204
2205 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
2206 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
2207 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
2208 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
2209 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
2210
2211 typedef struct _QUOTA_LIMITS {
2212 SIZE_T PagedPoolLimit;
2213 SIZE_T NonPagedPoolLimit;
2214 SIZE_T MinimumWorkingSetSize;
2215 SIZE_T MaximumWorkingSetSize;
2216 SIZE_T PagefileLimit;
2217 LARGE_INTEGER TimeLimit;
2218 } QUOTA_LIMITS, *PQUOTA_LIMITS;
2219
2220 typedef union _RATE_QUOTA_LIMIT {
2221 ULONG RateData;
2222 _ANONYMOUS_STRUCT struct {
2223 ULONG RatePercent:7;
2224 ULONG Reserved0:25;
2225 } DUMMYSTRUCTNAME;
2226 } RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT;
2227
2228 typedef struct _QUOTA_LIMITS_EX {
2229 SIZE_T PagedPoolLimit;
2230 SIZE_T NonPagedPoolLimit;
2231 SIZE_T MinimumWorkingSetSize;
2232 SIZE_T MaximumWorkingSetSize;
2233 SIZE_T PagefileLimit;
2234 LARGE_INTEGER TimeLimit;
2235 SIZE_T WorkingSetLimit;
2236 SIZE_T Reserved2;
2237 SIZE_T Reserved3;
2238 SIZE_T Reserved4;
2239 ULONG Flags;
2240 RATE_QUOTA_LIMIT CpuRateLimit;
2241 } QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX;
2242
2243 typedef struct _IO_COUNTERS {
2244 ULONGLONG ReadOperationCount;
2245 ULONGLONG WriteOperationCount;
2246 ULONGLONG OtherOperationCount;
2247 ULONGLONG ReadTransferCount;
2248 ULONGLONG WriteTransferCount;
2249 ULONGLONG OtherTransferCount;
2250 } IO_COUNTERS, *PIO_COUNTERS;
2251
2252 typedef struct _VM_COUNTERS {
2253 SIZE_T PeakVirtualSize;
2254 SIZE_T VirtualSize;
2255 ULONG PageFaultCount;
2256 SIZE_T PeakWorkingSetSize;
2257 SIZE_T WorkingSetSize;
2258 SIZE_T QuotaPeakPagedPoolUsage;
2259 SIZE_T QuotaPagedPoolUsage;
2260 SIZE_T QuotaPeakNonPagedPoolUsage;
2261 SIZE_T QuotaNonPagedPoolUsage;
2262 SIZE_T PagefileUsage;
2263 SIZE_T PeakPagefileUsage;
2264 } VM_COUNTERS, *PVM_COUNTERS;
2265
2266 typedef struct _VM_COUNTERS_EX {
2267 SIZE_T PeakVirtualSize;
2268 SIZE_T VirtualSize;
2269 ULONG PageFaultCount;
2270 SIZE_T PeakWorkingSetSize;
2271 SIZE_T WorkingSetSize;
2272 SIZE_T QuotaPeakPagedPoolUsage;
2273 SIZE_T QuotaPagedPoolUsage;
2274 SIZE_T QuotaPeakNonPagedPoolUsage;
2275 SIZE_T QuotaNonPagedPoolUsage;
2276 SIZE_T PagefileUsage;
2277 SIZE_T PeakPagefileUsage;
2278 SIZE_T PrivateUsage;
2279 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
2280
2281 #define MAX_HW_COUNTERS 16
2282 #define THREAD_PROFILING_FLAG_DISPATCH 0x00000001
2283
2284 typedef enum _HARDWARE_COUNTER_TYPE {
2285 PMCCounter,
2286 MaxHardwareCounterType
2287 } HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE;
2288
2289 typedef struct _HARDWARE_COUNTER {
2290 HARDWARE_COUNTER_TYPE Type;
2291 ULONG Reserved;
2292 ULONG64 Index;
2293 } HARDWARE_COUNTER, *PHARDWARE_COUNTER;
2294
2295 typedef struct _POOLED_USAGE_AND_LIMITS {
2296 SIZE_T PeakPagedPoolUsage;
2297 SIZE_T PagedPoolUsage;
2298 SIZE_T PagedPoolLimit;
2299 SIZE_T PeakNonPagedPoolUsage;
2300 SIZE_T NonPagedPoolUsage;
2301 SIZE_T NonPagedPoolLimit;
2302 SIZE_T PeakPagefileUsage;
2303 SIZE_T PagefileUsage;
2304 SIZE_T PagefileLimit;
2305 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
2306
2307 typedef struct _PROCESS_ACCESS_TOKEN {
2308 HANDLE Token;
2309 HANDLE Thread;
2310 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
2311
2312 #define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL
2313 #define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1))
2314
2315 typedef struct _PROCESS_EXCEPTION_PORT {
2316 IN HANDLE ExceptionPortHandle;
2317 IN OUT ULONG StateFlags;
2318 } PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT;
2319
2320 typedef VOID
2321 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
2322 IN HANDLE ParentId,
2323 IN HANDLE ProcessId,
2324 IN BOOLEAN Create);
2325
2326 typedef struct _PS_CREATE_NOTIFY_INFO {
2327 IN SIZE_T Size;
2328 _ANONYMOUS_UNION union {
2329 IN ULONG Flags;
2330 _ANONYMOUS_STRUCT struct {
2331 IN ULONG FileOpenNameAvailable:1;
2332 IN ULONG Reserved:31;
2333 } DUMMYSTRUCTNAME;
2334 } DUMMYUNIONNAME;
2335 IN HANDLE ParentProcessId;
2336 IN CLIENT_ID CreatingThreadId;
2337 IN OUT struct _FILE_OBJECT *FileObject;
2338 IN PCUNICODE_STRING ImageFileName;
2339 IN PCUNICODE_STRING CommandLine OPTIONAL;
2340 IN OUT NTSTATUS CreationStatus;
2341 } PS_CREATE_NOTIFY_INFO, *PPS_CREATE_NOTIFY_INFO;
2342
2343 typedef VOID
2344 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE_EX)(
2345 IN OUT PEPROCESS Process,
2346 IN HANDLE ProcessId,
2347 IN PPS_CREATE_NOTIFY_INFO CreateInfo OPTIONAL);
2348
2349 typedef VOID
2350 (NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
2351 IN HANDLE ProcessId,
2352 IN HANDLE ThreadId,
2353 IN BOOLEAN Create);
2354
2355 #define IMAGE_ADDRESSING_MODE_32BIT 3
2356
2357 typedef struct _IMAGE_INFO {
2358 _ANONYMOUS_UNION union {
2359 ULONG Properties;
2360 _ANONYMOUS_STRUCT struct {
2361 ULONG ImageAddressingMode:8;
2362 ULONG SystemModeImage:1;
2363 ULONG ImageMappedToAllPids:1;
2364 ULONG ExtendedInfoPresent:1;
2365 ULONG Reserved:21;
2366 } DUMMYSTRUCTNAME;
2367 } DUMMYUNIONNAME;
2368 PVOID ImageBase;
2369 ULONG ImageSelector;
2370 SIZE_T ImageSize;
2371 ULONG ImageSectionNumber;
2372 } IMAGE_INFO, *PIMAGE_INFO;
2373
2374 typedef struct _IMAGE_INFO_EX {
2375 SIZE_T Size;
2376 IMAGE_INFO ImageInfo;
2377 struct _FILE_OBJECT *FileObject;
2378 } IMAGE_INFO_EX, *PIMAGE_INFO_EX;
2379
2380 typedef VOID
2381 (NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
2382 IN PUNICODE_STRING FullImageName,
2383 IN HANDLE ProcessId,
2384 IN PIMAGE_INFO ImageInfo);
2385
2386 #define THREAD_CSWITCH_PMU_DISABLE FALSE
2387 #define THREAD_CSWITCH_PMU_ENABLE TRUE
2388
2389 #define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001
2390
2391 #define PROCESS_HANDLE_TRACING_MAX_STACKS 16
2392
2393 typedef struct _NT_TIB {
2394 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2395 PVOID StackBase;
2396 PVOID StackLimit;
2397 PVOID SubSystemTib;
2398 _ANONYMOUS_UNION union {
2399 PVOID FiberData;
2400 ULONG Version;
2401 } DUMMYUNIONNAME;
2402 PVOID ArbitraryUserPointer;
2403 struct _NT_TIB *Self;
2404 } NT_TIB, *PNT_TIB;
2405
2406 typedef struct _NT_TIB32 {
2407 ULONG ExceptionList;
2408 ULONG StackBase;
2409 ULONG StackLimit;
2410 ULONG SubSystemTib;
2411 _ANONYMOUS_UNION union {
2412 ULONG FiberData;
2413 ULONG Version;
2414 } DUMMYUNIONNAME;
2415 ULONG ArbitraryUserPointer;
2416 ULONG Self;
2417 } NT_TIB32,*PNT_TIB32;
2418
2419 typedef struct _NT_TIB64 {
2420 ULONG64 ExceptionList;
2421 ULONG64 StackBase;
2422 ULONG64 StackLimit;
2423 ULONG64 SubSystemTib;
2424 _ANONYMOUS_UNION union {
2425 ULONG64 FiberData;
2426 ULONG Version;
2427 } DUMMYUNIONNAME;
2428 ULONG64 ArbitraryUserPointer;
2429 ULONG64 Self;
2430 } NT_TIB64,*PNT_TIB64;
2431
2432 typedef enum _PROCESSINFOCLASS {
2433 ProcessBasicInformation,
2434 ProcessQuotaLimits,
2435 ProcessIoCounters,
2436 ProcessVmCounters,
2437 ProcessTimes,
2438 ProcessBasePriority,
2439 ProcessRaisePriority,
2440 ProcessDebugPort,
2441 ProcessExceptionPort,
2442 ProcessAccessToken,
2443 ProcessLdtInformation,
2444 ProcessLdtSize,
2445 ProcessDefaultHardErrorMode,
2446 ProcessIoPortHandlers,
2447 ProcessPooledUsageAndLimits,
2448 ProcessWorkingSetWatch,
2449 ProcessUserModeIOPL,
2450 ProcessEnableAlignmentFaultFixup,
2451 ProcessPriorityClass,
2452 ProcessWx86Information,
2453 ProcessHandleCount,
2454 ProcessAffinityMask,
2455 ProcessPriorityBoost,
2456 ProcessDeviceMap,
2457 ProcessSessionInformation,
2458 ProcessForegroundInformation,
2459 ProcessWow64Information,
2460 ProcessImageFileName,
2461 ProcessLUIDDeviceMapsEnabled,
2462 ProcessBreakOnTermination,
2463 ProcessDebugObjectHandle,
2464 ProcessDebugFlags,
2465 ProcessHandleTracing,
2466 ProcessIoPriority,
2467 ProcessExecuteFlags,
2468 ProcessTlsInformation,
2469 ProcessCookie,
2470 ProcessImageInformation,
2471 ProcessCycleTime,
2472 ProcessPagePriority,
2473 ProcessInstrumentationCallback,
2474 ProcessThreadStackAllocation,
2475 ProcessWorkingSetWatchEx,
2476 ProcessImageFileNameWin32,
2477 ProcessImageFileMapping,
2478 ProcessAffinityUpdateMode,
2479 ProcessMemoryAllocationMode,
2480 ProcessGroupInformation,
2481 ProcessTokenVirtualizationEnabled,
2482 ProcessConsoleHostProcess,
2483 ProcessWindowInformation,
2484 MaxProcessInfoClass
2485 } PROCESSINFOCLASS;
2486
2487 typedef enum _THREADINFOCLASS {
2488 ThreadBasicInformation,
2489 ThreadTimes,
2490 ThreadPriority,
2491 ThreadBasePriority,
2492 ThreadAffinityMask,
2493 ThreadImpersonationToken,
2494 ThreadDescriptorTableEntry,
2495 ThreadEnableAlignmentFaultFixup,
2496 ThreadEventPair_Reusable,
2497 ThreadQuerySetWin32StartAddress,
2498 ThreadZeroTlsCell,
2499 ThreadPerformanceCount,
2500 ThreadAmILastThread,
2501 ThreadIdealProcessor,
2502 ThreadPriorityBoost,
2503 ThreadSetTlsArrayAddress,
2504 ThreadIsIoPending,
2505 ThreadHideFromDebugger,
2506 ThreadBreakOnTermination,
2507 ThreadSwitchLegacyState,
2508 ThreadIsTerminated,
2509 ThreadLastSystemCall,
2510 ThreadIoPriority,
2511 ThreadCycleTime,
2512 ThreadPagePriority,
2513 ThreadActualBasePriority,
2514 ThreadTebInformation,
2515 ThreadCSwitchMon,
2516 ThreadCSwitchPmu,
2517 ThreadWow64Context,
2518 ThreadGroupInformation,
2519 ThreadUmsInformation,
2520 ThreadCounterProfiling,
2521 ThreadIdealProcessorEx,
2522 MaxThreadInfoClass
2523 } THREADINFOCLASS;
2524
2525 typedef struct _PAGE_PRIORITY_INFORMATION {
2526 ULONG PagePriority;
2527 } PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION;
2528
2529 typedef struct _PROCESS_WS_WATCH_INFORMATION {
2530 PVOID FaultingPc;
2531 PVOID FaultingVa;
2532 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
2533
2534 typedef struct _PROCESS_BASIC_INFORMATION {
2535 NTSTATUS ExitStatus;
2536 struct _PEB *PebBaseAddress;
2537 ULONG_PTR AffinityMask;
2538 KPRIORITY BasePriority;
2539 ULONG_PTR UniqueProcessId;
2540 ULONG_PTR InheritedFromUniqueProcessId;
2541 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
2542
2543 typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION {
2544 SIZE_T Size;
2545 PROCESS_BASIC_INFORMATION BasicInfo;
2546 _ANONYMOUS_UNION union {
2547 ULONG Flags;
2548 _ANONYMOUS_STRUCT struct {
2549 ULONG IsProtectedProcess:1;
2550 ULONG IsWow64Process:1;
2551 ULONG IsProcessDeleting:1;
2552 ULONG IsCrossSessionCreate:1;
2553 ULONG SpareBits:28;
2554 } DUMMYSTRUCTNAME;
2555 } DUMMYUNIONNAME;
2556 } PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION;
2557
2558 typedef struct _PROCESS_DEVICEMAP_INFORMATION {
2559 _ANONYMOUS_UNION union {
2560 struct {
2561 HANDLE DirectoryHandle;
2562 } Set;
2563 struct {
2564 ULONG DriveMap;
2565 UCHAR DriveType[32];
2566 } Query;
2567 } DUMMYUNIONNAME;
2568 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
2569
2570 typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX {
2571 _ANONYMOUS_UNION union {
2572 struct {
2573 HANDLE DirectoryHandle;
2574 } Set;
2575 struct {
2576 ULONG DriveMap;
2577 UCHAR DriveType[32];
2578 } Query;
2579 } DUMMYUNIONNAME;
2580 ULONG Flags;
2581 } PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
2582
2583 typedef struct _PROCESS_SESSION_INFORMATION {
2584 ULONG SessionId;
2585 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
2586
2587 typedef struct _PROCESS_HANDLE_TRACING_ENABLE {
2588 ULONG Flags;
2589 } PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE;
2590
2591 typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX {
2592 ULONG Flags;
2593 ULONG TotalSlots;
2594 } PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX;
2595
2596 typedef struct _PROCESS_HANDLE_TRACING_ENTRY {
2597 HANDLE Handle;
2598 CLIENT_ID ClientId;
2599 ULONG Type;
2600 PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS];
2601 } PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY;
2602
2603 typedef struct _PROCESS_HANDLE_TRACING_QUERY {
2604 HANDLE Handle;
2605 ULONG TotalTraces;
2606 PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1];
2607 } PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY;
2608
2609 extern NTKERNELAPI PEPROCESS PsInitialSystemProcess;
2610
2611
2612 /******************************************************************************
2613 * Runtime Library Types *
2614 ******************************************************************************/
2615
2616
2617 #ifndef _RTL_RUN_ONCE_DEF
2618 #define _RTL_RUN_ONCE_DEF
2619
2620 #define RTL_RUN_ONCE_INIT {0}
2621
2622 #define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL
2623 #define RTL_RUN_ONCE_ASYNC 0x00000002UL
2624 #define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL
2625
2626 #define RTL_RUN_ONCE_CTX_RESERVED_BITS 2
2627
2628 #define RTL_HASH_ALLOCATED_HEADER 0x00000001
2629
2630 #define RTL_HASH_RESERVED_SIGNATURE 0
2631
2632 /* RtlVerifyVersionInfo() ComparisonType */
2633
2634 #define VER_EQUAL 1
2635 #define VER_GREATER 2
2636 #define VER_GREATER_EQUAL 3
2637 #define VER_LESS 4
2638 #define VER_LESS_EQUAL 5
2639 #define VER_AND 6
2640 #define VER_OR 7
2641
2642 #define VER_CONDITION_MASK 7
2643 #define VER_NUM_BITS_PER_CONDITION_MASK 3
2644
2645 /* RtlVerifyVersionInfo() TypeMask */
2646
2647 #define VER_MINORVERSION 0x0000001
2648 #define VER_MAJORVERSION 0x0000002
2649 #define VER_BUILDNUMBER 0x0000004
2650 #define VER_PLATFORMID 0x0000008
2651 #define VER_SERVICEPACKMINOR 0x0000010
2652 #define VER_SERVICEPACKMAJOR 0x0000020
2653 #define VER_SUITENAME 0x0000040
2654 #define VER_PRODUCT_TYPE 0x0000080
2655
2656 #define VER_NT_WORKSTATION 0x0000001
2657 #define VER_NT_DOMAIN_CONTROLLER 0x0000002
2658 #define VER_NT_SERVER 0x0000003
2659
2660 #define VER_PLATFORM_WIN32s 0
2661 #define VER_PLATFORM_WIN32_WINDOWS 1
2662 #define VER_PLATFORM_WIN32_NT 2
2663
2664 typedef union _RTL_RUN_ONCE {
2665 PVOID Ptr;
2666 } RTL_RUN_ONCE, *PRTL_RUN_ONCE;
2667
2668 typedef ULONG /* LOGICAL */
2669 (NTAPI *PRTL_RUN_ONCE_INIT_FN) (
2670 IN OUT PRTL_RUN_ONCE RunOnce,
2671 IN OUT PVOID Parameter OPTIONAL,
2672 IN OUT PVOID *Context OPTIONAL);
2673
2674 #endif /* _RTL_RUN_ONCE_DEF */
2675
2676 typedef enum _TABLE_SEARCH_RESULT {
2677 TableEmptyTree,
2678 TableFoundNode,
2679 TableInsertAsLeft,
2680 TableInsertAsRight
2681 } TABLE_SEARCH_RESULT;
2682
2683 typedef enum _RTL_GENERIC_COMPARE_RESULTS {
2684 GenericLessThan,
2685 GenericGreaterThan,
2686 GenericEqual
2687 } RTL_GENERIC_COMPARE_RESULTS;
2688
2689 // Forwarder
2690 struct _RTL_AVL_TABLE;
2691
2692 typedef RTL_GENERIC_COMPARE_RESULTS
2693 (NTAPI *PRTL_AVL_COMPARE_ROUTINE) (
2694 IN struct _RTL_AVL_TABLE *Table,
2695 IN PVOID FirstStruct,
2696 IN PVOID SecondStruct);
2697
2698 typedef PVOID
2699 (NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) (
2700 IN struct _RTL_AVL_TABLE *Table,
2701 IN CLONG ByteSize);
2702
2703 typedef VOID
2704 (NTAPI *PRTL_AVL_FREE_ROUTINE) (
2705 IN struct _RTL_AVL_TABLE *Table,
2706 IN PVOID Buffer);
2707
2708 typedef NTSTATUS
2709 (NTAPI *PRTL_AVL_MATCH_FUNCTION) (
2710 IN struct _RTL_AVL_TABLE *Table,
2711 IN PVOID UserData,
2712 IN PVOID MatchData);
2713
2714 typedef struct _RTL_BALANCED_LINKS {
2715 struct _RTL_BALANCED_LINKS *Parent;
2716 struct _RTL_BALANCED_LINKS *LeftChild;
2717 struct _RTL_BALANCED_LINKS *RightChild;
2718 CHAR Balance;
2719 UCHAR Reserved[3];
2720 } RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS;
2721
2722 typedef struct _RTL_AVL_TABLE {
2723 RTL_BALANCED_LINKS BalancedRoot;
2724 PVOID OrderedPointer;
2725 ULONG WhichOrderedElement;
2726 ULONG NumberGenericTableElements;
2727 ULONG DepthOfTree;
2728 PRTL_BALANCED_LINKS RestartKey;
2729 ULONG DeleteCount;
2730 PRTL_AVL_COMPARE_ROUTINE CompareRoutine;
2731 PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine;
2732 PRTL_AVL_FREE_ROUTINE FreeRoutine;
2733 PVOID TableContext;
2734 } RTL_AVL_TABLE, *PRTL_AVL_TABLE;
2735
2736 #ifndef RTL_USE_AVL_TABLES
2737
2738 struct _RTL_GENERIC_TABLE;
2739
2740 typedef RTL_GENERIC_COMPARE_RESULTS
2741 (NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) (
2742 IN struct _RTL_GENERIC_TABLE *Table,
2743 IN PVOID FirstStruct,
2744 IN PVOID SecondStruct);
2745
2746 typedef PVOID
2747 (NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) (
2748 IN struct _RTL_GENERIC_TABLE *Table,
2749 IN CLONG ByteSize);
2750
2751 typedef VOID
2752 (NTAPI *PRTL_GENERIC_FREE_ROUTINE) (
2753 IN struct _RTL_GENERIC_TABLE *Table,
2754 IN PVOID Buffer);
2755
2756 typedef struct _RTL_SPLAY_LINKS {
2757 struct _RTL_SPLAY_LINKS *Parent;
2758 struct _RTL_SPLAY_LINKS *LeftChild;
2759 struct _RTL_SPLAY_LINKS *RightChild;
2760 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
2761
2762 typedef struct _RTL_GENERIC_TABLE {
2763 PRTL_SPLAY_LINKS TableRoot;
2764 LIST_ENTRY InsertOrderList;
2765 PLIST_ENTRY OrderedPointer;
2766 ULONG WhichOrderedElement;
2767 ULONG NumberGenericTableElements;
2768 PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine;
2769 PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine;
2770 PRTL_GENERIC_FREE_ROUTINE FreeRoutine;
2771 PVOID TableContext;
2772 } RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE;
2773
2774 #endif /* !RTL_USE_AVL_TABLES */
2775
2776 #ifdef RTL_USE_AVL_TABLES
2777
2778 #undef PRTL_GENERIC_COMPARE_ROUTINE
2779 #undef RTL_GENERIC_COMPARE_ROUTINE
2780 #undef PRTL_GENERIC_ALLOCATE_ROUTINE
2781 #undef RTL_GENERIC_ALLOCATE_ROUTINE
2782 #undef PRTL_GENERIC_FREE_ROUTINE
2783 #undef RTL_GENERIC_FREE_ROUTINE
2784 #undef RTL_GENERIC_TABLE
2785 #undef PRTL_GENERIC_TABLE
2786
2787 #define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE
2788 #define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE
2789 #define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE
2790 #define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE
2791 #define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE
2792 #define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE
2793 #define RTL_GENERIC_TABLE RTL_AVL_TABLE
2794 #define PRTL_GENERIC_TABLE PRTL_AVL_TABLE
2795
2796 #endif /* RTL_USE_AVL_TABLES */
2797
2798 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY {
2799 LIST_ENTRY Linkage;
2800 ULONG_PTR Signature;
2801 } RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY;
2802
2803 typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT {
2804 PLIST_ENTRY ChainHead;
2805 PLIST_ENTRY PrevLinkage;
2806 ULONG_PTR Signature;
2807 } RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT;
2808
2809 typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR {
2810 RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry;
2811 PLIST_ENTRY ChainHead;
2812 ULONG BucketIndex;
2813 } RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR;
2814
2815 typedef struct _RTL_DYNAMIC_HASH_TABLE {
2816 ULONG Flags;
2817 ULONG Shift;
2818 ULONG TableSize;
2819 ULONG Pivot;
2820 ULONG DivisorMask;
2821 ULONG NumEntries;
2822 ULONG NonEmptyBuckets;
2823 ULONG NumEnumerators;
2824 PVOID Directory;
2825 } RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE;
2826
2827 typedef struct _OSVERSIONINFOA {
2828 ULONG dwOSVersionInfoSize;
2829 ULONG dwMajorVersion;
2830 ULONG dwMinorVersion;
2831 ULONG dwBuildNumber;
2832 ULONG dwPlatformId;
2833 CHAR szCSDVersion[128];
2834 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
2835
2836 typedef struct _OSVERSIONINFOW {
2837 ULONG dwOSVersionInfoSize;
2838 ULONG dwMajorVersion;
2839 ULONG dwMinorVersion;
2840 ULONG dwBuildNumber;
2841 ULONG dwPlatformId;
2842 WCHAR szCSDVersion[128];
2843 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
2844
2845 typedef struct _OSVERSIONINFOEXA {
2846 ULONG dwOSVersionInfoSize;
2847 ULONG dwMajorVersion;
2848 ULONG dwMinorVersion;
2849 ULONG dwBuildNumber;
2850 ULONG dwPlatformId;
2851 CHAR szCSDVersion[128];
2852 USHORT wServicePackMajor;
2853 USHORT wServicePackMinor;
2854 USHORT wSuiteMask;
2855 UCHAR wProductType;
2856 UCHAR wReserved;
2857 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
2858
2859 typedef struct _OSVERSIONINFOEXW {
2860 ULONG dwOSVersionInfoSize;
2861 ULONG dwMajorVersion;
2862 ULONG dwMinorVersion;
2863 ULONG dwBuildNumber;
2864 ULONG dwPlatformId;
2865 WCHAR szCSDVersion[128];
2866 USHORT wServicePackMajor;
2867 USHORT wServicePackMinor;
2868 USHORT wSuiteMask;
2869 UCHAR wProductType;
2870 UCHAR wReserved;
2871 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
2872
2873 #ifdef UNICODE
2874 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
2875 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
2876 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
2877 typedef OSVERSIONINFOW OSVERSIONINFO;
2878 typedef POSVERSIONINFOW POSVERSIONINFO;
2879 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
2880 #else
2881 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
2882 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
2883 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
2884 typedef OSVERSIONINFOA OSVERSIONINFO;
2885 typedef POSVERSIONINFOA POSVERSIONINFO;
2886 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
2887 #endif /* UNICODE */
2888
2889 #define HASH_ENTRY_KEY(x) ((x)->Signature)
2890
2891 /******************************************************************************
2892 * Security Manager Types *
2893 ******************************************************************************/
2894 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
2895
2896 typedef enum _WELL_KNOWN_SID_TYPE {
2897 WinNullSid = 0,
2898 WinWorldSid = 1,
2899 WinLocalSid = 2,
2900 WinCreatorOwnerSid = 3,
2901 WinCreatorGroupSid = 4,
2902 WinCreatorOwnerServerSid = 5,
2903 WinCreatorGroupServerSid = 6,
2904 WinNtAuthoritySid = 7,
2905 WinDialupSid = 8,
2906 WinNetworkSid = 9,
2907 WinBatchSid = 10,
2908 WinInteractiveSid = 11,
2909 WinServiceSid = 12,
2910 WinAnonymousSid = 13,
2911 WinProxySid = 14,
2912 WinEnterpriseControllersSid = 15,
2913 WinSelfSid = 16,
2914 WinAuthenticatedUserSid = 17,
2915 WinRestrictedCodeSid = 18,
2916 WinTerminalServerSid = 19,
2917 WinRemoteLogonIdSid = 20,
2918 WinLogonIdsSid = 21,
2919 WinLocalSystemSid = 22,
2920 WinLocalServiceSid = 23,
2921 WinNetworkServiceSid = 24,
2922 WinBuiltinDomainSid = 25,
2923 WinBuiltinAdministratorsSid = 26,
2924 WinBuiltinUsersSid = 27,
2925 WinBuiltinGuestsSid = 28,
2926 WinBuiltinPowerUsersSid = 29,
2927 WinBuiltinAccountOperatorsSid = 30,
2928 WinBuiltinSystemOperatorsSid = 31,
2929 WinBuiltinPrintOperatorsSid = 32,
2930 WinBuiltinBackupOperatorsSid = 33,
2931 WinBuiltinReplicatorSid = 34,
2932 WinBuiltinPreWindows2000CompatibleAccessSid = 35,
2933 WinBuiltinRemoteDesktopUsersSid = 36,
2934 WinBuiltinNetworkConfigurationOperatorsSid = 37,
2935 WinAccountAdministratorSid = 38,
2936 WinAccountGuestSid = 39,
2937 WinAccountKrbtgtSid = 40,
2938 WinAccountDomainAdminsSid = 41,
2939 WinAccountDomainUsersSid = 42,
2940 WinAccountDomainGuestsSid = 43,
2941 WinAccountComputersSid = 44,
2942 WinAccountControllersSid = 45,
2943 WinAccountCertAdminsSid = 46,
2944 WinAccountSchemaAdminsSid = 47,
2945 WinAccountEnterpriseAdminsSid = 48,
2946 WinAccountPolicyAdminsSid = 49,
2947 WinAccountRasAndIasServersSid = 50,
2948 WinNTLMAuthenticationSid = 51,
2949 WinDigestAuthenticationSid = 52,
2950 WinSChannelAuthenticationSid = 53,
2951 WinThisOrganizationSid = 54,
2952 WinOtherOrganizationSid = 55,
2953 WinBuiltinIncomingForestTrustBuildersSid = 56,
2954 WinBuiltinPerfMonitoringUsersSid = 57,
2955 WinBuiltinPerfLoggingUsersSid = 58,
2956 WinBuiltinAuthorizationAccessSid = 59,
2957 WinBuiltinTerminalServerLicenseServersSid = 60,
2958 WinBuiltinDCOMUsersSid = 61,
2959 WinBuiltinIUsersSid = 62,
2960 WinIUserSid = 63,
2961 WinBuiltinCryptoOperatorsSid = 64,
2962 WinUntrustedLabelSid = 65,
2963 WinLowLabelSid = 66,
2964 WinMediumLabelSid = 67,
2965 WinHighLabelSid = 68,
2966 WinSystemLabelSid = 69,
2967 WinWriteRestrictedCodeSid = 70,
2968 WinCreatorOwnerRightsSid = 71,
2969 WinCacheablePrincipalsGroupSid = 72,
2970 WinNonCacheablePrincipalsGroupSid = 73,
2971 WinEnterpriseReadonlyControllersSid = 74,
2972 WinAccountReadonlyControllersSid = 75,
2973 WinBuiltinEventLogReadersGroup = 76,
2974 WinNewEnterpriseReadonlyControllersSid = 77,
2975 WinBuiltinCertSvcDComAccessGroup = 78,
2976 WinMediumPlusLabelSid = 79,
2977 WinLocalLogonSid = 80,
2978 WinConsoleLogonSid = 81,
2979 WinThisOrganizationCertificateSid = 82,
2980 } WELL_KNOWN_SID_TYPE;
2981
2982 #if defined(_M_IX86)
2983
2984 #define PAUSE_PROCESSOR YieldProcessor();
2985
2986 #define KERNEL_STACK_SIZE 12288
2987 #define KERNEL_LARGE_STACK_SIZE 61440
2988 #define KERNEL_LARGE_STACK_COMMIT 12288
2989
2990 #define SIZE_OF_80387_REGISTERS 80
2991
2992 #if !defined(RC_INVOKED)
2993
2994 #define CONTEXT_i386 0x10000
2995 #define CONTEXT_i486 0x10000
2996 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
2997 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
2998 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
2999 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
3000 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
3001 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
3002
3003 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
3004 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \
3005 CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \
3006 CONTEXT_EXTENDED_REGISTERS)
3007
3008 #define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L)
3009
3010 #endif /* !defined(RC_INVOKED) */
3011
3012 typedef struct _FLOATING_SAVE_AREA {
3013 ULONG ControlWord;
3014 ULONG StatusWord;
3015 ULONG TagWord;
3016 ULONG ErrorOffset;
3017 ULONG ErrorSelector;
3018 ULONG DataOffset;
3019 ULONG DataSelector;
3020 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
3021 ULONG Cr0NpxState;
3022 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
3023
3024 #include "pshpack4.h"
3025 typedef struct _CONTEXT {
3026 ULONG ContextFlags;
3027 ULONG Dr0;
3028 ULONG Dr1;
3029 ULONG Dr2;
3030 ULONG Dr3;
3031 ULONG Dr6;
3032 ULONG Dr7;
3033 FLOATING_SAVE_AREA FloatSave;
3034 ULONG SegGs;
3035 ULONG SegFs;
3036 ULONG SegEs;
3037 ULONG SegDs;
3038 ULONG Edi;
3039 ULONG Esi;
3040 ULONG Ebx;
3041 ULONG Edx;
3042 ULONG Ecx;
3043 ULONG Eax;
3044 ULONG Ebp;
3045 ULONG Eip;
3046 ULONG SegCs;
3047 ULONG EFlags;
3048 ULONG Esp;
3049 ULONG SegSs;
3050 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
3051 } CONTEXT;
3052 #include "poppack.h"
3053
3054 #define KeGetPcr() PCR
3055
3056 #define PCR_MINOR_VERSION 1
3057 #define PCR_MAJOR_VERSION 1
3058
3059 typedef struct _KPCR {
3060 union {
3061 NT_TIB NtTib;
3062 struct {
3063 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
3064 PVOID Used_StackBase;
3065 PVOID Spare2;
3066 PVOID TssCopy;
3067 ULONG ContextSwitches;
3068 KAFFINITY SetMemberCopy;
3069 PVOID Used_Self;
3070 };
3071 };
3072 struct _KPCR *SelfPcr;
3073 struct _KPRCB *Prcb;
3074 KIRQL Irql;
3075 ULONG IRR;
3076 ULONG IrrActive;
3077 ULONG IDR;
3078 PVOID KdVersionBlock;
3079 struct _KIDTENTRY *IDT;
3080 struct _KGDTENTRY *GDT;
3081 struct _KTSS *TSS;
3082 USHORT MajorVersion;
3083 USHORT MinorVersion;
3084 KAFFINITY SetMember;
3085 ULONG StallScaleFactor;
3086 UCHAR SpareUnused;
3087 UCHAR Number;
3088 UCHAR Spare0;
3089 UCHAR SecondLevelCacheAssociativity;
3090 ULONG VdmAlert;
3091 ULONG KernelReserved[14];
3092 ULONG SecondLevelCacheSize;
3093 ULONG HalReserved[16];
3094 } KPCR, *PKPCR;
3095
3096 FORCEINLINE
3097 ULONG
3098 KeGetCurrentProcessorNumber(VOID)
3099 {
3100 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
3101 }
3102
3103
3104
3105
3106
3107
3108 extern NTKERNELAPI PVOID MmHighestUserAddress;
3109 extern NTKERNELAPI PVOID MmSystemRangeStart;
3110 extern NTKERNELAPI ULONG MmUserProbeAddress;
3111
3112 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3113 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3114 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
3115 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
3116 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
3117 #else
3118 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3119 #endif
3120 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3121 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
3122 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
3123 #if !defined (_X86PAE_)
3124 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
3125 #else
3126 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
3127 #endif
3128
3129 #elif defined(_M_AMD64)
3130
3131 #define PAUSE_PROCESSOR YieldProcessor();
3132
3133 #define KERNEL_STACK_SIZE 0x6000
3134 #define KERNEL_LARGE_STACK_SIZE 0x12000
3135 #define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE
3136
3137 #define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000
3138
3139 #define EXCEPTION_READ_FAULT 0
3140 #define EXCEPTION_WRITE_FAULT 1
3141 #define EXCEPTION_EXECUTE_FAULT 8
3142
3143 #if !defined(RC_INVOKED)
3144
3145 #define CONTEXT_AMD64 0x100000
3146
3147 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
3148 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
3149 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
3150 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
3151 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
3152
3153 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
3154 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
3155
3156 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
3157
3158 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
3159 #define CONTEXT_SERVICE_ACTIVE 0x10000000
3160 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
3161 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
3162
3163 #endif /* !defined(RC_INVOKED) */
3164
3165 #define INITIAL_MXCSR 0x1f80
3166 #define INITIAL_FPCSR 0x027f
3167
3168 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
3169 ULONG64 P1Home;
3170 ULONG64 P2Home;
3171 ULONG64 P3Home;
3172 ULONG64 P4Home;
3173 ULONG64 P5Home;
3174 ULONG64 P6Home;
3175 ULONG ContextFlags;
3176 ULONG MxCsr;
3177 USHORT SegCs;
3178 USHORT SegDs;
3179 USHORT SegEs;
3180 USHORT SegFs;
3181 USHORT SegGs;
3182 USHORT SegSs;
3183 ULONG EFlags;
3184 ULONG64 Dr0;
3185 ULONG64 Dr1;
3186 ULONG64 Dr2;
3187 ULONG64 Dr3;
3188 ULONG64 Dr6;
3189 ULONG64 Dr7;
3190 ULONG64 Rax;
3191 ULONG64 Rcx;
3192 ULONG64 Rdx;
3193 ULONG64 Rbx;
3194 ULONG64 Rsp;
3195 ULONG64 Rbp;
3196 ULONG64 Rsi;
3197 ULONG64 Rdi;
3198 ULONG64 R8;
3199 ULONG64 R9;
3200 ULONG64 R10;
3201 ULONG64 R11;
3202 ULONG64 R12;
3203 ULONG64 R13;
3204 ULONG64 R14;
3205 ULONG64 R15;
3206 ULONG64 Rip;
3207 union {
3208 XMM_SAVE_AREA32 FltSave;
3209 struct {
3210 M128A Header[2];
3211 M128A Legacy[8];
3212 M128A Xmm0;
3213 M128A Xmm1;
3214 M128A Xmm2;
3215 M128A Xmm3;
3216 M128A Xmm4;
3217 M128A Xmm5;
3218 M128A Xmm6;
3219 M128A Xmm7;
3220 M128A Xmm8;
3221 M128A Xmm9;
3222 M128A Xmm10;
3223 M128A Xmm11;
3224 M128A Xmm12;
3225 M128A Xmm13;
3226 M128A Xmm14;
3227 M128A Xmm15;
3228 } DUMMYSTRUCTNAME;
3229 } DUMMYUNIONNAME;
3230 M128A VectorRegister[26];
3231 ULONG64 VectorControl;
3232 ULONG64 DebugControl;
3233 ULONG64 LastBranchToRip;
3234 ULONG64 LastBranchFromRip;
3235 ULONG64 LastExceptionToRip;
3236 ULONG64 LastExceptionFromRip;
3237 } CONTEXT;
3238
3239 #define PCR_MINOR_VERSION 1
3240 #define PCR_MAJOR_VERSION 1
3241
3242 typedef struct _KPCR
3243 {
3244 _ANONYMOUS_UNION union
3245 {
3246 NT_TIB NtTib;
3247 _ANONYMOUS_STRUCT struct
3248 {
3249 union _KGDTENTRY64 *GdtBase;
3250 struct _KTSS64 *TssBase;
3251 ULONG64 UserRsp;
3252 struct _KPCR *Self;
3253 struct _KPRCB *CurrentPrcb;
3254 PKSPIN_LOCK_QUEUE LockArray;
3255 PVOID Used_Self;
3256 };
3257 };
3258 union _KIDTENTRY64 *IdtBase;
3259 ULONG64 Unused[2];
3260 KIRQL Irql;
3261 UCHAR SecondLevelCacheAssociativity;
3262 UCHAR ObsoleteNumber;
3263 UCHAR Fill0;
3264 ULONG Unused0[3];
3265 USHORT MajorVersion;
3266 USHORT MinorVersion;
3267 ULONG StallScaleFactor;
3268 PVOID Unused1[3];
3269 ULONG KernelReserved[15];
3270 ULONG SecondLevelCacheSize;
3271 ULONG HalReserved[16];
3272 ULONG Unused2;
3273 PVOID KdVersionBlock;
3274 PVOID Unused3;
3275 ULONG PcrAlign1[24];
3276 } KPCR, *PKPCR;
3277
3278 FORCEINLINE
3279 PKPCR
3280 KeGetPcr(VOID)
3281 {
3282 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
3283 }
3284
3285 FORCEINLINE
3286 ULONG
3287 KeGetCurrentProcessorNumber(VOID)
3288 {
3289 return (ULONG)__readgsword(0x184);
3290 }
3291
3292
3293 #define PTI_SHIFT 12L
3294 #define PDI_SHIFT 21L
3295 #define PPI_SHIFT 30L
3296 #define PXI_SHIFT 39L
3297 #define PTE_PER_PAGE 512
3298 #define PDE_PER_PAGE 512
3299 #define PPE_PER_PAGE 512
3300 #define PXE_PER_PAGE 512
3301 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
3302 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
3303 #define PPI_MASK (PPE_PER_PAGE - 1)
3304 #define PXI_MASK (PXE_PER_PAGE - 1)
3305
3306 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
3307 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
3308 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
3309 #define PDE_BASE 0xFFFFF6FB40000000ULL
3310 #define PTE_BASE 0xFFFFF68000000000ULL
3311 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
3312 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
3313 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
3314 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
3315
3316 extern NTKERNELAPI PVOID MmHighestUserAddress;
3317 extern NTKERNELAPI PVOID MmSystemRangeStart;
3318 extern NTKERNELAPI ULONG64 MmUserProbeAddress;
3319
3320 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3321 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3322 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3323 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3324 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
3325
3326
3327 #elif defined(_M_IA64)
3328
3329 #elif defined(_M_PPC)
3330
3331
3332 #elif defined(_M_MIPS)
3333
3334 #elif defined(_M_ARM)
3335 #else
3336 #error Unknown Architecture
3337 #endif
3338
3339 /******************************************************************************
3340 * Executive Functions *
3341 ******************************************************************************/
3342
3343 static __inline PVOID
3344 ExAllocateFromZone(
3345 IN PZONE_HEADER Zone)
3346 {
3347 if (Zone->FreeList.Next)
3348 Zone->FreeList.Next = Zone->FreeList.Next->Next;
3349 return (PVOID) Zone->FreeList.Next;
3350 }
3351
3352 static __inline PVOID
3353 ExFreeToZone(
3354 IN PZONE_HEADER Zone,
3355 IN PVOID Block)
3356 {
3357 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
3358 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
3359 return ((PSINGLE_LIST_ENTRY) Block)->Next;
3360 }
3361
3362 /*
3363 * PVOID
3364 * ExInterlockedAllocateFromZone(
3365 * IN PZONE_HEADER Zone,
3366 * IN PKSPIN_LOCK Lock)
3367 */
3368 #define ExInterlockedAllocateFromZone(Zone, Lock) \
3369 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
3370
3371 /* PVOID
3372 * ExInterlockedFreeToZone(
3373 * IN PZONE_HEADER Zone,
3374 * IN PVOID Block,
3375 * IN PKSPIN_LOCK Lock);
3376 */
3377 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
3378 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
3379
3380 /*
3381 * BOOLEAN
3382 * ExIsFullZone(
3383 * IN PZONE_HEADER Zone)
3384 */
3385 #define ExIsFullZone(Zone) \
3386 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
3387
3388 /* BOOLEAN
3389 * ExIsObjectInFirstZoneSegment(
3390 * IN PZONE_HEADER Zone,
3391 * IN PVOID Object);
3392 */
3393 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
3394 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
3395 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
3396 (Zone)->TotalSegmentSize)) )
3397
3398 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
3399 #define ExAcquireResourceShared ExAcquireResourceSharedLite
3400 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
3401 #define ExDeleteResource ExDeleteResourceLite
3402 #define ExInitializeResource ExInitializeResourceLite
3403 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
3404 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
3405 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
3406 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
3407
3408 #ifndef _M_IX86
3409 #define RESULT_ZERO 0
3410 #define RESULT_NEGATIVE 1
3411 #define RESULT_POSITIVE 2
3412 #endif
3413
3414 typedef enum _INTERLOCKED_RESULT {
3415 ResultNegative = RESULT_NEGATIVE,
3416 ResultZero = RESULT_ZERO,
3417 ResultPositive = RESULT_POSITIVE
3418 } INTERLOCKED_RESULT;
3419
3420 #ifdef _X86_
3421
3422 NTKERNELAPI
3423 INTERLOCKED_RESULT
3424 FASTCALL
3425 Exfi386InterlockedIncrementLong(
3426 IN OUT LONG volatile *Addend);
3427
3428 NTKERNELAPI
3429 INTERLOCKED_RESULT
3430 FASTCALL
3431 Exfi386InterlockedDecrementLong(
3432 IN PLONG Addend);
3433
3434 NTKERNELAPI
3435 ULONG
3436 FASTCALL
3437 Exfi386InterlockedExchangeUlong(
3438 IN PULONG Target,
3439 IN ULONG Value);
3440
3441 #endif
3442
3443
3444 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3445 NTKERNELAPI
3446 NTSTATUS
3447 NTAPI
3448 ExExtendZone(
3449 IN OUT PZONE_HEADER Zone,
3450 IN OUT PVOID Segment,
3451 IN ULONG SegmentSize);
3452
3453 NTKERNELAPI
3454 NTSTATUS
3455 NTAPI
3456 ExInitializeZone(
3457 OUT PZONE_HEADER Zone,
3458 IN ULONG BlockSize,
3459 IN OUT PVOID InitialSegment,
3460 IN ULONG InitialSegmentSize);
3461
3462 NTKERNELAPI
3463 NTSTATUS
3464 NTAPI
3465 ExInterlockedExtendZone(
3466 IN OUT PZONE_HEADER Zone,
3467 IN OUT PVOID Segment,
3468 IN ULONG SegmentSize,
3469 IN OUT PKSPIN_LOCK Lock);
3470
3471 NTKERNELAPI
3472 NTSTATUS
3473 NTAPI
3474 ExUuidCreate(
3475 OUT UUID *Uuid);
3476
3477 NTKERNELAPI
3478 DECLSPEC_NORETURN
3479 VOID
3480 NTAPI
3481 ExRaiseAccessViolation(VOID);
3482
3483 NTKERNELAPI
3484 DECLSPEC_NORETURN
3485 VOID
3486 NTAPI
3487 ExRaiseDatatypeMisalignment(VOID);
3488
3489 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3490
3491
3492 /* Hardware Abstraction Layer Functions */
3493
3494 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3495
3496 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
3497
3498 /* Nothing here */
3499
3500 #else /* USE_DMA_MACROS ... */
3501
3502 //DECLSPEC_DEPRECATED_DDK
3503 NTHALAPI
3504 VOID
3505 NTAPI
3506 IoFreeAdapterChannel(
3507 IN PADAPTER_OBJECT AdapterObject);
3508
3509 //DECLSPEC_DEPRECATED_DDK
3510 NTHALAPI
3511 BOOLEAN
3512 NTAPI
3513 IoFlushAdapterBuffers(
3514 IN PADAPTER_OBJECT AdapterObject,
3515 IN PMDL Mdl,
3516 IN PVOID MapRegisterBase,
3517 IN PVOID CurrentVa,
3518 IN ULONG Length,
3519 IN BOOLEAN WriteToDevice);
3520
3521 //DECLSPEC_DEPRECATED_DDK
3522 NTHALAPI
3523 VOID
3524 NTAPI
3525 IoFreeMapRegisters(
3526 IN PADAPTER_OBJECT AdapterObject,
3527 IN PVOID MapRegisterBase,
3528 IN ULONG NumberOfMapRegisters);
3529
3530 //DECLSPEC_DEPRECATED_DDK
3531 NTHALAPI
3532 PVOID
3533 NTAPI
3534 HalAllocateCommonBuffer(
3535 IN PADAPTER_OBJECT AdapterObject,
3536 IN ULONG Length,
3537 OUT PPHYSICAL_ADDRESS LogicalAddress,
3538 IN BOOLEAN CacheEnabled);
3539
3540 //DECLSPEC_DEPRECATED_DDK
3541 NTHALAPI
3542 VOID
3543 NTAPI
3544 HalFreeCommonBuffer(
3545 IN PADAPTER_OBJECT AdapterObject,
3546 IN ULONG Length,
3547 IN PHYSICAL_ADDRESS LogicalAddress,
3548 IN PVOID VirtualAddress,
3549 IN BOOLEAN CacheEnabled);
3550
3551 //DECLSPEC_DEPRECATED_DDK
3552 NTHALAPI
3553 ULONG
3554 NTAPI
3555 HalReadDmaCounter(
3556 IN PADAPTER_OBJECT AdapterObject);
3557
3558 NTHALAPI
3559 NTSTATUS
3560 NTAPI
3561 HalAllocateAdapterChannel(
3562 IN PADAPTER_OBJECT AdapterObject,
3563 IN PWAIT_CONTEXT_BLOCK Wcb,
3564 IN ULONG NumberOfMapRegisters,
3565 IN PDRIVER_CONTROL ExecutionRoutine);
3566
3567 #endif /* USE_DMA_MACROS ... */
3568
3569 #if !defined(NO_LEGACY_DRIVERS)
3570 NTHALAPI
3571 NTSTATUS
3572 NTAPI
3573 HalAssignSlotResources(
3574 IN PUNICODE_STRING RegistryPath,
3575 IN PUNICODE_STRING DriverClassName,
3576 IN PDRIVER_OBJECT DriverObject,
3577 IN PDEVICE_OBJECT DeviceObject,
3578 IN INTERFACE_TYPE BusType,
3579 IN ULONG BusNumber,
3580 IN ULONG SlotNumber,
3581 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3582
3583 NTHALAPI
3584 ULONG
3585 NTAPI
3586 HalGetInterruptVector(
3587 IN INTERFACE_TYPE InterfaceType,
3588 IN ULONG BusNumber,
3589 IN ULONG BusInterruptLevel,
3590 IN ULONG BusInterruptVector,
3591 OUT PKIRQL Irql,
3592 OUT PKAFFINITY Affinity);
3593
3594 NTHALAPI
3595 ULONG
3596 NTAPI
3597 HalSetBusData(
3598 IN BUS_DATA_TYPE BusDataType,
3599 IN ULONG BusNumber,
3600 IN ULONG SlotNumber,
3601 IN PVOID Buffer,
3602 IN ULONG Length);
3603
3604 NTHALAPI
3605 ULONG
3606 NTAPI
3607 HalGetBusData(
3608 IN BUS_DATA_TYPE BusDataType,
3609 IN ULONG BusNumber,
3610 IN ULONG SlotNumber,
3611 OUT PVOID Buffer,
3612 IN ULONG Length);
3613
3614 NTHALAPI
3615 BOOLEAN
3616 NTAPI
3617 HalMakeBeep(
3618 IN ULONG Frequency);
3619 #endif /* !defined(NO_LEGACY_DRIVERS) */
3620
3621 NTHALAPI
3622 PADAPTER_OBJECT
3623 NTAPI
3624 HalGetAdapter(
3625 IN PDEVICE_DESCRIPTION DeviceDescription,
3626 OUT PULONG NumberOfMapRegisters);
3627
3628 VOID
3629 NTAPI
3630 HalPutDmaAdapter(
3631 IN PADAPTER_OBJECT DmaAdapter);
3632
3633 NTHALAPI
3634 VOID
3635 NTAPI
3636 HalAcquireDisplayOwnership(
3637 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
3638
3639 NTHALAPI
3640 ULONG
3641 NTAPI
3642 HalGetBusDataByOffset(
3643 IN BUS_DATA_TYPE BusDataType,
3644 IN ULONG BusNumber,
3645 IN ULONG SlotNumber,
3646 OUT PVOID Buffer,
3647 IN ULONG Offset,
3648 IN ULONG Length);
3649
3650 NTHALAPI
3651 ULONG
3652 NTAPI
3653 HalSetBusDataByOffset(
3654 IN BUS_DATA_TYPE BusDataType,
3655 IN ULONG BusNumber,
3656 IN ULONG SlotNumber,
3657 IN PVOID Buffer,
3658 IN ULONG Offset,
3659 IN ULONG Length);
3660
3661 NTHALAPI
3662 BOOLEAN
3663 NTAPI
3664 HalTranslateBusAddress(
3665 IN INTERFACE_TYPE InterfaceType,
3666 IN ULONG BusNumber,
3667 IN PHYSICAL_ADDRESS BusAddress,
3668 IN OUT PULONG AddressSpace,
3669 OUT PPHYSICAL_ADDRESS TranslatedAddress);
3670
3671 NTHALAPI
3672 PVOID
3673 NTAPI
3674 HalAllocateCrashDumpRegisters(
3675 IN PADAPTER_OBJECT AdapterObject,
3676 IN OUT PULONG NumberOfMapRegisters);
3677
3678 NTSTATUS
3679 NTAPI
3680 HalGetScatterGatherList(
3681 IN PADAPTER_OBJECT DmaAdapter,
3682 IN PDEVICE_OBJECT DeviceObject,
3683 IN PMDL Mdl,
3684 IN PVOID CurrentVa,
3685 IN ULONG Length,
3686 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
3687 IN PVOID Context,
3688 IN BOOLEAN WriteToDevice);
3689
3690 VOID
3691 NTAPI
3692 HalPutScatterGatherList(
3693 IN PADAPTER_OBJECT DmaAdapter,
3694 IN PSCATTER_GATHER_LIST ScatterGather,
3695 IN BOOLEAN WriteToDevice);
3696
3697 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
3698
3699 #if (NTDDI_VERSION >= NTDDI_WINXP)
3700 NTKERNELAPI
3701 VOID
3702 FASTCALL
3703 HalExamineMBR(
3704 IN PDEVICE_OBJECT DeviceObject,
3705 IN ULONG SectorSize,
3706 IN ULONG MBRTypeIdentifier,
3707 OUT PVOID *Buffer);
3708 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
3709
3710 #if (NTDDI_VERSION >= NTDDI_WIN7)
3711
3712 NTSTATUS
3713 NTAPI
3714 HalAllocateHardwareCounters(
3715 IN PGROUP_AFFINITY GroupAffinty,
3716 IN ULONG GroupCount,
3717 IN PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList,
3718 OUT PHANDLE CounterSetHandle);
3719
3720 NTSTATUS
3721 NTAPI
3722 HalFreeHardwareCounters(
3723 IN HANDLE CounterSetHandle);
3724
3725 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3726
3727 #if defined(_IA64_)
3728 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3729 NTHALAPI
3730 ULONG
3731 NTAPI
3732 HalGetDmaAlignmentRequirement(VOID);
3733 #endif
3734 #endif /* defined(_IA64_) */
3735
3736 #if defined(_M_IX86) || defined(_M_AMD64)
3737 #define HalGetDmaAlignmentRequirement() 1L
3738 #endif
3739
3740 #if (NTDDI_VERSION >= NTDDI_WIN7)
3741
3742 typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR;
3743 typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD;
3744
3745 NTHALAPI
3746 VOID
3747 NTAPI
3748 HalBugCheckSystem(
3749 IN PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource,
3750 IN PWHEA_ERROR_RECORD ErrorRecord);
3751
3752 #else
3753
3754 typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD;
3755
3756 NTHALAPI
3757 VOID
3758 NTAPI
3759 HalBugCheckSystem(
3760 IN PWHEA_ERROR_RECORD ErrorRecord);
3761
3762 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
3763
3764 /******************************************************************************
3765 * I/O Manager Functions *
3766 ******************************************************************************/
3767
3768 /*
3769 * VOID IoAssignArcName(
3770 * IN PUNICODE_STRING ArcName,
3771 * IN PUNICODE_STRING DeviceName);
3772 */
3773 #define IoAssignArcName(_ArcName, _DeviceName) ( \
3774 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
3775
3776 /*
3777 * VOID
3778 * IoDeassignArcName(
3779 * IN PUNICODE_STRING ArcName)
3780 */
3781 #define IoDeassignArcName IoDeleteSymbolicLink
3782
3783 FORCEINLINE
3784 VOID
3785 NTAPI
3786 IoInitializeDriverCreateContext(
3787 PIO_DRIVER_CREATE_CONTEXT DriverContext)
3788 {
3789 RtlZeroMemory(DriverContext, sizeof(IO_DRIVER_CREATE_CONTEXT));
3790 DriverContext->Size = sizeof(IO_DRIVER_CREATE_CONTEXT);
3791 }
3792
3793 #if (NTDDI_VERSION >= NTDDI_WIN2K)
3794
3795 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
3796 NTKERNELAPI
3797 NTSTATUS
3798 NTAPI
3799 IoAllocateAdapterChannel(
3800 IN PADAPTER_OBJECT AdapterObject,
3801 IN PDEVICE_OBJECT DeviceObject,
3802 IN ULONG NumberOfMapRegisters,
3803 IN PDRIVER_CONTROL ExecutionRoutine,
3804 IN PVOID Context);
3805 #endif
3806
3807 #if !defined(DMA_MACROS_DEFINED)
3808 //DECLSPEC_DEPRECATED_DDK
3809 NTHALAPI
3810 PHYSICAL_ADDRESS
3811 NTAPI
3812 IoMapTransfer(
3813 IN PADAPTER_OBJECT AdapterObject,
3814 IN PMDL Mdl,
3815 IN PVOID MapRegisterBase,
3816 IN PVOID CurrentVa,
3817 IN OUT PULONG Length,
3818 IN BOOLEAN WriteToDevice);
3819 #endif
3820
3821 NTKERNELAPI
3822 VOID
3823 NTAPI
3824 IoAllocateController(
3825 IN PCONTROLLER_OBJECT ControllerObject,
3826 IN PDEVICE_OBJECT DeviceObject,
3827 IN PDRIVER_CONTROL ExecutionRoutine,
3828 IN PVOID Context OPTIONAL);
3829
3830 NTKERNELAPI
3831 PCONTROLLER_OBJECT
3832 NTAPI
3833 IoCreateController(
3834 IN ULONG Size);
3835
3836 NTKERNELAPI
3837 VOID
3838 NTAPI
3839 IoDeleteController(
3840 IN PCONTROLLER_OBJECT ControllerObject);
3841
3842 NTKERNELAPI
3843 VOID
3844 NTAPI
3845 IoFreeController(
3846 IN PCONTROLLER_OBJECT ControllerObject);
3847