2 * Copyright 2004-2005 Ivan Leo Puoti
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
28 #define POINTER_ALIGNMENT
31 typedef ULONG_PTR KSPIN_LOCK
, *PKSPIN_LOCK
;
36 struct _DEVICE_OBJECT
;
37 struct _DRIVER_OBJECT
;
39 typedef VOID (WINAPI
*PKDEFERRED_ROUTINE
)(struct _KDPC
*, PVOID
, PVOID
, PVOID
);
40 typedef VOID (WINAPI
*PKSTART_ROUTINE
)(PVOID
);
42 typedef NTSTATUS (WINAPI
*PDRIVER_INITIALIZE
)(struct _DRIVER_OBJECT
*, PUNICODE_STRING
);
43 typedef NTSTATUS (WINAPI
*PDRIVER_DISPATCH
)(struct _DEVICE_OBJECT
*, struct _IRP
*);
44 typedef void (WINAPI
*PDRIVER_STARTIO
)(struct _DEVICE_OBJECT
*, struct _IRP
*);
45 typedef void (WINAPI
*PDRIVER_UNLOAD
)(struct _DRIVER_OBJECT
*);
47 typedef struct _DISPATCHER_HEADER
{
53 LIST_ENTRY WaitListHead
;
54 } DISPATCHER_HEADER
, *PDISPATCHER_HEADER
;
56 typedef struct _KEVENT
{
57 DISPATCHER_HEADER Header
;
58 } KEVENT
, *PKEVENT
, *RESTRICTED_POINTER PRKEVENT
;
60 typedef struct _KDPC
{
64 LIST_ENTRY DpcListEntry
;
65 PKDEFERRED_ROUTINE DeferredRoutine
;
66 PVOID DeferredContext
;
67 PVOID SystemArgument1
;
68 PVOID SystemArgument2
;
70 } KDPC
, *PKDPC
, *RESTRICTED_POINTER PRKDPC
;
72 typedef struct _KDEVICE_QUEUE_ENTRY
{
73 LIST_ENTRY DeviceListEntry
;
76 } KDEVICE_QUEUE_ENTRY
, *PKDEVICE_QUEUE_ENTRY
,
77 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY
;
79 typedef struct _KDEVICE_QUEUE
{
82 LIST_ENTRY DeviceListHead
;
85 } KDEVICE_QUEUE
, *PKDEVICE_QUEUE
, *RESTRICTED_POINTER PRKDEVICE_QUEUE
;
87 typedef struct _IO_TIMER
*PIO_TIMER
;
88 typedef struct _ETHREAD
*PETHREAD
;
89 typedef struct _KTHREAD
*PKTHREAD
;
90 typedef struct _EPROCESS
*PEPROCESS
;
91 typedef struct _IO_WORKITEM
*PIO_WORKITEM
;
93 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
99 USHORT VolumeLabelLength
;
100 struct _DEVICE_OBJECT
*DeviceObject
;
101 struct _DEVICE_OBJECT
*RealDevice
;
103 ULONG ReferenceCount
;
104 WCHAR VolumeLabel
[MAXIMUM_VOLUME_LABEL_LENGTH
/ sizeof(WCHAR
)];
107 typedef enum _POOL_TYPE
{
110 NonPagedPoolMustSucceed
,
112 NonPagedPoolCacheAligned
,
113 PagedPoolCacheAligned
,
114 NonPagedPoolCacheAlignedMustS
,
118 typedef struct _WAIT_CONTEXT_BLOCK
{
119 KDEVICE_QUEUE_ENTRY WaitQueueEntry
;
120 struct _DRIVER_CONTROL
*DeviceRoutine
;
122 ULONG NumberOfMapRegisters
;
125 PKDPC BufferChainingDpc
;
126 } WAIT_CONTEXT_BLOCK
, *PWAIT_CONTEXT_BLOCK
;
128 #define DO_BUFFERED_IO 0x00000004
129 #define DO_EXCLUSIVE 0x00000008
130 #define DO_DIRECT_IO 0x00000010
131 #define DO_MAP_IO_BUFFER 0x00000020
132 #define DO_DEVICE_INITIALIZING 0x00000080
133 #define DO_SHUTDOWN_REGISTERED 0x00000800
134 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
135 #define DO_POWER_PAGABLE 0x00002000
136 #define DO_POWER_INRUSH 0x00004000
138 #define IO_NO_INCREMENT 0
139 #define IO_CD_ROM_INCREMENT 1
140 #define IO_DISK_INCREMENT 1
141 #define IO_KEYBOARD_INCREMENT 6
142 #define IO_MAILSLOT_INCREMENT 2
143 #define IO_MOUSE_INCREMENT 6
144 #define IO_NAMED_PIPE_INCREMENT 2
145 #define IO_NETWORK_INCREMENT 2
146 #define IO_PARALLEL_INCREMENT 1
147 #define IO_SERIAL_INCREMENT 2
148 #define IO_SOUND_INCREMENT 8
149 #define IO_VIDEO_INCREMENT 1
152 #define DEVICE_TYPE ULONG
154 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
155 #define IRP_MJ_CREATE 0x00
156 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
157 #define IRP_MJ_CLOSE 0x02
158 #define IRP_MJ_READ 0x03
159 #define IRP_MJ_WRITE 0x04
160 #define IRP_MJ_QUERY_INFORMATION 0x05
161 #define IRP_MJ_SET_INFORMATION 0x06
162 #define IRP_MJ_QUERY_EA 0x07
163 #define IRP_MJ_SET_EA 0x08
164 #define IRP_MJ_FLUSH_BUFFERS 0x09
165 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
166 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
167 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
168 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
169 #define IRP_MJ_DEVICE_CONTROL 0x0e
170 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
171 #define IRP_MJ_SHUTDOWN 0x10
172 #define IRP_MJ_LOCK_CONTROL 0x11
173 #define IRP_MJ_CLEANUP 0x12
174 #define IRP_MJ_CREATE_MAILSLOT 0x13
175 #define IRP_MJ_QUERY_SECURITY 0x14
176 #define IRP_MJ_SET_SECURITY 0x15
177 #define IRP_MJ_POWER 0x16
178 #define IRP_MJ_SYSTEM_CONTROL 0x17
179 #define IRP_MJ_DEVICE_CHANGE 0x18
180 #define IRP_MJ_QUERY_QUOTA 0x19
181 #define IRP_MJ_SET_QUOTA 0x1a
182 #define IRP_MJ_PNP 0x1b
184 #define IRP_QUOTA_CHARGED 0x01
185 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
186 #define IRP_ALLOCATED_FIXED_SIZE 0x04
187 #define IRP_LOOKASIDE_ALLOCATION 0x08
189 typedef struct _DEVICE_OBJECT
{
193 struct _DRIVER_OBJECT
*DriverObject
;
194 struct _DEVICE_OBJECT
*NextDevice
;
195 struct _DEVICE_OBJECT
*AttachedDevice
;
196 struct _IRP
*CurrentIrp
;
199 ULONG Characteristics
;
201 PVOID DeviceExtension
;
202 DEVICE_TYPE DeviceType
;
205 LIST_ENTRY ListEntry
;
206 WAIT_CONTEXT_BLOCK Wcb
;
208 ULONG AlignmentRequirement
;
209 KDEVICE_QUEUE DeviceQueue
;
211 ULONG ActiveThreadCount
;
212 PSECURITY_DESCRIPTOR SecurityDescriptor
;
216 struct _DEVOBJ_EXTENSION
*DeviceObjectExtension
;
219 typedef struct _DEVICE_OBJECT
*PDEVICE_OBJECT
;
221 typedef struct _DRIVER_EXTENSION
{
222 struct _DRIVER_OBJECT
*DriverObject
;
225 UNICODE_STRING ServiceKeyName
;
226 } DRIVER_EXTENSION
, *PDRIVER_EXTENSION
;
228 typedef struct _DRIVER_OBJECT
{
231 PDEVICE_OBJECT DeviceObject
;
236 PDRIVER_EXTENSION DriverExtension
;
237 UNICODE_STRING DriverName
;
238 PUNICODE_STRING HardwareDatabase
;
239 PVOID FastIoDispatch
;
240 PDRIVER_INITIALIZE DriverInit
;
241 PDRIVER_STARTIO DriverStartIo
;
242 PDRIVER_UNLOAD DriverUnload
;
243 PDRIVER_DISPATCH MajorFunction
[IRP_MJ_MAXIMUM_FUNCTION
+ 1];
245 typedef struct _DRIVER_OBJECT
*PDRIVER_OBJECT
;
247 /* Irp definitions */
248 typedef UCHAR KIRQL
, *PKIRQL
;
249 typedef CCHAR KPROCESSOR_MODE
;
251 typedef VOID (WINAPI
*PDRIVER_CANCEL
)(
252 IN
struct _DEVICE_OBJECT
*DeviceObject
,
253 IN
struct _IRP
*Irp
);
255 typedef VOID (WINAPI
*PKNORMAL_ROUTINE
)(
256 IN PVOID NormalContext
,
257 IN PVOID SystemArgument1
,
258 IN PVOID SystemArgument2
);
260 typedef VOID (WINAPI
*PKKERNEL_ROUTINE
)(
261 IN
struct _KAPC
*Apc
,
262 IN OUT PKNORMAL_ROUTINE
*NormalRoutine
,
263 IN OUT PVOID
*NormalContext
,
264 IN OUT PVOID
*SystemArgument1
,
265 IN OUT PVOID
*SystemArgument2
);
267 typedef VOID (WINAPI
*PKRUNDOWN_ROUTINE
)(
268 IN
struct _KAPC
*Apc
);
270 typedef struct _KAPC
{
274 struct _KTHREAD
*Thread
;
275 LIST_ENTRY ApcListEntry
;
276 PKKERNEL_ROUTINE KernelRoutine
;
277 PKRUNDOWN_ROUTINE RundownRoutine
;
278 PKNORMAL_ROUTINE NormalRoutine
;
280 PVOID SystemArgument1
;
281 PVOID SystemArgument2
;
283 KPROCESSOR_MODE ApcMode
;
285 } KAPC
, *PKAPC
, *RESTRICTED_POINTER PRKAPC
;
287 #include <pshpack1.h>
288 typedef struct _IRP
{
291 struct _MDL
*MdlAddress
;
294 struct _IRP
*MasterIrp
;
298 LIST_ENTRY ThreadListEntry
;
299 IO_STATUS_BLOCK IoStatus
;
300 KPROCESSOR_MODE RequestorMode
;
301 BOOLEAN PendingReturned
;
303 CHAR CurrentLocation
;
306 CCHAR ApcEnvironment
;
307 UCHAR AllocationFlags
;
308 PIO_STATUS_BLOCK UserIosb
;
312 PIO_APC_ROUTINE UserApcRoutine
;
313 PVOID UserApcContext
;
314 } AsynchronousParameters
;
315 LARGE_INTEGER AllocationSize
;
317 PDRIVER_CANCEL CancelRoutine
;
322 KDEVICE_QUEUE_ENTRY DeviceQueueEntry
;
324 PVOID DriverContext
[4];
328 PCHAR AuxiliaryBuffer
;
330 LIST_ENTRY ListEntry
;
332 struct _IO_STACK_LOCATION
*CurrentStackLocation
;
336 struct _FILE_OBJECT
*OriginalFileObject
;
342 typedef struct _IRP
*PIRP
;
345 /* MDL definitions */
347 typedef VOID (WINAPI
*PINTERFACE_REFERENCE
)(
350 typedef VOID (WINAPI
*PINTERFACE_DEREFERENCE
)(
353 typedef struct _INTERFACE
{
357 PINTERFACE_REFERENCE InterfaceReference
;
358 PINTERFACE_DEREFERENCE InterfaceDereference
;
359 } INTERFACE
, *PINTERFACE
;
361 typedef struct _SECTION_OBJECT_POINTERS
{
362 PVOID DataSectionObject
;
363 PVOID SharedCacheMap
;
364 PVOID ImageSectionObject
;
365 } SECTION_OBJECT_POINTERS
, *PSECTION_OBJECT_POINTERS
;
367 typedef struct _IO_COMPLETION_CONTEXT
{
370 } IO_COMPLETION_CONTEXT
, *PIO_COMPLETION_CONTEXT
;
372 typedef enum _DEVICE_RELATION_TYPE
{
377 TargetDeviceRelation
,
379 } DEVICE_RELATION_TYPE
, *PDEVICE_RELATION_TYPE
;
381 typedef struct _FILE_OBJECT
{
384 PDEVICE_OBJECT DeviceObject
;
388 PSECTION_OBJECT_POINTERS SectionObjectPointer
;
389 PVOID PrivateCacheMap
;
390 NTSTATUS FinalStatus
;
391 struct _FILE_OBJECT
*RelatedFileObject
;
392 BOOLEAN LockOperation
;
393 BOOLEAN DeletePending
;
396 BOOLEAN DeleteAccess
;
399 BOOLEAN SharedDelete
;
401 UNICODE_STRING FileName
;
402 LARGE_INTEGER CurrentByteOffset
;
408 PIO_COMPLETION_CONTEXT CompletionContext
;
410 typedef struct _FILE_OBJECT
*PFILE_OBJECT
;
412 #define INITIAL_PRIVILEGE_COUNT 3
414 typedef struct _INITIAL_PRIVILEGE_SET
{
415 ULONG PrivilegeCount
;
417 LUID_AND_ATTRIBUTES Privilege
[INITIAL_PRIVILEGE_COUNT
];
418 } INITIAL_PRIVILEGE_SET
, * PINITIAL_PRIVILEGE_SET
;
420 typedef struct _SECURITY_SUBJECT_CONTEXT
{
421 PACCESS_TOKEN ClientToken
;
422 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
423 PACCESS_TOKEN PrimaryToken
;
424 PVOID ProcessAuditId
;
425 } SECURITY_SUBJECT_CONTEXT
, *PSECURITY_SUBJECT_CONTEXT
;
427 typedef struct _ACCESS_STATE
{
429 BOOLEAN SecurityEvaluated
;
430 BOOLEAN GenerateAudit
;
431 BOOLEAN GenerateOnClose
;
432 BOOLEAN PrivilegesAllocated
;
434 ACCESS_MASK RemainingDesiredAccess
;
435 ACCESS_MASK PreviouslyGrantedAccess
;
436 ACCESS_MASK OriginalDesiredAccess
;
437 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext
;
438 PSECURITY_DESCRIPTOR SecurityDescriptor
;
441 INITIAL_PRIVILEGE_SET InitialPrivilegeSet
;
442 PRIVILEGE_SET PrivilegeSet
;
445 BOOLEAN AuditPrivileges
;
446 UNICODE_STRING ObjectName
;
447 UNICODE_STRING ObjectTypeName
;
448 } ACCESS_STATE
, *PACCESS_STATE
;
450 typedef struct _IO_SECURITY_CONTEXT
{
451 PSECURITY_QUALITY_OF_SERVICE SecurityQos
;
452 PACCESS_STATE AccessState
;
453 ACCESS_MASK DesiredAccess
;
454 ULONG FullCreateOptions
;
455 } IO_SECURITY_CONTEXT
, *PIO_SECURITY_CONTEXT
;
457 typedef struct _DEVICE_CAPABILITIES
{
462 ULONG LockSupported
: 1;
463 ULONG EjectSupported
: 1;
465 ULONG DockDevice
: 1;
467 ULONG SilentInstall
: 1;
468 ULONG RawDeviceOK
: 1;
469 ULONG SurpriseRemovalOK
: 1;
470 ULONG WakeFromD0
: 1;
471 ULONG WakeFromD1
: 1;
472 ULONG WakeFromD2
: 1;
473 ULONG WakeFromD3
: 1;
474 ULONG HardwareDisabled
: 1;
475 ULONG NonDynamic
: 1;
476 ULONG WarmEjectSupported
: 1;
477 ULONG NoDisplayInUI
: 1;
481 DEVICE_POWER_STATE DeviceState
[PowerSystemMaximum
];
482 SYSTEM_POWER_STATE SystemWake
;
483 DEVICE_POWER_STATE DeviceWake
;
487 } DEVICE_CAPABILITIES
, *PDEVICE_CAPABILITIES
;
489 typedef enum _INTERFACE_TYPE
{
490 InterfaceTypeUndefined
= -1,
508 } INTERFACE_TYPE
, *PINTERFACE_TYPE
;
510 typedef LARGE_INTEGER PHYSICAL_ADDRESS
, *PPHYSICAL_ADDRESS
;
512 #define IO_RESOURCE_PREFERRED 0x01
513 #define IO_RESOURCE_DEFAULT 0x02
514 #define IO_RESOURCE_ALTERNATIVE 0x08
516 typedef struct _IO_RESOURCE_DESCRIPTOR
{
519 UCHAR ShareDisposition
;
527 PHYSICAL_ADDRESS MinimumAddress
;
528 PHYSICAL_ADDRESS MaximumAddress
;
533 PHYSICAL_ADDRESS MinimumAddress
;
534 PHYSICAL_ADDRESS MaximumAddress
;
541 ULONG MinimumChannel
;
542 ULONG MaximumChannel
;
547 PHYSICAL_ADDRESS MinimumAddress
;
548 PHYSICAL_ADDRESS MaximumAddress
;
565 } IO_RESOURCE_DESCRIPTOR
, *PIO_RESOURCE_DESCRIPTOR
;
567 typedef struct _IO_RESOURCE_LIST
{
571 IO_RESOURCE_DESCRIPTOR Descriptors
[1];
572 } IO_RESOURCE_LIST
, *PIO_RESOURCE_LIST
;
574 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST
{
576 INTERFACE_TYPE InterfaceType
;
580 ULONG AlternativeLists
;
581 IO_RESOURCE_LIST List
[1];
582 } IO_RESOURCE_REQUIREMENTS_LIST
, *PIO_RESOURCE_REQUIREMENTS_LIST
;
584 typedef enum _BUS_QUERY_ID_TYPE
{
587 BusQueryCompatibleIDs
,
589 BusQueryDeviceSerialNumber
590 } BUS_QUERY_ID_TYPE
, *PBUS_QUERY_ID_TYPE
;
592 typedef enum _DEVICE_TEXT_TYPE
{
593 DeviceTextDescription
,
594 DeviceTextLocationInformation
595 } DEVICE_TEXT_TYPE
, *PDEVICE_TEXT_TYPE
;
597 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE
{
598 DeviceUsageTypeUndefined
,
599 DeviceUsageTypePaging
,
600 DeviceUsageTypeHibernation
,
601 DeviceUsageTypeDumpFile
602 } DEVICE_USAGE_NOTIFICATION_TYPE
;
604 typedef struct _POWER_SEQUENCE
{
608 } POWER_SEQUENCE
, *PPOWER_SEQUENCE
;
610 typedef enum _POWER_STATE_TYPE
{
613 } POWER_STATE_TYPE
, *PPOWER_STATE_TYPE
;
615 typedef union _POWER_STATE
{
616 SYSTEM_POWER_STATE SystemState
;
617 DEVICE_POWER_STATE DeviceState
;
618 } POWER_STATE
, *PPOWER_STATE
;
620 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
{
622 UCHAR ShareDisposition
;
626 PHYSICAL_ADDRESS Start
;
630 PHYSICAL_ADDRESS Start
;
639 PHYSICAL_ADDRESS Start
;
659 } DeviceSpecificData
;
661 } CM_PARTIAL_RESOURCE_DESCRIPTOR
, *PCM_PARTIAL_RESOURCE_DESCRIPTOR
;
663 typedef struct _CM_PARTIAL_RESOURCE_LIST
{
667 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors
[1];
668 } CM_PARTIAL_RESOURCE_LIST
, *PCM_PARTIAL_RESOURCE_LIST
;
670 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR
{
671 INTERFACE_TYPE InterfaceType
;
673 CM_PARTIAL_RESOURCE_LIST PartialResourceList
;
674 } CM_FULL_RESOURCE_DESCRIPTOR
, *PCM_FULL_RESOURCE_DESCRIPTOR
;
676 typedef struct _CM_RESOURCE_LIST
{
678 CM_FULL_RESOURCE_DESCRIPTOR List
[1];
679 } CM_RESOURCE_LIST
, *PCM_RESOURCE_LIST
;
681 typedef NTSTATUS (WINAPI
*PIO_COMPLETION_ROUTINE
)(
682 IN
struct _DEVICE_OBJECT
*DeviceObject
,
686 #include <pshpack1.h>
687 typedef struct _IO_STACK_LOCATION
{
694 PIO_SECURITY_CONTEXT SecurityContext
;
696 USHORT POINTER_ALIGNMENT FileAttributes
;
698 ULONG POINTER_ALIGNMENT EaLength
;
702 ULONG POINTER_ALIGNMENT Key
;
703 LARGE_INTEGER ByteOffset
;
707 ULONG POINTER_ALIGNMENT Key
;
708 LARGE_INTEGER ByteOffset
;
712 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass
;
716 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass
;
717 PFILE_OBJECT FileObject
;
720 BOOLEAN ReplaceIfExists
;
729 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass
;
732 ULONG OutputBufferLength
;
733 ULONG POINTER_ALIGNMENT InputBufferLength
;
734 ULONG POINTER_ALIGNMENT IoControlCode
;
735 PVOID Type3InputBuffer
;
738 SECURITY_INFORMATION SecurityInformation
;
739 ULONG POINTER_ALIGNMENT Length
;
742 SECURITY_INFORMATION SecurityInformation
;
743 PSECURITY_DESCRIPTOR SecurityDescriptor
;
747 PDEVICE_OBJECT DeviceObject
;
751 PDEVICE_OBJECT DeviceObject
;
754 struct _SCSI_REQUEST_BLOCK
*Srb
;
757 DEVICE_RELATION_TYPE Type
;
758 } QueryDeviceRelations
;
760 CONST GUID
*InterfaceType
;
763 PINTERFACE Interface
;
764 PVOID InterfaceSpecificData
;
767 PDEVICE_CAPABILITIES Capabilities
;
768 } DeviceCapabilities
;
770 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList
;
771 } FilterResourceRequirements
;
776 ULONG POINTER_ALIGNMENT Length
;
782 BUS_QUERY_ID_TYPE IdType
;
785 DEVICE_TEXT_TYPE DeviceTextType
;
786 LCID POINTER_ALIGNMENT LocaleId
;
791 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type
;
794 SYSTEM_POWER_STATE PowerState
;
797 PPOWER_SEQUENCE PowerSequence
;
801 POWER_STATE_TYPE POINTER_ALIGNMENT Type
;
802 POWER_STATE POINTER_ALIGNMENT State
;
803 POWER_ACTION POINTER_ALIGNMENT ShutdownType
;
806 PCM_RESOURCE_LIST AllocatedResources
;
807 PCM_RESOURCE_LIST AllocatedResourcesTranslated
;
810 ULONG_PTR ProviderId
;
822 PDEVICE_OBJECT DeviceObject
;
823 PFILE_OBJECT FileObject
;
824 PIO_COMPLETION_ROUTINE CompletionRoutine
;
826 } IO_STACK_LOCATION
, *PIO_STACK_LOCATION
;
829 typedef struct _MDL
{
833 struct _EPROCESS
*Process
;
834 PVOID MappedSystemVa
;
840 typedef struct _KTIMER
{
841 DISPATCHER_HEADER Header
;
842 ULARGE_INTEGER DueTime
;
843 LIST_ENTRY TimerListEntry
;
848 typedef struct _KSYSTEM_TIME
{
852 } KSYSTEM_TIME
, *PKSYSTEM_TIME
;
854 typedef enum _NT_PRODUCT_TYPE
{
858 } NT_PRODUCT_TYPE
, *PNT_PRODUCT_TYPE
;
860 #define PROCESSOR_FEATURE_MAX 64
862 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
867 } ALTERNATIVE_ARCHITECTURE_TYPE
;
869 typedef struct _KUSER_SHARED_DATA
{
870 ULONG TickCountLowDeprecated
;
871 ULONG TickCountMultiplier
;
872 volatile KSYSTEM_TIME InterruptTime
;
873 volatile KSYSTEM_TIME SystemTime
;
874 volatile KSYSTEM_TIME TimeZoneBias
;
875 USHORT ImageNumberLow
;
876 USHORT ImageNumberHigh
;
877 WCHAR NtSystemRoot
[260];
878 ULONG MaxStckTraceDepth
;
879 ULONG CryptoExponent
;
881 ULONG LargePageMinimum
;
883 NT_PRODUCT_TYPE NtProductType
;
884 BOOLEAN ProductTypeIsValid
;
885 ULONG MajorNtVersion
;
886 ULONG MinorNtVersion
;
887 BOOLEAN ProcessorFeatures
[PROCESSOR_FEATURE_MAX
];
890 volatile ULONG TimeSlip
;
891 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture
;
892 LARGE_INTEGER SystemExpirationDate
;
894 BOOLEAN KdDebuggerEnabled
;
895 volatile ULONG ActiveConsoleId
;
896 volatile ULONG DismountCount
;
897 ULONG ComPlusPackage
;
898 ULONG LastSystemRITEventTickCount
;
899 ULONG NumberOfPhysicalPages
;
900 BOOLEAN SafeBootMode
;
903 ULONGLONG SystemCall
[4];
905 volatile KSYSTEM_TIME TickCount
;
906 volatile ULONG64 TickCountQuad
;
908 } KSHARED_USER_DATA
, *PKSHARED_USER_DATA
;
910 NTSTATUS WINAPI
ObCloseHandle(IN HANDLE handle
);
912 #define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation)
917 /* directory object access rights */
918 #define DIRECTORY_QUERY 0x0001
919 #define DIRECTORY_TRAVERSE 0x0002
920 #define DIRECTORY_CREATE_OBJECT 0x0004
921 #define DIRECTORY_CREATE_SUBDIRECTORY 0x0008
922 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
924 /* symbolic link access rights */
925 #define SYMBOLIC_LINK_QUERY 0x0001
926 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
928 PVOID WINAPI
ExAllocatePool(POOL_TYPE
,SIZE_T
);
929 PVOID WINAPI
ExAllocatePoolWithQuota(POOL_TYPE
,SIZE_T
);
930 PVOID WINAPI
ExAllocatePoolWithTag(POOL_TYPE
,SIZE_T
,ULONG
);
931 PVOID WINAPI
ExAllocatePoolWithQuotaTag(POOL_TYPE
,SIZE_T
,ULONG
);
932 void WINAPI
ExFreePool(PVOID
);
933 void WINAPI
ExFreePoolWithTag(PVOID
,ULONG
);
935 PIRP WINAPI
IoAllocateIrp(CCHAR
,BOOLEAN
);
936 NTSTATUS WINAPI
IoCreateDevice(DRIVER_OBJECT
*,ULONG
,UNICODE_STRING
*,DEVICE_TYPE
,ULONG
,BOOLEAN
,DEVICE_OBJECT
**);
937 NTSTATUS WINAPI
IoCreateDriver(UNICODE_STRING
*,PDRIVER_INITIALIZE
);
938 NTSTATUS WINAPI
IoCreateSymbolicLink(UNICODE_STRING
*,UNICODE_STRING
*);
939 void WINAPI
IoDeleteDevice(DEVICE_OBJECT
*);
940 void WINAPI
IoDeleteDriver(DRIVER_OBJECT
*);
941 NTSTATUS WINAPI
IoDeleteSymbolicLink(UNICODE_STRING
*);
942 void WINAPI
IoFreeIrp(IRP
*);
943 PEPROCESS WINAPI
IoGetCurrentProcess(void);
944 void WINAPI
IoInitializeIrp(IRP
*,USHORT
,CCHAR
);
946 PKTHREAD WINAPI
KeGetCurrentThread(void);
947 void WINAPI
KeQuerySystemTime(LARGE_INTEGER
*);
948 void WINAPI
KeQueryTickCount(LARGE_INTEGER
*);
949 ULONG WINAPI
KeQueryTimeIncrement(void);
951 PVOID WINAPI
MmAllocateNonCachedMemory(SIZE_T
);
952 void WINAPI
MmFreeNonCachedMemory(PVOID
,SIZE_T
);
954 NTSTATUS WINAPI
PsCreateSystemThread(PHANDLE
,ULONG
,POBJECT_ATTRIBUTES
,HANDLE
,PCLIENT_ID
,PKSTART_ROUTINE
,PVOID
);
955 #define PsGetCurrentProcess() IoGetCurrentProcess()
956 #define PsGetCurrentThread() ((PETHREAD)KeGetCurrentThread())
957 HANDLE WINAPI
PsGetCurrentProcessId(void);
958 HANDLE WINAPI
PsGetCurrentThreadId(void);
959 BOOLEAN WINAPI
PsGetVersion(ULONG
*,ULONG
*,ULONG
*,UNICODE_STRING
*);
960 NTSTATUS WINAPI
PsTerminateSystemThread(NTSTATUS
);
962 NTSTATUS WINAPI
ZwAddBootEntry(PUNICODE_STRING
,PUNICODE_STRING
);
963 NTSTATUS WINAPI
ZwAccessCheckAndAuditAlarm(PUNICODE_STRING
,HANDLE
,PUNICODE_STRING
,PUNICODE_STRING
,PSECURITY_DESCRIPTOR
,ACCESS_MASK
,PGENERIC_MAPPING
,BOOLEAN
,PACCESS_MASK
,PBOOLEAN
,PBOOLEAN
);
964 NTSTATUS WINAPI
ZwAdjustPrivilegesToken(HANDLE
,BOOLEAN
,PTOKEN_PRIVILEGES
,DWORD
,PTOKEN_PRIVILEGES
,PDWORD
);
965 NTSTATUS WINAPI
ZwAlertThread(HANDLE ThreadHandle
);
966 NTSTATUS WINAPI
ZwAllocateVirtualMemory(HANDLE
,PVOID
*,ULONG
,SIZE_T
*,ULONG
,ULONG
);
967 NTSTATUS WINAPI
ZwCancelIoFile(HANDLE
,PIO_STATUS_BLOCK
);
968 NTSTATUS WINAPI
ZwCancelTimer(HANDLE
, BOOLEAN
*);
969 NTSTATUS WINAPI
ZwClearEvent(HANDLE
);
970 NTSTATUS WINAPI
ZwClose(HANDLE
);
971 NTSTATUS WINAPI
ZwCloseObjectAuditAlarm(PUNICODE_STRING
,HANDLE
,BOOLEAN
);
972 NTSTATUS WINAPI
ZwConnectPort(PHANDLE
,PUNICODE_STRING
,PSECURITY_QUALITY_OF_SERVICE
,PLPC_SECTION_WRITE
,PLPC_SECTION_READ
,PULONG
,PVOID
,PULONG
);
973 NTSTATUS WINAPI
ZwCreateDirectoryObject(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
);
974 NTSTATUS WINAPI
ZwCreateEvent(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,BOOLEAN
,BOOLEAN
);
975 NTSTATUS WINAPI
ZwCreateFile(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,PIO_STATUS_BLOCK
,PLARGE_INTEGER
,ULONG
,ULONG
,ULONG
,ULONG
,PVOID
,ULONG
);
976 NTSTATUS WINAPI
ZwCreateKey(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,ULONG
,const UNICODE_STRING
*,ULONG
,PULONG
);
977 NTSTATUS WINAPI
ZwCreateSection(HANDLE
*,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,const LARGE_INTEGER
*,ULONG
,ULONG
,HANDLE
);
978 NTSTATUS WINAPI
ZwCreateSymbolicLinkObject(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,PUNICODE_STRING
);
979 NTSTATUS WINAPI
ZwCreateTimer(HANDLE
*, ACCESS_MASK
, const OBJECT_ATTRIBUTES
*, TIMER_TYPE
);
980 NTSTATUS WINAPI
ZwDeleteAtom(RTL_ATOM
);
981 NTSTATUS WINAPI
ZwDeleteFile(POBJECT_ATTRIBUTES
);
982 NTSTATUS WINAPI
ZwDeleteKey(HANDLE
);
983 NTSTATUS WINAPI
ZwDeleteValueKey(HANDLE
,const UNICODE_STRING
*);
984 NTSTATUS WINAPI
ZwDeviceIoControlFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,ULONG
,PVOID
,ULONG
,PVOID
,ULONG
);
985 NTSTATUS WINAPI
ZwDisplayString(PUNICODE_STRING
);
986 NTSTATUS WINAPI
ZwDuplicateObject(HANDLE
,HANDLE
,HANDLE
,PHANDLE
,ACCESS_MASK
,ULONG
,ULONG
);
987 NTSTATUS WINAPI
ZwDuplicateToken(HANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,SECURITY_IMPERSONATION_LEVEL
,TOKEN_TYPE
,PHANDLE
);
988 NTSTATUS WINAPI
ZwEnumerateKey(HANDLE
,ULONG
,KEY_INFORMATION_CLASS
,void *,DWORD
,DWORD
*);
989 NTSTATUS WINAPI
ZwEnumerateValueKey(HANDLE
,ULONG
,KEY_VALUE_INFORMATION_CLASS
,PVOID
,ULONG
,PULONG
);
990 NTSTATUS WINAPI
ZwFlushInstructionCache(HANDLE
,LPCVOID
,SIZE_T
);
991 NTSTATUS WINAPI
ZwFlushKey(HANDLE
);
992 NTSTATUS WINAPI
ZwFlushVirtualMemory(HANDLE
,LPCVOID
*,SIZE_T
*,ULONG
);
993 NTSTATUS WINAPI
ZwFreeVirtualMemory(HANDLE
,PVOID
*,SIZE_T
*,ULONG
);
994 NTSTATUS WINAPI
ZwFsControlFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,ULONG
,PVOID
,ULONG
,PVOID
,ULONG
);
995 NTSTATUS WINAPI
ZwInitiatePowerAction(POWER_ACTION
,SYSTEM_POWER_STATE
,ULONG
,BOOLEAN
);
996 NTSTATUS WINAPI
ZwLoadDriver(const UNICODE_STRING
*);
997 NTSTATUS WINAPI
ZwLoadKey(const OBJECT_ATTRIBUTES
*,OBJECT_ATTRIBUTES
*);
998 NTSTATUS WINAPI
ZwLockVirtualMemory(HANDLE
,PVOID
*,SIZE_T
*,ULONG
);
999 NTSTATUS WINAPI
ZwMakeTemporaryObject(HANDLE
);
1000 NTSTATUS WINAPI
ZwMapViewOfSection(HANDLE
,HANDLE
,PVOID
*,ULONG
,SIZE_T
,const LARGE_INTEGER
*,SIZE_T
*,SECTION_INHERIT
,ULONG
,ULONG
);
1001 NTSTATUS WINAPI
ZwNotifyChangeKey(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,ULONG
,BOOLEAN
,PVOID
,ULONG
,BOOLEAN
);
1002 NTSTATUS WINAPI
ZwOpenDirectoryObject(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
);
1003 NTSTATUS WINAPI
ZwOpenEvent(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*);
1004 NTSTATUS WINAPI
ZwOpenFile(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,PIO_STATUS_BLOCK
,ULONG
,ULONG
);
1005 NTSTATUS WINAPI
ZwOpenKey(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*);
1006 NTSTATUS WINAPI
ZwOpenProcess(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,const CLIENT_ID
*);
1007 NTSTATUS WINAPI
ZwOpenProcessToken(HANDLE
,DWORD
,HANDLE
*);
1008 NTSTATUS WINAPI
ZwOpenSection(HANDLE
*,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*);
1009 NTSTATUS WINAPI
ZwOpenSymbolicLinkObject(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
);
1010 NTSTATUS WINAPI
ZwOpenThread(HANDLE
*,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,const CLIENT_ID
*);
1011 NTSTATUS WINAPI
ZwOpenThreadToken(HANDLE
,DWORD
,BOOLEAN
,HANDLE
*);
1012 NTSTATUS WINAPI
ZwOpenTimer(HANDLE
*, ACCESS_MASK
, const OBJECT_ATTRIBUTES
*);
1013 NTSTATUS WINAPI
ZwPowerInformation(POWER_INFORMATION_LEVEL
,PVOID
,ULONG
,PVOID
,ULONG
);
1014 NTSTATUS WINAPI
ZwPulseEvent(HANDLE
,PULONG
);
1015 NTSTATUS WINAPI
ZwQueryDefaultLocale(BOOLEAN
,LCID
*);
1016 NTSTATUS WINAPI
ZwQueryDefaultUILanguage(LANGID
*);
1017 NTSTATUS WINAPI
ZwQueryDirectoryFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FILE_INFORMATION_CLASS
,BOOLEAN
,PUNICODE_STRING
,BOOLEAN
);
1018 NTSTATUS WINAPI
ZwQueryDirectoryObject(HANDLE
,PDIRECTORY_BASIC_INFORMATION
,ULONG
,BOOLEAN
,BOOLEAN
,PULONG
,PULONG
);
1019 NTSTATUS WINAPI
ZwQueryEaFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,BOOLEAN
,PVOID
,ULONG
,PVOID
,BOOLEAN
);
1020 NTSTATUS WINAPI
ZwQueryFullAttributesFile(const OBJECT_ATTRIBUTES
*,FILE_NETWORK_OPEN_INFORMATION
*);
1021 NTSTATUS WINAPI
ZwQueryInformationFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,LONG
,FILE_INFORMATION_CLASS
);
1022 NTSTATUS WINAPI
ZwQueryInformationThread(HANDLE
,THREADINFOCLASS
,PVOID
,ULONG
,PULONG
);
1023 NTSTATUS WINAPI
ZwQueryInformationToken(HANDLE
,DWORD
,PVOID
,DWORD
,LPDWORD
);
1024 NTSTATUS WINAPI
ZwQueryInstallUILanguage(LANGID
*);
1025 NTSTATUS WINAPI
ZwQueryKey(HANDLE
,KEY_INFORMATION_CLASS
,void *,DWORD
,DWORD
*);
1026 NTSTATUS WINAPI
ZwQueryObject(HANDLE
, OBJECT_INFORMATION_CLASS
, PVOID
, ULONG
, PULONG
);
1027 NTSTATUS WINAPI
ZwQuerySecurityObject(HANDLE
,SECURITY_INFORMATION
,PSECURITY_DESCRIPTOR
,ULONG
,PULONG
);
1028 NTSTATUS WINAPI
ZwQuerySection(HANDLE
,SECTION_INFORMATION_CLASS
,PVOID
,ULONG
,PULONG
);
1029 NTSTATUS WINAPI
ZwQuerySymbolicLinkObject(HANDLE
,PUNICODE_STRING
,PULONG
);
1030 NTSTATUS WINAPI
ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS
,PVOID
,ULONG
,PULONG
);
1031 NTSTATUS WINAPI
ZwQueryTimerResolution(PULONG
,PULONG
,PULONG
);
1032 NTSTATUS WINAPI
ZwQueryValueKey(HANDLE
,const UNICODE_STRING
*,KEY_VALUE_INFORMATION_CLASS
,void *,DWORD
,DWORD
*);
1033 NTSTATUS WINAPI
ZwQueryVolumeInformationFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FS_INFORMATION_CLASS
);
1034 NTSTATUS WINAPI
ZwReadFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,PLARGE_INTEGER
,PULONG
);
1035 NTSTATUS WINAPI
ZwReplaceKey(POBJECT_ATTRIBUTES
,HANDLE
,POBJECT_ATTRIBUTES
);
1036 NTSTATUS WINAPI
ZwRequestWaitReplyPort(HANDLE
,PLPC_MESSAGE
,PLPC_MESSAGE
);
1037 NTSTATUS WINAPI
ZwResetEvent(HANDLE
,PULONG
);
1038 NTSTATUS WINAPI
ZwRestoreKey(HANDLE
,HANDLE
,ULONG
);
1039 NTSTATUS WINAPI
ZwSaveKey(HANDLE
,HANDLE
);
1040 NTSTATUS WINAPI
ZwSecureConnectPort(PHANDLE
,PUNICODE_STRING
,PSECURITY_QUALITY_OF_SERVICE
,PLPC_SECTION_WRITE
,PSID
,PLPC_SECTION_READ
,PULONG
,PVOID
,PULONG
);
1041 NTSTATUS WINAPI
ZwSetDefaultLocale(BOOLEAN
,LCID
);
1042 NTSTATUS WINAPI
ZwSetDefaultUILanguage(LANGID
);
1043 NTSTATUS WINAPI
ZwSetEaFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
);
1044 NTSTATUS WINAPI
ZwSetEvent(HANDLE
,PULONG
);
1045 NTSTATUS WINAPI
ZwSetInformationFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FILE_INFORMATION_CLASS
);
1046 NTSTATUS WINAPI
ZwSetInformationKey(HANDLE
,const int,PVOID
,ULONG
);
1047 NTSTATUS WINAPI
ZwSetInformationObject(HANDLE
, OBJECT_INFORMATION_CLASS
, PVOID
, ULONG
);
1048 NTSTATUS WINAPI
ZwSetInformationProcess(HANDLE
,PROCESS_INFORMATION_CLASS
,PVOID
,ULONG
);
1049 NTSTATUS WINAPI
ZwSetInformationThread(HANDLE
,THREADINFOCLASS
,LPCVOID
,ULONG
);
1050 NTSTATUS WINAPI
ZwSetIoCompletion(HANDLE
,ULONG
,ULONG
,NTSTATUS
,ULONG
);
1051 NTSTATUS WINAPI
ZwSetSecurityObject(HANDLE
,SECURITY_INFORMATION
,PSECURITY_DESCRIPTOR
);
1052 NTSTATUS WINAPI
ZwSetSystemInformation(SYSTEM_INFORMATION_CLASS
,PVOID
,ULONG
);
1053 NTSTATUS WINAPI
ZwSetSystemTime(const LARGE_INTEGER
*,LARGE_INTEGER
*);
1054 NTSTATUS WINAPI
ZwSetTimer(HANDLE
, const LARGE_INTEGER
*, PTIMER_APC_ROUTINE
, PVOID
, BOOLEAN
, ULONG
, BOOLEAN
*);
1055 NTSTATUS WINAPI
ZwSetValueKey(HANDLE
,const UNICODE_STRING
*,ULONG
,ULONG
,const void *,ULONG
);
1056 NTSTATUS WINAPI
ZwSetVolumeInformationFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FS_INFORMATION_CLASS
);
1057 NTSTATUS WINAPI
ZwSuspendThread(HANDLE
,PULONG
);
1058 NTSTATUS WINAPI
ZwTerminateProcess(HANDLE
,LONG
);
1059 NTSTATUS WINAPI
ZwUnloadDriver(const UNICODE_STRING
*);
1060 NTSTATUS WINAPI
ZwUnloadKey(HANDLE
);
1061 NTSTATUS WINAPI
ZwUnmapViewOfSection(HANDLE
,PVOID
);
1062 NTSTATUS WINAPI
ZwWaitForSingleObject(HANDLE
,BOOLEAN
,const LARGE_INTEGER
*);
1063 NTSTATUS WINAPI
ZwWaitForMultipleObjects(ULONG
,const HANDLE
*,BOOLEAN
,BOOLEAN
,const LARGE_INTEGER
*);
1064 NTSTATUS WINAPI
ZwWriteFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,const void*,ULONG
,PLARGE_INTEGER
,PULONG
);
1065 NTSTATUS WINAPI
ZwYieldExecution(void);