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