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;
92 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
93 typedef struct _OBJECT_HANDLE_INFORMATION *POBJECT_HANDLE_INFORMATION;
95 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
101 USHORT VolumeLabelLength;
102 struct _DEVICE_OBJECT *DeviceObject;
103 struct _DEVICE_OBJECT *RealDevice;
105 ULONG ReferenceCount;
106 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
109 typedef enum _POOL_TYPE {
112 NonPagedPoolMustSucceed,
114 NonPagedPoolCacheAligned,
115 PagedPoolCacheAligned,
116 NonPagedPoolCacheAlignedMustS,
120 typedef struct _WAIT_CONTEXT_BLOCK {
121 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
122 struct _DRIVER_CONTROL *DeviceRoutine;
124 ULONG NumberOfMapRegisters;
127 PKDPC BufferChainingDpc;
128 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
130 #define DO_BUFFERED_IO 0x00000004
131 #define DO_EXCLUSIVE 0x00000008
132 #define DO_DIRECT_IO 0x00000010
133 #define DO_MAP_IO_BUFFER 0x00000020
134 #define DO_DEVICE_INITIALIZING 0x00000080
135 #define DO_SHUTDOWN_REGISTERED 0x00000800
136 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
137 #define DO_POWER_PAGABLE 0x00002000
138 #define DO_POWER_INRUSH 0x00004000
140 #define IO_NO_INCREMENT 0
141 #define IO_CD_ROM_INCREMENT 1
142 #define IO_DISK_INCREMENT 1
143 #define IO_KEYBOARD_INCREMENT 6
144 #define IO_MAILSLOT_INCREMENT 2
145 #define IO_MOUSE_INCREMENT 6
146 #define IO_NAMED_PIPE_INCREMENT 2
147 #define IO_NETWORK_INCREMENT 2
148 #define IO_PARALLEL_INCREMENT 1
149 #define IO_SERIAL_INCREMENT 2
150 #define IO_SOUND_INCREMENT 8
151 #define IO_VIDEO_INCREMENT 1
154 #define DEVICE_TYPE ULONG
156 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
157 #define IRP_MJ_CREATE 0x00
158 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
159 #define IRP_MJ_CLOSE 0x02
160 #define IRP_MJ_READ 0x03
161 #define IRP_MJ_WRITE 0x04
162 #define IRP_MJ_QUERY_INFORMATION 0x05
163 #define IRP_MJ_SET_INFORMATION 0x06
164 #define IRP_MJ_QUERY_EA 0x07
165 #define IRP_MJ_SET_EA 0x08
166 #define IRP_MJ_FLUSH_BUFFERS 0x09
167 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
168 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
169 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
170 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
171 #define IRP_MJ_DEVICE_CONTROL 0x0e
172 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
173 #define IRP_MJ_SHUTDOWN 0x10
174 #define IRP_MJ_LOCK_CONTROL 0x11
175 #define IRP_MJ_CLEANUP 0x12
176 #define IRP_MJ_CREATE_MAILSLOT 0x13
177 #define IRP_MJ_QUERY_SECURITY 0x14
178 #define IRP_MJ_SET_SECURITY 0x15
179 #define IRP_MJ_POWER 0x16
180 #define IRP_MJ_SYSTEM_CONTROL 0x17
181 #define IRP_MJ_DEVICE_CHANGE 0x18
182 #define IRP_MJ_QUERY_QUOTA 0x19
183 #define IRP_MJ_SET_QUOTA 0x1a
184 #define IRP_MJ_PNP 0x1b
186 #define IRP_QUOTA_CHARGED 0x01
187 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
188 #define IRP_ALLOCATED_FIXED_SIZE 0x04
189 #define IRP_LOOKASIDE_ALLOCATION 0x08
191 typedef struct _DEVICE_OBJECT {
195 struct _DRIVER_OBJECT *DriverObject;
196 struct _DEVICE_OBJECT *NextDevice;
197 struct _DEVICE_OBJECT *AttachedDevice;
198 struct _IRP *CurrentIrp;
201 ULONG Characteristics;
203 PVOID DeviceExtension;
204 DEVICE_TYPE DeviceType;
207 LIST_ENTRY ListEntry;
208 WAIT_CONTEXT_BLOCK Wcb;
210 ULONG AlignmentRequirement;
211 KDEVICE_QUEUE DeviceQueue;
213 ULONG ActiveThreadCount;
214 PSECURITY_DESCRIPTOR SecurityDescriptor;
218 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
221 typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT;
223 typedef struct _DRIVER_EXTENSION {
224 struct _DRIVER_OBJECT *DriverObject;
227 UNICODE_STRING ServiceKeyName;
228 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
230 typedef struct _DRIVER_OBJECT {
233 PDEVICE_OBJECT DeviceObject;
238 PDRIVER_EXTENSION DriverExtension;
239 UNICODE_STRING DriverName;
240 PUNICODE_STRING HardwareDatabase;
241 PVOID FastIoDispatch;
242 PDRIVER_INITIALIZE DriverInit;
243 PDRIVER_STARTIO DriverStartIo;
244 PDRIVER_UNLOAD DriverUnload;
245 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
247 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
249 /* Irp definitions */
250 typedef UCHAR KIRQL, *PKIRQL;
251 typedef CCHAR KPROCESSOR_MODE;
253 typedef VOID (WINAPI *PDRIVER_CANCEL)(
254 IN struct _DEVICE_OBJECT *DeviceObject,
255 IN struct _IRP *Irp);
257 typedef VOID (WINAPI *PKNORMAL_ROUTINE)(
258 IN PVOID NormalContext,
259 IN PVOID SystemArgument1,
260 IN PVOID SystemArgument2);
262 typedef VOID (WINAPI *PKKERNEL_ROUTINE)(
263 IN struct _KAPC *Apc,
264 IN OUT PKNORMAL_ROUTINE *NormalRoutine,
265 IN OUT PVOID *NormalContext,
266 IN OUT PVOID *SystemArgument1,
267 IN OUT PVOID *SystemArgument2);
269 typedef VOID (WINAPI *PKRUNDOWN_ROUTINE)(
270 IN struct _KAPC *Apc);
272 typedef struct _KAPC {
276 struct _KTHREAD *Thread;
277 LIST_ENTRY ApcListEntry;
278 PKKERNEL_ROUTINE KernelRoutine;
279 PKRUNDOWN_ROUTINE RundownRoutine;
280 PKNORMAL_ROUTINE NormalRoutine;
282 PVOID SystemArgument1;
283 PVOID SystemArgument2;
285 KPROCESSOR_MODE ApcMode;
287 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
289 #include <pshpack1.h>
290 typedef struct _IRP {
293 struct _MDL *MdlAddress;
296 struct _IRP *MasterIrp;
300 LIST_ENTRY ThreadListEntry;
301 IO_STATUS_BLOCK IoStatus;
302 KPROCESSOR_MODE RequestorMode;
303 BOOLEAN PendingReturned;
305 CHAR CurrentLocation;
308 CCHAR ApcEnvironment;
309 UCHAR AllocationFlags;
310 PIO_STATUS_BLOCK UserIosb;
314 PIO_APC_ROUTINE UserApcRoutine;
315 PVOID UserApcContext;
316 } AsynchronousParameters;
317 LARGE_INTEGER AllocationSize;
319 PDRIVER_CANCEL CancelRoutine;
324 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
326 PVOID DriverContext[4];
330 PCHAR AuxiliaryBuffer;
332 LIST_ENTRY ListEntry;
334 struct _IO_STACK_LOCATION *CurrentStackLocation;
338 struct _FILE_OBJECT *OriginalFileObject;
344 typedef struct _IRP *PIRP;
347 /* MDL definitions */
349 typedef VOID (WINAPI *PINTERFACE_REFERENCE)(
352 typedef VOID (WINAPI *PINTERFACE_DEREFERENCE)(
355 typedef struct _INTERFACE {
359 PINTERFACE_REFERENCE InterfaceReference;
360 PINTERFACE_DEREFERENCE InterfaceDereference;
361 } INTERFACE, *PINTERFACE;
363 typedef struct _SECTION_OBJECT_POINTERS {
364 PVOID DataSectionObject;
365 PVOID SharedCacheMap;
366 PVOID ImageSectionObject;
367 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
369 typedef struct _IO_COMPLETION_CONTEXT {
372 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
374 typedef enum _DEVICE_RELATION_TYPE {
379 TargetDeviceRelation,
381 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
383 typedef struct _FILE_OBJECT {
386 PDEVICE_OBJECT DeviceObject;
390 PSECTION_OBJECT_POINTERS SectionObjectPointer;
391 PVOID PrivateCacheMap;
392 NTSTATUS FinalStatus;
393 struct _FILE_OBJECT *RelatedFileObject;
394 BOOLEAN LockOperation;
395 BOOLEAN DeletePending;
398 BOOLEAN DeleteAccess;
401 BOOLEAN SharedDelete;
403 UNICODE_STRING FileName;
404 LARGE_INTEGER CurrentByteOffset;
410 PIO_COMPLETION_CONTEXT CompletionContext;
412 typedef struct _FILE_OBJECT *PFILE_OBJECT;
414 #define INITIAL_PRIVILEGE_COUNT 3
416 typedef struct _INITIAL_PRIVILEGE_SET {
417 ULONG PrivilegeCount;
419 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
420 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
422 typedef struct _SECURITY_SUBJECT_CONTEXT {
423 PACCESS_TOKEN ClientToken;
424 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
425 PACCESS_TOKEN PrimaryToken;
426 PVOID ProcessAuditId;
427 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
429 typedef struct _ACCESS_STATE {
431 BOOLEAN SecurityEvaluated;
432 BOOLEAN GenerateAudit;
433 BOOLEAN GenerateOnClose;
434 BOOLEAN PrivilegesAllocated;
436 ACCESS_MASK RemainingDesiredAccess;
437 ACCESS_MASK PreviouslyGrantedAccess;
438 ACCESS_MASK OriginalDesiredAccess;
439 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
440 PSECURITY_DESCRIPTOR SecurityDescriptor;
443 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
444 PRIVILEGE_SET PrivilegeSet;
447 BOOLEAN AuditPrivileges;
448 UNICODE_STRING ObjectName;
449 UNICODE_STRING ObjectTypeName;
450 } ACCESS_STATE, *PACCESS_STATE;
452 typedef struct _IO_SECURITY_CONTEXT {
453 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
454 PACCESS_STATE AccessState;
455 ACCESS_MASK DesiredAccess;
456 ULONG FullCreateOptions;
457 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
459 typedef struct _DEVICE_CAPABILITIES {
464 ULONG LockSupported : 1;
465 ULONG EjectSupported : 1;
467 ULONG DockDevice : 1;
469 ULONG SilentInstall : 1;
470 ULONG RawDeviceOK : 1;
471 ULONG SurpriseRemovalOK : 1;
472 ULONG WakeFromD0 : 1;
473 ULONG WakeFromD1 : 1;
474 ULONG WakeFromD2 : 1;
475 ULONG WakeFromD3 : 1;
476 ULONG HardwareDisabled : 1;
477 ULONG NonDynamic : 1;
478 ULONG WarmEjectSupported : 1;
479 ULONG NoDisplayInUI : 1;
483 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
484 SYSTEM_POWER_STATE SystemWake;
485 DEVICE_POWER_STATE DeviceWake;
489 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
491 typedef enum _INTERFACE_TYPE {
492 InterfaceTypeUndefined = -1,
510 } INTERFACE_TYPE, *PINTERFACE_TYPE;
512 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
514 #define IO_RESOURCE_PREFERRED 0x01
515 #define IO_RESOURCE_DEFAULT 0x02
516 #define IO_RESOURCE_ALTERNATIVE 0x08
518 typedef struct _IO_RESOURCE_DESCRIPTOR {
521 UCHAR ShareDisposition;
529 PHYSICAL_ADDRESS MinimumAddress;
530 PHYSICAL_ADDRESS MaximumAddress;
535 PHYSICAL_ADDRESS MinimumAddress;
536 PHYSICAL_ADDRESS MaximumAddress;
543 ULONG MinimumChannel;
544 ULONG MaximumChannel;
549 PHYSICAL_ADDRESS MinimumAddress;
550 PHYSICAL_ADDRESS MaximumAddress;
567 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
569 typedef struct _IO_RESOURCE_LIST {
573 IO_RESOURCE_DESCRIPTOR Descriptors[1];
574 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
576 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
578 INTERFACE_TYPE InterfaceType;
582 ULONG AlternativeLists;
583 IO_RESOURCE_LIST List[1];
584 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
586 typedef enum _BUS_QUERY_ID_TYPE {
589 BusQueryCompatibleIDs,
591 BusQueryDeviceSerialNumber
592 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
594 typedef enum _DEVICE_TEXT_TYPE {
595 DeviceTextDescription,
596 DeviceTextLocationInformation
597 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
599 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
600 DeviceUsageTypeUndefined,
601 DeviceUsageTypePaging,
602 DeviceUsageTypeHibernation,
603 DeviceUsageTypeDumpFile
604 } DEVICE_USAGE_NOTIFICATION_TYPE;
606 typedef struct _POWER_SEQUENCE {
610 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
612 typedef enum _POWER_STATE_TYPE {
615 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
617 typedef union _POWER_STATE {
618 SYSTEM_POWER_STATE SystemState;
619 DEVICE_POWER_STATE DeviceState;
620 } POWER_STATE, *PPOWER_STATE;
622 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
624 UCHAR ShareDisposition;
628 PHYSICAL_ADDRESS Start;
632 PHYSICAL_ADDRESS Start;
641 PHYSICAL_ADDRESS Start;
661 } DeviceSpecificData;
663 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
665 typedef struct _CM_PARTIAL_RESOURCE_LIST {
669 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
670 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
672 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
673 INTERFACE_TYPE InterfaceType;
675 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
676 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
678 typedef struct _CM_RESOURCE_LIST {
680 CM_FULL_RESOURCE_DESCRIPTOR List[1];
681 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
683 typedef NTSTATUS (WINAPI *PIO_COMPLETION_ROUTINE)(
684 IN struct _DEVICE_OBJECT *DeviceObject,
688 #include <pshpack1.h>
689 typedef struct _IO_STACK_LOCATION {
696 PIO_SECURITY_CONTEXT SecurityContext;
698 USHORT POINTER_ALIGNMENT FileAttributes;
700 ULONG POINTER_ALIGNMENT EaLength;
704 ULONG POINTER_ALIGNMENT Key;
705 LARGE_INTEGER ByteOffset;
709 ULONG POINTER_ALIGNMENT Key;
710 LARGE_INTEGER ByteOffset;
714 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
718 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
719 PFILE_OBJECT FileObject;
722 BOOLEAN ReplaceIfExists;
731 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
734 ULONG OutputBufferLength;
735 ULONG POINTER_ALIGNMENT InputBufferLength;
736 ULONG POINTER_ALIGNMENT IoControlCode;
737 PVOID Type3InputBuffer;
740 SECURITY_INFORMATION SecurityInformation;
741 ULONG POINTER_ALIGNMENT Length;
744 SECURITY_INFORMATION SecurityInformation;
745 PSECURITY_DESCRIPTOR SecurityDescriptor;
749 PDEVICE_OBJECT DeviceObject;
753 PDEVICE_OBJECT DeviceObject;
756 struct _SCSI_REQUEST_BLOCK *Srb;
759 DEVICE_RELATION_TYPE Type;
760 } QueryDeviceRelations;
762 CONST GUID *InterfaceType;
765 PINTERFACE Interface;
766 PVOID InterfaceSpecificData;
769 PDEVICE_CAPABILITIES Capabilities;
770 } DeviceCapabilities;
772 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
773 } FilterResourceRequirements;
778 ULONG POINTER_ALIGNMENT Length;
784 BUS_QUERY_ID_TYPE IdType;
787 DEVICE_TEXT_TYPE DeviceTextType;
788 LCID POINTER_ALIGNMENT LocaleId;
793 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
796 SYSTEM_POWER_STATE PowerState;
799 PPOWER_SEQUENCE PowerSequence;
803 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
804 POWER_STATE POINTER_ALIGNMENT State;
805 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
808 PCM_RESOURCE_LIST AllocatedResources;
809 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
812 ULONG_PTR ProviderId;
824 PDEVICE_OBJECT DeviceObject;
825 PFILE_OBJECT FileObject;
826 PIO_COMPLETION_ROUTINE CompletionRoutine;
828 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
831 typedef struct _MDL {
835 struct _EPROCESS *Process;
836 PVOID MappedSystemVa;
842 typedef struct _KTIMER {
843 DISPATCHER_HEADER Header;
844 ULARGE_INTEGER DueTime;
845 LIST_ENTRY TimerListEntry;
850 typedef struct _KSYSTEM_TIME {
854 } KSYSTEM_TIME, *PKSYSTEM_TIME;
856 typedef enum _NT_PRODUCT_TYPE {
860 } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
862 #define PROCESSOR_FEATURE_MAX 64
864 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
869 } ALTERNATIVE_ARCHITECTURE_TYPE;
871 typedef struct _KUSER_SHARED_DATA {
872 ULONG TickCountLowDeprecated;
873 ULONG TickCountMultiplier;
874 volatile KSYSTEM_TIME InterruptTime;
875 volatile KSYSTEM_TIME SystemTime;
876 volatile KSYSTEM_TIME TimeZoneBias;
877 USHORT ImageNumberLow;
878 USHORT ImageNumberHigh;
879 WCHAR NtSystemRoot[260];
880 ULONG MaxStckTraceDepth;
881 ULONG CryptoExponent;
883 ULONG LargePageMinimum;
885 NT_PRODUCT_TYPE NtProductType;
886 BOOLEAN ProductTypeIsValid;
887 ULONG MajorNtVersion;
888 ULONG MinorNtVersion;
889 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
892 volatile ULONG TimeSlip;
893 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
894 LARGE_INTEGER SystemExpirationDate;
896 BOOLEAN KdDebuggerEnabled;
897 volatile ULONG ActiveConsoleId;
898 volatile ULONG DismountCount;
899 ULONG ComPlusPackage;
900 ULONG LastSystemRITEventTickCount;
901 ULONG NumberOfPhysicalPages;
902 BOOLEAN SafeBootMode;
905 ULONGLONG SystemCall[4];
907 volatile KSYSTEM_TIME TickCount;
908 volatile ULONG64 TickCountQuad;
910 } KSHARED_USER_DATA, *PKSHARED_USER_DATA;
912 NTSTATUS WINAPI ObCloseHandle(IN HANDLE handle);
914 #define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation)
919 /* directory object access rights */
920 #define DIRECTORY_QUERY 0x0001
921 #define DIRECTORY_TRAVERSE 0x0002
922 #define DIRECTORY_CREATE_OBJECT 0x0004
923 #define DIRECTORY_CREATE_SUBDIRECTORY 0x0008
924 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
926 /* symbolic link access rights */
927 #define SYMBOLIC_LINK_QUERY 0x0001
928 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
930 PVOID WINAPI ExAllocatePool(POOL_TYPE,SIZE_T);
931 PVOID WINAPI ExAllocatePoolWithQuota(POOL_TYPE,SIZE_T);
932 PVOID WINAPI ExAllocatePoolWithTag(POOL_TYPE,SIZE_T,ULONG);
933 PVOID WINAPI ExAllocatePoolWithQuotaTag(POOL_TYPE,SIZE_T,ULONG);
934 void WINAPI ExFreePool(PVOID);
935 void WINAPI ExFreePoolWithTag(PVOID,ULONG);
937 PIRP WINAPI IoAllocateIrp(CCHAR,BOOLEAN);
938 NTSTATUS WINAPI IoCreateDevice(DRIVER_OBJECT*,ULONG,UNICODE_STRING*,DEVICE_TYPE,ULONG,BOOLEAN,DEVICE_OBJECT**);
939 NTSTATUS WINAPI IoCreateDriver(UNICODE_STRING*,PDRIVER_INITIALIZE);
940 NTSTATUS WINAPI IoCreateSymbolicLink(UNICODE_STRING*,UNICODE_STRING*);
941 void WINAPI IoDeleteDevice(DEVICE_OBJECT*);
942 void WINAPI IoDeleteDriver(DRIVER_OBJECT*);
943 NTSTATUS WINAPI IoDeleteSymbolicLink(UNICODE_STRING*);
944 void WINAPI IoFreeIrp(IRP*);
945 PEPROCESS WINAPI IoGetCurrentProcess(void);
946 NTSTATUS WINAPI IoGetDeviceObjectPointer(UNICODE_STRING*,ACCESS_MASK,PFILE_OBJECT*,PDEVICE_OBJECT*);
947 PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject(PFILE_OBJECT);
948 void WINAPI IoInitializeIrp(IRP*,USHORT,CCHAR);
950 PKTHREAD WINAPI KeGetCurrentThread(void);
951 void WINAPI KeQuerySystemTime(LARGE_INTEGER*);
952 void WINAPI KeQueryTickCount(LARGE_INTEGER*);
953 ULONG WINAPI KeQueryTimeIncrement(void);
955 PVOID WINAPI MmAllocateNonCachedMemory(SIZE_T);
956 void WINAPI MmFreeNonCachedMemory(PVOID,SIZE_T);
958 NTSTATUS WINAPI ObReferenceObjectByHandle(HANDLE,ACCESS_MASK,POBJECT_TYPE,KPROCESSOR_MODE,PVOID*,POBJECT_HANDLE_INFORMATION);
960 NTSTATUS WINAPI PsCreateSystemThread(PHANDLE,ULONG,POBJECT_ATTRIBUTES,HANDLE,PCLIENT_ID,PKSTART_ROUTINE,PVOID);
961 #define PsGetCurrentProcess() IoGetCurrentProcess()
962 #define PsGetCurrentThread() ((PETHREAD)KeGetCurrentThread())
963 HANDLE WINAPI PsGetCurrentProcessId(void);
964 HANDLE WINAPI PsGetCurrentThreadId(void);
965 BOOLEAN WINAPI PsGetVersion(ULONG*,ULONG*,ULONG*,UNICODE_STRING*);
966 NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS);
968 NTSTATUS WINAPI ZwAddBootEntry(PUNICODE_STRING,PUNICODE_STRING);
969 NTSTATUS WINAPI ZwAccessCheckAndAuditAlarm(PUNICODE_STRING,HANDLE,PUNICODE_STRING,PUNICODE_STRING,PSECURITY_DESCRIPTOR,ACCESS_MASK,PGENERIC_MAPPING,BOOLEAN,PACCESS_MASK,PBOOLEAN,PBOOLEAN);
970 NTSTATUS WINAPI ZwAdjustPrivilegesToken(HANDLE,BOOLEAN,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
971 NTSTATUS WINAPI ZwAlertThread(HANDLE ThreadHandle);
972 NTSTATUS WINAPI ZwAllocateVirtualMemory(HANDLE,PVOID*,ULONG,SIZE_T*,ULONG,ULONG);
973 NTSTATUS WINAPI ZwCancelIoFile(HANDLE,PIO_STATUS_BLOCK);
974 NTSTATUS WINAPI ZwCancelTimer(HANDLE, BOOLEAN*);
975 NTSTATUS WINAPI ZwClearEvent(HANDLE);
976 NTSTATUS WINAPI ZwClose(HANDLE);
977 NTSTATUS WINAPI ZwCloseObjectAuditAlarm(PUNICODE_STRING,HANDLE,BOOLEAN);
978 NTSTATUS WINAPI ZwConnectPort(PHANDLE,PUNICODE_STRING,PSECURITY_QUALITY_OF_SERVICE,PLPC_SECTION_WRITE,PLPC_SECTION_READ,PULONG,PVOID,PULONG);
979 NTSTATUS WINAPI ZwCreateDirectoryObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
980 NTSTATUS WINAPI ZwCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
981 NTSTATUS WINAPI ZwCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG);
982 NTSTATUS WINAPI ZwCreateKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG);
983 NTSTATUS WINAPI ZwCreateSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const LARGE_INTEGER*,ULONG,ULONG,HANDLE);
984 NTSTATUS WINAPI ZwCreateSymbolicLinkObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PUNICODE_STRING);
985 NTSTATUS WINAPI ZwCreateTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*, TIMER_TYPE);
986 NTSTATUS WINAPI ZwDeleteAtom(RTL_ATOM);
987 NTSTATUS WINAPI ZwDeleteFile(POBJECT_ATTRIBUTES);
988 NTSTATUS WINAPI ZwDeleteKey(HANDLE);
989 NTSTATUS WINAPI ZwDeleteValueKey(HANDLE,const UNICODE_STRING *);
990 NTSTATUS WINAPI ZwDeviceIoControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
991 NTSTATUS WINAPI ZwDisplayString(PUNICODE_STRING);
992 NTSTATUS WINAPI ZwDuplicateObject(HANDLE,HANDLE,HANDLE,PHANDLE,ACCESS_MASK,ULONG,ULONG);
993 NTSTATUS WINAPI ZwDuplicateToken(HANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,SECURITY_IMPERSONATION_LEVEL,TOKEN_TYPE,PHANDLE);
994 NTSTATUS WINAPI ZwEnumerateKey(HANDLE,ULONG,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
995 NTSTATUS WINAPI ZwEnumerateValueKey(HANDLE,ULONG,KEY_VALUE_INFORMATION_CLASS,PVOID,ULONG,PULONG);
996 NTSTATUS WINAPI ZwFlushInstructionCache(HANDLE,LPCVOID,SIZE_T);
997 NTSTATUS WINAPI ZwFlushKey(HANDLE);
998 NTSTATUS WINAPI ZwFlushVirtualMemory(HANDLE,LPCVOID*,SIZE_T*,ULONG);
999 NTSTATUS WINAPI ZwFreeVirtualMemory(HANDLE,PVOID*,SIZE_T*,ULONG);
1000 NTSTATUS WINAPI ZwFsControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
1001 NTSTATUS WINAPI ZwInitiatePowerAction(POWER_ACTION,SYSTEM_POWER_STATE,ULONG,BOOLEAN);
1002 NTSTATUS WINAPI ZwLoadDriver(const UNICODE_STRING *);
1003 NTSTATUS WINAPI ZwLoadKey(const OBJECT_ATTRIBUTES *,OBJECT_ATTRIBUTES *);
1004 NTSTATUS WINAPI ZwLockVirtualMemory(HANDLE,PVOID*,SIZE_T*,ULONG);
1005 NTSTATUS WINAPI ZwMakeTemporaryObject(HANDLE);
1006 NTSTATUS WINAPI ZwMapViewOfSection(HANDLE,HANDLE,PVOID*,ULONG,SIZE_T,const LARGE_INTEGER*,SIZE_T*,SECTION_INHERIT,ULONG,ULONG);
1007 NTSTATUS WINAPI ZwNotifyChangeKey(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN);
1008 NTSTATUS WINAPI ZwOpenDirectoryObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1009 NTSTATUS WINAPI ZwOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
1010 NTSTATUS WINAPI ZwOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG);
1011 NTSTATUS WINAPI ZwOpenKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
1012 NTSTATUS WINAPI ZwOpenProcess(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
1013 NTSTATUS WINAPI ZwOpenProcessToken(HANDLE,DWORD,HANDLE *);
1014 NTSTATUS WINAPI ZwOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
1015 NTSTATUS WINAPI ZwOpenSymbolicLinkObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1016 NTSTATUS WINAPI ZwOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
1017 NTSTATUS WINAPI ZwOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *);
1018 NTSTATUS WINAPI ZwOpenTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*);
1019 NTSTATUS WINAPI ZwPowerInformation(POWER_INFORMATION_LEVEL,PVOID,ULONG,PVOID,ULONG);
1020 NTSTATUS WINAPI ZwPulseEvent(HANDLE,PULONG);
1021 NTSTATUS WINAPI ZwQueryDefaultLocale(BOOLEAN,LCID*);
1022 NTSTATUS WINAPI ZwQueryDefaultUILanguage(LANGID*);
1023 NTSTATUS WINAPI ZwQueryDirectoryFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS,BOOLEAN,PUNICODE_STRING,BOOLEAN);
1024 NTSTATUS WINAPI ZwQueryDirectoryObject(HANDLE,PDIRECTORY_BASIC_INFORMATION,ULONG,BOOLEAN,BOOLEAN,PULONG,PULONG);
1025 NTSTATUS WINAPI ZwQueryEaFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,BOOLEAN,PVOID,ULONG,PVOID,BOOLEAN);
1026 NTSTATUS WINAPI ZwQueryFullAttributesFile(const OBJECT_ATTRIBUTES*,FILE_NETWORK_OPEN_INFORMATION*);
1027 NTSTATUS WINAPI ZwQueryInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,LONG,FILE_INFORMATION_CLASS);
1028 NTSTATUS WINAPI ZwQueryInformationThread(HANDLE,THREADINFOCLASS,PVOID,ULONG,PULONG);
1029 NTSTATUS WINAPI ZwQueryInformationToken(HANDLE,DWORD,PVOID,DWORD,LPDWORD);
1030 NTSTATUS WINAPI ZwQueryInstallUILanguage(LANGID*);
1031 NTSTATUS WINAPI ZwQueryKey(HANDLE,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
1032 NTSTATUS WINAPI ZwQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
1033 NTSTATUS WINAPI ZwQuerySecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,ULONG,PULONG);
1034 NTSTATUS WINAPI ZwQuerySection(HANDLE,SECTION_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1035 NTSTATUS WINAPI ZwQuerySymbolicLinkObject(HANDLE,PUNICODE_STRING,PULONG);
1036 NTSTATUS WINAPI ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1037 NTSTATUS WINAPI ZwQueryTimerResolution(PULONG,PULONG,PULONG);
1038 NTSTATUS WINAPI ZwQueryValueKey(HANDLE,const UNICODE_STRING *,KEY_VALUE_INFORMATION_CLASS,void *,DWORD,DWORD *);
1039 NTSTATUS WINAPI ZwQueryVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FS_INFORMATION_CLASS);
1040 NTSTATUS WINAPI ZwReadFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,PLARGE_INTEGER,PULONG);
1041 NTSTATUS WINAPI ZwReplaceKey(POBJECT_ATTRIBUTES,HANDLE,POBJECT_ATTRIBUTES);
1042 NTSTATUS WINAPI ZwRequestWaitReplyPort(HANDLE,PLPC_MESSAGE,PLPC_MESSAGE);
1043 NTSTATUS WINAPI ZwResetEvent(HANDLE,PULONG);
1044 NTSTATUS WINAPI ZwRestoreKey(HANDLE,HANDLE,ULONG);
1045 NTSTATUS WINAPI ZwSaveKey(HANDLE,HANDLE);
1046 NTSTATUS WINAPI ZwSecureConnectPort(PHANDLE,PUNICODE_STRING,PSECURITY_QUALITY_OF_SERVICE,PLPC_SECTION_WRITE,PSID,PLPC_SECTION_READ,PULONG,PVOID,PULONG);
1047 NTSTATUS WINAPI ZwSetDefaultLocale(BOOLEAN,LCID);
1048 NTSTATUS WINAPI ZwSetDefaultUILanguage(LANGID);
1049 NTSTATUS WINAPI ZwSetEaFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG);
1050 NTSTATUS WINAPI ZwSetEvent(HANDLE,PULONG);
1051 NTSTATUS WINAPI ZwSetInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS);
1052 NTSTATUS WINAPI ZwSetInformationKey(HANDLE,const int,PVOID,ULONG);
1053 NTSTATUS WINAPI ZwSetInformationObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG);
1054 NTSTATUS WINAPI ZwSetInformationProcess(HANDLE,PROCESS_INFORMATION_CLASS,PVOID,ULONG);
1055 NTSTATUS WINAPI ZwSetInformationThread(HANDLE,THREADINFOCLASS,LPCVOID,ULONG);
1056 NTSTATUS WINAPI ZwSetIoCompletion(HANDLE,ULONG,ULONG,NTSTATUS,ULONG);
1057 NTSTATUS WINAPI ZwSetSecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
1058 NTSTATUS WINAPI ZwSetSystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG);
1059 NTSTATUS WINAPI ZwSetSystemTime(const LARGE_INTEGER*,LARGE_INTEGER*);
1060 NTSTATUS WINAPI ZwSetTimer(HANDLE, const LARGE_INTEGER*, PTIMER_APC_ROUTINE, PVOID, BOOLEAN, ULONG, BOOLEAN*);
1061 NTSTATUS WINAPI ZwSetValueKey(HANDLE,const UNICODE_STRING *,ULONG,ULONG,const void *,ULONG);
1062 NTSTATUS WINAPI ZwSetVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FS_INFORMATION_CLASS);
1063 NTSTATUS WINAPI ZwSuspendThread(HANDLE,PULONG);
1064 NTSTATUS WINAPI ZwTerminateProcess(HANDLE,LONG);
1065 NTSTATUS WINAPI ZwUnloadDriver(const UNICODE_STRING *);
1066 NTSTATUS WINAPI ZwUnloadKey(HANDLE);
1067 NTSTATUS WINAPI ZwUnmapViewOfSection(HANDLE,PVOID);
1068 NTSTATUS WINAPI ZwWaitForSingleObject(HANDLE,BOOLEAN,const LARGE_INTEGER*);
1069 NTSTATUS WINAPI ZwWaitForMultipleObjects(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
1070 NTSTATUS WINAPI ZwWriteFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,const void*,ULONG,PLARGE_INTEGER,PULONG);
1071 NTSTATUS WINAPI ZwYieldExecution(void);