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