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