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