Define PPEB in ntddk.h
[reactos.git] / reactos / include / ddk / ntddk.h
1 /*
2 * ntddk.h
3 *
4 * Windows Device Driver Kit
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * DEFINES:
22 * DBG - Debugging enabled/disabled (0/1)
23 * POOL_TAGGING - Enable pool tagging
24 * _X86_ - X86 environment
25 */
26
27 #ifndef _NTDDK_
28 #define _NTDDK_
29
30 #if !defined(_NTHAL_) && !defined(_NTIFS_)
31 #define _NTDDK_INCLUDED_
32 #define _DDK_DRIVER_
33 #endif
34
35 /* Dependencies */
36
37 #define NT_INCLUDED
38 #define _CTYPE_DISABLE_MACROS
39
40 #include <wdm.h>
41 #include <excpt.h>
42 #include <ntdef.h>
43 #include <ntstatus.h>
44
45 /* FIXME
46 #include <bugcodes.h>
47 #include <ntiologc.h>
48 */
49
50 #include <stdarg.h> // FIXME
51 #include <basetyps.h> // FIXME
52
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 struct _LOADER_PARAMETER_BLOCK;
59 struct _CREATE_DISK;
60 struct _DRIVE_LAYOUT_INFORMATION_EX;
61 struct _SET_PARTITION_INFORMATION_EX;
62
63 //
64 // GUID and UUID
65 //
66 #ifndef GUID_DEFINED
67 #include <guiddef.h>
68 #endif
69 typedef GUID UUID;
70
71 typedef struct _BUS_HANDLER *PBUS_HANDLER;
72
73 typedef struct _PEB *PPEB;
74
75 #define EXCEPTION_READ_FAULT 0
76 #define EXCEPTION_WRITE_FAULT 1
77 #define EXCEPTION_EXECUTE_FAULT 8
78
79 #if (NTDDI_VERSION >= NTDDI_VISTA)
80 extern NTSYSAPI volatile CCHAR KeNumberProcessors;
81 #elif (NTDDI_VERSION >= NTDDI_WINXP)
82 extern NTSYSAPI CCHAR KeNumberProcessors;
83 #else
84 extern PCCHAR KeNumberProcessors;
85 #endif
86
87 #define MAX_WOW64_SHARED_ENTRIES 16
88
89 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
90 #define NX_SUPPORT_POLICY_ALWAYSON 1
91 #define NX_SUPPORT_POLICY_OPTIN 2
92 #define NX_SUPPORT_POLICY_OPTOUT 3
93
94 /*
95 ** IRP function codes
96 */
97
98 #define IRP_MN_QUERY_DIRECTORY 0x01
99 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
100
101 #define IRP_MN_USER_FS_REQUEST 0x00
102 #define IRP_MN_MOUNT_VOLUME 0x01
103 #define IRP_MN_VERIFY_VOLUME 0x02
104 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
105 #define IRP_MN_TRACK_LINK 0x04
106 #define IRP_MN_KERNEL_CALL 0x04
107
108 #define IRP_MN_LOCK 0x01
109 #define IRP_MN_UNLOCK_SINGLE 0x02
110 #define IRP_MN_UNLOCK_ALL 0x03
111 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
112
113 #define IRP_MN_FLUSH_AND_PURGE 0x01
114
115 #define IRP_MN_NORMAL 0x00
116 #define IRP_MN_DPC 0x01
117 #define IRP_MN_MDL 0x02
118 #define IRP_MN_COMPLETE 0x04
119 #define IRP_MN_COMPRESSED 0x08
120
121 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
122 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
123 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
124
125 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
126
127 typedef struct _IO_COUNTERS {
128 ULONGLONG ReadOperationCount;
129 ULONGLONG WriteOperationCount;
130 ULONGLONG OtherOperationCount;
131 ULONGLONG ReadTransferCount;
132 ULONGLONG WriteTransferCount;
133 ULONGLONG OtherTransferCount;
134 } IO_COUNTERS, *PIO_COUNTERS;
135
136 typedef struct _VM_COUNTERS {
137 SIZE_T PeakVirtualSize;
138 SIZE_T VirtualSize;
139 ULONG PageFaultCount;
140 SIZE_T PeakWorkingSetSize;
141 SIZE_T WorkingSetSize;
142 SIZE_T QuotaPeakPagedPoolUsage;
143 SIZE_T QuotaPagedPoolUsage;
144 SIZE_T QuotaPeakNonPagedPoolUsage;
145 SIZE_T QuotaNonPagedPoolUsage;
146 SIZE_T PagefileUsage;
147 SIZE_T PeakPagefileUsage;
148 } VM_COUNTERS, *PVM_COUNTERS;
149
150 typedef struct _VM_COUNTERS_EX
151 {
152 SIZE_T PeakVirtualSize;
153 SIZE_T VirtualSize;
154 ULONG PageFaultCount;
155 SIZE_T PeakWorkingSetSize;
156 SIZE_T WorkingSetSize;
157 SIZE_T QuotaPeakPagedPoolUsage;
158 SIZE_T QuotaPagedPoolUsage;
159 SIZE_T QuotaPeakNonPagedPoolUsage;
160 SIZE_T QuotaNonPagedPoolUsage;
161 SIZE_T PagefileUsage;
162 SIZE_T PeakPagefileUsage;
163 SIZE_T PrivateUsage;
164 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
165
166 typedef struct _POOLED_USAGE_AND_LIMITS
167 {
168 SIZE_T PeakPagedPoolUsage;
169 SIZE_T PagedPoolUsage;
170 SIZE_T PagedPoolLimit;
171 SIZE_T PeakNonPagedPoolUsage;
172 SIZE_T NonPagedPoolUsage;
173 SIZE_T NonPagedPoolLimit;
174 SIZE_T PeakPagefileUsage;
175 SIZE_T PagefileUsage;
176 SIZE_T PagefileLimit;
177 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
178
179 /* DEVICE_OBJECT.Flags */
180
181 #define DO_VERIFY_VOLUME 0x00000002
182 #define DO_BUFFERED_IO 0x00000004
183 #define DO_EXCLUSIVE 0x00000008
184 #define DO_DIRECT_IO 0x00000010
185 #define DO_MAP_IO_BUFFER 0x00000020
186 #define DO_DEVICE_HAS_NAME 0x00000040
187 #define DO_DEVICE_INITIALIZING 0x00000080
188 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
189 #define DO_LONG_TERM_REQUESTS 0x00000200
190 #define DO_NEVER_LAST_DEVICE 0x00000400
191 #define DO_SHUTDOWN_REGISTERED 0x00000800
192 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
193 #define DO_POWER_PAGABLE 0x00002000
194 #define DO_POWER_INRUSH 0x00004000
195 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
196 #define DO_SUPPORTS_TRANSACTIONS 0x00040000
197 #define DO_FORCE_NEITHER_IO 0x00080000
198 #define DO_VOLUME_DEVICE_OBJECT 0x00100000
199 #define DO_SYSTEM_SYSTEM_PARTITION 0x00200000
200 #define DO_SYSTEM_CRITICAL_PARTITION 0x00400000
201 #define DO_DISALLOW_EXECUTE 0x00800000
202
203 #define DRVO_REINIT_REGISTERED 0x00000008
204 #define DRVO_INITIALIZED 0x00000010
205 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
206 #define DRVO_LEGACY_RESOURCES 0x00000040
207
208 typedef enum _ARBITER_REQUEST_SOURCE {
209 ArbiterRequestUndefined = -1,
210 ArbiterRequestLegacyReported,
211 ArbiterRequestHalReported,
212 ArbiterRequestLegacyAssigned,
213 ArbiterRequestPnpDetected,
214 ArbiterRequestPnpEnumerated
215 } ARBITER_REQUEST_SOURCE;
216
217 typedef enum _ARBITER_RESULT {
218 ArbiterResultUndefined = -1,
219 ArbiterResultSuccess,
220 ArbiterResultExternalConflict,
221 ArbiterResultNullRequest
222 } ARBITER_RESULT;
223
224 typedef enum _ARBITER_ACTION {
225 ArbiterActionTestAllocation,
226 ArbiterActionRetestAllocation,
227 ArbiterActionCommitAllocation,
228 ArbiterActionRollbackAllocation,
229 ArbiterActionQueryAllocatedResources,
230 ArbiterActionWriteReservedResources,
231 ArbiterActionQueryConflict,
232 ArbiterActionQueryArbitrate,
233 ArbiterActionAddReserved,
234 ArbiterActionBootAllocation
235 } ARBITER_ACTION, *PARBITER_ACTION;
236
237 typedef struct _ARBITER_CONFLICT_INFO {
238 PDEVICE_OBJECT OwningObject;
239 ULONGLONG Start;
240 ULONGLONG End;
241 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
242
243 typedef struct _ARBITER_PARAMETERS {
244 union {
245 struct {
246 IN OUT PLIST_ENTRY ArbitrationList;
247 IN ULONG AllocateFromCount;
248 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
249 } TestAllocation;
250 struct {
251 IN OUT PLIST_ENTRY ArbitrationList;
252 IN ULONG AllocateFromCount;
253 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
254 } RetestAllocation;
255 struct {
256 IN OUT PLIST_ENTRY ArbitrationList;
257 } BootAllocation;
258 struct {
259 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
260 } QueryAllocatedResources;
261 struct {
262 IN PDEVICE_OBJECT PhysicalDeviceObject;
263 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
264 OUT PULONG ConflictCount;
265 OUT PARBITER_CONFLICT_INFO *Conflicts;
266 } QueryConflict;
267 struct {
268 IN PLIST_ENTRY ArbitrationList;
269 } QueryArbitrate;
270 struct {
271 IN PDEVICE_OBJECT ReserveDevice;
272 } AddReserved;
273 } Parameters;
274 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
275
276 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
277
278 typedef struct _ARBITER_LIST_ENTRY {
279 LIST_ENTRY ListEntry;
280 ULONG AlternativeCount;
281 PIO_RESOURCE_DESCRIPTOR Alternatives;
282 PDEVICE_OBJECT PhysicalDeviceObject;
283 ARBITER_REQUEST_SOURCE RequestSource;
284 ULONG Flags;
285 LONG_PTR WorkSpace;
286 INTERFACE_TYPE InterfaceType;
287 ULONG SlotNumber;
288 ULONG BusNumber;
289 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
290 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
291 ARBITER_RESULT Result;
292 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
293
294 typedef NTSTATUS
295 (NTAPI *PARBITER_HANDLER)(
296 IN OUT PVOID Context,
297 IN ARBITER_ACTION Action,
298 IN OUT PARBITER_PARAMETERS Parameters);
299
300 #define ARBITER_PARTIAL 0x00000001
301
302 typedef struct _ARBITER_INTERFACE {
303 USHORT Size;
304 USHORT Version;
305 PVOID Context;
306 PINTERFACE_REFERENCE InterfaceReference;
307 PINTERFACE_DEREFERENCE InterfaceDereference;
308 PARBITER_HANDLER ArbiterHandler;
309 ULONG Flags;
310 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
311
312 typedef enum _HAL_QUERY_INFORMATION_CLASS {
313 HalInstalledBusInformation,
314 HalProfileSourceInformation,
315 HalInformationClassUnused1,
316 HalPowerInformation,
317 HalProcessorSpeedInformation,
318 HalCallbackInformation,
319 HalMapRegisterInformation,
320 HalMcaLogInformation,
321 HalFrameBufferCachingInformation,
322 HalDisplayBiosInformation,
323 HalProcessorFeatureInformation,
324 HalNumaTopologyInterface,
325 HalErrorInformation,
326 HalCmcLogInformation,
327 HalCpeLogInformation,
328 HalQueryMcaInterface,
329 HalQueryAMLIIllegalIOPortAddresses,
330 HalQueryMaxHotPlugMemoryAddress,
331 HalPartitionIpiInterface,
332 HalPlatformInformation,
333 HalQueryProfileSourceList,
334 HalInitLogInformation,
335 HalFrequencyInformation,
336 HalProcessorBrandString,
337 HalHypervisorInformation,
338 HalPlatformTimerInformation,
339 HalAcpiAuditInformation
340 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
341
342 typedef enum _HAL_SET_INFORMATION_CLASS {
343 HalProfileSourceInterval,
344 HalProfileSourceInterruptHandler,
345 HalMcaRegisterDriver,
346 HalKernelErrorHandler,
347 HalCmcRegisterDriver,
348 HalCpeRegisterDriver,
349 HalMcaLog,
350 HalCmcLog,
351 HalCpeLog,
352 HalGenerateCmcInterrupt,
353 HalProfileSourceTimerHandler,
354 HalEnlightenment,
355 HalProfileDpgoSourceInterruptHandler
356 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
357
358 typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
359 KPROFILE_SOURCE Source;
360 ULONG_PTR Interval;
361 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
362
363 typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
364 KPROFILE_SOURCE Source;
365 BOOLEAN Supported;
366 ULONG Interval;
367 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
368
369 typedef struct _MAP_REGISTER_ENTRY {
370 PVOID MapRegister;
371 BOOLEAN WriteToDevice;
372 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
373
374 typedef struct _DEBUG_DEVICE_ADDRESS {
375 UCHAR Type;
376 BOOLEAN Valid;
377 UCHAR Reserved[2];
378 PUCHAR TranslatedAddress;
379 ULONG Length;
380 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
381
382 typedef struct _DEBUG_MEMORY_REQUIREMENTS {
383 PHYSICAL_ADDRESS Start;
384 PHYSICAL_ADDRESS MaxEnd;
385 PVOID VirtualAddress;
386 ULONG Length;
387 BOOLEAN Cached;
388 BOOLEAN Aligned;
389 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
390
391 typedef struct _DEBUG_DEVICE_DESCRIPTOR {
392 ULONG Bus;
393 ULONG Slot;
394 USHORT Segment;
395 USHORT VendorID;
396 USHORT DeviceID;
397 UCHAR BaseClass;
398 UCHAR SubClass;
399 UCHAR ProgIf;
400 BOOLEAN Initialized;
401 BOOLEAN Configured;
402 DEBUG_DEVICE_ADDRESS BaseAddress[6];
403 DEBUG_MEMORY_REQUIREMENTS Memory;
404 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
405
406 typedef struct _PM_DISPATCH_TABLE {
407 ULONG Signature;
408 ULONG Version;
409 PVOID Function[1];
410 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
411
412 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
413 TranslateChildToParent,
414 TranslateParentToChild
415 } RESOURCE_TRANSLATION_DIRECTION;
416
417 typedef NTSTATUS
418 (NTAPI *PTRANSLATE_RESOURCE_HANDLER)(
419 IN OUT PVOID Context,
420 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
421 IN RESOURCE_TRANSLATION_DIRECTION Direction,
422 IN ULONG AlternativesCount OPTIONAL,
423 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
424 IN PDEVICE_OBJECT PhysicalDeviceObject,
425 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
426
427 typedef NTSTATUS
428 (NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
429 IN PVOID Context OPTIONAL,
430 IN PIO_RESOURCE_DESCRIPTOR Source,
431 IN PDEVICE_OBJECT PhysicalDeviceObject,
432 OUT PULONG TargetCount,
433 OUT PIO_RESOURCE_DESCRIPTOR *Target);
434
435 typedef struct _TRANSLATOR_INTERFACE {
436 USHORT Size;
437 USHORT Version;
438 PVOID Context;
439 PINTERFACE_REFERENCE InterfaceReference;
440 PINTERFACE_DEREFERENCE InterfaceDereference;
441 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
442 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
443 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
444
445 typedef VOID
446 (FASTCALL *pHalExamineMBR)(
447 IN PDEVICE_OBJECT DeviceObject,
448 IN ULONG SectorSize,
449 IN ULONG MBRTypeIdentifier,
450 OUT PVOID *Buffer);
451
452 typedef NTSTATUS
453 (FASTCALL *pHalIoReadPartitionTable)(
454 IN PDEVICE_OBJECT DeviceObject,
455 IN ULONG SectorSize,
456 IN BOOLEAN ReturnRecognizedPartitions,
457 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
458
459 typedef NTSTATUS
460 (FASTCALL *pHalIoSetPartitionInformation)(
461 IN PDEVICE_OBJECT DeviceObject,
462 IN ULONG SectorSize,
463 IN ULONG PartitionNumber,
464 IN ULONG PartitionType);
465
466 typedef NTSTATUS
467 (FASTCALL *pHalIoWritePartitionTable)(
468 IN PDEVICE_OBJECT DeviceObject,
469 IN ULONG SectorSize,
470 IN ULONG SectorsPerTrack,
471 IN ULONG NumberOfHeads,
472 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
473
474 typedef PBUS_HANDLER
475 (FASTCALL *pHalHandlerForBus)(
476 IN INTERFACE_TYPE InterfaceType,
477 IN ULONG BusNumber);
478
479 typedef VOID
480 (FASTCALL *pHalReferenceBusHandler)(
481 IN PBUS_HANDLER BusHandler);
482
483 typedef NTSTATUS
484 (NTAPI *pHalQuerySystemInformation)(
485 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
486 IN ULONG BufferSize,
487 IN OUT PVOID Buffer,
488 OUT PULONG ReturnedLength);
489
490 typedef NTSTATUS
491 (NTAPI *pHalSetSystemInformation)(
492 IN HAL_SET_INFORMATION_CLASS InformationClass,
493 IN ULONG BufferSize,
494 IN PVOID Buffer);
495
496 typedef NTSTATUS
497 (NTAPI *pHalQueryBusSlots)(
498 IN PBUS_HANDLER BusHandler,
499 IN ULONG BufferSize,
500 OUT PULONG SlotNumbers,
501 OUT PULONG ReturnedLength);
502
503 typedef NTSTATUS
504 (NTAPI *pHalInitPnpDriver)(
505 VOID);
506
507 typedef NTSTATUS
508 (NTAPI *pHalInitPowerManagement)(
509 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
510 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
511
512 typedef struct _DMA_ADAPTER*
513 (NTAPI *pHalGetDmaAdapter)(
514 IN PVOID Context,
515 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
516 OUT PULONG NumberOfMapRegisters);
517
518 typedef NTSTATUS
519 (NTAPI *pHalGetInterruptTranslator)(
520 IN INTERFACE_TYPE ParentInterfaceType,
521 IN ULONG ParentBusNumber,
522 IN INTERFACE_TYPE BridgeInterfaceType,
523 IN USHORT Size,
524 IN USHORT Version,
525 OUT PTRANSLATOR_INTERFACE Translator,
526 OUT PULONG BridgeBusNumber);
527
528 typedef NTSTATUS
529 (NTAPI *pHalStartMirroring)(
530 VOID);
531
532 typedef NTSTATUS
533 (NTAPI *pHalEndMirroring)(
534 IN ULONG PassNumber);
535
536 typedef NTSTATUS
537 (NTAPI *pHalMirrorPhysicalMemory)(
538 IN PHYSICAL_ADDRESS PhysicalAddress,
539 IN LARGE_INTEGER NumberOfBytes);
540
541 typedef NTSTATUS
542 (NTAPI *pHalMirrorVerify)(
543 IN PHYSICAL_ADDRESS PhysicalAddress,
544 IN LARGE_INTEGER NumberOfBytes);
545
546 typedef VOID
547 (NTAPI *pHalEndOfBoot)(
548 VOID);
549
550 typedef
551 BOOLEAN
552 (NTAPI *pHalTranslateBusAddress)(
553 IN INTERFACE_TYPE InterfaceType,
554 IN ULONG BusNumber,
555 IN PHYSICAL_ADDRESS BusAddress,
556 IN OUT PULONG AddressSpace,
557 OUT PPHYSICAL_ADDRESS TranslatedAddress);
558
559 typedef
560 NTSTATUS
561 (NTAPI *pHalAssignSlotResources)(
562 IN PUNICODE_STRING RegistryPath,
563 IN PUNICODE_STRING DriverClassName OPTIONAL,
564 IN PDRIVER_OBJECT DriverObject,
565 IN PDEVICE_OBJECT DeviceObject,
566 IN INTERFACE_TYPE BusType,
567 IN ULONG BusNumber,
568 IN ULONG SlotNumber,
569 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
570
571 typedef
572 VOID
573 (NTAPI *pHalHaltSystem)(
574 VOID);
575
576 typedef
577 BOOLEAN
578 (NTAPI *pHalResetDisplay)(
579 VOID);
580
581 typedef
582 UCHAR
583 (NTAPI *pHalVectorToIDTEntry)(
584 ULONG Vector);
585
586 typedef
587 BOOLEAN
588 (NTAPI *pHalFindBusAddressTranslation)(
589 IN PHYSICAL_ADDRESS BusAddress,
590 IN OUT PULONG AddressSpace,
591 OUT PPHYSICAL_ADDRESS TranslatedAddress,
592 IN OUT PULONG_PTR Context,
593 IN BOOLEAN NextBus);
594
595 typedef
596 NTSTATUS
597 (NTAPI *pKdSetupPciDeviceForDebugging)(
598 IN PVOID LoaderBlock OPTIONAL,
599 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
600
601 typedef
602 NTSTATUS
603 (NTAPI *pKdReleasePciDeviceForDebugging)(
604 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice);
605
606 typedef
607 PVOID
608 (NTAPI *pKdGetAcpiTablePhase0)(
609 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
610 IN ULONG Signature);
611
612 typedef
613 PVOID
614 (NTAPI *pHalGetAcpiTable)(
615 IN ULONG Signature,
616 IN PCSTR OemId OPTIONAL,
617 IN PCSTR OemTableId OPTIONAL);
618
619 typedef
620 VOID
621 (NTAPI *pKdCheckPowerButton)(
622 VOID);
623
624 #if (NTDDI_VERSION >= NTDDI_VISTA)
625 typedef
626 PVOID
627 (NTAPI *pKdMapPhysicalMemory64)(
628 IN PHYSICAL_ADDRESS PhysicalAddress,
629 IN ULONG NumberPages,
630 IN BOOLEAN FlushCurrentTLB);
631
632 typedef
633 VOID
634 (NTAPI *pKdUnmapVirtualAddress)(
635 IN PVOID VirtualAddress,
636 IN ULONG NumberPages,
637 IN BOOLEAN FlushCurrentTLB);
638 #else
639 typedef
640 PVOID
641 (NTAPI *pKdMapPhysicalMemory64)(
642 IN PHYSICAL_ADDRESS PhysicalAddress,
643 IN ULONG NumberPages);
644
645 typedef
646 VOID
647 (NTAPI *pKdUnmapVirtualAddress)(
648 IN PVOID VirtualAddress,
649 IN ULONG NumberPages);
650 #endif
651
652
653 typedef
654 ULONG
655 (NTAPI *pKdGetPciDataByOffset)(
656 IN ULONG BusNumber,
657 IN ULONG SlotNumber,
658 OUT PVOID Buffer,
659 IN ULONG Offset,
660 IN ULONG Length);
661
662 typedef
663 ULONG
664 (NTAPI *pKdSetPciDataByOffset)(
665 IN ULONG BusNumber,
666 IN ULONG SlotNumber,
667 IN PVOID Buffer,
668 IN ULONG Offset,
669 IN ULONG Length);
670
671 typedef BOOLEAN
672 (NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
673 IN ULONG Columns,
674 IN ULONG Rows);
675
676 typedef
677 VOID
678 (NTAPI *PCI_ERROR_HANDLER_CALLBACK)(
679 VOID);
680
681 typedef
682 VOID
683 (NTAPI *pHalSetPciErrorHandlerCallback)(
684 IN PCI_ERROR_HANDLER_CALLBACK Callback);
685
686 #if 1 /* Not present in WDK 7600 */
687 typedef VOID
688 (FASTCALL *pHalIoAssignDriveLetters)(
689 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
690 IN PSTRING NtDeviceName,
691 OUT PUCHAR NtSystemPath,
692 OUT PSTRING NtSystemPathString);
693 #endif
694
695 typedef struct {
696 ULONG Version;
697 pHalQuerySystemInformation HalQuerySystemInformation;
698 pHalSetSystemInformation HalSetSystemInformation;
699 pHalQueryBusSlots HalQueryBusSlots;
700 ULONG Spare1;
701 pHalExamineMBR HalExamineMBR;
702 #if 1 /* Not present in WDK 7600 */
703 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
704 #endif
705 pHalIoReadPartitionTable HalIoReadPartitionTable;
706 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
707 pHalIoWritePartitionTable HalIoWritePartitionTable;
708 pHalHandlerForBus HalReferenceHandlerForBus;
709 pHalReferenceBusHandler HalReferenceBusHandler;
710 pHalReferenceBusHandler HalDereferenceBusHandler;
711 pHalInitPnpDriver HalInitPnpDriver;
712 pHalInitPowerManagement HalInitPowerManagement;
713 pHalGetDmaAdapter HalGetDmaAdapter;
714 pHalGetInterruptTranslator HalGetInterruptTranslator;
715 pHalStartMirroring HalStartMirroring;
716 pHalEndMirroring HalEndMirroring;
717 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
718 pHalEndOfBoot HalEndOfBoot;
719 pHalMirrorVerify HalMirrorVerify;
720 pHalGetAcpiTable HalGetCachedAcpiTable;
721 pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback;
722 #if defined(_IA64_)
723 pHalGetErrorCapList HalGetErrorCapList;
724 pHalInjectError HalInjectError;
725 #endif
726 } HAL_DISPATCH, *PHAL_DISPATCH;
727
728 /* GCC/MSVC and WDK compatible declaration */
729 extern NTKERNELAPI HAL_DISPATCH HalDispatchTable;
730
731 #if defined(_NTOSKRNL_) || defined(_BLDR_)
732 #define HALDISPATCH (&HalDispatchTable)
733 #else
734 /* This is a WDK compatibility definition */
735 #define HalDispatchTable (&HalDispatchTable)
736 #define HALDISPATCH HalDispatchTable
737 #endif
738
739 #define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */
740 #define HalDispatchTableVersion HALDISPATCH->Version
741 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
742 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
743 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
744 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
745 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
746 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
747 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
748 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
749 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
750 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
751 #define HalStartMirroring HALDISPATCH->HalStartMirroring
752 #define HalEndMirroring HALDISPATCH->HalEndMirroring
753 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
754 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
755 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
756
757 typedef struct _FILE_ALIGNMENT_INFORMATION {
758 ULONG AlignmentRequirement;
759 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
760
761 typedef struct _FILE_NAME_INFORMATION {
762 ULONG FileNameLength;
763 WCHAR FileName[1];
764 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
765
766
767 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
768 ULONG FileAttributes;
769 ULONG ReparseTag;
770 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
771
772 typedef struct _FILE_DISPOSITION_INFORMATION {
773 BOOLEAN DeleteFile;
774 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
775
776 typedef struct _FILE_END_OF_FILE_INFORMATION {
777 LARGE_INTEGER EndOfFile;
778 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
779
780 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
781 LARGE_INTEGER ValidDataLength;
782 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
783
784 typedef union _FILE_SEGMENT_ELEMENT {
785 PVOID64 Buffer;
786 ULONGLONG Alignment;
787 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
788
789 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
790
791 #if (NTDDI_VERSION >= NTDDI_WIN2K)
792 NTSYSAPI
793 ULONGLONG
794 NTAPI
795 VerSetConditionMask(
796 IN ULONGLONG ConditionMask,
797 IN ULONG TypeMask,
798 IN UCHAR Condition);
799 #endif
800
801 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
802 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
803 (TypeBitMask), (ComparisonType)))
804
805 /* RtlVerifyVersionInfo() TypeMask */
806
807 #define VER_MINORVERSION 0x0000001
808 #define VER_MAJORVERSION 0x0000002
809 #define VER_BUILDNUMBER 0x0000004
810 #define VER_PLATFORMID 0x0000008
811 #define VER_SERVICEPACKMINOR 0x0000010
812 #define VER_SERVICEPACKMAJOR 0x0000020
813 #define VER_SUITENAME 0x0000040
814 #define VER_PRODUCT_TYPE 0x0000080
815
816 /* RtlVerifyVersionInfo() ComparisonType */
817
818 #define VER_EQUAL 1
819 #define VER_GREATER 2
820 #define VER_GREATER_EQUAL 3
821 #define VER_LESS 4
822 #define VER_LESS_EQUAL 5
823 #define VER_AND 6
824 #define VER_OR 7
825
826 #define VER_CONDITION_MASK 7
827 #define VER_NUM_BITS_PER_CONDITION_MASK 3
828
829 typedef struct _IMAGE_INFO {
830 _ANONYMOUS_UNION union {
831 ULONG Properties;
832 _ANONYMOUS_STRUCT struct {
833 ULONG ImageAddressingMode:8;
834 ULONG SystemModeImage:1;
835 ULONG ImageMappedToAllPids:1;
836 ULONG ExtendedInfoPresent:1;
837 ULONG Reserved:22;
838 } DUMMYSTRUCTNAME;
839 } DUMMYUNIONNAME;
840 PVOID ImageBase;
841 ULONG ImageSelector;
842 SIZE_T ImageSize;
843 ULONG ImageSectionNumber;
844 } IMAGE_INFO, *PIMAGE_INFO;
845
846 #define IMAGE_ADDRESSING_MODE_32BIT 3
847
848 typedef enum _BUS_DATA_TYPE {
849 ConfigurationSpaceUndefined = -1,
850 Cmos,
851 EisaConfiguration,
852 Pos,
853 CbusConfiguration,
854 PCIConfiguration,
855 VMEConfiguration,
856 NuBusConfiguration,
857 PCMCIAConfiguration,
858 MPIConfiguration,
859 MPSAConfiguration,
860 PNPISAConfiguration,
861 SgiInternalConfiguration,
862 MaximumBusDataType
863 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
864
865 typedef struct _NT_TIB {
866 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
867 PVOID StackBase;
868 PVOID StackLimit;
869 PVOID SubSystemTib;
870 _ANONYMOUS_UNION union {
871 PVOID FiberData;
872 ULONG Version;
873 } DUMMYUNIONNAME;
874 PVOID ArbitraryUserPointer;
875 struct _NT_TIB *Self;
876 } NT_TIB, *PNT_TIB;
877
878 typedef struct _NT_TIB32 {
879 ULONG ExceptionList;
880 ULONG StackBase;
881 ULONG StackLimit;
882 ULONG SubSystemTib;
883 __GNU_EXTENSION union {
884 ULONG FiberData;
885 ULONG Version;
886 };
887 ULONG ArbitraryUserPointer;
888 ULONG Self;
889 } NT_TIB32,*PNT_TIB32;
890
891 typedef struct _NT_TIB64 {
892 ULONG64 ExceptionList;
893 ULONG64 StackBase;
894 ULONG64 StackLimit;
895 ULONG64 SubSystemTib;
896 __GNU_EXTENSION union {
897 ULONG64 FiberData;
898 ULONG Version;
899 };
900 ULONG64 ArbitraryUserPointer;
901 ULONG64 Self;
902 } NT_TIB64,*PNT_TIB64;
903
904 typedef enum _PROCESSINFOCLASS {
905 ProcessBasicInformation,
906 ProcessQuotaLimits,
907 ProcessIoCounters,
908 ProcessVmCounters,
909 ProcessTimes,
910 ProcessBasePriority,
911 ProcessRaisePriority,
912 ProcessDebugPort,
913 ProcessExceptionPort,
914 ProcessAccessToken,
915 ProcessLdtInformation,
916 ProcessLdtSize,
917 ProcessDefaultHardErrorMode,
918 ProcessIoPortHandlers,
919 ProcessPooledUsageAndLimits,
920 ProcessWorkingSetWatch,
921 ProcessUserModeIOPL,
922 ProcessEnableAlignmentFaultFixup,
923 ProcessPriorityClass,
924 ProcessWx86Information,
925 ProcessHandleCount,
926 ProcessAffinityMask,
927 ProcessPriorityBoost,
928 ProcessDeviceMap,
929 ProcessSessionInformation,
930 ProcessForegroundInformation,
931 ProcessWow64Information,
932 ProcessImageFileName,
933 ProcessLUIDDeviceMapsEnabled,
934 ProcessBreakOnTermination,
935 ProcessDebugObjectHandle,
936 ProcessDebugFlags,
937 ProcessHandleTracing,
938 ProcessIoPriority,
939 ProcessExecuteFlags,
940 ProcessTlsInformation,
941 ProcessCookie,
942 ProcessImageInformation,
943 ProcessCycleTime,
944 ProcessPagePriority,
945 ProcessInstrumentationCallback,
946 ProcessThreadStackAllocation,
947 ProcessWorkingSetWatchEx,
948 ProcessImageFileNameWin32,
949 ProcessImageFileMapping,
950 ProcessAffinityUpdateMode,
951 ProcessMemoryAllocationMode,
952 ProcessGroupInformation,
953 ProcessTokenVirtualizationEnabled,
954 ProcessConsoleHostProcess,
955 ProcessWindowInformation,
956 MaxProcessInfoClass
957 } PROCESSINFOCLASS;
958
959 typedef enum _THREADINFOCLASS {
960 ThreadBasicInformation,
961 ThreadTimes,
962 ThreadPriority,
963 ThreadBasePriority,
964 ThreadAffinityMask,
965 ThreadImpersonationToken,
966 ThreadDescriptorTableEntry,
967 ThreadEnableAlignmentFaultFixup,
968 ThreadEventPair_Reusable,
969 ThreadQuerySetWin32StartAddress,
970 ThreadZeroTlsCell,
971 ThreadPerformanceCount,
972 ThreadAmILastThread,
973 ThreadIdealProcessor,
974 ThreadPriorityBoost,
975 ThreadSetTlsArrayAddress,
976 ThreadIsIoPending,
977 ThreadHideFromDebugger,
978 ThreadBreakOnTermination,
979 ThreadSwitchLegacyState,
980 ThreadIsTerminated,
981 ThreadLastSystemCall,
982 ThreadIoPriority,
983 ThreadCycleTime,
984 ThreadPagePriority,
985 ThreadActualBasePriority,
986 ThreadTebInformation,
987 ThreadCSwitchMon,
988 ThreadCSwitchPmu,
989 ThreadWow64Context,
990 ThreadGroupInformation,
991 ThreadUmsInformation,
992 ThreadCounterProfiling,
993 ThreadIdealProcessorEx,
994 MaxThreadInfoClass
995 } THREADINFOCLASS;
996
997 typedef struct _PROCESS_BASIC_INFORMATION {
998 NTSTATUS ExitStatus;
999 struct _PEB *PebBaseAddress;
1000 ULONG_PTR AffinityMask;
1001 KPRIORITY BasePriority;
1002 ULONG_PTR UniqueProcessId;
1003 ULONG_PTR InheritedFromUniqueProcessId;
1004 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
1005
1006 typedef struct _PROCESS_WS_WATCH_INFORMATION {
1007 PVOID FaultingPc;
1008 PVOID FaultingVa;
1009 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
1010
1011 typedef struct _PROCESS_DEVICEMAP_INFORMATION {
1012 __GNU_EXTENSION union {
1013 struct {
1014 HANDLE DirectoryHandle;
1015 } Set;
1016 struct {
1017 ULONG DriveMap;
1018 UCHAR DriveType[32];
1019 } Query;
1020 };
1021 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
1022
1023 typedef struct _KERNEL_USER_TIMES {
1024 LARGE_INTEGER CreateTime;
1025 LARGE_INTEGER ExitTime;
1026 LARGE_INTEGER KernelTime;
1027 LARGE_INTEGER UserTime;
1028 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
1029
1030 typedef struct _PROCESS_ACCESS_TOKEN {
1031 HANDLE Token;
1032 HANDLE Thread;
1033 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
1034
1035 typedef struct _PROCESS_SESSION_INFORMATION {
1036 ULONG SessionId;
1037 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
1038
1039 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
1040 IoQueryDeviceIdentifier = 0,
1041 IoQueryDeviceConfigurationData,
1042 IoQueryDeviceComponentInformation,
1043 IoQueryDeviceMaxData
1044 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
1045
1046 typedef struct _DISK_SIGNATURE {
1047 ULONG PartitionStyle;
1048 _ANONYMOUS_UNION union {
1049 struct {
1050 ULONG Signature;
1051 ULONG CheckSum;
1052 } Mbr;
1053 struct {
1054 GUID DiskId;
1055 } Gpt;
1056 } DUMMYUNIONNAME;
1057 } DISK_SIGNATURE, *PDISK_SIGNATURE;
1058
1059 typedef ULONG_PTR
1060 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
1061 IN PVOID Context);
1062
1063 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
1064 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
1065 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
1066 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
1067
1068 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
1069 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
1070 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
1071 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
1072 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
1073
1074 typedef VOID
1075 (NTAPI *PTIMER_APC_ROUTINE)(
1076 IN PVOID TimerContext,
1077 IN ULONG TimerLowValue,
1078 IN LONG TimerHighValue);
1079
1080 typedef struct _KUSER_SHARED_DATA
1081 {
1082 ULONG TickCountLowDeprecated;
1083 ULONG TickCountMultiplier;
1084 volatile KSYSTEM_TIME InterruptTime;
1085 volatile KSYSTEM_TIME SystemTime;
1086 volatile KSYSTEM_TIME TimeZoneBias;
1087 USHORT ImageNumberLow;
1088 USHORT ImageNumberHigh;
1089 WCHAR NtSystemRoot[260];
1090 ULONG MaxStackTraceDepth;
1091 ULONG CryptoExponent;
1092 ULONG TimeZoneId;
1093 ULONG LargePageMinimum;
1094 ULONG Reserved2[7];
1095 NT_PRODUCT_TYPE NtProductType;
1096 BOOLEAN ProductTypeIsValid;
1097 ULONG NtMajorVersion;
1098 ULONG NtMinorVersion;
1099 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
1100 ULONG Reserved1;
1101 ULONG Reserved3;
1102 volatile ULONG TimeSlip;
1103 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
1104 ULONG AltArchitecturePad[1];
1105 LARGE_INTEGER SystemExpirationDate;
1106 ULONG SuiteMask;
1107 BOOLEAN KdDebuggerEnabled;
1108 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
1109 UCHAR NXSupportPolicy;
1110 #endif
1111 volatile ULONG ActiveConsoleId;
1112 volatile ULONG DismountCount;
1113 ULONG ComPlusPackage;
1114 ULONG LastSystemRITEventTickCount;
1115 ULONG NumberOfPhysicalPages;
1116 BOOLEAN SafeBootMode;
1117 #if (NTDDI_VERSION >= NTDDI_WIN7)
1118 union {
1119 UCHAR TscQpcData;
1120 struct {
1121 UCHAR TscQpcEnabled:1;
1122 UCHAR TscQpcSpareFlag:1;
1123 UCHAR TscQpcShift:6;
1124 } DUMMYSTRUCTNAME;
1125 } DUMMYUNIONNAME;
1126 UCHAR TscQpcPad[2];
1127 #endif
1128 #if (NTDDI_VERSION >= NTDDI_VISTA)
1129 union {
1130 ULONG SharedDataFlags;
1131 struct {
1132 ULONG DbgErrorPortPresent:1;
1133 ULONG DbgElevationEnabled:1;
1134 ULONG DbgVirtEnabled:1;
1135 ULONG DbgInstallerDetectEnabled:1;
1136 ULONG DbgSystemDllRelocated:1;
1137 ULONG DbgDynProcessorEnabled:1;
1138 ULONG DbgSEHValidationEnabled:1;
1139 ULONG SpareBits:25;
1140 } DUMMYSTRUCTNAME2;
1141 } DUMMYUNIONNAME2;
1142 #else
1143 ULONG TraceLogging;
1144 #endif
1145 ULONG DataFlagsPad[1];
1146 ULONGLONG TestRetInstruction;
1147 ULONG SystemCall;
1148 ULONG SystemCallReturn;
1149 ULONGLONG SystemCallPad[3];
1150 _ANONYMOUS_UNION union {
1151 volatile KSYSTEM_TIME TickCount;
1152 volatile ULONG64 TickCountQuad;
1153 _ANONYMOUS_STRUCT struct {
1154 ULONG ReservedTickCountOverlay[3];
1155 ULONG TickCountPad[1];
1156 } DUMMYSTRUCTNAME;
1157 } DUMMYUNIONNAME3;
1158 ULONG Cookie;
1159 ULONG CookiePad[1];
1160 #if (NTDDI_VERSION >= NTDDI_WS03)
1161 LONGLONG ConsoleSessionForegroundProcessId;
1162 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
1163 #endif
1164 #if (NTDDI_VERSION >= NTDDI_VISTA)
1165 #if (NTDDI_VERSION >= NTDDI_WIN7)
1166 USHORT UserModeGlobalLogger[16];
1167 #else
1168 USHORT UserModeGlobalLogger[8];
1169 ULONG HeapTracingPid[2];
1170 ULONG CritSecTracingPid[2];
1171 #endif
1172 ULONG ImageFileExecutionOptions;
1173 #if (NTDDI_VERSION >= NTDDI_VISTASP1)
1174 ULONG LangGenerationCount;
1175 #else
1176 /* 4 bytes padding */
1177 #endif
1178 ULONGLONG Reserved5;
1179 volatile ULONG64 InterruptTimeBias;
1180 #endif
1181 #if (NTDDI_VERSION >= NTDDI_WIN7)
1182 volatile ULONG64 TscQpcBias;
1183 volatile ULONG ActiveProcessorCount;
1184 volatile USHORT ActiveGroupCount;
1185 USHORT Reserved4;
1186 volatile ULONG AitSamplingValue;
1187 volatile ULONG AppCompatFlag;
1188 ULONGLONG SystemDllNativeRelocation;
1189 ULONG SystemDllWowRelocation;
1190 ULONG XStatePad[1];
1191 XSTATE_CONFIGURATION XState;
1192 #endif
1193 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
1194
1195 extern NTKERNELAPI PVOID MmHighestUserAddress;
1196 extern NTKERNELAPI PVOID MmSystemRangeStart;
1197 extern NTKERNELAPI ULONG MmUserProbeAddress;
1198
1199
1200 #ifdef _X86_
1201
1202 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
1203 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
1204 #if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_)
1205 #define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_
1206 extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_;
1207 #else
1208 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
1209 #endif
1210 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
1211 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
1212 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
1213 #if !defined (_X86PAE_)
1214 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
1215 #else
1216 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
1217 #endif
1218
1219 #define KeGetPcr() PCR
1220
1221 #define KERNEL_STACK_SIZE 12288
1222 #define KERNEL_LARGE_STACK_SIZE 61440
1223 #define KERNEL_LARGE_STACK_COMMIT 12288
1224
1225 #define SIZE_OF_80387_REGISTERS 80
1226
1227 #define PCR_MINOR_VERSION 1
1228 #define PCR_MAJOR_VERSION 1
1229
1230 #if !defined(RC_INVOKED)
1231
1232 #define CONTEXT_i386 0x10000
1233 #define CONTEXT_i486 0x10000
1234 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
1235 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
1236 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
1237 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
1238 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
1239 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
1240
1241 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
1242
1243 #endif /* !defined(RC_INVOKED) */
1244
1245 typedef struct _KPCR {
1246 union {
1247 NT_TIB NtTib;
1248 struct {
1249 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
1250 PVOID Used_StackBase;
1251 PVOID Spare2;
1252 PVOID TssCopy;
1253 ULONG ContextSwitches;
1254 KAFFINITY SetMemberCopy;
1255 PVOID Used_Self;
1256 };
1257 };
1258 struct _KPCR *SelfPcr;
1259 struct _KPRCB *Prcb;
1260 KIRQL Irql;
1261 ULONG IRR;
1262 ULONG IrrActive;
1263 ULONG IDR;
1264 PVOID KdVersionBlock;
1265 struct _KIDTENTRY *IDT;
1266 struct _KGDTENTRY *GDT;
1267 struct _KTSS *TSS;
1268 USHORT MajorVersion;
1269 USHORT MinorVersion;
1270 KAFFINITY SetMember;
1271 ULONG StallScaleFactor;
1272 UCHAR SpareUnused;
1273 UCHAR Number;
1274 UCHAR Spare0;
1275 UCHAR SecondLevelCacheAssociativity;
1276 ULONG VdmAlert;
1277 ULONG KernelReserved[14];
1278 ULONG SecondLevelCacheSize;
1279 ULONG HalReserved[16];
1280 } KPCR, *PKPCR;
1281
1282 FORCEINLINE
1283 ULONG
1284 KeGetCurrentProcessorNumber(VOID)
1285 {
1286 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
1287 }
1288
1289 typedef struct _FLOATING_SAVE_AREA {
1290 ULONG ControlWord;
1291 ULONG StatusWord;
1292 ULONG TagWord;
1293 ULONG ErrorOffset;
1294 ULONG ErrorSelector;
1295 ULONG DataOffset;
1296 ULONG DataSelector;
1297 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
1298 ULONG Cr0NpxState;
1299 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
1300
1301 #include "pshpack4.h"
1302 typedef struct _CONTEXT {
1303 ULONG ContextFlags;
1304 ULONG Dr0;
1305 ULONG Dr1;
1306 ULONG Dr2;
1307 ULONG Dr3;
1308 ULONG Dr6;
1309 ULONG Dr7;
1310 FLOATING_SAVE_AREA FloatSave;
1311 ULONG SegGs;
1312 ULONG SegFs;
1313 ULONG SegEs;
1314 ULONG SegDs;
1315 ULONG Edi;
1316 ULONG Esi;
1317 ULONG Ebx;
1318 ULONG Edx;
1319 ULONG Ecx;
1320 ULONG Eax;
1321 ULONG Ebp;
1322 ULONG Eip;
1323 ULONG SegCs;
1324 ULONG EFlags;
1325 ULONG Esp;
1326 ULONG SegSs;
1327 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
1328 } CONTEXT;
1329 #include "poppack.h"
1330
1331 #endif /* _X86_ */
1332
1333 #ifdef _AMD64_
1334
1335 #define PTI_SHIFT 12L
1336 #define PDI_SHIFT 21L
1337 #define PPI_SHIFT 30L
1338 #define PXI_SHIFT 39L
1339 #define PTE_PER_PAGE 512
1340 #define PDE_PER_PAGE 512
1341 #define PPE_PER_PAGE 512
1342 #define PXE_PER_PAGE 512
1343 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
1344 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
1345 #define PPI_MASK (PPE_PER_PAGE - 1)
1346 #define PXI_MASK (PXE_PER_PAGE - 1)
1347
1348 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
1349 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
1350 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
1351 #define PDE_BASE 0xFFFFF6FB40000000ULL
1352 #define PTE_BASE 0xFFFFF68000000000ULL
1353 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
1354 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
1355 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
1356 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
1357
1358 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
1359 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
1360 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
1361 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
1362 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
1363 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
1364
1365 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
1366 ULONG64 P1Home;
1367 ULONG64 P2Home;
1368 ULONG64 P3Home;
1369 ULONG64 P4Home;
1370 ULONG64 P5Home;
1371 ULONG64 P6Home;
1372
1373 /* Control flags */
1374 ULONG ContextFlags;
1375 ULONG MxCsr;
1376
1377 /* Segment */
1378 USHORT SegCs;
1379 USHORT SegDs;
1380 USHORT SegEs;
1381 USHORT SegFs;
1382 USHORT SegGs;
1383 USHORT SegSs;
1384 ULONG EFlags;
1385
1386 /* Debug */
1387 ULONG64 Dr0;
1388 ULONG64 Dr1;
1389 ULONG64 Dr2;
1390 ULONG64 Dr3;
1391 ULONG64 Dr6;
1392 ULONG64 Dr7;
1393
1394 /* Integer */
1395 ULONG64 Rax;
1396 ULONG64 Rcx;
1397 ULONG64 Rdx;
1398 ULONG64 Rbx;
1399 ULONG64 Rsp;
1400 ULONG64 Rbp;
1401 ULONG64 Rsi;
1402 ULONG64 Rdi;
1403 ULONG64 R8;
1404 ULONG64 R9;
1405 ULONG64 R10;
1406 ULONG64 R11;
1407 ULONG64 R12;
1408 ULONG64 R13;
1409 ULONG64 R14;
1410 ULONG64 R15;
1411
1412 /* Counter */
1413 ULONG64 Rip;
1414
1415 /* Floating point */
1416 union {
1417 XMM_SAVE_AREA32 FltSave;
1418 struct {
1419 M128A Header[2];
1420 M128A Legacy[8];
1421 M128A Xmm0;
1422 M128A Xmm1;
1423 M128A Xmm2;
1424 M128A Xmm3;
1425 M128A Xmm4;
1426 M128A Xmm5;
1427 M128A Xmm6;
1428 M128A Xmm7;
1429 M128A Xmm8;
1430 M128A Xmm9;
1431 M128A Xmm10;
1432 M128A Xmm11;
1433 M128A Xmm12;
1434 M128A Xmm13;
1435 M128A Xmm14;
1436 M128A Xmm15;
1437 } DUMMYSTRUCTNAME;
1438 } DUMMYUNIONNAME;
1439
1440 /* Vector */
1441 M128A VectorRegister[26];
1442 ULONG64 VectorControl;
1443
1444 /* Debug control */
1445 ULONG64 DebugControl;
1446 ULONG64 LastBranchToRip;
1447 ULONG64 LastBranchFromRip;
1448 ULONG64 LastExceptionToRip;
1449 ULONG64 LastExceptionFromRip;
1450 } CONTEXT;
1451
1452 typedef struct _KPCR
1453 {
1454 _ANONYMOUS_UNION union
1455 {
1456 NT_TIB NtTib;
1457 _ANONYMOUS_STRUCT struct
1458 {
1459 union _KGDTENTRY64 *GdtBase;
1460 struct _KTSS64 *TssBase;
1461 ULONG64 UserRsp;
1462 struct _KPCR *Self;
1463 struct _KPRCB *CurrentPrcb;
1464 PKSPIN_LOCK_QUEUE LockArray;
1465 PVOID Used_Self;
1466 };
1467 };
1468 union _KIDTENTRY64 *IdtBase;
1469 ULONG64 Unused[2];
1470 KIRQL Irql;
1471 UCHAR SecondLevelCacheAssociativity;
1472 UCHAR ObsoleteNumber;
1473 UCHAR Fill0;
1474 ULONG Unused0[3];
1475 USHORT MajorVersion;
1476 USHORT MinorVersion;
1477 ULONG StallScaleFactor;
1478 PVOID Unused1[3];
1479 ULONG KernelReserved[15];
1480 ULONG SecondLevelCacheSize;
1481 ULONG HalReserved[16];
1482 ULONG Unused2;
1483 PVOID KdVersionBlock;
1484 PVOID Unused3;
1485 ULONG PcrAlign1[24];
1486 } KPCR, *PKPCR;
1487
1488 FORCEINLINE
1489 PKPCR
1490 KeGetPcr(VOID)
1491 {
1492 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
1493 }
1494
1495 FORCEINLINE
1496 ULONG
1497 KeGetCurrentProcessorNumber(VOID)
1498 {
1499 return (ULONG)__readgsword(0x184);
1500 }
1501
1502 #if !defined(RC_INVOKED)
1503
1504 #define CONTEXT_AMD64 0x100000
1505
1506 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
1507 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
1508 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
1509 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
1510 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
1511
1512 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
1513 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
1514
1515 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
1516
1517 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
1518 #define CONTEXT_SERVICE_ACTIVE 0x10000000
1519 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
1520 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
1521
1522 #endif /* RC_INVOKED */
1523
1524 #endif /* _AMD64_ */
1525
1526 typedef enum _INTERLOCKED_RESULT {
1527 ResultNegative = RESULT_NEGATIVE,
1528 ResultZero = RESULT_ZERO,
1529 ResultPositive = RESULT_POSITIVE
1530 } INTERLOCKED_RESULT;
1531
1532 typedef struct _OSVERSIONINFOA {
1533 ULONG dwOSVersionInfoSize;
1534 ULONG dwMajorVersion;
1535 ULONG dwMinorVersion;
1536 ULONG dwBuildNumber;
1537 ULONG dwPlatformId;
1538 CHAR szCSDVersion[128];
1539 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
1540
1541 typedef struct _OSVERSIONINFOW {
1542 ULONG dwOSVersionInfoSize;
1543 ULONG dwMajorVersion;
1544 ULONG dwMinorVersion;
1545 ULONG dwBuildNumber;
1546 ULONG dwPlatformId;
1547 WCHAR szCSDVersion[128];
1548 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
1549
1550 typedef struct _OSVERSIONINFOEXA {
1551 ULONG dwOSVersionInfoSize;
1552 ULONG dwMajorVersion;
1553 ULONG dwMinorVersion;
1554 ULONG dwBuildNumber;
1555 ULONG dwPlatformId;
1556 CHAR szCSDVersion[128];
1557 USHORT wServicePackMajor;
1558 USHORT wServicePackMinor;
1559 USHORT wSuiteMask;
1560 UCHAR wProductType;
1561 UCHAR wReserved;
1562 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
1563
1564 typedef struct _OSVERSIONINFOEXW {
1565 ULONG dwOSVersionInfoSize;
1566 ULONG dwMajorVersion;
1567 ULONG dwMinorVersion;
1568 ULONG dwBuildNumber;
1569 ULONG dwPlatformId;
1570 WCHAR szCSDVersion[128];
1571 USHORT wServicePackMajor;
1572 USHORT wServicePackMinor;
1573 USHORT wSuiteMask;
1574 UCHAR wProductType;
1575 UCHAR wReserved;
1576 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
1577
1578 #ifdef UNICODE
1579 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
1580 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
1581 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
1582 typedef OSVERSIONINFOW OSVERSIONINFO;
1583 typedef POSVERSIONINFOW POSVERSIONINFO;
1584 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
1585 #else
1586 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
1587 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
1588 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
1589 typedef OSVERSIONINFOA OSVERSIONINFO;
1590 typedef POSVERSIONINFOA POSVERSIONINFO;
1591 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
1592 #endif /* UNICODE */
1593
1594 /* Executive Types */
1595
1596 #define PROTECTED_POOL 0x80000000
1597
1598 typedef struct _ZONE_SEGMENT_HEADER {
1599 SINGLE_LIST_ENTRY SegmentList;
1600 PVOID Reserved;
1601 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
1602
1603 typedef struct _ZONE_HEADER {
1604 SINGLE_LIST_ENTRY FreeList;
1605 SINGLE_LIST_ENTRY SegmentList;
1606 ULONG BlockSize;
1607 ULONG TotalSegmentSize;
1608 } ZONE_HEADER, *PZONE_HEADER;
1609
1610 /* Executive Functions */
1611
1612 static __inline PVOID
1613 ExAllocateFromZone(
1614 IN PZONE_HEADER Zone)
1615 {
1616 if (Zone->FreeList.Next)
1617 Zone->FreeList.Next = Zone->FreeList.Next->Next;
1618 return (PVOID) Zone->FreeList.Next;
1619 }
1620
1621 static __inline PVOID
1622 ExFreeToZone(
1623 IN PZONE_HEADER Zone,
1624 IN PVOID Block)
1625 {
1626 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
1627 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
1628 return ((PSINGLE_LIST_ENTRY) Block)->Next;
1629 }
1630
1631 /*
1632 * PVOID
1633 * ExInterlockedAllocateFromZone(
1634 * IN PZONE_HEADER Zone,
1635 * IN PKSPIN_LOCK Lock)
1636 */
1637 #define ExInterlockedAllocateFromZone(Zone, Lock) \
1638 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
1639
1640 /* PVOID
1641 * ExInterlockedFreeToZone(
1642 * IN PZONE_HEADER Zone,
1643 * IN PVOID Block,
1644 * IN PKSPIN_LOCK Lock);
1645 */
1646 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
1647 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
1648
1649 /*
1650 * BOOLEAN
1651 * ExIsFullZone(
1652 * IN PZONE_HEADER Zone)
1653 */
1654 #define ExIsFullZone(Zone) \
1655 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
1656
1657 /* BOOLEAN
1658 * ExIsObjectInFirstZoneSegment(
1659 * IN PZONE_HEADER Zone,
1660 * IN PVOID Object);
1661 */
1662 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
1663 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
1664 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
1665 (Zone)->TotalSegmentSize)) )
1666
1667 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
1668 #define ExAcquireResourceShared ExAcquireResourceSharedLite
1669 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
1670 #define ExDeleteResource ExDeleteResourceLite
1671 #define ExInitializeResource ExInitializeResourceLite
1672 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
1673 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
1674 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
1675 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
1676
1677 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1678
1679 NTKERNELAPI
1680 NTSTATUS
1681 NTAPI
1682 ExExtendZone(
1683 IN OUT PZONE_HEADER Zone,
1684 IN OUT PVOID Segment,
1685 IN ULONG SegmentSize);
1686
1687 NTKERNELAPI
1688 NTSTATUS
1689 NTAPI
1690 ExInitializeZone(
1691 OUT PZONE_HEADER Zone,
1692 IN ULONG BlockSize,
1693 IN OUT PVOID InitialSegment,
1694 IN ULONG InitialSegmentSize);
1695
1696 NTKERNELAPI
1697 NTSTATUS
1698 NTAPI
1699 ExInterlockedExtendZone(
1700 IN OUT PZONE_HEADER Zone,
1701 IN OUT PVOID Segment,
1702 IN ULONG SegmentSize,
1703 IN OUT PKSPIN_LOCK Lock);
1704
1705 NTKERNELAPI
1706 NTSTATUS
1707 NTAPI
1708 ExUuidCreate(
1709 OUT UUID *Uuid);
1710
1711 NTKERNELAPI
1712 DECLSPEC_NORETURN
1713 VOID
1714 NTAPI
1715 ExRaiseAccessViolation(
1716 VOID);
1717
1718 NTKERNELAPI
1719 DECLSPEC_NORETURN
1720 VOID
1721 NTAPI
1722 ExRaiseDatatypeMisalignment(
1723 VOID);
1724
1725 #endif
1726
1727 #ifdef _X86_
1728
1729 NTKERNELAPI
1730 INTERLOCKED_RESULT
1731 FASTCALL
1732 Exfi386InterlockedIncrementLong(
1733 IN OUT LONG volatile *Addend);
1734
1735 NTKERNELAPI
1736 INTERLOCKED_RESULT
1737 FASTCALL
1738 Exfi386InterlockedDecrementLong(
1739 IN PLONG Addend);
1740
1741 NTKERNELAPI
1742 ULONG
1743 FASTCALL
1744 Exfi386InterlockedExchangeUlong(
1745 IN PULONG Target,
1746 IN ULONG Value);
1747
1748 #endif /* _X86_ */
1749
1750 #ifndef _ARC_DDK_
1751 #define _ARC_DDK_
1752 typedef enum _CONFIGURATION_TYPE {
1753 ArcSystem,
1754 CentralProcessor,
1755 FloatingPointProcessor,
1756 PrimaryIcache,
1757 PrimaryDcache,
1758 SecondaryIcache,
1759 SecondaryDcache,
1760 SecondaryCache,
1761 EisaAdapter,
1762 TcAdapter,
1763 ScsiAdapter,
1764 DtiAdapter,
1765 MultiFunctionAdapter,
1766 DiskController,
1767 TapeController,
1768 CdromController,
1769 WormController,
1770 SerialController,
1771 NetworkController,
1772 DisplayController,
1773 ParallelController,
1774 PointerController,
1775 KeyboardController,
1776 AudioController,
1777 OtherController,
1778 DiskPeripheral,
1779 FloppyDiskPeripheral,
1780 TapePeripheral,
1781 ModemPeripheral,
1782 MonitorPeripheral,
1783 PrinterPeripheral,
1784 PointerPeripheral,
1785 KeyboardPeripheral,
1786 TerminalPeripheral,
1787 OtherPeripheral,
1788 LinePeripheral,
1789 NetworkPeripheral,
1790 SystemMemory,
1791 DockingInformation,
1792 RealModeIrqRoutingTable,
1793 RealModePCIEnumeration,
1794 MaximumType
1795 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
1796 #endif /* !_ARC_DDK_ */
1797
1798 typedef struct _CONTROLLER_OBJECT {
1799 CSHORT Type;
1800 CSHORT Size;
1801 PVOID ControllerExtension;
1802 KDEVICE_QUEUE DeviceWaitQueue;
1803 ULONG Spare1;
1804 LARGE_INTEGER Spare2;
1805 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
1806
1807 typedef struct _CONFIGURATION_INFORMATION {
1808 ULONG DiskCount;
1809 ULONG FloppyCount;
1810 ULONG CdRomCount;
1811 ULONG TapeCount;
1812 ULONG ScsiPortCount;
1813 ULONG SerialCount;
1814 ULONG ParallelCount;
1815 BOOLEAN AtDiskPrimaryAddressClaimed;
1816 BOOLEAN AtDiskSecondaryAddressClaimed;
1817 ULONG Version;
1818 ULONG MediumChangerCount;
1819 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
1820
1821 typedef
1822 NTSTATUS
1823 (NTAPI *PIO_QUERY_DEVICE_ROUTINE)(
1824 IN PVOID Context,
1825 IN PUNICODE_STRING PathName,
1826 IN INTERFACE_TYPE BusType,
1827 IN ULONG BusNumber,
1828 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
1829 IN CONFIGURATION_TYPE ControllerType,
1830 IN ULONG ControllerNumber,
1831 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
1832 IN CONFIGURATION_TYPE PeripheralType,
1833 IN ULONG PeripheralNumber,
1834 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
1835
1836 typedef
1837 VOID
1838 (NTAPI DRIVER_REINITIALIZE)(
1839 IN struct _DRIVER_OBJECT *DriverObject,
1840 IN PVOID Context,
1841 IN ULONG Count);
1842
1843 typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE;
1844
1845 /** Filesystem runtime library routines **/
1846
1847 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1848 NTKERNELAPI
1849 BOOLEAN
1850 NTAPI
1851 FsRtlIsTotalDeviceFailure(
1852 IN NTSTATUS Status);
1853 #endif
1854
1855 /* Hardware Abstraction Layer Types */
1856
1857 typedef VOID
1858 (NTAPI *PciPin2Line)(
1859 IN struct _BUS_HANDLER *BusHandler,
1860 IN struct _BUS_HANDLER *RootHandler,
1861 IN PCI_SLOT_NUMBER SlotNumber,
1862 IN PPCI_COMMON_CONFIG PciData);
1863
1864 typedef VOID
1865 (NTAPI *PciLine2Pin)(
1866 IN struct _BUS_HANDLER *BusHandler,
1867 IN struct _BUS_HANDLER *RootHandler,
1868 IN PCI_SLOT_NUMBER SlotNumber,
1869 IN PPCI_COMMON_CONFIG PciNewData,
1870 IN PPCI_COMMON_CONFIG PciOldData);
1871
1872 typedef VOID
1873 (NTAPI *PciReadWriteConfig)(
1874 IN struct _BUS_HANDLER *BusHandler,
1875 IN PCI_SLOT_NUMBER Slot,
1876 IN PVOID Buffer,
1877 IN ULONG Offset,
1878 IN ULONG Length);
1879
1880 #define PCI_DATA_TAG ' ICP'
1881 #define PCI_DATA_VERSION 1
1882
1883 typedef struct _PCIBUSDATA {
1884 ULONG Tag;
1885 ULONG Version;
1886 PciReadWriteConfig ReadConfig;
1887 PciReadWriteConfig WriteConfig;
1888 PciPin2Line Pin2Line;
1889 PciLine2Pin Line2Pin;
1890 PCI_SLOT_NUMBER ParentSlot;
1891 PVOID Reserved[4];
1892 } PCIBUSDATA, *PPCIBUSDATA;
1893
1894 /* Hardware Abstraction Layer Functions */
1895
1896 #if !defined(NO_LEGACY_DRIVERS)
1897
1898 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1899
1900 NTHALAPI
1901 NTSTATUS
1902 NTAPI
1903 HalAssignSlotResources(
1904 IN PUNICODE_STRING RegistryPath,
1905 IN PUNICODE_STRING DriverClassName,
1906 IN PDRIVER_OBJECT DriverObject,
1907 IN PDEVICE_OBJECT DeviceObject,
1908 IN INTERFACE_TYPE BusType,
1909 IN ULONG BusNumber,
1910 IN ULONG SlotNumber,
1911 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
1912
1913 NTHALAPI
1914 ULONG
1915 NTAPI
1916 HalGetInterruptVector(
1917 IN INTERFACE_TYPE InterfaceType,
1918 IN ULONG BusNumber,
1919 IN ULONG BusInterruptLevel,
1920 IN ULONG BusInterruptVector,
1921 OUT PKIRQL Irql,
1922 OUT PKAFFINITY Affinity);
1923
1924 NTHALAPI
1925 ULONG
1926 NTAPI
1927 HalSetBusData(
1928 IN BUS_DATA_TYPE BusDataType,
1929 IN ULONG BusNumber,
1930 IN ULONG SlotNumber,
1931 IN PVOID Buffer,
1932 IN ULONG Length);
1933
1934 #endif
1935
1936 #endif /* !defined(NO_LEGACY_DRIVERS) */
1937
1938 #if (NTDDI_VERSION >= NTDDI_WIN2K)
1939
1940 NTHALAPI
1941 PADAPTER_OBJECT
1942 NTAPI
1943 HalGetAdapter(
1944 IN PDEVICE_DESCRIPTION DeviceDescription,
1945 IN OUT PULONG NumberOfMapRegisters);
1946
1947 NTHALAPI
1948 BOOLEAN
1949 NTAPI
1950 HalMakeBeep(
1951 IN ULONG Frequency);
1952
1953 VOID
1954 NTAPI
1955 HalPutDmaAdapter(
1956 IN PADAPTER_OBJECT DmaAdapter);
1957
1958 NTHALAPI
1959 VOID
1960 NTAPI
1961 HalAcquireDisplayOwnership(
1962 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
1963
1964 NTHALAPI
1965 ULONG
1966 NTAPI
1967 HalGetBusData(
1968 IN BUS_DATA_TYPE BusDataType,
1969 IN ULONG BusNumber,
1970 IN ULONG SlotNumber,
1971 OUT PVOID Buffer,
1972 IN ULONG Length);
1973
1974 NTHALAPI
1975 ULONG
1976 NTAPI
1977 HalGetBusDataByOffset(
1978 IN BUS_DATA_TYPE BusDataType,
1979 IN ULONG BusNumber,
1980 IN ULONG SlotNumber,
1981 OUT PVOID Buffer,
1982 IN ULONG Offset,
1983 IN ULONG Length);
1984
1985 NTHALAPI
1986 ULONG
1987 NTAPI
1988 HalSetBusDataByOffset(
1989 IN BUS_DATA_TYPE BusDataType,
1990 IN ULONG BusNumber,
1991 IN ULONG SlotNumber,
1992 IN PVOID Buffer,
1993 IN ULONG Offset,
1994 IN ULONG Length);
1995
1996 NTHALAPI
1997 BOOLEAN
1998 NTAPI
1999 HalTranslateBusAddress(
2000 IN INTERFACE_TYPE InterfaceType,
2001 IN ULONG BusNumber,
2002 IN PHYSICAL_ADDRESS BusAddress,
2003 IN OUT PULONG AddressSpace,
2004 OUT PPHYSICAL_ADDRESS TranslatedAddress);
2005
2006 #endif
2007
2008 #if (NTDDI_VERSION >= NTDDI_WINXP)
2009 NTKERNELAPI
2010 VOID
2011 FASTCALL
2012 HalExamineMBR(
2013 IN PDEVICE_OBJECT DeviceObject,
2014 IN ULONG SectorSize,
2015 IN ULONG MBRTypeIdentifier,
2016 OUT PVOID *Buffer);
2017 #endif
2018
2019 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
2020 // nothing here
2021 #else
2022
2023 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2024 //DECLSPEC_DEPRECATED_DDK
2025 NTHALAPI
2026 VOID
2027 NTAPI
2028 IoFreeAdapterChannel(
2029 IN PADAPTER_OBJECT AdapterObject);
2030
2031 //DECLSPEC_DEPRECATED_DDK
2032 NTHALAPI
2033 BOOLEAN
2034 NTAPI
2035 IoFlushAdapterBuffers(
2036 IN PADAPTER_OBJECT AdapterObject,
2037 IN PMDL Mdl,
2038 IN PVOID MapRegisterBase,
2039 IN PVOID CurrentVa,
2040 IN ULONG Length,
2041 IN BOOLEAN WriteToDevice);
2042
2043 //DECLSPEC_DEPRECATED_DDK
2044 NTHALAPI
2045 VOID
2046 NTAPI
2047 IoFreeMapRegisters(
2048 IN PADAPTER_OBJECT AdapterObject,
2049 IN PVOID MapRegisterBase,
2050 IN ULONG NumberOfMapRegisters);
2051
2052 //DECLSPEC_DEPRECATED_DDK
2053 NTHALAPI
2054 PVOID
2055 NTAPI
2056 HalAllocateCommonBuffer(
2057 IN PADAPTER_OBJECT AdapterObject,
2058 IN ULONG Length,
2059 OUT PPHYSICAL_ADDRESS LogicalAddress,
2060 IN BOOLEAN CacheEnabled);
2061
2062 //DECLSPEC_DEPRECATED_DDK
2063 NTHALAPI
2064 VOID
2065 NTAPI
2066 HalFreeCommonBuffer(
2067 IN PADAPTER_OBJECT AdapterObject,
2068 IN ULONG Length,
2069 IN PHYSICAL_ADDRESS LogicalAddress,
2070 IN PVOID VirtualAddress,
2071 IN BOOLEAN CacheEnabled);
2072
2073 //DECLSPEC_DEPRECATED_DDK
2074 NTHALAPI
2075 ULONG
2076 NTAPI
2077 HalReadDmaCounter(
2078 IN PADAPTER_OBJECT AdapterObject);
2079
2080 NTHALAPI
2081 NTSTATUS
2082 NTAPI
2083 HalAllocateAdapterChannel(
2084 IN PADAPTER_OBJECT AdapterObject,
2085 IN PWAIT_CONTEXT_BLOCK Wcb,
2086 IN ULONG NumberOfMapRegisters,
2087 IN PDRIVER_CONTROL ExecutionRoutine);
2088
2089 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2090
2091 #endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */
2092
2093 /* I/O Manager Functions */
2094
2095 /*
2096 * VOID IoAssignArcName(
2097 * IN PUNICODE_STRING ArcName,
2098 * IN PUNICODE_STRING DeviceName);
2099 */
2100 #define IoAssignArcName(_ArcName, _DeviceName) ( \
2101 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
2102
2103 /*
2104 * VOID
2105 * IoDeassignArcName(
2106 * IN PUNICODE_STRING ArcName)
2107 */
2108 #define IoDeassignArcName IoDeleteSymbolicLink
2109
2110 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2111
2112 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
2113 NTKERNELAPI
2114 NTSTATUS
2115 NTAPI
2116 IoAllocateAdapterChannel(
2117 IN PADAPTER_OBJECT AdapterObject,
2118 IN PDEVICE_OBJECT DeviceObject,
2119 IN ULONG NumberOfMapRegisters,
2120 IN PDRIVER_CONTROL ExecutionRoutine,
2121 IN PVOID Context);
2122 #endif
2123
2124 //DECLSPEC_DEPRECATED_DDK
2125 NTHALAPI
2126 PHYSICAL_ADDRESS
2127 NTAPI
2128 IoMapTransfer(
2129 IN PADAPTER_OBJECT AdapterObject,
2130 IN PMDL Mdl,
2131 IN PVOID MapRegisterBase,
2132 IN PVOID CurrentVa,
2133 IN OUT PULONG Length,
2134 IN BOOLEAN WriteToDevice);
2135
2136 NTKERNELAPI
2137 VOID
2138 NTAPI
2139 IoAllocateController(
2140 IN PCONTROLLER_OBJECT ControllerObject,
2141 IN PDEVICE_OBJECT DeviceObject,
2142 IN PDRIVER_CONTROL ExecutionRoutine,
2143 IN PVOID Context OPTIONAL);
2144
2145 NTKERNELAPI
2146 PCONTROLLER_OBJECT
2147 NTAPI
2148 IoCreateController(
2149 IN ULONG Size);
2150
2151 NTKERNELAPI
2152 VOID
2153 NTAPI
2154 IoDeleteController(
2155 IN PCONTROLLER_OBJECT ControllerObject);
2156
2157 NTKERNELAPI
2158 VOID
2159 NTAPI
2160 IoFreeController(
2161 IN PCONTROLLER_OBJECT ControllerObject);
2162
2163 NTKERNELAPI
2164 PCONFIGURATION_INFORMATION
2165 NTAPI
2166 IoGetConfigurationInformation(
2167 VOID);
2168
2169 NTKERNELAPI
2170 PDEVICE_OBJECT
2171 NTAPI
2172 IoGetDeviceToVerify(
2173 IN PETHREAD Thread);
2174
2175 NTKERNELAPI
2176 VOID
2177 NTAPI
2178 IoCancelFileOpen(
2179 IN PDEVICE_OBJECT DeviceObject,
2180 IN PFILE_OBJECT FileObject);
2181
2182 NTKERNELAPI
2183 PGENERIC_MAPPING
2184 NTAPI
2185 IoGetFileObjectGenericMapping(
2186 VOID);
2187
2188 NTKERNELAPI
2189 PIRP
2190 NTAPI
2191 IoMakeAssociatedIrp(
2192 IN PIRP Irp,
2193 IN CCHAR StackSize);
2194
2195 NTKERNELAPI
2196 NTSTATUS
2197 NTAPI
2198 IoQueryDeviceDescription(
2199 IN PINTERFACE_TYPE BusType OPTIONAL,
2200 IN PULONG BusNumber OPTIONAL,
2201 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
2202 IN PULONG ControllerNumber OPTIONAL,
2203 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
2204 IN PULONG PeripheralNumber OPTIONAL,
2205 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
2206 IN OUT PVOID Context OPTIONAL);
2207
2208 NTKERNELAPI
2209 VOID
2210 NTAPI
2211 IoRaiseHardError(
2212 IN PIRP Irp,
2213 IN PVPB Vpb OPTIONAL,
2214 IN PDEVICE_OBJECT RealDeviceObject);
2215
2216 NTKERNELAPI
2217 BOOLEAN
2218 NTAPI
2219 IoRaiseInformationalHardError(
2220 IN NTSTATUS ErrorStatus,
2221 IN PUNICODE_STRING String OPTIONAL,
2222 IN PKTHREAD Thread OPTIONAL);
2223
2224 NTKERNELAPI
2225 VOID
2226 NTAPI
2227 IoRegisterBootDriverReinitialization(
2228 IN PDRIVER_OBJECT DriverObject,
2229 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
2230 IN PVOID Context OPTIONAL);
2231
2232 NTKERNELAPI
2233 VOID
2234 NTAPI
2235 IoRegisterDriverReinitialization(
2236 IN PDRIVER_OBJECT DriverObject,
2237 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
2238 IN PVOID Context OPTIONAL);
2239
2240 NTKERNELAPI
2241 NTSTATUS
2242 NTAPI
2243 IoAttachDeviceByPointer(
2244 IN PDEVICE_OBJECT SourceDevice,
2245 IN PDEVICE_OBJECT TargetDevice);
2246
2247 NTKERNELAPI
2248 NTSTATUS
2249 NTAPI
2250 IoReportDetectedDevice(
2251 IN PDRIVER_OBJECT DriverObject,
2252 IN INTERFACE_TYPE LegacyBusType,
2253 IN ULONG BusNumber,
2254 IN ULONG SlotNumber,
2255 IN PCM_RESOURCE_LIST ResourceList OPTIONAL,
2256 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
2257 IN BOOLEAN ResourceAssigned,
2258 IN OUT PDEVICE_OBJECT *DeviceObject);
2259
2260 NTKERNELAPI
2261 NTSTATUS
2262 NTAPI
2263 IoReportResourceForDetection(
2264 IN PDRIVER_OBJECT DriverObject,
2265 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
2266 IN ULONG DriverListSize OPTIONAL,
2267 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
2268 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
2269 IN ULONG DeviceListSize OPTIONAL,
2270 OUT PBOOLEAN ConflictDetected);
2271
2272 NTKERNELAPI
2273 NTSTATUS
2274 NTAPI
2275 IoReportResourceUsage(
2276 IN PUNICODE_STRING DriverClassName OPTIONAL,
2277 IN PDRIVER_OBJECT DriverObject,
2278 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
2279 IN ULONG DriverListSize OPTIONAL,
2280 IN PDEVICE_OBJECT DeviceObject,
2281 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
2282 IN ULONG DeviceListSize OPTIONAL,
2283 IN BOOLEAN OverrideConflict,
2284 OUT PBOOLEAN ConflictDetected);
2285
2286 NTKERNELAPI
2287 VOID
2288 NTAPI
2289 IoSetHardErrorOrVerifyDevice(
2290 IN PIRP Irp,
2291 IN PDEVICE_OBJECT DeviceObject);
2292
2293 NTKERNELAPI
2294 NTSTATUS
2295 NTAPI
2296 IoAssignResources(
2297 IN PUNICODE_STRING RegistryPath,
2298 IN PUNICODE_STRING DriverClassName OPTIONAL,
2299 IN PDRIVER_OBJECT DriverObject,
2300 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
2301 IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL,
2302 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
2303
2304 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2305
2306 #if (NTDDI_VERSION >= NTDDI_WINXP)
2307
2308 NTKERNELAPI
2309 NTSTATUS
2310 NTAPI
2311 IoCreateDisk(
2312 IN PDEVICE_OBJECT DeviceObject,
2313 IN struct _CREATE_DISK* Disk OPTIONAL);
2314
2315 NTKERNELAPI
2316 NTSTATUS
2317 NTAPI
2318 IoReadDiskSignature(
2319 IN PDEVICE_OBJECT DeviceObject,
2320 IN ULONG BytesPerSector,
2321 OUT PDISK_SIGNATURE Signature);
2322
2323 NTKERNELAPI
2324 NTSTATUS
2325 FASTCALL
2326 IoReadPartitionTable(
2327 IN PDEVICE_OBJECT DeviceObject,
2328 IN ULONG SectorSize,
2329 IN BOOLEAN ReturnRecognizedPartitions,
2330 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2331
2332 NTKERNELAPI
2333 NTSTATUS
2334 NTAPI
2335 IoReadPartitionTableEx(
2336 IN PDEVICE_OBJECT DeviceObject,
2337 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
2338
2339 NTKERNELAPI
2340 NTSTATUS
2341 FASTCALL
2342 IoSetPartitionInformation(
2343 IN PDEVICE_OBJECT DeviceObject,
2344 IN ULONG SectorSize,
2345 IN ULONG PartitionNumber,
2346 IN ULONG PartitionType);
2347
2348 NTKERNELAPI
2349 NTSTATUS
2350 NTAPI
2351 IoSetPartitionInformationEx(
2352 IN PDEVICE_OBJECT DeviceObject,
2353 IN ULONG PartitionNumber,
2354 IN struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
2355
2356 NTKERNELAPI
2357 NTSTATUS
2358 NTAPI
2359 IoSetSystemPartition(
2360 IN PUNICODE_STRING VolumeNameString);
2361
2362 NTKERNELAPI
2363 BOOLEAN
2364 NTAPI
2365 IoSetThreadHardErrorMode(
2366 IN BOOLEAN EnableHardErrors);
2367
2368 NTKERNELAPI
2369 NTSTATUS
2370 NTAPI
2371 IoVerifyPartitionTable(
2372 IN PDEVICE_OBJECT DeviceObject,
2373 IN BOOLEAN FixErrors);
2374
2375 NTKERNELAPI
2376 NTSTATUS
2377 NTAPI
2378 IoVolumeDeviceToDosName(
2379 IN PVOID VolumeDeviceObject,
2380 OUT PUNICODE_STRING DosName);
2381
2382 NTKERNELAPI
2383 NTSTATUS
2384 FASTCALL
2385 IoWritePartitionTable(
2386 IN PDEVICE_OBJECT DeviceObject,
2387 IN ULONG SectorSize,
2388 IN ULONG SectorsPerTrack,
2389 IN ULONG NumberOfHeads,
2390 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
2391
2392 NTKERNELAPI
2393 NTSTATUS
2394 NTAPI
2395 IoWritePartitionTableEx(
2396 IN PDEVICE_OBJECT DeviceObject,
2397 IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout);
2398
2399 NTKERNELAPI
2400 NTSTATUS
2401 NTAPI
2402 IoAttachDeviceToDeviceStackSafe(
2403 IN PDEVICE_OBJECT SourceDevice,
2404 IN PDEVICE_OBJECT TargetDevice,
2405 OUT PDEVICE_OBJECT *AttachedToDeviceObject);
2406
2407 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2408
2409 /** Kernel debugger routines **/
2410
2411 NTSYSAPI
2412 ULONG
2413 NTAPI
2414 DbgPrompt(
2415 IN PCCH Prompt,
2416 OUT PCH Response,
2417 IN ULONG MaximumResponseLength);
2418
2419 /* Kernel Functions */
2420
2421 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2422
2423 NTKERNELAPI
2424 DECLSPEC_NORETURN
2425 VOID
2426 NTAPI
2427 KeBugCheck(
2428 IN ULONG BugCheckCode);
2429
2430 NTKERNELAPI
2431 LONG
2432 NTAPI
2433 KePulseEvent(
2434 IN OUT PRKEVENT Event,
2435 IN KPRIORITY Increment,
2436 IN BOOLEAN Wait);
2437
2438 NTKERNELAPI
2439 LONG
2440 NTAPI
2441 KeSetBasePriorityThread(
2442 IN OUT PRKTHREAD Thread,
2443 IN LONG Increment);
2444
2445 #endif
2446
2447 /* Memory Manager Types */
2448
2449 typedef struct _PHYSICAL_MEMORY_RANGE {
2450 PHYSICAL_ADDRESS BaseAddress;
2451 LARGE_INTEGER NumberOfBytes;
2452 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
2453
2454 /* Memory Manager Functions */
2455
2456 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2457
2458 NTKERNELAPI
2459 PPHYSICAL_MEMORY_RANGE
2460 NTAPI
2461 MmGetPhysicalMemoryRanges(
2462 VOID);
2463
2464 NTKERNELAPI
2465 PHYSICAL_ADDRESS
2466 NTAPI
2467 MmGetPhysicalAddress(
2468 IN PVOID BaseAddress);
2469
2470 NTKERNELAPI
2471 BOOLEAN
2472 NTAPI
2473 MmIsNonPagedSystemAddressValid(
2474 IN PVOID VirtualAddress);
2475
2476 NTKERNELAPI
2477 PVOID
2478 NTAPI
2479 MmAllocateNonCachedMemory(
2480 IN SIZE_T NumberOfBytes);
2481
2482 NTKERNELAPI
2483 VOID
2484 NTAPI
2485 MmFreeNonCachedMemory(
2486 IN PVOID BaseAddress,
2487 IN SIZE_T NumberOfBytes);
2488
2489 NTKERNELAPI
2490 PVOID
2491 NTAPI
2492 MmGetVirtualForPhysical(
2493 IN PHYSICAL_ADDRESS PhysicalAddress);
2494
2495 NTKERNELAPI
2496 NTSTATUS
2497 NTAPI
2498 MmMapUserAddressesToPage(
2499 IN PVOID BaseAddress,
2500 IN SIZE_T NumberOfBytes,
2501 IN PVOID PageAddress);
2502
2503 NTKERNELAPI
2504 PVOID
2505 NTAPI
2506 MmMapVideoDisplay(
2507 IN PHYSICAL_ADDRESS PhysicalAddress,
2508 IN SIZE_T NumberOfBytes,
2509 IN MEMORY_CACHING_TYPE CacheType);
2510
2511 NTKERNELAPI
2512 NTSTATUS
2513 NTAPI
2514 MmMapViewInSessionSpace(
2515 IN PVOID Section,
2516 OUT PVOID *MappedBase,
2517 IN OUT PSIZE_T ViewSize);
2518
2519 NTKERNELAPI
2520 NTSTATUS
2521 NTAPI
2522 MmMapViewInSystemSpace(
2523 IN PVOID Section,
2524 OUT PVOID *MappedBase,
2525 IN OUT PSIZE_T ViewSize);
2526
2527 NTKERNELAPI
2528 BOOLEAN
2529 NTAPI
2530 MmIsAddressValid(
2531 IN PVOID VirtualAddress);
2532
2533 NTKERNELAPI
2534 BOOLEAN
2535 NTAPI
2536 MmIsThisAnNtAsSystem(
2537 VOID);
2538
2539 NTKERNELAPI
2540 VOID
2541 NTAPI
2542 MmLockPagableSectionByHandle(
2543 IN PVOID ImageSectionHandle);
2544
2545 NTKERNELAPI
2546 NTSTATUS
2547 NTAPI
2548 MmUnmapViewInSessionSpace(
2549 IN PVOID MappedBase);
2550
2551 NTKERNELAPI
2552 NTSTATUS
2553 NTAPI
2554 MmUnmapViewInSystemSpace(
2555 IN PVOID MappedBase);
2556
2557 NTKERNELAPI
2558 VOID
2559 NTAPI
2560 MmUnsecureVirtualMemory(
2561 IN HANDLE SecureHandle);
2562
2563 NTKERNELAPI
2564 NTSTATUS
2565 NTAPI
2566 MmRemovePhysicalMemory(
2567 IN PPHYSICAL_ADDRESS StartAddress,
2568 IN OUT PLARGE_INTEGER NumberOfBytes);
2569
2570 NTKERNELAPI
2571 HANDLE
2572 NTAPI
2573 MmSecureVirtualMemory(
2574 IN PVOID Address,
2575 IN SIZE_T Size,
2576 IN ULONG ProbeMode);
2577
2578 NTKERNELAPI
2579 VOID
2580 NTAPI
2581 MmUnmapVideoDisplay(
2582 IN PVOID BaseAddress,
2583 IN SIZE_T NumberOfBytes);
2584
2585 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2586
2587 /* NtXxx Functions */
2588
2589 NTSYSCALLAPI
2590 NTSTATUS
2591 NTAPI
2592 NtOpenProcess(
2593 OUT PHANDLE ProcessHandle,
2594 IN ACCESS_MASK DesiredAccess,
2595 IN POBJECT_ATTRIBUTES ObjectAttributes,
2596 IN PCLIENT_ID ClientId OPTIONAL);
2597
2598 NTSYSCALLAPI
2599 NTSTATUS
2600 NTAPI
2601 NtQueryInformationProcess(
2602 IN HANDLE ProcessHandle,
2603 IN PROCESSINFOCLASS ProcessInformationClass,
2604 OUT PVOID ProcessInformation OPTIONAL,
2605 IN ULONG ProcessInformationLength,
2606 OUT PULONG ReturnLength OPTIONAL);
2607
2608 /** Process manager types **/
2609
2610 typedef VOID
2611 (NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
2612 IN HANDLE ParentId,
2613 IN HANDLE ProcessId,
2614 IN BOOLEAN Create);
2615
2616 typedef VOID
2617 (NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
2618 IN HANDLE ProcessId,
2619 IN HANDLE ThreadId,
2620 IN BOOLEAN Create);
2621
2622 typedef VOID
2623 (NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
2624 IN PUNICODE_STRING FullImageName,
2625 IN HANDLE ProcessId,
2626 IN PIMAGE_INFO ImageInfo);
2627
2628 /** Process manager routines **/
2629
2630 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2631
2632 NTKERNELAPI
2633 NTSTATUS
2634 NTAPI
2635 PsSetLoadImageNotifyRoutine(
2636 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
2637
2638 NTKERNELAPI
2639 NTSTATUS
2640 NTAPI
2641 PsSetCreateThreadNotifyRoutine(
2642 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
2643
2644 NTKERNELAPI
2645 NTSTATUS
2646 NTAPI
2647 PsSetCreateProcessNotifyRoutine(
2648 IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
2649 IN BOOLEAN Remove);
2650
2651 NTKERNELAPI
2652 HANDLE
2653 NTAPI
2654 PsGetCurrentProcessId(
2655 VOID);
2656
2657 NTKERNELAPI
2658 HANDLE
2659 NTAPI
2660 PsGetCurrentThreadId(
2661 VOID);
2662
2663 NTKERNELAPI
2664 BOOLEAN
2665 NTAPI
2666 PsGetVersion(
2667 OUT PULONG MajorVersion OPTIONAL,
2668 OUT PULONG MinorVersion OPTIONAL,
2669 OUT PULONG BuildNumber OPTIONAL,
2670 OUT PUNICODE_STRING CSDVersion OPTIONAL);
2671
2672 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2673
2674 #if (NTDDI_VERSION >= NTDDI_WINXP)
2675
2676 NTKERNELAPI
2677 HANDLE
2678 NTAPI
2679 PsGetProcessId(
2680 IN PEPROCESS Process);
2681
2682 NTKERNELAPI
2683 NTSTATUS
2684 NTAPI
2685 PsRemoveCreateThreadNotifyRoutine(
2686 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
2687
2688 NTKERNELAPI
2689 NTSTATUS
2690 NTAPI
2691 PsRemoveLoadImageNotifyRoutine(
2692 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
2693
2694 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2695
2696 extern NTKERNELAPI PEPROCESS PsInitialSystemProcess;
2697
2698 /* RTL Types */
2699
2700 typedef struct _RTL_SPLAY_LINKS {
2701 struct _RTL_SPLAY_LINKS *Parent;
2702 struct _RTL_SPLAY_LINKS *LeftChild;
2703 struct _RTL_SPLAY_LINKS *RightChild;
2704 } RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
2705
2706 /* RTL Functions */
2707
2708 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
2709
2710 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
2711 *CallersAddress = (PVOID)_ReturnAddress(); \
2712 *CallersCaller = NULL;
2713 #else
2714
2715 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2716 NTSYSAPI
2717 VOID
2718 NTAPI
2719 RtlGetCallersAddress(
2720 OUT PVOID *CallersAddress,
2721 OUT PVOID *CallersCaller);
2722 #endif
2723
2724 #endif
2725
2726 #if !defined(MIDL_PASS)
2727
2728 FORCEINLINE
2729 LUID
2730 NTAPI_INLINE
2731 RtlConvertLongToLuid(
2732 IN LONG Val)
2733 {
2734 LUID Luid;
2735 LARGE_INTEGER Temp;
2736
2737 Temp.QuadPart = Val;
2738 Luid.LowPart = Temp.u.LowPart;
2739 Luid.HighPart = Temp.u.HighPart;
2740 return Luid;
2741 }
2742
2743 FORCEINLINE
2744 LUID
2745 NTAPI_INLINE
2746 RtlConvertUlongToLuid(
2747 IN ULONG Val)
2748 {
2749 LUID Luid;
2750
2751 Luid.LowPart = Val;
2752 Luid.HighPart = 0;
2753 return Luid;
2754 }
2755
2756 #endif
2757
2758 #if defined(_AMD64_) || defined(_IA64_)
2759 //DECLSPEC_DEPRECATED_DDK_WINXP
2760 __inline
2761 LARGE_INTEGER
2762 NTAPI_INLINE
2763 RtlLargeIntegerDivide(
2764 IN LARGE_INTEGER Dividend,
2765 IN LARGE_INTEGER Divisor,
2766 OUT PLARGE_INTEGER Remainder OPTIONAL)
2767 {
2768 LARGE_INTEGER ret;
2769 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
2770 if (Remainder)
2771 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
2772 return ret;
2773 }
2774
2775 #else
2776
2777 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2778 NTSYSAPI
2779 LARGE_INTEGER
2780 NTAPI
2781 RtlLargeIntegerDivide(
2782 IN LARGE_INTEGER Dividend,
2783 IN LARGE_INTEGER Divisor,
2784 OUT PLARGE_INTEGER Remainder OPTIONAL);
2785 #endif
2786
2787 #endif /* defined(_AMD64_) || defined(_IA64_) */
2788
2789 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2790
2791 NTSYSAPI
2792 BOOLEAN
2793 NTAPI
2794 RtlPrefixUnicodeString(
2795 IN PCUNICODE_STRING String1,
2796 IN PCUNICODE_STRING String2,
2797 IN BOOLEAN CaseInSensitive);
2798
2799 NTSYSAPI
2800 VOID
2801 NTAPI
2802 RtlUpperString(
2803 IN OUT PSTRING DestinationString,
2804 IN const PSTRING SourceString);
2805
2806 NTSYSAPI
2807 NTSTATUS
2808 NTAPI
2809 RtlUpcaseUnicodeString(
2810 IN OUT PUNICODE_STRING DestinationString,
2811 IN PCUNICODE_STRING SourceString,
2812 IN BOOLEAN AllocateDestinationString);
2813
2814 NTSYSAPI
2815 VOID
2816 NTAPI
2817 RtlMapGenericMask(
2818 IN OUT PACCESS_MASK AccessMask,
2819 IN PGENERIC_MAPPING GenericMapping);
2820
2821 NTSYSAPI
2822 NTSTATUS
2823 NTAPI
2824 RtlVolumeDeviceToDosName(
2825 IN PVOID VolumeDeviceObject,
2826 OUT PUNICODE_STRING DosName);
2827
2828 NTSYSAPI
2829 NTSTATUS
2830 NTAPI
2831 RtlGetVersion(
2832 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
2833
2834 NTSYSAPI
2835 NTSTATUS
2836 NTAPI
2837 RtlVerifyVersionInfo(
2838 IN PRTL_OSVERSIONINFOEXW VersionInfo,
2839 IN ULONG TypeMask,
2840 IN ULONGLONG ConditionMask);
2841
2842 NTSYSAPI
2843 LONG
2844 NTAPI
2845 RtlCompareString(
2846 IN const PSTRING String1,
2847 IN const PSTRING String2,
2848 BOOLEAN CaseInSensitive);
2849
2850 NTSYSAPI
2851 VOID
2852 NTAPI
2853 RtlCopyString(
2854 OUT PSTRING DestinationString,
2855 IN const PSTRING SourceString OPTIONAL);
2856
2857 NTSYSAPI
2858 BOOLEAN
2859 NTAPI
2860 RtlEqualString(
2861 IN const PSTRING String1,
2862 IN const PSTRING String2,
2863 IN BOOLEAN CaseInSensitive);
2864
2865 NTSYSAPI
2866 NTSTATUS
2867 NTAPI
2868 RtlCharToInteger(
2869 IN PCSZ String,
2870 IN ULONG Base OPTIONAL,
2871 OUT PULONG Value);
2872
2873 NTSYSAPI
2874 CHAR
2875 NTAPI
2876 RtlUpperChar(
2877 IN CHAR Character);
2878
2879 NTSYSAPI
2880 ULONG
2881 NTAPI
2882 RtlWalkFrameChain(
2883 OUT PVOID *Callers,
2884 IN ULONG Count,
2885 IN ULONG Flags);
2886
2887 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
2888
2889 /* Security reference monitor routines */
2890
2891 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2892 NTKERNELAPI
2893 BOOLEAN
2894 NTAPI
2895 SeSinglePrivilegeCheck(
2896 IN LUID PrivilegeValue,
2897 IN KPROCESSOR_MODE PreviousMode);
2898 #endif
2899
2900 /* ZwXxx Functions */
2901
2902 #if (NTDDI_VERSION >= NTDDI_WIN2K)
2903
2904 NTSTATUS
2905 NTAPI
2906 ZwCancelTimer(
2907 IN HANDLE TimerHandle,
2908 OUT PBOOLEAN CurrentState OPTIONAL);
2909
2910 NTSTATUS
2911 NTAPI
2912 ZwCreateTimer(
2913 OUT PHANDLE TimerHandle,
2914 IN ACCESS_MASK DesiredAccess,
2915 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
2916 IN TIMER_TYPE TimerType);
2917
2918 NTSTATUS
2919 NTAPI
2920 ZwOpenTimer(
2921 OUT PHANDLE TimerHandle,
2922 IN ACCESS_MASK DesiredAccess,
2923 IN POBJECT_ATTRIBUTES ObjectAttributes);
2924
2925 NTSYSAPI
2926 NTSTATUS
2927 NTAPI
2928 ZwSetInformationThread(
2929 IN HANDLE ThreadHandle,
2930 IN THREADINFOCLASS ThreadInformationClass,
2931 IN PVOID ThreadInformation,
2932 IN ULONG ThreadInformationLength);
2933
2934 NTSTATUS
2935 NTAPI
2936 ZwSetTimer(
2937 IN HANDLE TimerHandle,
2938 IN PLARGE_INTEGER DueTime,
2939 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
2940 IN PVOID TimerContext OPTIONAL,
2941 IN BOOLEAN ResumeTimer,
2942 IN LONG Period OPTIONAL,
2943 OUT PBOOLEAN PreviousState OPTIONAL);
2944
2945 #endif
2946
2947
2948 #ifdef __cplusplus
2949 }
2950 #endif
2951
2952
2953 #endif /* _NTDDK_ */