4 * Windows Device Driver Kit
6 * This file is part of the w32api package.
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
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.
22 * DBG - Debugging enabled/disabled (0/1)
23 * POOL_TAGGING - Enable pool tagging
24 * _X86_ - X86 environment
30 #if !defined(_NTHAL_) && !defined(_NTIFS_)
31 #define _NTDDK_INCLUDED_
38 #define _CTYPE_DISABLE_MACROS
50 #include <stdarg.h> // FIXME
51 #include <basetyps.h> // FIXME
66 typedef struct _BUS_HANDLER
*PBUS_HANDLER
;
68 #define KERNEL_STACK_SIZE 12288
69 #define KERNEL_LARGE_STACK_SIZE 61440
70 #define KERNEL_LARGE_STACK_COMMIT 12288
74 #define SIZE_OF_80387_REGISTERS 80
76 typedef struct _FLOATING_SAVE_AREA
{
84 UCHAR RegisterArea
[SIZE_OF_80387_REGISTERS
];
86 } FLOATING_SAVE_AREA
, *PFLOATING_SAVE_AREA
;
89 typedef struct _CONTEXT
{
97 FLOATING_SAVE_AREA FloatSave
;
114 UCHAR ExtendedRegisters
[MAXIMUM_SUPPORTED_EXTENSION
];
122 #if !defined(RC_INVOKED)
124 #define CONTEXT_AMD64 0x100000
126 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
127 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
128 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
129 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
130 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
132 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
133 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
135 #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
137 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
138 #define CONTEXT_SERVICE_ACTIVE 0x10000000
139 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
140 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
142 #endif /* RC_INVOKED */
146 typedef enum _INTERLOCKED_RESULT
{
147 ResultNegative
= RESULT_NEGATIVE
,
148 ResultZero
= RESULT_ZERO
,
149 ResultPositive
= RESULT_POSITIVE
150 } INTERLOCKED_RESULT
;
152 typedef struct _OSVERSIONINFOA
{
153 ULONG dwOSVersionInfoSize
;
154 ULONG dwMajorVersion
;
155 ULONG dwMinorVersion
;
158 CHAR szCSDVersion
[128];
159 } OSVERSIONINFOA
, *POSVERSIONINFOA
, *LPOSVERSIONINFOA
;
161 typedef struct _OSVERSIONINFOW
{
162 ULONG dwOSVersionInfoSize
;
163 ULONG dwMajorVersion
;
164 ULONG dwMinorVersion
;
167 WCHAR szCSDVersion
[128];
168 } OSVERSIONINFOW
, *POSVERSIONINFOW
, *LPOSVERSIONINFOW
, RTL_OSVERSIONINFOW
, *PRTL_OSVERSIONINFOW
;
170 typedef struct _OSVERSIONINFOEXA
{
171 ULONG dwOSVersionInfoSize
;
172 ULONG dwMajorVersion
;
173 ULONG dwMinorVersion
;
176 CHAR szCSDVersion
[128];
177 USHORT wServicePackMajor
;
178 USHORT wServicePackMinor
;
182 } OSVERSIONINFOEXA
, *POSVERSIONINFOEXA
, *LPOSVERSIONINFOEXA
;
184 typedef struct _OSVERSIONINFOEXW
{
185 ULONG dwOSVersionInfoSize
;
186 ULONG dwMajorVersion
;
187 ULONG dwMinorVersion
;
190 WCHAR szCSDVersion
[128];
191 USHORT wServicePackMajor
;
192 USHORT wServicePackMinor
;
196 } OSVERSIONINFOEXW
, *POSVERSIONINFOEXW
, *LPOSVERSIONINFOEXW
, RTL_OSVERSIONINFOEXW
, *PRTL_OSVERSIONINFOEXW
;
199 typedef OSVERSIONINFOEXW OSVERSIONINFOEX
;
200 typedef POSVERSIONINFOEXW POSVERSIONINFOEX
;
201 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX
;
202 typedef OSVERSIONINFOW OSVERSIONINFO
;
203 typedef POSVERSIONINFOW POSVERSIONINFO
;
204 typedef LPOSVERSIONINFOW LPOSVERSIONINFO
;
206 typedef OSVERSIONINFOEXA OSVERSIONINFOEX
;
207 typedef POSVERSIONINFOEXA POSVERSIONINFOEX
;
208 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX
;
209 typedef OSVERSIONINFOA OSVERSIONINFO
;
210 typedef POSVERSIONINFOA POSVERSIONINFO
;
211 typedef LPOSVERSIONINFOA LPOSVERSIONINFO
;
214 typedef struct _RTL_SPLAY_LINKS
{
215 struct _RTL_SPLAY_LINKS
*Parent
;
216 struct _RTL_SPLAY_LINKS
*LeftChild
;
217 struct _RTL_SPLAY_LINKS
*RightChild
;
218 } RTL_SPLAY_LINKS
, *PRTL_SPLAY_LINKS
;
220 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
222 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
223 *CallersAddress = (PVOID)_ReturnAddress(); \
224 *CallersCaller = NULL;
227 #if (NTDDI_VERSION >= NTDDI_WIN2K)
231 RtlGetCallersAddress(
232 OUT PVOID
*CallersAddress
,
233 OUT PVOID
*CallersCaller
);
238 #if !defined(MIDL_PASS)
243 RtlConvertLongToLuid(
250 Luid
.LowPart
= Temp
.u
.LowPart
;
251 Luid
.HighPart
= Temp
.u
.HighPart
;
258 RtlConvertUlongToLuid(
270 #if (NTDDI_VERSION >= NTDDI_WIN2K)
275 RtlPrefixUnicodeString(
276 IN PCUNICODE_STRING String1
,
277 IN PCUNICODE_STRING String2
,
278 IN BOOLEAN CaseInSensitive
);
284 IN OUT PSTRING DestinationString
,
285 IN
const PSTRING SourceString
);
290 RtlUpcaseUnicodeString(
291 IN OUT PUNICODE_STRING DestinationString
,
292 IN PCUNICODE_STRING SourceString
,
293 IN BOOLEAN AllocateDestinationString
);
299 IN OUT PACCESS_MASK AccessMask
,
300 IN PGENERIC_MAPPING GenericMapping
);
305 RtlVolumeDeviceToDosName(
306 IN PVOID VolumeDeviceObject
,
307 OUT PUNICODE_STRING DosName
);
313 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation
);
318 RtlVerifyVersionInfo(
319 IN PRTL_OSVERSIONINFOEXW VersionInfo
,
321 IN ULONGLONG ConditionMask
);
327 IN
const PSTRING String1
,
328 IN
const PSTRING String2
,
329 BOOLEAN CaseInSensitive
);
335 OUT PSTRING DestinationString
,
336 IN
const PSTRING SourceString OPTIONAL
);
342 IN
const PSTRING String1
,
343 IN
const PSTRING String2
,
344 IN BOOLEAN CaseInSensitive
);
348 /* Executive Types */
350 #define PROTECTED_POOL 0x80000000
352 typedef struct _ZONE_SEGMENT_HEADER
{
353 SINGLE_LIST_ENTRY SegmentList
;
355 } ZONE_SEGMENT_HEADER
, *PZONE_SEGMENT_HEADER
;
357 typedef struct _ZONE_HEADER
{
358 SINGLE_LIST_ENTRY FreeList
;
359 SINGLE_LIST_ENTRY SegmentList
;
361 ULONG TotalSegmentSize
;
362 } ZONE_HEADER
, *PZONE_HEADER
;
364 /* Executive Functions */
369 * IN PZONE_HEADER Zone)
371 #define ExIsFullZone(Zone) \
372 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
375 * ExIsObjectInFirstZoneSegment(
376 * IN PZONE_HEADER Zone,
379 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
380 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
381 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
382 (Zone)->TotalSegmentSize)) )
384 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
385 #define ExAcquireResourceShared ExAcquireResourceSharedLite
386 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
387 #define ExDeleteResource ExDeleteResourceLite
388 #define ExInitializeResource ExInitializeResourceLite
389 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
390 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
391 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
392 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
394 #if (NTDDI_VERSION >= NTDDI_WIN2K)
400 IN OUT PZONE_HEADER Zone
,
401 IN OUT PVOID Segment
,
402 IN ULONG SegmentSize
);
408 OUT PZONE_HEADER Zone
,
410 IN OUT PVOID InitialSegment
,
411 IN ULONG InitialSegmentSize
);
416 ExInterlockedExtendZone(
417 IN OUT PZONE_HEADER Zone
,
418 IN OUT PVOID Segment
,
419 IN ULONG SegmentSize
,
420 IN OUT PKSPIN_LOCK Lock
);
432 typedef enum _CONFIGURATION_TYPE
{
435 FloatingPointProcessor
,
445 MultiFunctionAdapter
,
459 FloppyDiskPeripheral
,
472 RealModeIrqRoutingTable
,
473 RealModePCIEnumeration
,
475 } CONFIGURATION_TYPE
, *PCONFIGURATION_TYPE
;
476 #endif /* !_ARC_DDK_ */
478 typedef struct _CONTROLLER_OBJECT
{
481 PVOID ControllerExtension
;
482 KDEVICE_QUEUE DeviceWaitQueue
;
484 LARGE_INTEGER Spare2
;
485 } CONTROLLER_OBJECT
, *PCONTROLLER_OBJECT
;
487 typedef struct _CONFIGURATION_INFORMATION
{
495 BOOLEAN AtDiskPrimaryAddressClaimed
;
496 BOOLEAN AtDiskSecondaryAddressClaimed
;
498 ULONG MediumChangerCount
;
499 } CONFIGURATION_INFORMATION
, *PCONFIGURATION_INFORMATION
;
503 (DDKAPI
*PIO_QUERY_DEVICE_ROUTINE
)(
505 IN PUNICODE_STRING PathName
,
506 IN INTERFACE_TYPE BusType
,
508 IN PKEY_VALUE_FULL_INFORMATION
*BusInformation
,
509 IN CONFIGURATION_TYPE ControllerType
,
510 IN ULONG ControllerNumber
,
511 IN PKEY_VALUE_FULL_INFORMATION
*ControllerInformation
,
512 IN CONFIGURATION_TYPE PeripheralType
,
513 IN ULONG PeripheralNumber
,
514 IN PKEY_VALUE_FULL_INFORMATION
*PeripheralInformation
);
518 (DDKAPI DRIVER_REINITIALIZE
)(
519 IN
struct _DRIVER_OBJECT
*DriverObject
,
523 typedef DRIVER_REINITIALIZE
*PDRIVER_REINITIALIZE
;
525 /* I/O Manager Functions */
527 #if (NTDDI_VERSION >= NTDDI_WIN2K)
529 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
533 IoAllocateAdapterChannel(
534 IN PADAPTER_OBJECT AdapterObject
,
535 IN PDEVICE_OBJECT DeviceObject
,
536 IN ULONG NumberOfMapRegisters
,
537 IN PDRIVER_CONTROL ExecutionRoutine
,
541 //DECLSPEC_DEPRECATED_DDK
546 IN PADAPTER_OBJECT AdapterObject
,
548 IN PVOID MapRegisterBase
,
550 IN OUT PULONG Length
,
551 IN BOOLEAN WriteToDevice
);
556 IoAllocateController(
557 IN PCONTROLLER_OBJECT ControllerObject
,
558 IN PDEVICE_OBJECT DeviceObject
,
559 IN PDRIVER_CONTROL ExecutionRoutine
,
560 IN PVOID Context OPTIONAL
);
572 IN PCONTROLLER_OBJECT ControllerObject
);
578 IN PCONTROLLER_OBJECT ControllerObject
);
581 PCONFIGURATION_INFORMATION
583 IoGetConfigurationInformation(
596 IN PDEVICE_OBJECT DeviceObject
,
597 IN PFILE_OBJECT FileObject
);
602 IoGetFileObjectGenericMapping(
615 IoQueryDeviceDescription(
616 IN PINTERFACE_TYPE BusType OPTIONAL
,
617 IN PULONG BusNumber OPTIONAL
,
618 IN PCONFIGURATION_TYPE ControllerType OPTIONAL
,
619 IN PULONG ControllerNumber OPTIONAL
,
620 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL
,
621 IN PULONG PeripheralNumber OPTIONAL
,
622 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine
,
623 IN OUT PVOID Context OPTIONAL
);
630 IN PVPB Vpb OPTIONAL
,
631 IN PDEVICE_OBJECT RealDeviceObject
);
636 IoRaiseInformationalHardError(
637 IN NTSTATUS ErrorStatus
,
638 IN PUNICODE_STRING String OPTIONAL
,
639 IN PKTHREAD Thread OPTIONAL
);
644 IoRegisterBootDriverReinitialization(
645 IN PDRIVER_OBJECT DriverObject
,
646 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine
,
647 IN PVOID Context OPTIONAL
);
652 IoRegisterDriverReinitialization(
653 IN PDRIVER_OBJECT DriverObject
,
654 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine
,
655 IN PVOID Context OPTIONAL
);
660 IoAttachDeviceByPointer(
661 IN PDEVICE_OBJECT SourceDevice
,
662 IN PDEVICE_OBJECT TargetDevice
);
664 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
667 /* Memory Manager Types */
669 typedef struct _PHYSICAL_MEMORY_RANGE
{
670 PHYSICAL_ADDRESS BaseAddress
;
671 LARGE_INTEGER NumberOfBytes
;
672 } PHYSICAL_MEMORY_RANGE
, *PPHYSICAL_MEMORY_RANGE
;
674 /* Memory Manager Functions */
676 #if (NTDDI_VERSION >= NTDDI_WIN2K)
679 PPHYSICAL_MEMORY_RANGE
681 MmGetPhysicalMemoryRanges(
687 MmGetPhysicalAddress(
688 IN PVOID BaseAddress
);
690 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
692 /* Windows Device Driver Kit */