source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/ddk/ntddk.h@ 1167

Last change on this file since 1167 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

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