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