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 /* FIXME: We suppose that page size is 4096 */
33 #define PAGE_SIZE 0x1000
36 #define BYTE_OFFSET(va) ((ULONG)((ULONG_PTR)(va) & (PAGE_SIZE - 1)))
37 #define PAGE_ALIGN(va) ((PVOID)((ULONG_PTR)(va) & ~(PAGE_SIZE - 1)))
38 #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(va, length) \
39 ((BYTE_OFFSET(va) + ((SIZE_T)(length)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)
41 typedef LONG KPRIORITY
;
43 typedef ULONG_PTR KSPIN_LOCK
, *PKSPIN_LOCK
;
45 typedef ULONG_PTR ERESOURCE_THREAD
;
46 typedef ERESOURCE_THREAD
*PERESOURCE_THREAD
;
51 struct _DEVICE_OBJECT
;
52 struct _DRIVER_OBJECT
;
54 typedef VOID (WINAPI
*PKDEFERRED_ROUTINE
)(struct _KDPC
*, PVOID
, PVOID
, PVOID
);
55 typedef VOID (WINAPI
*PKSTART_ROUTINE
)(PVOID
);
57 typedef NTSTATUS (WINAPI
*PDRIVER_INITIALIZE
)(struct _DRIVER_OBJECT
*, PUNICODE_STRING
);
58 typedef NTSTATUS (WINAPI
*PDRIVER_DISPATCH
)(struct _DEVICE_OBJECT
*, struct _IRP
*);
59 typedef void (WINAPI
*PDRIVER_STARTIO
)(struct _DEVICE_OBJECT
*, struct _IRP
*);
60 typedef void (WINAPI
*PDRIVER_UNLOAD
)(struct _DRIVER_OBJECT
*);
61 typedef NTSTATUS (WINAPI
*PDRIVER_ADD_DEVICE
)(struct _DRIVER_OBJECT
*, struct _DEVICE_OBJECT
*);
63 typedef struct _DISPATCHER_HEADER
{
69 LIST_ENTRY WaitListHead
;
70 } DISPATCHER_HEADER
, *PDISPATCHER_HEADER
;
72 typedef struct _KEVENT
{
73 DISPATCHER_HEADER Header
;
74 } KEVENT
, *PKEVENT
, *RESTRICTED_POINTER PRKEVENT
;
76 typedef struct _KSEMAPHORE
{
77 DISPATCHER_HEADER Header
;
79 } KSEMAPHORE
, *PKSEMAPHORE
, *PRKSEMAPHORE
;
81 typedef struct _KDPC
{
85 LIST_ENTRY DpcListEntry
;
86 PKDEFERRED_ROUTINE DeferredRoutine
;
87 PVOID DeferredContext
;
88 PVOID SystemArgument1
;
89 PVOID SystemArgument2
;
91 } KDPC
, *PKDPC
, *RESTRICTED_POINTER PRKDPC
;
93 typedef struct _KDEVICE_QUEUE_ENTRY
{
94 LIST_ENTRY DeviceListEntry
;
97 } KDEVICE_QUEUE_ENTRY
, *PKDEVICE_QUEUE_ENTRY
,
98 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY
;
100 typedef struct _KDEVICE_QUEUE
{
103 LIST_ENTRY DeviceListHead
;
106 } KDEVICE_QUEUE
, *PKDEVICE_QUEUE
, *RESTRICTED_POINTER PRKDEVICE_QUEUE
;
108 typedef struct _KMUTANT
{
109 DISPATCHER_HEADER Header
;
110 LIST_ENTRY MutantListEntry
;
111 struct _KTHREAD
*RESTRICTED_POINTER OwnerThread
;
114 } KMUTANT
, *PKMUTANT
, *RESTRICTED_POINTER PRKMUTANT
, KMUTEX
, *PKMUTEX
, *RESTRICTED_POINTER PRKMUTEX
;
116 typedef enum _KWAIT_REASON
146 typedef struct _ALLOCATE_FUNCTION
*PALLOCATE_FUNCTION
;
147 typedef struct _IO_TIMER
*PIO_TIMER
;
148 typedef struct _IO_TIMER_ROUTINE
*PIO_TIMER_ROUTINE
;
149 typedef struct _ETHREAD
*PETHREAD
;
150 typedef struct _FREE_FUNCTION
*PFREE_FUNCTION
;
151 typedef struct _KTHREAD
*PKTHREAD
, *PRKTHREAD
;
152 typedef struct _EPROCESS
*PEPROCESS
;
153 typedef struct _ERESOURCE
*PERESOURCE
;
154 typedef struct _IO_WORKITEM
*PIO_WORKITEM
;
155 typedef struct _NPAGED_LOOKASIDE_LIST
*PNPAGED_LOOKASIDE_LIST
;
156 typedef struct _PAGED_LOOKASIDE_LIST
*PPAGED_LOOKASIDE_LIST
;
157 typedef struct _OBJECT_TYPE
*POBJECT_TYPE
;
158 typedef struct _OBJECT_HANDLE_INFORMATION
*POBJECT_HANDLE_INFORMATION
;
159 typedef struct _ZONE_HEADER
*PZONE_HEADER
;
161 typedef struct _FAST_MUTEX
168 } FAST_MUTEX
, *PFAST_MUTEX
;
170 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
172 typedef struct _VPB
{
176 USHORT VolumeLabelLength
;
177 struct _DEVICE_OBJECT
*DeviceObject
;
178 struct _DEVICE_OBJECT
*RealDevice
;
180 ULONG ReferenceCount
;
181 WCHAR VolumeLabel
[MAXIMUM_VOLUME_LABEL_LENGTH
/ sizeof(WCHAR
)];
184 typedef enum _POOL_TYPE
{
187 NonPagedPoolMustSucceed
,
189 NonPagedPoolCacheAligned
,
190 PagedPoolCacheAligned
,
191 NonPagedPoolCacheAlignedMustS
,
195 typedef struct _WAIT_CONTEXT_BLOCK
{
196 KDEVICE_QUEUE_ENTRY WaitQueueEntry
;
197 struct _DRIVER_CONTROL
*DeviceRoutine
;
199 ULONG NumberOfMapRegisters
;
202 PKDPC BufferChainingDpc
;
203 } WAIT_CONTEXT_BLOCK
, *PWAIT_CONTEXT_BLOCK
;
205 #define DO_BUFFERED_IO 0x00000004
206 #define DO_EXCLUSIVE 0x00000008
207 #define DO_DIRECT_IO 0x00000010
208 #define DO_MAP_IO_BUFFER 0x00000020
209 #define DO_DEVICE_INITIALIZING 0x00000080
210 #define DO_SHUTDOWN_REGISTERED 0x00000800
211 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
212 #define DO_POWER_PAGABLE 0x00002000
213 #define DO_POWER_INRUSH 0x00004000
215 #define IO_NO_INCREMENT 0
216 #define IO_CD_ROM_INCREMENT 1
217 #define IO_DISK_INCREMENT 1
218 #define IO_KEYBOARD_INCREMENT 6
219 #define IO_MAILSLOT_INCREMENT 2
220 #define IO_MOUSE_INCREMENT 6
221 #define IO_NAMED_PIPE_INCREMENT 2
222 #define IO_NETWORK_INCREMENT 2
223 #define IO_PARALLEL_INCREMENT 1
224 #define IO_SERIAL_INCREMENT 2
225 #define IO_SOUND_INCREMENT 8
226 #define IO_VIDEO_INCREMENT 1
229 #define DEVICE_TYPE ULONG
231 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
232 #define IRP_MJ_CREATE 0x00
233 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
234 #define IRP_MJ_CLOSE 0x02
235 #define IRP_MJ_READ 0x03
236 #define IRP_MJ_WRITE 0x04
237 #define IRP_MJ_QUERY_INFORMATION 0x05
238 #define IRP_MJ_SET_INFORMATION 0x06
239 #define IRP_MJ_QUERY_EA 0x07
240 #define IRP_MJ_SET_EA 0x08
241 #define IRP_MJ_FLUSH_BUFFERS 0x09
242 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
243 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
244 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
245 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
246 #define IRP_MJ_DEVICE_CONTROL 0x0e
247 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
248 #define IRP_MJ_SHUTDOWN 0x10
249 #define IRP_MJ_LOCK_CONTROL 0x11
250 #define IRP_MJ_CLEANUP 0x12
251 #define IRP_MJ_CREATE_MAILSLOT 0x13
252 #define IRP_MJ_QUERY_SECURITY 0x14
253 #define IRP_MJ_SET_SECURITY 0x15
254 #define IRP_MJ_POWER 0x16
255 #define IRP_MJ_SYSTEM_CONTROL 0x17
256 #define IRP_MJ_DEVICE_CHANGE 0x18
257 #define IRP_MJ_QUERY_QUOTA 0x19
258 #define IRP_MJ_SET_QUOTA 0x1a
259 #define IRP_MJ_PNP 0x1b
261 #define IRP_MN_START_DEVICE 0x00
262 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
263 #define IRP_MN_REMOVE_DEVICE 0x02
264 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
265 #define IRP_MN_STOP_DEVICE 0x04
266 #define IRP_MN_QUERY_STOP_DEVICE 0x05
267 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
268 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
269 #define IRP_MN_QUERY_INTERFACE 0x08
270 #define IRP_MN_QUERY_CAPABILITIES 0x09
271 #define IRP_MN_QUERY_RESOURCES 0x0A
272 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
273 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
274 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
275 #define IRP_MN_READ_CONFIG 0x0F
276 #define IRP_MN_WRITE_CONFIG 0x10
277 #define IRP_MN_EJECT 0x11
278 #define IRP_MN_SET_LOCK 0x12
279 #define IRP_MN_QUERY_ID 0x13
280 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
281 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
282 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
283 #define IRP_MN_SURPRISE_REMOVAL 0x17
284 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
286 #define IRP_MN_WAIT_WAKE 0x00
287 #define IRP_MN_POWER_SEQUENCE 0x01
288 #define IRP_MN_SET_POWER 0x02
289 #define IRP_MN_QUERY_POWER 0x03
291 #define IRP_QUOTA_CHARGED 0x01
292 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
293 #define IRP_ALLOCATED_FIXED_SIZE 0x04
294 #define IRP_LOOKASIDE_ALLOCATION 0x08
296 #define IO_TYPE_ADAPTER 0x01
297 #define IO_TYPE_CONTROLLER 0x02
298 #define IO_TYPE_DEVICE 0x03
299 #define IO_TYPE_DRIVER 0x04
300 #define IO_TYPE_FILE 0x05
301 #define IO_TYPE_IRP 0x06
302 #define IO_TYPE_MASTER_ADAPTER 0x07
303 #define IO_TYPE_OPEN_PACKET 0x08
304 #define IO_TYPE_TIMER 0x09
305 #define IO_TYPE_VPB 0x0a
306 #define IO_TYPE_ERROR_LOG 0x0b
307 #define IO_TYPE_ERROR_MESSAGE 0x0c
308 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 0x0d
310 typedef struct _DEVICE_OBJECT
{
314 struct _DRIVER_OBJECT
*DriverObject
;
315 struct _DEVICE_OBJECT
*NextDevice
;
316 struct _DEVICE_OBJECT
*AttachedDevice
;
317 struct _IRP
*CurrentIrp
;
320 ULONG Characteristics
;
322 PVOID DeviceExtension
;
323 DEVICE_TYPE DeviceType
;
326 LIST_ENTRY ListEntry
;
327 WAIT_CONTEXT_BLOCK Wcb
;
329 ULONG AlignmentRequirement
;
330 KDEVICE_QUEUE DeviceQueue
;
332 ULONG ActiveThreadCount
;
333 PSECURITY_DESCRIPTOR SecurityDescriptor
;
337 struct _DEVOBJ_EXTENSION
*DeviceObjectExtension
;
340 typedef struct _DEVICE_OBJECT
*PDEVICE_OBJECT
;
342 typedef struct _DEVICE_RELATIONS
{
344 PDEVICE_OBJECT Objects
[1];
346 typedef struct _DEVICE_RELATIONS
*PDEVICE_RELATIONS
;
348 typedef struct _DRIVER_EXTENSION
{
349 struct _DRIVER_OBJECT
*DriverObject
;
350 PDRIVER_ADD_DEVICE AddDevice
;
352 UNICODE_STRING ServiceKeyName
;
353 } DRIVER_EXTENSION
, *PDRIVER_EXTENSION
;
355 typedef struct _DRIVER_OBJECT
{
358 PDEVICE_OBJECT DeviceObject
;
363 PDRIVER_EXTENSION DriverExtension
;
364 UNICODE_STRING DriverName
;
365 PUNICODE_STRING HardwareDatabase
;
366 PVOID FastIoDispatch
;
367 PDRIVER_INITIALIZE DriverInit
;
368 PDRIVER_STARTIO DriverStartIo
;
369 PDRIVER_UNLOAD DriverUnload
;
370 PDRIVER_DISPATCH MajorFunction
[IRP_MJ_MAXIMUM_FUNCTION
+ 1];
372 typedef struct _DRIVER_OBJECT
*PDRIVER_OBJECT
;
374 /* Irp definitions */
375 typedef UCHAR KIRQL
, *PKIRQL
;
376 typedef CCHAR KPROCESSOR_MODE
;
378 typedef VOID (WINAPI
*PDRIVER_CANCEL
)(
379 IN
struct _DEVICE_OBJECT
*DeviceObject
,
380 IN
struct _IRP
*Irp
);
382 typedef VOID (WINAPI
*PKNORMAL_ROUTINE
)(
383 IN PVOID NormalContext
,
384 IN PVOID SystemArgument1
,
385 IN PVOID SystemArgument2
);
387 typedef VOID (WINAPI
*PKKERNEL_ROUTINE
)(
388 IN
struct _KAPC
*Apc
,
389 IN OUT PKNORMAL_ROUTINE
*NormalRoutine
,
390 IN OUT PVOID
*NormalContext
,
391 IN OUT PVOID
*SystemArgument1
,
392 IN OUT PVOID
*SystemArgument2
);
394 typedef VOID (WINAPI
*PKRUNDOWN_ROUTINE
)(
395 IN
struct _KAPC
*Apc
);
397 typedef struct _KAPC
{
401 struct _KTHREAD
*Thread
;
402 LIST_ENTRY ApcListEntry
;
403 PKKERNEL_ROUTINE KernelRoutine
;
404 PKRUNDOWN_ROUTINE RundownRoutine
;
405 PKNORMAL_ROUTINE NormalRoutine
;
407 PVOID SystemArgument1
;
408 PVOID SystemArgument2
;
410 KPROCESSOR_MODE ApcMode
;
412 } KAPC
, *PKAPC
, *RESTRICTED_POINTER PRKAPC
;
414 typedef struct _IRP
{
417 struct _MDL
*MdlAddress
;
420 struct _IRP
*MasterIrp
;
424 LIST_ENTRY ThreadListEntry
;
425 IO_STATUS_BLOCK IoStatus
;
426 KPROCESSOR_MODE RequestorMode
;
427 BOOLEAN PendingReturned
;
429 CHAR CurrentLocation
;
432 CCHAR ApcEnvironment
;
433 UCHAR AllocationFlags
;
434 PIO_STATUS_BLOCK UserIosb
;
438 PIO_APC_ROUTINE UserApcRoutine
;
439 PVOID UserApcContext
;
440 } AsynchronousParameters
;
441 LARGE_INTEGER AllocationSize
;
443 PDRIVER_CANCEL CancelRoutine
;
448 KDEVICE_QUEUE_ENTRY DeviceQueueEntry
;
450 PVOID DriverContext
[4];
454 PCHAR AuxiliaryBuffer
;
456 LIST_ENTRY ListEntry
;
458 struct _IO_STACK_LOCATION
*CurrentStackLocation
;
462 struct _FILE_OBJECT
*OriginalFileObject
;
468 typedef struct _IRP
*PIRP
;
470 #define IRP_NOCACHE 0x0001
471 #define IRP_PAGING_IO 0x0002
472 #define IRP_MOUNT_COMPLETION 0x0002
473 #define IRP_SYNCHRONOUS_API 0x0004
474 #define IRP_ASSOCIATED_IRP 0x0008
475 #define IRP_BUFFERED_IO 0x0010
476 #define IRP_DEALLOCATE_BUFFER 0x0020
477 #define IRP_INPUT_OPERATION 0x0040
478 #define IRP_SYNCHRONOUS_PAGING_IO 0x0040
479 #define IRP_CREATE_OPERATION 0x0080
480 #define IRP_READ_OPERATION 0x0100
481 #define IRP_WRITE_OPERATION 0x0200
482 #define IRP_CLOSE_OPERATION 0x0400
483 #define IRP_DEFER_IO_COMPLETION 0x0800
484 #define IRP_OB_QUERY_NAME 0x1000
485 #define IRP_HOLD_DEVICE_QUEUE 0x2000
487 typedef VOID (WINAPI
*PINTERFACE_REFERENCE
)(
490 typedef VOID (WINAPI
*PINTERFACE_DEREFERENCE
)(
493 typedef struct _INTERFACE
{
497 PINTERFACE_REFERENCE InterfaceReference
;
498 PINTERFACE_DEREFERENCE InterfaceDereference
;
499 } INTERFACE
, *PINTERFACE
;
501 typedef struct _SECTION_OBJECT_POINTERS
{
502 PVOID DataSectionObject
;
503 PVOID SharedCacheMap
;
504 PVOID ImageSectionObject
;
505 } SECTION_OBJECT_POINTERS
, *PSECTION_OBJECT_POINTERS
;
507 typedef struct _IO_COMPLETION_CONTEXT
{
510 } IO_COMPLETION_CONTEXT
, *PIO_COMPLETION_CONTEXT
;
512 typedef enum _DEVICE_RELATION_TYPE
{
517 TargetDeviceRelation
,
519 } DEVICE_RELATION_TYPE
, *PDEVICE_RELATION_TYPE
;
521 typedef struct _FILE_OBJECT
{
524 PDEVICE_OBJECT DeviceObject
;
528 PSECTION_OBJECT_POINTERS SectionObjectPointer
;
529 PVOID PrivateCacheMap
;
530 NTSTATUS FinalStatus
;
531 struct _FILE_OBJECT
*RelatedFileObject
;
532 BOOLEAN LockOperation
;
533 BOOLEAN DeletePending
;
536 BOOLEAN DeleteAccess
;
539 BOOLEAN SharedDelete
;
541 UNICODE_STRING FileName
;
542 LARGE_INTEGER CurrentByteOffset
;
548 PIO_COMPLETION_CONTEXT CompletionContext
;
550 typedef struct _FILE_OBJECT
*PFILE_OBJECT
;
552 #define INITIAL_PRIVILEGE_COUNT 3
554 typedef struct _INITIAL_PRIVILEGE_SET
{
555 ULONG PrivilegeCount
;
557 LUID_AND_ATTRIBUTES Privilege
[INITIAL_PRIVILEGE_COUNT
];
558 } INITIAL_PRIVILEGE_SET
, * PINITIAL_PRIVILEGE_SET
;
560 typedef struct _SECURITY_SUBJECT_CONTEXT
{
561 PACCESS_TOKEN ClientToken
;
562 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
563 PACCESS_TOKEN PrimaryToken
;
564 PVOID ProcessAuditId
;
565 } SECURITY_SUBJECT_CONTEXT
, *PSECURITY_SUBJECT_CONTEXT
;
567 typedef struct _ACCESS_STATE
{
569 BOOLEAN SecurityEvaluated
;
570 BOOLEAN GenerateAudit
;
571 BOOLEAN GenerateOnClose
;
572 BOOLEAN PrivilegesAllocated
;
574 ACCESS_MASK RemainingDesiredAccess
;
575 ACCESS_MASK PreviouslyGrantedAccess
;
576 ACCESS_MASK OriginalDesiredAccess
;
577 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext
;
578 PSECURITY_DESCRIPTOR SecurityDescriptor
;
581 INITIAL_PRIVILEGE_SET InitialPrivilegeSet
;
582 PRIVILEGE_SET PrivilegeSet
;
585 BOOLEAN AuditPrivileges
;
586 UNICODE_STRING ObjectName
;
587 UNICODE_STRING ObjectTypeName
;
588 } ACCESS_STATE
, *PACCESS_STATE
;
590 typedef struct _IO_SECURITY_CONTEXT
{
591 PSECURITY_QUALITY_OF_SERVICE SecurityQos
;
592 PACCESS_STATE AccessState
;
593 ACCESS_MASK DesiredAccess
;
594 ULONG FullCreateOptions
;
595 } IO_SECURITY_CONTEXT
, *PIO_SECURITY_CONTEXT
;
597 typedef struct _DEVICE_CAPABILITIES
{
602 ULONG LockSupported
: 1;
603 ULONG EjectSupported
: 1;
605 ULONG DockDevice
: 1;
607 ULONG SilentInstall
: 1;
608 ULONG RawDeviceOK
: 1;
609 ULONG SurpriseRemovalOK
: 1;
610 ULONG WakeFromD0
: 1;
611 ULONG WakeFromD1
: 1;
612 ULONG WakeFromD2
: 1;
613 ULONG WakeFromD3
: 1;
614 ULONG HardwareDisabled
: 1;
615 ULONG NonDynamic
: 1;
616 ULONG WarmEjectSupported
: 1;
617 ULONG NoDisplayInUI
: 1;
621 DEVICE_POWER_STATE DeviceState
[PowerSystemMaximum
];
622 SYSTEM_POWER_STATE SystemWake
;
623 DEVICE_POWER_STATE DeviceWake
;
627 } DEVICE_CAPABILITIES
, *PDEVICE_CAPABILITIES
;
629 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION
{
633 GUID InterfaceClassGuid
;
634 PUNICODE_STRING SymbolicLinkName
;
635 } DEVICE_INTERFACE_CHANGE_NOTIFICATION
, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION
;
637 typedef enum _INTERFACE_TYPE
{
638 InterfaceTypeUndefined
= -1,
656 } INTERFACE_TYPE
, *PINTERFACE_TYPE
;
658 typedef LARGE_INTEGER PHYSICAL_ADDRESS
, *PPHYSICAL_ADDRESS
;
660 #define IO_RESOURCE_PREFERRED 0x01
661 #define IO_RESOURCE_DEFAULT 0x02
662 #define IO_RESOURCE_ALTERNATIVE 0x08
664 typedef struct _IO_RESOURCE_DESCRIPTOR
{
667 UCHAR ShareDisposition
;
675 PHYSICAL_ADDRESS MinimumAddress
;
676 PHYSICAL_ADDRESS MaximumAddress
;
681 PHYSICAL_ADDRESS MinimumAddress
;
682 PHYSICAL_ADDRESS MaximumAddress
;
689 ULONG MinimumChannel
;
690 ULONG MaximumChannel
;
695 PHYSICAL_ADDRESS MinimumAddress
;
696 PHYSICAL_ADDRESS MaximumAddress
;
713 } IO_RESOURCE_DESCRIPTOR
, *PIO_RESOURCE_DESCRIPTOR
;
715 typedef struct _IO_RESOURCE_LIST
{
719 IO_RESOURCE_DESCRIPTOR Descriptors
[1];
720 } IO_RESOURCE_LIST
, *PIO_RESOURCE_LIST
;
722 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST
{
724 INTERFACE_TYPE InterfaceType
;
728 ULONG AlternativeLists
;
729 IO_RESOURCE_LIST List
[1];
730 } IO_RESOURCE_REQUIREMENTS_LIST
, *PIO_RESOURCE_REQUIREMENTS_LIST
;
732 typedef enum _BUS_QUERY_ID_TYPE
{
735 BusQueryCompatibleIDs
,
737 BusQueryDeviceSerialNumber
738 } BUS_QUERY_ID_TYPE
, *PBUS_QUERY_ID_TYPE
;
740 typedef enum _CREATE_FILE_TYPE
{
742 CreateFileTypeNamedPipe
,
743 CreateFileTypeMailslot
747 DevicePropertyDeviceDescription
,
748 DevicePropertyHardwareID
,
749 DevicePropertyCompatibleIDs
,
750 DevicePropertyBootConfiguration
,
751 DevicePropertyBootConfigurationTranslated
,
752 DevicePropertyClassName
,
753 DevicePropertyClassGuid
,
754 DevicePropertyDriverKeyName
,
755 DevicePropertyManufacturer
,
756 DevicePropertyFriendlyName
,
757 DevicePropertyLocationInformation
,
758 DevicePropertyPhysicalDeviceObjectName
,
759 DevicePropertyBusTypeGuid
,
760 DevicePropertyLegacyBusType
,
761 DevicePropertyBusNumber
,
762 DevicePropertyEnumeratorName
,
763 DevicePropertyAddress
,
764 DevicePropertyUINumber
,
765 DevicePropertyInstallState
,
766 DevicePropertyRemovalPolicy
767 } DEVICE_REGISTRY_PROPERTY
;
769 typedef enum _DEVICE_TEXT_TYPE
{
770 DeviceTextDescription
,
771 DeviceTextLocationInformation
772 } DEVICE_TEXT_TYPE
, *PDEVICE_TEXT_TYPE
;
774 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE
{
775 DeviceUsageTypeUndefined
,
776 DeviceUsageTypePaging
,
777 DeviceUsageTypeHibernation
,
778 DeviceUsageTypeDumpFile
779 } DEVICE_USAGE_NOTIFICATION_TYPE
;
781 typedef struct _POWER_SEQUENCE
{
785 } POWER_SEQUENCE
, *PPOWER_SEQUENCE
;
787 typedef enum _POWER_STATE_TYPE
{
790 } POWER_STATE_TYPE
, *PPOWER_STATE_TYPE
;
792 typedef union _POWER_STATE
{
793 SYSTEM_POWER_STATE SystemState
;
794 DEVICE_POWER_STATE DeviceState
;
795 } POWER_STATE
, *PPOWER_STATE
;
797 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR
{
799 UCHAR ShareDisposition
;
803 PHYSICAL_ADDRESS Start
;
807 PHYSICAL_ADDRESS Start
;
816 PHYSICAL_ADDRESS Start
;
836 } DeviceSpecificData
;
838 } CM_PARTIAL_RESOURCE_DESCRIPTOR
, *PCM_PARTIAL_RESOURCE_DESCRIPTOR
;
840 typedef struct _CM_PARTIAL_RESOURCE_LIST
{
844 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors
[1];
845 } CM_PARTIAL_RESOURCE_LIST
, *PCM_PARTIAL_RESOURCE_LIST
;
847 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR
{
848 INTERFACE_TYPE InterfaceType
;
850 CM_PARTIAL_RESOURCE_LIST PartialResourceList
;
851 } CM_FULL_RESOURCE_DESCRIPTOR
, *PCM_FULL_RESOURCE_DESCRIPTOR
;
853 typedef struct _CM_RESOURCE_LIST
{
855 CM_FULL_RESOURCE_DESCRIPTOR List
[1];
856 } CM_RESOURCE_LIST
, *PCM_RESOURCE_LIST
;
858 typedef NTSTATUS (WINAPI
*PIO_COMPLETION_ROUTINE
)(
859 IN
struct _DEVICE_OBJECT
*DeviceObject
,
863 #define SL_PENDING_RETURNED 0x01
864 #define SL_INVOKE_ON_CANCEL 0x20
865 #define SL_INVOKE_ON_SUCCESS 0x40
866 #define SL_INVOKE_ON_ERROR 0x80
869 #include <pshpack4.h>
871 typedef struct _IO_STACK_LOCATION
{
878 PIO_SECURITY_CONTEXT SecurityContext
;
880 USHORT POINTER_ALIGNMENT FileAttributes
;
882 ULONG POINTER_ALIGNMENT EaLength
;
886 ULONG POINTER_ALIGNMENT Key
;
887 LARGE_INTEGER ByteOffset
;
891 ULONG POINTER_ALIGNMENT Key
;
892 LARGE_INTEGER ByteOffset
;
896 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass
;
900 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass
;
901 PFILE_OBJECT FileObject
;
904 BOOLEAN ReplaceIfExists
;
913 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass
;
916 ULONG OutputBufferLength
;
917 ULONG POINTER_ALIGNMENT InputBufferLength
;
918 ULONG POINTER_ALIGNMENT IoControlCode
;
919 PVOID Type3InputBuffer
;
922 SECURITY_INFORMATION SecurityInformation
;
923 ULONG POINTER_ALIGNMENT Length
;
926 SECURITY_INFORMATION SecurityInformation
;
927 PSECURITY_DESCRIPTOR SecurityDescriptor
;
931 PDEVICE_OBJECT DeviceObject
;
935 PDEVICE_OBJECT DeviceObject
;
938 struct _SCSI_REQUEST_BLOCK
*Srb
;
941 DEVICE_RELATION_TYPE Type
;
942 } QueryDeviceRelations
;
944 const GUID
*InterfaceType
;
947 PINTERFACE Interface
;
948 PVOID InterfaceSpecificData
;
951 PDEVICE_CAPABILITIES Capabilities
;
952 } DeviceCapabilities
;
954 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList
;
955 } FilterResourceRequirements
;
960 ULONG POINTER_ALIGNMENT Length
;
966 BUS_QUERY_ID_TYPE IdType
;
969 DEVICE_TEXT_TYPE DeviceTextType
;
970 LCID POINTER_ALIGNMENT LocaleId
;
975 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type
;
978 SYSTEM_POWER_STATE PowerState
;
981 PPOWER_SEQUENCE PowerSequence
;
985 POWER_STATE_TYPE POINTER_ALIGNMENT Type
;
986 POWER_STATE POINTER_ALIGNMENT State
;
987 POWER_ACTION POINTER_ALIGNMENT ShutdownType
;
990 PCM_RESOURCE_LIST AllocatedResources
;
991 PCM_RESOURCE_LIST AllocatedResourcesTranslated
;
994 ULONG_PTR ProviderId
;
1006 PDEVICE_OBJECT DeviceObject
;
1007 PFILE_OBJECT FileObject
;
1008 PIO_COMPLETION_ROUTINE CompletionRoutine
;
1010 } IO_STACK_LOCATION
, *PIO_STACK_LOCATION
;
1011 #if !defined(_WIN64)
1012 #include <poppack.h>
1015 /* MDL definitions */
1017 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
1018 #define MDL_PAGES_LOCKED 0x0002
1019 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
1020 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
1021 #define MDL_PARTIAL 0x0010
1022 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
1023 #define MDL_IO_PAGE_READ 0x0040
1024 #define MDL_WRITE_OPERATION 0x0080
1025 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
1026 #define MDL_FREE_EXTRA_PTES 0x0200
1027 #define MDL_DESCRIBES_AWE 0x0400
1028 #define MDL_IO_SPACE 0x0800
1029 #define MDL_NETWORK_HEADER 0x1000
1030 #define MDL_MAPPING_CAN_FAIL 0x2000
1031 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
1032 #define MDL_INTERNAL 0x8000
1034 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
1035 MDL_PAGES_LOCKED | \
1036 MDL_SOURCE_IS_NONPAGED_POOL | \
1037 MDL_PARTIAL_HAS_BEEN_MAPPED | \
1038 MDL_PARENT_MAPPED_SYSTEM_VA | \
1042 typedef struct _MDL
{
1046 struct _EPROCESS
*Process
;
1047 PVOID MappedSystemVa
;
1054 typedef ULONG PFN_NUMBER
, *PPFN_NUMBER
;
1056 static inline void MmInitializeMdl(MDL
*mdl
, void *va
, SIZE_T length
)
1059 mdl
->Size
= sizeof(MDL
) + sizeof(PFN_NUMBER
) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(va
, length
);
1061 mdl
->StartVa
= (void *)PAGE_ALIGN(va
);
1062 mdl
->ByteOffset
= BYTE_OFFSET(va
);
1063 mdl
->ByteCount
= length
;
1066 typedef struct _KTIMER
{
1067 DISPATCHER_HEADER Header
;
1068 ULARGE_INTEGER DueTime
;
1069 LIST_ENTRY TimerListEntry
;
1074 typedef struct _KSYSTEM_TIME
{
1078 } KSYSTEM_TIME
, *PKSYSTEM_TIME
;
1080 typedef enum _NT_PRODUCT_TYPE
{
1084 } NT_PRODUCT_TYPE
, *PNT_PRODUCT_TYPE
;
1086 #define PROCESSOR_FEATURE_MAX 64
1088 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
1093 } ALTERNATIVE_ARCHITECTURE_TYPE
;
1095 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
1096 #define NX_SUPPORT_POLICY_ALWAYSON 1
1097 #define NX_SUPPORT_POLICY_OPTIN 2
1098 #define NX_SUPPORT_POLICY_OPTOUT 3
1100 #define MAX_WOW64_SHARED_ENTRIES 16
1102 typedef struct _KUSER_SHARED_DATA
{
1103 ULONG TickCountLowDeprecated
;
1104 ULONG TickCountMultiplier
;
1105 volatile KSYSTEM_TIME InterruptTime
;
1106 volatile KSYSTEM_TIME SystemTime
;
1107 volatile KSYSTEM_TIME TimeZoneBias
;
1108 USHORT ImageNumberLow
;
1109 USHORT ImageNumberHigh
;
1110 WCHAR NtSystemRoot
[260];
1111 ULONG MaxStackTraceDepth
;
1112 ULONG CryptoExponent
;
1114 ULONG LargePageMinimum
;
1116 NT_PRODUCT_TYPE NtProductType
;
1117 BOOLEAN ProductTypeIsValid
;
1118 ULONG NtMajorVersion
;
1119 ULONG NtMinorVersion
;
1120 BOOLEAN ProcessorFeatures
[PROCESSOR_FEATURE_MAX
];
1123 volatile ULONG TimeSlip
;
1124 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture
;
1125 LARGE_INTEGER SystemExpirationDate
;
1127 BOOLEAN KdDebuggerEnabled
;
1128 UCHAR NXSupportPolicy
;
1129 volatile ULONG ActiveConsoleId
;
1130 volatile ULONG DismountCount
;
1131 ULONG ComPlusPackage
;
1132 ULONG LastSystemRITEventTickCount
;
1133 ULONG NumberOfPhysicalPages
;
1134 BOOLEAN SafeBootMode
;
1136 ULONGLONG TestRetInstruction
;
1138 ULONG SystemCallReturn
;
1139 ULONGLONG SystemCallPad
[3];
1141 volatile KSYSTEM_TIME TickCount
;
1142 volatile ULONG64 TickCountQuad
;
1145 ULONG Wow64SharedInformation
[MAX_WOW64_SHARED_ENTRIES
];
1146 } KSHARED_USER_DATA
, *PKSHARED_USER_DATA
;
1148 typedef enum _MEMORY_CACHING_TYPE
{
1151 MmWriteCombined
= 2,
1152 MmHardwareCoherentCached
= 3,
1153 MmNonCachedUnordered
= 4,
1155 MmMaximumCacheType
= 6
1156 } MEMORY_CACHING_TYPE
;
1158 typedef enum _MM_PAGE_PRIORITY
{
1160 NormalPagePriority
= 16,
1161 HighPagePriority
= 32
1164 typedef enum _MM_SYSTEM_SIZE
1171 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK
{
1173 BOOLEAN Reserved
[3];
1176 } IO_REMOVE_LOCK_COMMON_BLOCK
;
1178 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK
*PIO_REMOVE_LOCK_TRACKING_BLOCK
;
1180 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK
{
1183 LONGLONG MaxLockedTicks
;
1185 LIST_ENTRY LockList
;
1187 LONG LowMemoryCount
;
1190 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks
;
1191 } IO_REMOVE_LOCK_DBG_BLOCK
;
1193 typedef struct _IO_REMOVE_LOCK
{
1194 IO_REMOVE_LOCK_COMMON_BLOCK Common
;
1195 IO_REMOVE_LOCK_DBG_BLOCK Dbg
;
1196 } IO_REMOVE_LOCK
, *PIO_REMOVE_LOCK
;
1204 typedef struct _CALLBACK_OBJECT
1208 LIST_ENTRY RegisteredCallbacks
;
1209 BOOLEAN AllowMultipleCallbacks
;
1211 } CALLBACK_OBJECT
, *PCALLBACK_OBJECT
;
1213 typedef struct _KSPIN_LOCK_QUEUE
{
1214 struct _KSPIN_LOCK_QUEUE
* volatile Next
;
1215 volatile PKSPIN_LOCK Lock
;
1216 } KSPIN_LOCK_QUEUE
, *PKSPIN_LOCK_QUEUE
;
1218 typedef struct _KLOCK_QUEUE_HANDLE
{
1219 KSPIN_LOCK_QUEUE LockQueue
;
1221 } KLOCK_QUEUE_HANDLE
, *PKLOCK_QUEUE_HANDLE
;
1223 typedef NTSTATUS (NTAPI EX_CALLBACK_FUNCTION
)(void *CallbackContext
, void *Argument1
, void *Argument2
);
1224 typedef EX_CALLBACK_FUNCTION
*PEX_CALLBACK_FUNCTION
;
1226 NTSTATUS WINAPI
ObCloseHandle(IN HANDLE handle
);
1228 #ifdef NONAMELESSUNION
1229 # ifdef NONAMELESSSTRUCT
1230 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.u2.CurrentStackLocation)
1231 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.u2.CurrentStackLocation - 1)
1232 static inline void IoSkipCurrentIrpStackLocation(IRP
*irp
) {irp
->Tail
.Overlay
.s
.u2
.CurrentStackLocation
++; irp
->CurrentLocation
++;}
1234 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.u2.CurrentStackLocation)
1235 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.u2.CurrentStackLocation - 1)
1236 static inline void IoSkipCurrentIrpStackLocation(IRP
*irp
) {irp
->Tail
.Overlay
.u2
.CurrentStackLocation
++; irp
->CurrentLocation
++;}
1239 # ifdef NONAMELESSSTRUCT
1240 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.CurrentStackLocation)
1241 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.CurrentStackLocation - 1)
1242 static inline void IoSkipCurrentIrpStackLocation(IRP
*irp
) {irp
->Tail
.Overlay
.s
.CurrentStackLocation
++; irp
->CurrentLocation
++;}
1244 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation)
1245 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation - 1)
1246 static inline void IoSkipCurrentIrpStackLocation(IRP
*irp
) {irp
->Tail
.Overlay
.CurrentStackLocation
++; irp
->CurrentLocation
++;}
1250 static inline void IoSetCompletionRoutine(IRP
*irp
, PIO_COMPLETION_ROUTINE routine
, void *context
,
1251 BOOLEAN on_success
, BOOLEAN on_error
, BOOLEAN on_cancel
)
1253 IO_STACK_LOCATION
*irpsp
= IoGetNextIrpStackLocation(irp
);
1254 irpsp
->CompletionRoutine
= routine
;
1255 irpsp
->Context
= context
;
1257 if (on_success
) irpsp
->Control
|= SL_INVOKE_ON_SUCCESS
;
1258 if (on_error
) irpsp
->Control
|= SL_INVOKE_ON_ERROR
;
1259 if (on_cancel
) irpsp
->Control
|= SL_INVOKE_ON_CANCEL
;
1262 #define KernelMode 0
1265 /* directory object access rights */
1266 #define DIRECTORY_QUERY 0x0001
1267 #define DIRECTORY_TRAVERSE 0x0002
1268 #define DIRECTORY_CREATE_OBJECT 0x0004
1269 #define DIRECTORY_CREATE_SUBDIRECTORY 0x0008
1270 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
1272 /* symbolic link access rights */
1273 #define SYMBOLIC_LINK_QUERY 0x0001
1274 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
1276 PVOID WINAPI
ExAllocatePool(POOL_TYPE
,SIZE_T
);
1277 PVOID WINAPI
ExAllocatePoolWithQuota(POOL_TYPE
,SIZE_T
);
1278 PVOID WINAPI
ExAllocatePoolWithTag(POOL_TYPE
,SIZE_T
,ULONG
);
1279 PVOID WINAPI
ExAllocatePoolWithQuotaTag(POOL_TYPE
,SIZE_T
,ULONG
);
1280 void WINAPI
ExFreePool(PVOID
);
1281 void WINAPI
ExFreePoolWithTag(PVOID
,ULONG
);
1283 NTSTATUS WINAPI
IoAllocateDriverObjectExtension(PDRIVER_OBJECT
,PVOID
,ULONG
,PVOID
*);
1284 PVOID WINAPI
IoAllocateErrorLogEntry(PVOID
,UCHAR
);
1285 PIRP WINAPI
IoAllocateIrp(CCHAR
,BOOLEAN
);
1286 PMDL WINAPI
IoAllocateMdl(PVOID
,ULONG
,BOOLEAN
,BOOLEAN
,IRP
*);
1287 PDEVICE_OBJECT WINAPI
IoAttachDeviceToDeviceStack(PDEVICE_OBJECT
,PDEVICE_OBJECT
);
1288 PIRP WINAPI
IoBuildDeviceIoControlRequest(ULONG
,DEVICE_OBJECT
*,PVOID
,ULONG
,PVOID
,ULONG
,BOOLEAN
,PKEVENT
,IO_STATUS_BLOCK
*);
1289 PIRP WINAPI
IoBuildSynchronousFsdRequest(ULONG
,DEVICE_OBJECT
*,PVOID
,ULONG
,PLARGE_INTEGER
,PKEVENT
,IO_STATUS_BLOCK
*);
1290 NTSTATUS WINAPI
IoCallDriver(DEVICE_OBJECT
*,IRP
*);
1291 VOID WINAPI
IoCompleteRequest(IRP
*,UCHAR
);
1292 NTSTATUS WINAPI
IoCreateDevice(DRIVER_OBJECT
*,ULONG
,UNICODE_STRING
*,DEVICE_TYPE
,ULONG
,BOOLEAN
,DEVICE_OBJECT
**);
1293 NTSTATUS WINAPI
IoCreateDriver(UNICODE_STRING
*,PDRIVER_INITIALIZE
);
1294 NTSTATUS WINAPI
IoCreateSymbolicLink(UNICODE_STRING
*,UNICODE_STRING
*);
1295 void WINAPI
IoDeleteDevice(DEVICE_OBJECT
*);
1296 void WINAPI
IoDeleteDriver(DRIVER_OBJECT
*);
1297 NTSTATUS WINAPI
IoDeleteSymbolicLink(UNICODE_STRING
*);
1298 void WINAPI
IoFreeIrp(IRP
*);
1299 void WINAPI
IoFreeMdl(MDL
*);
1300 PEPROCESS WINAPI
IoGetCurrentProcess(void);
1301 NTSTATUS WINAPI
IoGetDeviceInterfaces(const GUID
*,PDEVICE_OBJECT
,ULONG
,PWSTR
*);
1302 NTSTATUS WINAPI
IoGetDeviceObjectPointer(UNICODE_STRING
*,ACCESS_MASK
,PFILE_OBJECT
*,PDEVICE_OBJECT
*);
1303 NTSTATUS WINAPI
IoGetDeviceProperty(PDEVICE_OBJECT
,DEVICE_REGISTRY_PROPERTY
,ULONG
,PVOID
,PULONG
);
1304 PVOID WINAPI
IoGetDriverObjectExtension(PDRIVER_OBJECT
,PVOID
);
1305 PDEVICE_OBJECT WINAPI
IoGetRelatedDeviceObject(PFILE_OBJECT
);
1306 void WINAPI
IoInitializeIrp(IRP
*,USHORT
,CCHAR
);
1307 VOID WINAPI
IoInitializeRemoveLockEx(PIO_REMOVE_LOCK
,ULONG
,ULONG
,ULONG
,ULONG
);
1308 void WINAPI
IoInvalidateDeviceRelations(PDEVICE_OBJECT
,DEVICE_RELATION_TYPE
);
1309 NTSTATUS WINAPI
IoWMIRegistrationControl(PDEVICE_OBJECT
,ULONG
);
1311 PKTHREAD WINAPI
KeGetCurrentThread(void);
1312 void WINAPI
KeQuerySystemTime(LARGE_INTEGER
*);
1313 void WINAPI
KeQueryTickCount(LARGE_INTEGER
*);
1314 ULONG WINAPI
KeQueryTimeIncrement(void);
1315 LONG WINAPI
KeReleaseSemaphore(PRKSEMAPHORE
,KPRIORITY
,LONG
,BOOLEAN
);
1316 LONG WINAPI
KeResetEvent(PRKEVENT
);
1317 LONG WINAPI
KeSetEvent(PRKEVENT
,KPRIORITY
,BOOLEAN
);
1318 KPRIORITY WINAPI
KeSetPriorityThread(PKTHREAD
,KPRIORITY
);
1319 void WINAPI
KeSetSystemAffinityThread(KAFFINITY
);
1321 PVOID WINAPI
MmAllocateContiguousMemory(SIZE_T
,PHYSICAL_ADDRESS
);
1322 PVOID WINAPI
MmAllocateNonCachedMemory(SIZE_T
);
1323 PMDL WINAPI
MmAllocatePagesForMdl(PHYSICAL_ADDRESS
,PHYSICAL_ADDRESS
,PHYSICAL_ADDRESS
,SIZE_T
);
1324 void WINAPI
MmFreeNonCachedMemory(PVOID
,SIZE_T
);
1325 PVOID WINAPI
MmMapLockedPagesSpecifyCache(PMDL
,KPROCESSOR_MODE
,MEMORY_CACHING_TYPE
,PVOID
,ULONG
,ULONG
);
1326 MM_SYSTEMSIZE WINAPI
MmQuerySystemSize(void);
1328 static inline void *MmGetSystemAddressForMdlSafe(MDL
*mdl
, ULONG priority
)
1330 if (mdl
->MdlFlags
& (MDL_MAPPED_TO_SYSTEM_VA
| MDL_SOURCE_IS_NONPAGED_POOL
))
1331 return mdl
->MappedSystemVa
;
1333 return MmMapLockedPagesSpecifyCache(mdl
, KernelMode
, MmCached
, NULL
, FALSE
, priority
);
1336 void WINAPI
ObDereferenceObject(void*);
1337 NTSTATUS WINAPI
ObReferenceObjectByHandle(HANDLE
,ACCESS_MASK
,POBJECT_TYPE
,KPROCESSOR_MODE
,PVOID
*,POBJECT_HANDLE_INFORMATION
);
1338 NTSTATUS WINAPI
ObReferenceObjectByName(UNICODE_STRING
*,ULONG
,ACCESS_STATE
*,ACCESS_MASK
,POBJECT_TYPE
,KPROCESSOR_MODE
,void*,void**);
1340 POWER_STATE WINAPI
PoSetPowerState(PDEVICE_OBJECT
,POWER_STATE_TYPE
,POWER_STATE
);
1341 NTSTATUS WINAPI
PsCreateSystemThread(PHANDLE
,ULONG
,POBJECT_ATTRIBUTES
,HANDLE
,PCLIENT_ID
,PKSTART_ROUTINE
,PVOID
);
1342 #define PsGetCurrentProcess() IoGetCurrentProcess()
1343 #define PsGetCurrentThread() ((PETHREAD)KeGetCurrentThread())
1344 HANDLE WINAPI
PsGetCurrentProcessId(void);
1345 HANDLE WINAPI
PsGetCurrentThreadId(void);
1346 BOOLEAN WINAPI
PsGetVersion(ULONG
*,ULONG
*,ULONG
*,UNICODE_STRING
*);
1347 NTSTATUS WINAPI
PsTerminateSystemThread(NTSTATUS
);
1349 NTSTATUS WINAPI
ZwAddBootEntry(PUNICODE_STRING
,PUNICODE_STRING
);
1350 NTSTATUS WINAPI
ZwAccessCheckAndAuditAlarm(PUNICODE_STRING
,HANDLE
,PUNICODE_STRING
,PUNICODE_STRING
,PSECURITY_DESCRIPTOR
,ACCESS_MASK
,PGENERIC_MAPPING
,BOOLEAN
,PACCESS_MASK
,PBOOLEAN
,PBOOLEAN
);
1351 NTSTATUS WINAPI
ZwAdjustPrivilegesToken(HANDLE
,BOOLEAN
,PTOKEN_PRIVILEGES
,DWORD
,PTOKEN_PRIVILEGES
,PDWORD
);
1352 NTSTATUS WINAPI
ZwAlertThread(HANDLE ThreadHandle
);
1353 NTSTATUS WINAPI
ZwAllocateVirtualMemory(HANDLE
,PVOID
*,ULONG
,SIZE_T
*,ULONG
,ULONG
);
1354 NTSTATUS WINAPI
ZwCancelIoFile(HANDLE
,PIO_STATUS_BLOCK
);
1355 NTSTATUS WINAPI
ZwCancelTimer(HANDLE
, BOOLEAN
*);
1356 NTSTATUS WINAPI
ZwClearEvent(HANDLE
);
1357 NTSTATUS WINAPI
ZwClose(HANDLE
);
1358 NTSTATUS WINAPI
ZwCloseObjectAuditAlarm(PUNICODE_STRING
,HANDLE
,BOOLEAN
);
1359 NTSTATUS WINAPI
ZwConnectPort(PHANDLE
,PUNICODE_STRING
,PSECURITY_QUALITY_OF_SERVICE
,PLPC_SECTION_WRITE
,PLPC_SECTION_READ
,PULONG
,PVOID
,PULONG
);
1360 NTSTATUS WINAPI
ZwCreateDirectoryObject(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
);
1361 NTSTATUS WINAPI
ZwCreateEvent(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,BOOLEAN
,BOOLEAN
);
1362 NTSTATUS WINAPI
ZwCreateFile(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,PIO_STATUS_BLOCK
,PLARGE_INTEGER
,ULONG
,ULONG
,ULONG
,ULONG
,PVOID
,ULONG
);
1363 NTSTATUS WINAPI
ZwCreateKey(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,ULONG
,const UNICODE_STRING
*,ULONG
,PULONG
);
1364 NTSTATUS WINAPI
ZwCreateSection(HANDLE
*,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,const LARGE_INTEGER
*,ULONG
,ULONG
,HANDLE
);
1365 NTSTATUS WINAPI
ZwCreateSymbolicLinkObject(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,PUNICODE_STRING
);
1366 NTSTATUS WINAPI
ZwCreateTimer(HANDLE
*, ACCESS_MASK
, const OBJECT_ATTRIBUTES
*, TIMER_TYPE
);
1367 NTSTATUS WINAPI
ZwDeleteAtom(RTL_ATOM
);
1368 NTSTATUS WINAPI
ZwDeleteFile(POBJECT_ATTRIBUTES
);
1369 NTSTATUS WINAPI
ZwDeleteKey(HANDLE
);
1370 NTSTATUS WINAPI
ZwDeleteValueKey(HANDLE
,const UNICODE_STRING
*);
1371 NTSTATUS WINAPI
ZwDeviceIoControlFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,ULONG
,PVOID
,ULONG
,PVOID
,ULONG
);
1372 NTSTATUS WINAPI
ZwDisplayString(PUNICODE_STRING
);
1373 NTSTATUS WINAPI
ZwDuplicateObject(HANDLE
,HANDLE
,HANDLE
,PHANDLE
,ACCESS_MASK
,ULONG
,ULONG
);
1374 NTSTATUS WINAPI
ZwDuplicateToken(HANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,SECURITY_IMPERSONATION_LEVEL
,TOKEN_TYPE
,PHANDLE
);
1375 NTSTATUS WINAPI
ZwEnumerateKey(HANDLE
,ULONG
,KEY_INFORMATION_CLASS
,void *,DWORD
,DWORD
*);
1376 NTSTATUS WINAPI
ZwEnumerateValueKey(HANDLE
,ULONG
,KEY_VALUE_INFORMATION_CLASS
,PVOID
,ULONG
,PULONG
);
1377 NTSTATUS WINAPI
ZwFlushInstructionCache(HANDLE
,LPCVOID
,SIZE_T
);
1378 NTSTATUS WINAPI
ZwFlushKey(HANDLE
);
1379 NTSTATUS WINAPI
ZwFlushVirtualMemory(HANDLE
,LPCVOID
*,SIZE_T
*,ULONG
);
1380 NTSTATUS WINAPI
ZwFreeVirtualMemory(HANDLE
,PVOID
*,SIZE_T
*,ULONG
);
1381 NTSTATUS WINAPI
ZwFsControlFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,ULONG
,PVOID
,ULONG
,PVOID
,ULONG
);
1382 NTSTATUS WINAPI
ZwInitiatePowerAction(POWER_ACTION
,SYSTEM_POWER_STATE
,ULONG
,BOOLEAN
);
1383 NTSTATUS WINAPI
ZwLoadDriver(const UNICODE_STRING
*);
1384 NTSTATUS WINAPI
ZwLoadKey(const OBJECT_ATTRIBUTES
*,OBJECT_ATTRIBUTES
*);
1385 NTSTATUS WINAPI
ZwLockVirtualMemory(HANDLE
,PVOID
*,SIZE_T
*,ULONG
);
1386 NTSTATUS WINAPI
ZwMakeTemporaryObject(HANDLE
);
1387 NTSTATUS WINAPI
ZwMapViewOfSection(HANDLE
,HANDLE
,PVOID
*,ULONG
,SIZE_T
,const LARGE_INTEGER
*,SIZE_T
*,SECTION_INHERIT
,ULONG
,ULONG
);
1388 NTSTATUS WINAPI
ZwNotifyChangeKey(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,ULONG
,BOOLEAN
,PVOID
,ULONG
,BOOLEAN
);
1389 NTSTATUS WINAPI
ZwOpenDirectoryObject(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
);
1390 NTSTATUS WINAPI
ZwOpenEvent(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*);
1391 NTSTATUS WINAPI
ZwOpenFile(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
,PIO_STATUS_BLOCK
,ULONG
,ULONG
);
1392 NTSTATUS WINAPI
ZwOpenKey(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*);
1393 NTSTATUS WINAPI
ZwOpenProcess(PHANDLE
,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,const CLIENT_ID
*);
1394 NTSTATUS WINAPI
ZwOpenProcessToken(HANDLE
,DWORD
,HANDLE
*);
1395 NTSTATUS WINAPI
ZwOpenSection(HANDLE
*,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*);
1396 NTSTATUS WINAPI
ZwOpenSymbolicLinkObject(PHANDLE
,ACCESS_MASK
,POBJECT_ATTRIBUTES
);
1397 NTSTATUS WINAPI
ZwOpenThread(HANDLE
*,ACCESS_MASK
,const OBJECT_ATTRIBUTES
*,const CLIENT_ID
*);
1398 NTSTATUS WINAPI
ZwOpenThreadToken(HANDLE
,DWORD
,BOOLEAN
,HANDLE
*);
1399 NTSTATUS WINAPI
ZwOpenTimer(HANDLE
*, ACCESS_MASK
, const OBJECT_ATTRIBUTES
*);
1400 NTSTATUS WINAPI
ZwPowerInformation(POWER_INFORMATION_LEVEL
,PVOID
,ULONG
,PVOID
,ULONG
);
1401 NTSTATUS WINAPI
ZwPulseEvent(HANDLE
,PULONG
);
1402 NTSTATUS WINAPI
ZwQueryDefaultLocale(BOOLEAN
,LCID
*);
1403 NTSTATUS WINAPI
ZwQueryDefaultUILanguage(LANGID
*);
1404 NTSTATUS WINAPI
ZwQueryDirectoryFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FILE_INFORMATION_CLASS
,BOOLEAN
,PUNICODE_STRING
,BOOLEAN
);
1405 NTSTATUS WINAPI
ZwQueryDirectoryObject(HANDLE
,PDIRECTORY_BASIC_INFORMATION
,ULONG
,BOOLEAN
,BOOLEAN
,PULONG
,PULONG
);
1406 NTSTATUS WINAPI
ZwQueryEaFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,BOOLEAN
,PVOID
,ULONG
,PVOID
,BOOLEAN
);
1407 NTSTATUS WINAPI
ZwQueryFullAttributesFile(const OBJECT_ATTRIBUTES
*,FILE_NETWORK_OPEN_INFORMATION
*);
1408 NTSTATUS WINAPI
ZwQueryInformationFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,LONG
,FILE_INFORMATION_CLASS
);
1409 NTSTATUS WINAPI
ZwQueryInformationThread(HANDLE
,THREADINFOCLASS
,PVOID
,ULONG
,PULONG
);
1410 NTSTATUS WINAPI
ZwQueryInformationToken(HANDLE
,DWORD
,PVOID
,DWORD
,LPDWORD
);
1411 NTSTATUS WINAPI
ZwQueryInstallUILanguage(LANGID
*);
1412 NTSTATUS WINAPI
ZwQueryKey(HANDLE
,KEY_INFORMATION_CLASS
,void *,DWORD
,DWORD
*);
1413 NTSTATUS WINAPI
ZwQueryObject(HANDLE
, OBJECT_INFORMATION_CLASS
, PVOID
, ULONG
, PULONG
);
1414 NTSTATUS WINAPI
ZwQuerySecurityObject(HANDLE
,SECURITY_INFORMATION
,PSECURITY_DESCRIPTOR
,ULONG
,PULONG
);
1415 NTSTATUS WINAPI
ZwQuerySection(HANDLE
,SECTION_INFORMATION_CLASS
,PVOID
,ULONG
,PULONG
);
1416 NTSTATUS WINAPI
ZwQuerySymbolicLinkObject(HANDLE
,PUNICODE_STRING
,PULONG
);
1417 NTSTATUS WINAPI
ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS
,PVOID
,ULONG
,PULONG
);
1418 NTSTATUS WINAPI
ZwQueryTimerResolution(PULONG
,PULONG
,PULONG
);
1419 NTSTATUS WINAPI
ZwQueryValueKey(HANDLE
,const UNICODE_STRING
*,KEY_VALUE_INFORMATION_CLASS
,void *,DWORD
,DWORD
*);
1420 NTSTATUS WINAPI
ZwQueryVolumeInformationFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FS_INFORMATION_CLASS
);
1421 NTSTATUS WINAPI
ZwReadFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,PLARGE_INTEGER
,PULONG
);
1422 NTSTATUS WINAPI
ZwReplaceKey(POBJECT_ATTRIBUTES
,HANDLE
,POBJECT_ATTRIBUTES
);
1423 NTSTATUS WINAPI
ZwRequestWaitReplyPort(HANDLE
,PLPC_MESSAGE
,PLPC_MESSAGE
);
1424 NTSTATUS WINAPI
ZwResetEvent(HANDLE
,PULONG
);
1425 NTSTATUS WINAPI
ZwRestoreKey(HANDLE
,HANDLE
,ULONG
);
1426 NTSTATUS WINAPI
ZwSaveKey(HANDLE
,HANDLE
);
1427 NTSTATUS WINAPI
ZwSecureConnectPort(PHANDLE
,PUNICODE_STRING
,PSECURITY_QUALITY_OF_SERVICE
,PLPC_SECTION_WRITE
,PSID
,PLPC_SECTION_READ
,PULONG
,PVOID
,PULONG
);
1428 NTSTATUS WINAPI
ZwSetDefaultLocale(BOOLEAN
,LCID
);
1429 NTSTATUS WINAPI
ZwSetDefaultUILanguage(LANGID
);
1430 NTSTATUS WINAPI
ZwSetEaFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
);
1431 NTSTATUS WINAPI
ZwSetEvent(HANDLE
,PULONG
);
1432 NTSTATUS WINAPI
ZwSetInformationFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FILE_INFORMATION_CLASS
);
1433 NTSTATUS WINAPI
ZwSetInformationKey(HANDLE
,const int,PVOID
,ULONG
);
1434 NTSTATUS WINAPI
ZwSetInformationObject(HANDLE
, OBJECT_INFORMATION_CLASS
, PVOID
, ULONG
);
1435 NTSTATUS WINAPI
ZwSetInformationProcess(HANDLE
,PROCESS_INFORMATION_CLASS
,PVOID
,ULONG
);
1436 NTSTATUS WINAPI
ZwSetInformationThread(HANDLE
,THREADINFOCLASS
,LPCVOID
,ULONG
);
1437 NTSTATUS WINAPI
ZwSetIoCompletion(HANDLE
,ULONG
,ULONG
,NTSTATUS
,ULONG
);
1438 NTSTATUS WINAPI
ZwSetLdtEntries(ULONG
,ULONG
,ULONG
,ULONG
,ULONG
,ULONG
);
1439 NTSTATUS WINAPI
ZwSetSecurityObject(HANDLE
,SECURITY_INFORMATION
,PSECURITY_DESCRIPTOR
);
1440 NTSTATUS WINAPI
ZwSetSystemInformation(SYSTEM_INFORMATION_CLASS
,PVOID
,ULONG
);
1441 NTSTATUS WINAPI
ZwSetSystemTime(const LARGE_INTEGER
*,LARGE_INTEGER
*);
1442 NTSTATUS WINAPI
ZwSetTimer(HANDLE
, const LARGE_INTEGER
*, PTIMER_APC_ROUTINE
, PVOID
, BOOLEAN
, ULONG
, BOOLEAN
*);
1443 NTSTATUS WINAPI
ZwSetValueKey(HANDLE
,const UNICODE_STRING
*,ULONG
,ULONG
,const void *,ULONG
);
1444 NTSTATUS WINAPI
ZwSetVolumeInformationFile(HANDLE
,PIO_STATUS_BLOCK
,PVOID
,ULONG
,FS_INFORMATION_CLASS
);
1445 NTSTATUS WINAPI
ZwSuspendThread(HANDLE
,PULONG
);
1446 NTSTATUS WINAPI
ZwTerminateProcess(HANDLE
,LONG
);
1447 NTSTATUS WINAPI
ZwUnloadDriver(const UNICODE_STRING
*);
1448 NTSTATUS WINAPI
ZwUnloadKey(HANDLE
);
1449 NTSTATUS WINAPI
ZwUnmapViewOfSection(HANDLE
,PVOID
);
1450 NTSTATUS WINAPI
ZwWaitForSingleObject(HANDLE
,BOOLEAN
,const LARGE_INTEGER
*);
1451 NTSTATUS WINAPI
ZwWaitForMultipleObjects(ULONG
,const HANDLE
*,BOOLEAN
,BOOLEAN
,const LARGE_INTEGER
*);
1452 NTSTATUS WINAPI
ZwWriteFile(HANDLE
,HANDLE
,PIO_APC_ROUTINE
,PVOID
,PIO_STATUS_BLOCK
,const void*,ULONG
,PLARGE_INTEGER
,PULONG
);
1453 NTSTATUS WINAPI
ZwYieldExecution(void);