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