kernel32: Use the Mach host_info(HOST_BASIC_INFO) API to obtain total RAM after tryin...
[wine/multimedia.git] / include / ddk / wdm.h
blob29b24e729947802b349a10f546d553af92830624
1 /*
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
19 #ifndef _WDMDDK_
20 #define _WDMDDK_
21 #define _NTDDK_
23 #include <ntstatus.h>
25 #ifdef _WIN64
26 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
27 #else
28 #define POINTER_ALIGNMENT
29 #endif
31 typedef LONG KPRIORITY;
33 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
35 struct _KDPC;
36 struct _KAPC;
37 struct _IRP;
38 struct _DEVICE_OBJECT;
39 struct _DRIVER_OBJECT;
41 typedef VOID (WINAPI *PKDEFERRED_ROUTINE)(struct _KDPC *, PVOID, PVOID, PVOID);
42 typedef VOID (WINAPI *PKSTART_ROUTINE)(PVOID);
44 typedef NTSTATUS (WINAPI *PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT *, PUNICODE_STRING);
45 typedef NTSTATUS (WINAPI *PDRIVER_DISPATCH)(struct _DEVICE_OBJECT *, struct _IRP *);
46 typedef void (WINAPI *PDRIVER_STARTIO)(struct _DEVICE_OBJECT *, struct _IRP *);
47 typedef void (WINAPI *PDRIVER_UNLOAD)(struct _DRIVER_OBJECT *);
49 typedef struct _DISPATCHER_HEADER {
50 UCHAR Type;
51 UCHAR Absolute;
52 UCHAR Size;
53 UCHAR Inserted;
54 LONG SignalState;
55 LIST_ENTRY WaitListHead;
56 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
58 typedef struct _KEVENT {
59 DISPATCHER_HEADER Header;
60 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
62 typedef struct _KSEMAPHORE {
63 DISPATCHER_HEADER Header;
64 LONG Limit;
65 } KSEMAPHORE, *PKSEMAPHORE, *PRKSEMAPHORE;
67 typedef struct _KDPC {
68 CSHORT Type;
69 UCHAR Number;
70 UCHAR Importance;
71 LIST_ENTRY DpcListEntry;
72 PKDEFERRED_ROUTINE DeferredRoutine;
73 PVOID DeferredContext;
74 PVOID SystemArgument1;
75 PVOID SystemArgument2;
76 PULONG_PTR Lock;
77 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
79 typedef struct _KDEVICE_QUEUE_ENTRY {
80 LIST_ENTRY DeviceListEntry;
81 ULONG SortKey;
82 BOOLEAN Inserted;
83 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
84 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
86 typedef struct _KDEVICE_QUEUE {
87 CSHORT Type;
88 CSHORT Size;
89 LIST_ENTRY DeviceListHead;
90 KSPIN_LOCK Lock;
91 BOOLEAN Busy;
92 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
94 typedef struct _KMUTANT {
95 DISPATCHER_HEADER Header;
96 LIST_ENTRY MutantListEntry;
97 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
98 BOOLEAN Abandoned;
99 UCHAR ApcDisable;
100 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
102 typedef enum _KWAIT_REASON
104 Executive,
105 FreePage,
106 PageIn,
107 PoolAllocation,
108 DelayExecution,
109 Suspended,
110 UserRequest,
111 WrExecutive,
112 WrFreePage,
113 WrPageIn,
114 WrDelayExecution,
115 WrSuspended,
116 WrUserRequest,
117 WrQueue,
118 WrLpcReceive,
119 WrLpcReply,
120 WrVirtualMemory,
121 WrPageOut,
122 WrRendezvous,
123 Spare2,
124 Spare3,
125 Spare4,
126 Spare5,
127 Spare6,
128 WrKernel,
129 MaximumWaitReason,
130 } KWAIT_REASON;
132 typedef struct _ALLOCATE_FUNCTION *PALLOCATE_FUNCTION;
133 typedef struct _IO_TIMER *PIO_TIMER;
134 typedef struct _IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE;
135 typedef struct _ETHREAD *PETHREAD;
136 typedef struct _FREE_FUNCTION *PFREE_FUNCTION;
137 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
138 typedef struct _EPROCESS *PEPROCESS;
139 typedef struct _ERESOURCE *PERESOURCE;
140 typedef struct _IO_WORKITEM *PIO_WORKITEM;
141 typedef struct _NPAGED_LOOKASIDE_LIST *PNPAGED_LOOKASIDE_LIST;
142 typedef struct _PAGED_LOOKASIDE_LIST *PPAGED_LOOKASIDE_LIST;
143 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
144 typedef struct _OBJECT_HANDLE_INFORMATION *POBJECT_HANDLE_INFORMATION;
145 typedef struct _ZONE_HEADER *PZONE_HEADER;
147 typedef struct _FAST_MUTEX
149 LONG Count;
150 PKTHREAD Owner;
151 ULONG Contention;
152 KEVENT Gate;
153 ULONG OldIrql;
154 } FAST_MUTEX, *PFAST_MUTEX;
156 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
158 typedef struct _VPB {
159 CSHORT Type;
160 CSHORT Size;
161 USHORT Flags;
162 USHORT VolumeLabelLength;
163 struct _DEVICE_OBJECT *DeviceObject;
164 struct _DEVICE_OBJECT *RealDevice;
165 ULONG SerialNumber;
166 ULONG ReferenceCount;
167 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
168 } VPB, *PVPB;
170 typedef enum _POOL_TYPE {
171 NonPagedPool,
172 PagedPool,
173 NonPagedPoolMustSucceed,
174 DontUseThisType,
175 NonPagedPoolCacheAligned,
176 PagedPoolCacheAligned,
177 NonPagedPoolCacheAlignedMustS,
178 MaxPoolType
179 } POOL_TYPE;
181 typedef struct _WAIT_CONTEXT_BLOCK {
182 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
183 struct _DRIVER_CONTROL *DeviceRoutine;
184 PVOID DeviceContext;
185 ULONG NumberOfMapRegisters;
186 PVOID DeviceObject;
187 PVOID CurrentIrp;
188 PKDPC BufferChainingDpc;
189 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
191 #define DO_BUFFERED_IO 0x00000004
192 #define DO_EXCLUSIVE 0x00000008
193 #define DO_DIRECT_IO 0x00000010
194 #define DO_MAP_IO_BUFFER 0x00000020
195 #define DO_DEVICE_INITIALIZING 0x00000080
196 #define DO_SHUTDOWN_REGISTERED 0x00000800
197 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
198 #define DO_POWER_PAGABLE 0x00002000
199 #define DO_POWER_INRUSH 0x00004000
201 #define IO_NO_INCREMENT 0
202 #define IO_CD_ROM_INCREMENT 1
203 #define IO_DISK_INCREMENT 1
204 #define IO_KEYBOARD_INCREMENT 6
205 #define IO_MAILSLOT_INCREMENT 2
206 #define IO_MOUSE_INCREMENT 6
207 #define IO_NAMED_PIPE_INCREMENT 2
208 #define IO_NETWORK_INCREMENT 2
209 #define IO_PARALLEL_INCREMENT 1
210 #define IO_SERIAL_INCREMENT 2
211 #define IO_SOUND_INCREMENT 8
212 #define IO_VIDEO_INCREMENT 1
214 #ifndef DEVICE_TYPE
215 #define DEVICE_TYPE ULONG
216 #endif
217 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
218 #define IRP_MJ_CREATE 0x00
219 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
220 #define IRP_MJ_CLOSE 0x02
221 #define IRP_MJ_READ 0x03
222 #define IRP_MJ_WRITE 0x04
223 #define IRP_MJ_QUERY_INFORMATION 0x05
224 #define IRP_MJ_SET_INFORMATION 0x06
225 #define IRP_MJ_QUERY_EA 0x07
226 #define IRP_MJ_SET_EA 0x08
227 #define IRP_MJ_FLUSH_BUFFERS 0x09
228 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
229 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
230 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
231 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
232 #define IRP_MJ_DEVICE_CONTROL 0x0e
233 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
234 #define IRP_MJ_SHUTDOWN 0x10
235 #define IRP_MJ_LOCK_CONTROL 0x11
236 #define IRP_MJ_CLEANUP 0x12
237 #define IRP_MJ_CREATE_MAILSLOT 0x13
238 #define IRP_MJ_QUERY_SECURITY 0x14
239 #define IRP_MJ_SET_SECURITY 0x15
240 #define IRP_MJ_POWER 0x16
241 #define IRP_MJ_SYSTEM_CONTROL 0x17
242 #define IRP_MJ_DEVICE_CHANGE 0x18
243 #define IRP_MJ_QUERY_QUOTA 0x19
244 #define IRP_MJ_SET_QUOTA 0x1a
245 #define IRP_MJ_PNP 0x1b
247 #define IRP_MN_START_DEVICE 0x00
248 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
249 #define IRP_MN_REMOVE_DEVICE 0x02
250 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
251 #define IRP_MN_STOP_DEVICE 0x04
252 #define IRP_MN_QUERY_STOP_DEVICE 0x05
253 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
254 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
255 #define IRP_MN_QUERY_INTERFACE 0x08
256 #define IRP_MN_QUERY_CAPABILITIES 0x09
257 #define IRP_MN_QUERY_RESOURCES 0x0A
258 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
259 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
260 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
261 #define IRP_MN_READ_CONFIG 0x0F
262 #define IRP_MN_WRITE_CONFIG 0x10
263 #define IRP_MN_EJECT 0x11
264 #define IRP_MN_SET_LOCK 0x12
265 #define IRP_MN_QUERY_ID 0x13
266 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
267 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
268 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
269 #define IRP_MN_SURPRISE_REMOVAL 0x17
270 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
272 #define IRP_QUOTA_CHARGED 0x01
273 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
274 #define IRP_ALLOCATED_FIXED_SIZE 0x04
275 #define IRP_LOOKASIDE_ALLOCATION 0x08
277 #define IO_TYPE_ADAPTER 0x01
278 #define IO_TYPE_CONTROLLER 0x02
279 #define IO_TYPE_DEVICE 0x03
280 #define IO_TYPE_DRIVER 0x04
281 #define IO_TYPE_FILE 0x05
282 #define IO_TYPE_IRP 0x06
283 #define IO_TYPE_MASTER_ADAPTER 0x07
284 #define IO_TYPE_OPEN_PACKET 0x08
285 #define IO_TYPE_TIMER 0x09
286 #define IO_TYPE_VPB 0x0a
287 #define IO_TYPE_ERROR_LOG 0x0b
288 #define IO_TYPE_ERROR_MESSAGE 0x0c
289 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 0x0d
291 typedef struct _DEVICE_OBJECT {
292 CSHORT Type;
293 USHORT Size;
294 LONG ReferenceCount;
295 struct _DRIVER_OBJECT *DriverObject;
296 struct _DEVICE_OBJECT *NextDevice;
297 struct _DEVICE_OBJECT *AttachedDevice;
298 struct _IRP *CurrentIrp;
299 PIO_TIMER Timer;
300 ULONG Flags;
301 ULONG Characteristics;
302 PVPB Vpb;
303 PVOID DeviceExtension;
304 DEVICE_TYPE DeviceType;
305 CCHAR StackSize;
306 union {
307 LIST_ENTRY ListEntry;
308 WAIT_CONTEXT_BLOCK Wcb;
309 } Queue;
310 ULONG AlignmentRequirement;
311 KDEVICE_QUEUE DeviceQueue;
312 KDPC Dpc;
313 ULONG ActiveThreadCount;
314 PSECURITY_DESCRIPTOR SecurityDescriptor;
315 KEVENT DeviceLock;
316 USHORT SectorSize;
317 USHORT Spare1;
318 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
319 PVOID Reserved;
320 } DEVICE_OBJECT;
321 typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT;
323 typedef struct _DEVICE_RELATIONS {
324 ULONG Count;
325 PDEVICE_OBJECT Objects[1];
326 } DEVICE_RELATIONS;
327 typedef struct _DEVICE_RELATIONS *PDEVICE_RELATIONS;
329 typedef struct _DRIVER_EXTENSION {
330 struct _DRIVER_OBJECT *DriverObject;
331 PVOID AddDevice;
332 ULONG Count;
333 UNICODE_STRING ServiceKeyName;
334 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
336 typedef struct _DRIVER_OBJECT {
337 CSHORT Type;
338 CSHORT Size;
339 PDEVICE_OBJECT DeviceObject;
340 ULONG Flags;
341 PVOID DriverStart;
342 ULONG DriverSize;
343 PVOID DriverSection;
344 PDRIVER_EXTENSION DriverExtension;
345 UNICODE_STRING DriverName;
346 PUNICODE_STRING HardwareDatabase;
347 PVOID FastIoDispatch;
348 PDRIVER_INITIALIZE DriverInit;
349 PDRIVER_STARTIO DriverStartIo;
350 PDRIVER_UNLOAD DriverUnload;
351 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
352 } DRIVER_OBJECT;
353 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
355 /* Irp definitions */
356 typedef UCHAR KIRQL, *PKIRQL;
357 typedef CCHAR KPROCESSOR_MODE;
359 typedef VOID (WINAPI *PDRIVER_CANCEL)(
360 IN struct _DEVICE_OBJECT *DeviceObject,
361 IN struct _IRP *Irp);
363 typedef VOID (WINAPI *PKNORMAL_ROUTINE)(
364 IN PVOID NormalContext,
365 IN PVOID SystemArgument1,
366 IN PVOID SystemArgument2);
368 typedef VOID (WINAPI *PKKERNEL_ROUTINE)(
369 IN struct _KAPC *Apc,
370 IN OUT PKNORMAL_ROUTINE *NormalRoutine,
371 IN OUT PVOID *NormalContext,
372 IN OUT PVOID *SystemArgument1,
373 IN OUT PVOID *SystemArgument2);
375 typedef VOID (WINAPI *PKRUNDOWN_ROUTINE)(
376 IN struct _KAPC *Apc);
378 typedef struct _KAPC {
379 CSHORT Type;
380 CSHORT Size;
381 ULONG Spare0;
382 struct _KTHREAD *Thread;
383 LIST_ENTRY ApcListEntry;
384 PKKERNEL_ROUTINE KernelRoutine;
385 PKRUNDOWN_ROUTINE RundownRoutine;
386 PKNORMAL_ROUTINE NormalRoutine;
387 PVOID NormalContext;
388 PVOID SystemArgument1;
389 PVOID SystemArgument2;
390 CCHAR ApcStateIndex;
391 KPROCESSOR_MODE ApcMode;
392 BOOLEAN Inserted;
393 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
395 #include <pshpack1.h>
396 typedef struct _IRP {
397 CSHORT Type;
398 USHORT Size;
399 struct _MDL *MdlAddress;
400 ULONG Flags;
401 union {
402 struct _IRP *MasterIrp;
403 LONG IrpCount;
404 PVOID SystemBuffer;
405 } AssociatedIrp;
406 LIST_ENTRY ThreadListEntry;
407 IO_STATUS_BLOCK IoStatus;
408 KPROCESSOR_MODE RequestorMode;
409 BOOLEAN PendingReturned;
410 CHAR StackCount;
411 CHAR CurrentLocation;
412 BOOLEAN Cancel;
413 KIRQL CancelIrql;
414 CCHAR ApcEnvironment;
415 UCHAR AllocationFlags;
416 PIO_STATUS_BLOCK UserIosb;
417 PKEVENT UserEvent;
418 union {
419 struct {
420 PIO_APC_ROUTINE UserApcRoutine;
421 PVOID UserApcContext;
422 } AsynchronousParameters;
423 LARGE_INTEGER AllocationSize;
424 } Overlay;
425 PDRIVER_CANCEL CancelRoutine;
426 PVOID UserBuffer;
427 union {
428 struct {
429 union {
430 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
431 struct {
432 PVOID DriverContext[4];
433 } DUMMYSTRUCTNAME;
434 } DUMMYUNIONNAME1;
435 PETHREAD Thread;
436 PCHAR AuxiliaryBuffer;
437 struct {
438 LIST_ENTRY ListEntry;
439 union {
440 struct _IO_STACK_LOCATION *CurrentStackLocation;
441 ULONG PacketType;
442 } DUMMYUNIONNAME2;
443 } DUMMYSTRUCTNAME;
444 struct _FILE_OBJECT *OriginalFileObject;
445 } Overlay;
446 KAPC Apc;
447 PVOID CompletionKey;
448 } Tail;
449 } IRP;
450 typedef struct _IRP *PIRP;
451 #include <poppack.h>
453 typedef VOID (WINAPI *PINTERFACE_REFERENCE)(
454 PVOID Context);
456 typedef VOID (WINAPI *PINTERFACE_DEREFERENCE)(
457 PVOID Context);
459 typedef struct _INTERFACE {
460 USHORT Size;
461 USHORT Version;
462 PVOID Context;
463 PINTERFACE_REFERENCE InterfaceReference;
464 PINTERFACE_DEREFERENCE InterfaceDereference;
465 } INTERFACE, *PINTERFACE;
467 typedef struct _SECTION_OBJECT_POINTERS {
468 PVOID DataSectionObject;
469 PVOID SharedCacheMap;
470 PVOID ImageSectionObject;
471 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
473 typedef struct _IO_COMPLETION_CONTEXT {
474 PVOID Port;
475 PVOID Key;
476 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
478 typedef enum _DEVICE_RELATION_TYPE {
479 BusRelations,
480 EjectionRelations,
481 PowerRelations,
482 RemovalRelations,
483 TargetDeviceRelation,
484 SingleBusRelations
485 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
487 typedef struct _FILE_OBJECT {
488 CSHORT Type;
489 CSHORT Size;
490 PDEVICE_OBJECT DeviceObject;
491 PVPB Vpb;
492 PVOID FsContext;
493 PVOID FsContext2;
494 PSECTION_OBJECT_POINTERS SectionObjectPointer;
495 PVOID PrivateCacheMap;
496 NTSTATUS FinalStatus;
497 struct _FILE_OBJECT *RelatedFileObject;
498 BOOLEAN LockOperation;
499 BOOLEAN DeletePending;
500 BOOLEAN ReadAccess;
501 BOOLEAN WriteAccess;
502 BOOLEAN DeleteAccess;
503 BOOLEAN SharedRead;
504 BOOLEAN SharedWrite;
505 BOOLEAN SharedDelete;
506 ULONG Flags;
507 UNICODE_STRING FileName;
508 LARGE_INTEGER CurrentByteOffset;
509 ULONG Waiters;
510 ULONG Busy;
511 PVOID LastLock;
512 KEVENT Lock;
513 KEVENT Event;
514 PIO_COMPLETION_CONTEXT CompletionContext;
515 } FILE_OBJECT;
516 typedef struct _FILE_OBJECT *PFILE_OBJECT;
518 #define INITIAL_PRIVILEGE_COUNT 3
520 typedef struct _INITIAL_PRIVILEGE_SET {
521 ULONG PrivilegeCount;
522 ULONG Control;
523 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
524 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
526 typedef struct _SECURITY_SUBJECT_CONTEXT {
527 PACCESS_TOKEN ClientToken;
528 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
529 PACCESS_TOKEN PrimaryToken;
530 PVOID ProcessAuditId;
531 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
533 typedef struct _ACCESS_STATE {
534 LUID OperationID;
535 BOOLEAN SecurityEvaluated;
536 BOOLEAN GenerateAudit;
537 BOOLEAN GenerateOnClose;
538 BOOLEAN PrivilegesAllocated;
539 ULONG Flags;
540 ACCESS_MASK RemainingDesiredAccess;
541 ACCESS_MASK PreviouslyGrantedAccess;
542 ACCESS_MASK OriginalDesiredAccess;
543 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
544 PSECURITY_DESCRIPTOR SecurityDescriptor;
545 PVOID AuxData;
546 union {
547 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
548 PRIVILEGE_SET PrivilegeSet;
549 } Privileges;
551 BOOLEAN AuditPrivileges;
552 UNICODE_STRING ObjectName;
553 UNICODE_STRING ObjectTypeName;
554 } ACCESS_STATE, *PACCESS_STATE;
556 typedef struct _IO_SECURITY_CONTEXT {
557 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
558 PACCESS_STATE AccessState;
559 ACCESS_MASK DesiredAccess;
560 ULONG FullCreateOptions;
561 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
563 typedef struct _DEVICE_CAPABILITIES {
564 USHORT Size;
565 USHORT Version;
566 ULONG DeviceD1 : 1;
567 ULONG DeviceD2 : 1;
568 ULONG LockSupported : 1;
569 ULONG EjectSupported : 1;
570 ULONG Removable : 1;
571 ULONG DockDevice : 1;
572 ULONG UniqueID : 1;
573 ULONG SilentInstall : 1;
574 ULONG RawDeviceOK : 1;
575 ULONG SurpriseRemovalOK : 1;
576 ULONG WakeFromD0 : 1;
577 ULONG WakeFromD1 : 1;
578 ULONG WakeFromD2 : 1;
579 ULONG WakeFromD3 : 1;
580 ULONG HardwareDisabled : 1;
581 ULONG NonDynamic : 1;
582 ULONG WarmEjectSupported : 1;
583 ULONG NoDisplayInUI : 1;
584 ULONG Reserved : 14;
585 ULONG Address;
586 ULONG UINumber;
587 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
588 SYSTEM_POWER_STATE SystemWake;
589 DEVICE_POWER_STATE DeviceWake;
590 ULONG D1Latency;
591 ULONG D2Latency;
592 ULONG D3Latency;
593 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
595 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
596 USHORT Version;
597 USHORT Size;
598 GUID Event;
599 GUID InterfaceClassGuid;
600 PUNICODE_STRING SymbolicLinkName;
601 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
603 typedef enum _INTERFACE_TYPE {
604 InterfaceTypeUndefined = -1,
605 Internal,
606 Isa,
607 Eisa,
608 MicroChannel,
609 TurboChannel,
610 PCIBus,
611 VMEBus,
612 NuBus,
613 PCMCIABus,
614 CBus,
615 MPIBus,
616 MPSABus,
617 ProcessorInternal,
618 InternalPowerBus,
619 PNPISABus,
620 PNPBus,
621 MaximumInterfaceType
622 } INTERFACE_TYPE, *PINTERFACE_TYPE;
624 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
626 #define IO_RESOURCE_PREFERRED 0x01
627 #define IO_RESOURCE_DEFAULT 0x02
628 #define IO_RESOURCE_ALTERNATIVE 0x08
630 typedef struct _IO_RESOURCE_DESCRIPTOR {
631 UCHAR Option;
632 UCHAR Type;
633 UCHAR ShareDisposition;
634 UCHAR Spare1;
635 USHORT Flags;
636 USHORT Spare2;
637 union {
638 struct {
639 ULONG Length;
640 ULONG Alignment;
641 PHYSICAL_ADDRESS MinimumAddress;
642 PHYSICAL_ADDRESS MaximumAddress;
643 } Port;
644 struct {
645 ULONG Length;
646 ULONG Alignment;
647 PHYSICAL_ADDRESS MinimumAddress;
648 PHYSICAL_ADDRESS MaximumAddress;
649 } Memory;
650 struct {
651 ULONG MinimumVector;
652 ULONG MaximumVector;
653 } Interrupt;
654 struct {
655 ULONG MinimumChannel;
656 ULONG MaximumChannel;
657 } Dma;
658 struct {
659 ULONG Length;
660 ULONG Alignment;
661 PHYSICAL_ADDRESS MinimumAddress;
662 PHYSICAL_ADDRESS MaximumAddress;
663 } Generic;
664 struct {
665 ULONG Data[3];
666 } DevicePrivate;
667 struct {
668 ULONG Length;
669 ULONG MinBusNumber;
670 ULONG MaxBusNumber;
671 ULONG Reserved;
672 } BusNumber;
673 struct {
674 ULONG Priority;
675 ULONG Reserved1;
676 ULONG Reserved2;
677 } ConfigData;
678 } u;
679 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
681 typedef struct _IO_RESOURCE_LIST {
682 USHORT Version;
683 USHORT Revision;
684 ULONG Count;
685 IO_RESOURCE_DESCRIPTOR Descriptors[1];
686 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
688 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
689 ULONG ListSize;
690 INTERFACE_TYPE InterfaceType;
691 ULONG BusNumber;
692 ULONG SlotNumber;
693 ULONG Reserved[3];
694 ULONG AlternativeLists;
695 IO_RESOURCE_LIST List[1];
696 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
698 typedef enum _BUS_QUERY_ID_TYPE {
699 BusQueryDeviceID,
700 BusQueryHardwareIDs,
701 BusQueryCompatibleIDs,
702 BusQueryInstanceID,
703 BusQueryDeviceSerialNumber
704 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
706 typedef enum {
707 DevicePropertyDeviceDescription,
708 DevicePropertyHardwareID,
709 DevicePropertyCompatibleIDs,
710 DevicePropertyBootConfiguration,
711 DevicePropertyBootConfigurationTranslated,
712 DevicePropertyClassName,
713 DevicePropertyClassGuid,
714 DevicePropertyDriverKeyName,
715 DevicePropertyManufacturer,
716 DevicePropertyFriendlyName,
717 DevicePropertyLocationInformation,
718 DevicePropertyPhysicalDeviceObjectName,
719 DevicePropertyBusTypeGuid,
720 DevicePropertyLegacyBusType,
721 DevicePropertyBusNumber,
722 DevicePropertyEnumeratorName,
723 DevicePropertyAddress,
724 DevicePropertyUINumber,
725 DevicePropertyInstallState,
726 DevicePropertyRemovalPolicy
727 } DEVICE_REGISTRY_PROPERTY;
729 typedef enum _DEVICE_TEXT_TYPE {
730 DeviceTextDescription,
731 DeviceTextLocationInformation
732 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
734 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
735 DeviceUsageTypeUndefined,
736 DeviceUsageTypePaging,
737 DeviceUsageTypeHibernation,
738 DeviceUsageTypeDumpFile
739 } DEVICE_USAGE_NOTIFICATION_TYPE;
741 typedef struct _POWER_SEQUENCE {
742 ULONG SequenceD1;
743 ULONG SequenceD2;
744 ULONG SequenceD3;
745 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
747 typedef enum _POWER_STATE_TYPE {
748 SystemPowerState,
749 DevicePowerState
750 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
752 typedef union _POWER_STATE {
753 SYSTEM_POWER_STATE SystemState;
754 DEVICE_POWER_STATE DeviceState;
755 } POWER_STATE, *PPOWER_STATE;
757 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
758 UCHAR Type;
759 UCHAR ShareDisposition;
760 USHORT Flags;
761 union {
762 struct {
763 PHYSICAL_ADDRESS Start;
764 ULONG Length;
765 } Generic;
766 struct {
767 PHYSICAL_ADDRESS Start;
768 ULONG Length;
769 } Port;
770 struct {
771 ULONG Level;
772 ULONG Vector;
773 ULONG Affinity;
774 } Interrupt;
775 struct {
776 PHYSICAL_ADDRESS Start;
777 ULONG Length;
778 } Memory;
779 struct {
780 ULONG Channel;
781 ULONG Port;
782 ULONG Reserved1;
783 } Dma;
784 struct {
785 ULONG Data[3];
786 } DevicePrivate;
787 struct {
788 ULONG Start;
789 ULONG Length;
790 ULONG Reserved;
791 } BusNumber;
792 struct {
793 ULONG DataSize;
794 ULONG Reserved1;
795 ULONG Reserved2;
796 } DeviceSpecificData;
797 } u;
798 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
800 typedef struct _CM_PARTIAL_RESOURCE_LIST {
801 USHORT Version;
802 USHORT Revision;
803 ULONG Count;
804 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
805 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
807 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
808 INTERFACE_TYPE InterfaceType;
809 ULONG BusNumber;
810 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
811 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
813 typedef struct _CM_RESOURCE_LIST {
814 ULONG Count;
815 CM_FULL_RESOURCE_DESCRIPTOR List[1];
816 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
818 typedef NTSTATUS (WINAPI *PIO_COMPLETION_ROUTINE)(
819 IN struct _DEVICE_OBJECT *DeviceObject,
820 IN struct _IRP *Irp,
821 IN PVOID Context);
823 #define SL_PENDING_RETURNED 0x01
824 #define SL_INVOKE_ON_CANCEL 0x20
825 #define SL_INVOKE_ON_SUCCESS 0x40
826 #define SL_INVOKE_ON_ERROR 0x80
828 #include <pshpack1.h>
829 typedef struct _IO_STACK_LOCATION {
830 UCHAR MajorFunction;
831 UCHAR MinorFunction;
832 UCHAR Flags;
833 UCHAR Control;
834 union {
835 struct {
836 PIO_SECURITY_CONTEXT SecurityContext;
837 ULONG Options;
838 USHORT POINTER_ALIGNMENT FileAttributes;
839 USHORT ShareAccess;
840 ULONG POINTER_ALIGNMENT EaLength;
841 } Create;
842 struct {
843 ULONG Length;
844 ULONG POINTER_ALIGNMENT Key;
845 LARGE_INTEGER ByteOffset;
846 } Read;
847 struct {
848 ULONG Length;
849 ULONG POINTER_ALIGNMENT Key;
850 LARGE_INTEGER ByteOffset;
851 } Write;
852 struct {
853 ULONG Length;
854 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
855 } QueryFile;
856 struct {
857 ULONG Length;
858 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
859 PFILE_OBJECT FileObject;
860 union {
861 struct {
862 BOOLEAN ReplaceIfExists;
863 BOOLEAN AdvanceOnly;
864 } DUMMYSTRUCTNAME;
865 ULONG ClusterCount;
866 HANDLE DeleteHandle;
867 } DUMMYUNIONNAME;
868 } SetFile;
869 struct {
870 ULONG Length;
871 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
872 } QueryVolume;
873 struct {
874 ULONG OutputBufferLength;
875 ULONG POINTER_ALIGNMENT InputBufferLength;
876 ULONG POINTER_ALIGNMENT IoControlCode;
877 PVOID Type3InputBuffer;
878 } DeviceIoControl;
879 struct {
880 SECURITY_INFORMATION SecurityInformation;
881 ULONG POINTER_ALIGNMENT Length;
882 } QuerySecurity;
883 struct {
884 SECURITY_INFORMATION SecurityInformation;
885 PSECURITY_DESCRIPTOR SecurityDescriptor;
886 } SetSecurity;
887 struct {
888 PVPB Vpb;
889 PDEVICE_OBJECT DeviceObject;
890 } MountVolume;
891 struct {
892 PVPB Vpb;
893 PDEVICE_OBJECT DeviceObject;
894 } VerifyVolume;
895 struct {
896 struct _SCSI_REQUEST_BLOCK *Srb;
897 } Scsi;
898 struct {
899 DEVICE_RELATION_TYPE Type;
900 } QueryDeviceRelations;
901 struct {
902 const GUID *InterfaceType;
903 USHORT Size;
904 USHORT Version;
905 PINTERFACE Interface;
906 PVOID InterfaceSpecificData;
907 } QueryInterface;
908 struct {
909 PDEVICE_CAPABILITIES Capabilities;
910 } DeviceCapabilities;
911 struct {
912 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
913 } FilterResourceRequirements;
914 struct {
915 ULONG WhichSpace;
916 PVOID Buffer;
917 ULONG Offset;
918 ULONG POINTER_ALIGNMENT Length;
919 } ReadWriteConfig;
920 struct {
921 BOOLEAN Lock;
922 } SetLock;
923 struct {
924 BUS_QUERY_ID_TYPE IdType;
925 } QueryId;
926 struct {
927 DEVICE_TEXT_TYPE DeviceTextType;
928 LCID POINTER_ALIGNMENT LocaleId;
929 } QueryDeviceText;
930 struct {
931 BOOLEAN InPath;
932 BOOLEAN Reserved[3];
933 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
934 } UsageNotification;
935 struct {
936 SYSTEM_POWER_STATE PowerState;
937 } WaitWake;
938 struct {
939 PPOWER_SEQUENCE PowerSequence;
940 } PowerSequence;
941 struct {
942 ULONG SystemContext;
943 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
944 POWER_STATE POINTER_ALIGNMENT State;
945 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
946 } Power;
947 struct {
948 PCM_RESOURCE_LIST AllocatedResources;
949 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
950 } StartDevice;
951 struct {
952 ULONG_PTR ProviderId;
953 PVOID DataPath;
954 ULONG BufferSize;
955 PVOID Buffer;
956 } WMI;
957 struct {
958 PVOID Argument1;
959 PVOID Argument2;
960 PVOID Argument3;
961 PVOID Argument4;
962 } Others;
963 } Parameters;
964 PDEVICE_OBJECT DeviceObject;
965 PFILE_OBJECT FileObject;
966 PIO_COMPLETION_ROUTINE CompletionRoutine;
967 PVOID Context;
968 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
969 #include <poppack.h>
971 /* MDL definitions */
973 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
974 #define MDL_PAGES_LOCKED 0x0002
975 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
976 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
977 #define MDL_PARTIAL 0x0010
978 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
979 #define MDL_IO_PAGE_READ 0x0040
980 #define MDL_WRITE_OPERATION 0x0080
981 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
982 #define MDL_FREE_EXTRA_PTES 0x0200
983 #define MDL_DESCRIBES_AWE 0x0400
984 #define MDL_IO_SPACE 0x0800
985 #define MDL_NETWORK_HEADER 0x1000
986 #define MDL_MAPPING_CAN_FAIL 0x2000
987 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
988 #define MDL_INTERNAL 0x8000
990 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
991 MDL_PAGES_LOCKED | \
992 MDL_SOURCE_IS_NONPAGED_POOL | \
993 MDL_PARTIAL_HAS_BEEN_MAPPED | \
994 MDL_PARENT_MAPPED_SYSTEM_VA | \
995 MDL_SYSTEM_VA | \
996 MDL_IO_SPACE )
998 typedef struct _MDL {
999 struct _MDL *Next;
1000 CSHORT Size;
1001 CSHORT MdlFlags;
1002 struct _EPROCESS *Process;
1003 PVOID MappedSystemVa;
1004 PVOID StartVa;
1005 ULONG ByteCount;
1006 ULONG ByteOffset;
1007 } MDL, *PMDL;
1009 typedef MDL *PMDLX;
1011 typedef struct _KTIMER {
1012 DISPATCHER_HEADER Header;
1013 ULARGE_INTEGER DueTime;
1014 LIST_ENTRY TimerListEntry;
1015 struct _KDPC *Dpc;
1016 LONG Period;
1017 } KTIMER, *PKTIMER;
1019 typedef struct _KSYSTEM_TIME {
1020 ULONG LowPart;
1021 LONG High1Time;
1022 LONG High2Time;
1023 } KSYSTEM_TIME, *PKSYSTEM_TIME;
1025 typedef enum _NT_PRODUCT_TYPE {
1026 NtProductWinNt = 1,
1027 NtProductLanManNt,
1028 NtProductServer
1029 } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
1031 #define PROCESSOR_FEATURE_MAX 64
1033 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
1035 StandardDesign,
1036 NEC98x86,
1037 EndAlternatives
1038 } ALTERNATIVE_ARCHITECTURE_TYPE;
1040 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
1041 #define NX_SUPPORT_POLICY_ALWAYSON 1
1042 #define NX_SUPPORT_POLICY_OPTIN 2
1043 #define NX_SUPPORT_POLICY_OPTOUT 3
1045 #define MAX_WOW64_SHARED_ENTRIES 16
1047 typedef struct _KUSER_SHARED_DATA {
1048 ULONG TickCountLowDeprecated;
1049 ULONG TickCountMultiplier;
1050 volatile KSYSTEM_TIME InterruptTime;
1051 volatile KSYSTEM_TIME SystemTime;
1052 volatile KSYSTEM_TIME TimeZoneBias;
1053 USHORT ImageNumberLow;
1054 USHORT ImageNumberHigh;
1055 WCHAR NtSystemRoot[260];
1056 ULONG MaxStackTraceDepth;
1057 ULONG CryptoExponent;
1058 ULONG TimeZoneId;
1059 ULONG LargePageMinimum;
1060 ULONG Reserved2[7];
1061 NT_PRODUCT_TYPE NtProductType;
1062 BOOLEAN ProductTypeIsValid;
1063 ULONG NtMajorVersion;
1064 ULONG NtMinorVersion;
1065 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
1066 ULONG Reserved1;
1067 ULONG Reserved3;
1068 volatile ULONG TimeSlip;
1069 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
1070 LARGE_INTEGER SystemExpirationDate;
1071 ULONG SuiteMask;
1072 BOOLEAN KdDebuggerEnabled;
1073 UCHAR NXSupportPolicy;
1074 volatile ULONG ActiveConsoleId;
1075 volatile ULONG DismountCount;
1076 ULONG ComPlusPackage;
1077 ULONG LastSystemRITEventTickCount;
1078 ULONG NumberOfPhysicalPages;
1079 BOOLEAN SafeBootMode;
1080 ULONG TraceLogging;
1081 ULONGLONG TestRetInstruction;
1082 ULONG SystemCall;
1083 ULONG SystemCallReturn;
1084 ULONGLONG SystemCallPad[3];
1085 union {
1086 volatile KSYSTEM_TIME TickCount;
1087 volatile ULONG64 TickCountQuad;
1088 } DUMMYUNIONNAME;
1089 ULONG Cookie;
1090 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
1091 } KSHARED_USER_DATA, *PKSHARED_USER_DATA;
1093 typedef enum _MEMORY_CACHING_TYPE {
1094 MmNonCached = 0,
1095 MmCached = 1,
1096 MmWriteCombined = 2,
1097 MmHardwareCoherentCached = 3,
1098 MmNonCachedUnordered = 4,
1099 MmUSWCCached = 5,
1100 MmMaximumCacheType = 6
1101 } MEMORY_CACHING_TYPE;
1103 typedef enum _MM_PAGE_PRIORITY {
1104 LowPagePriority,
1105 NormalPagePriority = 16,
1106 HighPagePriority = 32
1107 } MM_PAGE_PRIORITY;
1109 typedef enum _MM_SYSTEM_SIZE
1111 MmSmallSystem,
1112 MmMediumSystem,
1113 MmLargeSystem
1114 } MM_SYSTEMSIZE;
1116 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
1117 BOOLEAN Removed;
1118 BOOLEAN Reserved[3];
1119 LONG IoCount;
1120 KEVENT RemoveEvent;
1121 } IO_REMOVE_LOCK_COMMON_BLOCK;
1123 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK *PIO_REMOVE_LOCK_TRACKING_BLOCK;
1125 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
1126 LONG Signature;
1127 LONG HighWatermark;
1128 LONGLONG MaxLockedTicks;
1129 LONG AllocateTag;
1130 LIST_ENTRY LockList;
1131 KSPIN_LOCK Spin;
1132 LONG LowMemoryCount;
1133 ULONG Reserved1[4];
1134 PVOID Reserved2;
1135 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
1136 } IO_REMOVE_LOCK_DBG_BLOCK;
1138 typedef struct _IO_REMOVE_LOCK {
1139 IO_REMOVE_LOCK_COMMON_BLOCK Common;
1140 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
1141 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
1143 typedef enum {
1144 IoReadAccess,
1145 IoWriteAccess,
1146 IoModifyAccess
1147 } LOCK_OPERATION;
1149 typedef struct _CALLBACK_OBJECT
1151 ULONG Signature;
1152 KSPIN_LOCK Lock;
1153 LIST_ENTRY RegisteredCallbacks;
1154 BOOLEAN AllowMultipleCallbacks;
1155 UCHAR reserved[3];
1156 } CALLBACK_OBJECT, *PCALLBACK_OBJECT;
1158 NTSTATUS WINAPI ObCloseHandle(IN HANDLE handle);
1160 #ifdef NONAMELESSUNION
1161 # ifdef NONAMELESSSTRUCT
1162 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.u2.CurrentStackLocation)
1163 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.u2.CurrentStackLocation - 1)
1164 # else
1165 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.u2.CurrentStackLocation)
1166 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.u2.CurrentStackLocation - 1)
1167 # endif
1168 #else
1169 # ifdef NONAMELESSSTRUCT
1170 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.CurrentStackLocation)
1171 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.CurrentStackLocation - 1)
1172 # else
1173 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation)
1174 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation - 1)
1175 # endif
1176 #endif
1178 #define KernelMode 0
1179 #define UserMode 1
1181 /* directory object access rights */
1182 #define DIRECTORY_QUERY 0x0001
1183 #define DIRECTORY_TRAVERSE 0x0002
1184 #define DIRECTORY_CREATE_OBJECT 0x0004
1185 #define DIRECTORY_CREATE_SUBDIRECTORY 0x0008
1186 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
1188 /* symbolic link access rights */
1189 #define SYMBOLIC_LINK_QUERY 0x0001
1190 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
1192 PVOID WINAPI ExAllocatePool(POOL_TYPE,SIZE_T);
1193 PVOID WINAPI ExAllocatePoolWithQuota(POOL_TYPE,SIZE_T);
1194 PVOID WINAPI ExAllocatePoolWithTag(POOL_TYPE,SIZE_T,ULONG);
1195 PVOID WINAPI ExAllocatePoolWithQuotaTag(POOL_TYPE,SIZE_T,ULONG);
1196 void WINAPI ExFreePool(PVOID);
1197 void WINAPI ExFreePoolWithTag(PVOID,ULONG);
1199 NTSTATUS WINAPI IoAllocateDriverObjectExtension(PDRIVER_OBJECT,PVOID,ULONG,PVOID*);
1200 PVOID WINAPI IoAllocateErrorLogEntry(PVOID,UCHAR);
1201 PIRP WINAPI IoAllocateIrp(CCHAR,BOOLEAN);
1202 NTSTATUS WINAPI IoCallDriver(DEVICE_OBJECT*,IRP*);
1203 VOID WINAPI IoCompleteRequest(IRP*,UCHAR);
1204 NTSTATUS WINAPI IoCreateDevice(DRIVER_OBJECT*,ULONG,UNICODE_STRING*,DEVICE_TYPE,ULONG,BOOLEAN,DEVICE_OBJECT**);
1205 NTSTATUS WINAPI IoCreateDriver(UNICODE_STRING*,PDRIVER_INITIALIZE);
1206 NTSTATUS WINAPI IoCreateSymbolicLink(UNICODE_STRING*,UNICODE_STRING*);
1207 void WINAPI IoDeleteDevice(DEVICE_OBJECT*);
1208 void WINAPI IoDeleteDriver(DRIVER_OBJECT*);
1209 NTSTATUS WINAPI IoDeleteSymbolicLink(UNICODE_STRING*);
1210 void WINAPI IoFreeIrp(IRP*);
1211 PEPROCESS WINAPI IoGetCurrentProcess(void);
1212 NTSTATUS WINAPI IoGetDeviceInterfaces(const GUID*,PDEVICE_OBJECT,ULONG,PWSTR*);
1213 NTSTATUS WINAPI IoGetDeviceObjectPointer(UNICODE_STRING*,ACCESS_MASK,PFILE_OBJECT*,PDEVICE_OBJECT*);
1214 NTSTATUS WINAPI IoGetDeviceProperty(PDEVICE_OBJECT,DEVICE_REGISTRY_PROPERTY,ULONG,PVOID,PULONG);
1215 PVOID WINAPI IoGetDriverObjectExtension(PDRIVER_OBJECT,PVOID);
1216 PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject(PFILE_OBJECT);
1217 void WINAPI IoInitializeIrp(IRP*,USHORT,CCHAR);
1218 VOID WINAPI IoInitializeRemoveLockEx(PIO_REMOVE_LOCK,ULONG,ULONG,ULONG,ULONG);
1219 NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
1221 PKTHREAD WINAPI KeGetCurrentThread(void);
1222 void WINAPI KeQuerySystemTime(LARGE_INTEGER*);
1223 void WINAPI KeQueryTickCount(LARGE_INTEGER*);
1224 ULONG WINAPI KeQueryTimeIncrement(void);
1225 LONG WINAPI KeReleaseSemaphore(PRKSEMAPHORE,KPRIORITY,LONG,BOOLEAN);
1226 LONG WINAPI KeResetEvent(PRKEVENT);
1227 LONG WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN);
1228 KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
1230 PVOID WINAPI MmAllocateContiguousMemory(SIZE_T,PHYSICAL_ADDRESS);
1231 PVOID WINAPI MmAllocateNonCachedMemory(SIZE_T);
1232 PMDL WINAPI MmAllocatePagesForMdl(PHYSICAL_ADDRESS,PHYSICAL_ADDRESS,PHYSICAL_ADDRESS,SIZE_T);
1233 void WINAPI MmFreeNonCachedMemory(PVOID,SIZE_T);
1234 MM_SYSTEMSIZE WINAPI MmQuerySystemSize(void);
1236 NTSTATUS WINAPI ObReferenceObjectByHandle(HANDLE,ACCESS_MASK,POBJECT_TYPE,KPROCESSOR_MODE,PVOID*,POBJECT_HANDLE_INFORMATION);
1238 POWER_STATE WINAPI PoSetPowerState(PDEVICE_OBJECT,POWER_STATE_TYPE,POWER_STATE);
1239 NTSTATUS WINAPI PsCreateSystemThread(PHANDLE,ULONG,POBJECT_ATTRIBUTES,HANDLE,PCLIENT_ID,PKSTART_ROUTINE,PVOID);
1240 #define PsGetCurrentProcess() IoGetCurrentProcess()
1241 #define PsGetCurrentThread() ((PETHREAD)KeGetCurrentThread())
1242 HANDLE WINAPI PsGetCurrentProcessId(void);
1243 HANDLE WINAPI PsGetCurrentThreadId(void);
1244 BOOLEAN WINAPI PsGetVersion(ULONG*,ULONG*,ULONG*,UNICODE_STRING*);
1245 NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS);
1247 NTSTATUS WINAPI ZwAddBootEntry(PUNICODE_STRING,PUNICODE_STRING);
1248 NTSTATUS WINAPI ZwAccessCheckAndAuditAlarm(PUNICODE_STRING,HANDLE,PUNICODE_STRING,PUNICODE_STRING,PSECURITY_DESCRIPTOR,ACCESS_MASK,PGENERIC_MAPPING,BOOLEAN,PACCESS_MASK,PBOOLEAN,PBOOLEAN);
1249 NTSTATUS WINAPI ZwAdjustPrivilegesToken(HANDLE,BOOLEAN,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
1250 NTSTATUS WINAPI ZwAlertThread(HANDLE ThreadHandle);
1251 NTSTATUS WINAPI ZwAllocateVirtualMemory(HANDLE,PVOID*,ULONG,SIZE_T*,ULONG,ULONG);
1252 NTSTATUS WINAPI ZwCancelIoFile(HANDLE,PIO_STATUS_BLOCK);
1253 NTSTATUS WINAPI ZwCancelTimer(HANDLE, BOOLEAN*);
1254 NTSTATUS WINAPI ZwClearEvent(HANDLE);
1255 NTSTATUS WINAPI ZwClose(HANDLE);
1256 NTSTATUS WINAPI ZwCloseObjectAuditAlarm(PUNICODE_STRING,HANDLE,BOOLEAN);
1257 NTSTATUS WINAPI ZwConnectPort(PHANDLE,PUNICODE_STRING,PSECURITY_QUALITY_OF_SERVICE,PLPC_SECTION_WRITE,PLPC_SECTION_READ,PULONG,PVOID,PULONG);
1258 NTSTATUS WINAPI ZwCreateDirectoryObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1259 NTSTATUS WINAPI ZwCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
1260 NTSTATUS WINAPI ZwCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG);
1261 NTSTATUS WINAPI ZwCreateKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG);
1262 NTSTATUS WINAPI ZwCreateSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const LARGE_INTEGER*,ULONG,ULONG,HANDLE);
1263 NTSTATUS WINAPI ZwCreateSymbolicLinkObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PUNICODE_STRING);
1264 NTSTATUS WINAPI ZwCreateTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*, TIMER_TYPE);
1265 NTSTATUS WINAPI ZwDeleteAtom(RTL_ATOM);
1266 NTSTATUS WINAPI ZwDeleteFile(POBJECT_ATTRIBUTES);
1267 NTSTATUS WINAPI ZwDeleteKey(HANDLE);
1268 NTSTATUS WINAPI ZwDeleteValueKey(HANDLE,const UNICODE_STRING *);
1269 NTSTATUS WINAPI ZwDeviceIoControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
1270 NTSTATUS WINAPI ZwDisplayString(PUNICODE_STRING);
1271 NTSTATUS WINAPI ZwDuplicateObject(HANDLE,HANDLE,HANDLE,PHANDLE,ACCESS_MASK,ULONG,ULONG);
1272 NTSTATUS WINAPI ZwDuplicateToken(HANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,SECURITY_IMPERSONATION_LEVEL,TOKEN_TYPE,PHANDLE);
1273 NTSTATUS WINAPI ZwEnumerateKey(HANDLE,ULONG,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
1274 NTSTATUS WINAPI ZwEnumerateValueKey(HANDLE,ULONG,KEY_VALUE_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1275 NTSTATUS WINAPI ZwFlushInstructionCache(HANDLE,LPCVOID,SIZE_T);
1276 NTSTATUS WINAPI ZwFlushKey(HANDLE);
1277 NTSTATUS WINAPI ZwFlushVirtualMemory(HANDLE,LPCVOID*,SIZE_T*,ULONG);
1278 NTSTATUS WINAPI ZwFreeVirtualMemory(HANDLE,PVOID*,SIZE_T*,ULONG);
1279 NTSTATUS WINAPI ZwFsControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
1280 NTSTATUS WINAPI ZwInitiatePowerAction(POWER_ACTION,SYSTEM_POWER_STATE,ULONG,BOOLEAN);
1281 NTSTATUS WINAPI ZwLoadDriver(const UNICODE_STRING *);
1282 NTSTATUS WINAPI ZwLoadKey(const OBJECT_ATTRIBUTES *,OBJECT_ATTRIBUTES *);
1283 NTSTATUS WINAPI ZwLockVirtualMemory(HANDLE,PVOID*,SIZE_T*,ULONG);
1284 NTSTATUS WINAPI ZwMakeTemporaryObject(HANDLE);
1285 NTSTATUS WINAPI ZwMapViewOfSection(HANDLE,HANDLE,PVOID*,ULONG,SIZE_T,const LARGE_INTEGER*,SIZE_T*,SECTION_INHERIT,ULONG,ULONG);
1286 NTSTATUS WINAPI ZwNotifyChangeKey(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN);
1287 NTSTATUS WINAPI ZwOpenDirectoryObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1288 NTSTATUS WINAPI ZwOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
1289 NTSTATUS WINAPI ZwOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG);
1290 NTSTATUS WINAPI ZwOpenKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
1291 NTSTATUS WINAPI ZwOpenProcess(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
1292 NTSTATUS WINAPI ZwOpenProcessToken(HANDLE,DWORD,HANDLE *);
1293 NTSTATUS WINAPI ZwOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
1294 NTSTATUS WINAPI ZwOpenSymbolicLinkObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1295 NTSTATUS WINAPI ZwOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
1296 NTSTATUS WINAPI ZwOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *);
1297 NTSTATUS WINAPI ZwOpenTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*);
1298 NTSTATUS WINAPI ZwPowerInformation(POWER_INFORMATION_LEVEL,PVOID,ULONG,PVOID,ULONG);
1299 NTSTATUS WINAPI ZwPulseEvent(HANDLE,PULONG);
1300 NTSTATUS WINAPI ZwQueryDefaultLocale(BOOLEAN,LCID*);
1301 NTSTATUS WINAPI ZwQueryDefaultUILanguage(LANGID*);
1302 NTSTATUS WINAPI ZwQueryDirectoryFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS,BOOLEAN,PUNICODE_STRING,BOOLEAN);
1303 NTSTATUS WINAPI ZwQueryDirectoryObject(HANDLE,PDIRECTORY_BASIC_INFORMATION,ULONG,BOOLEAN,BOOLEAN,PULONG,PULONG);
1304 NTSTATUS WINAPI ZwQueryEaFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,BOOLEAN,PVOID,ULONG,PVOID,BOOLEAN);
1305 NTSTATUS WINAPI ZwQueryFullAttributesFile(const OBJECT_ATTRIBUTES*,FILE_NETWORK_OPEN_INFORMATION*);
1306 NTSTATUS WINAPI ZwQueryInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,LONG,FILE_INFORMATION_CLASS);
1307 NTSTATUS WINAPI ZwQueryInformationThread(HANDLE,THREADINFOCLASS,PVOID,ULONG,PULONG);
1308 NTSTATUS WINAPI ZwQueryInformationToken(HANDLE,DWORD,PVOID,DWORD,LPDWORD);
1309 NTSTATUS WINAPI ZwQueryInstallUILanguage(LANGID*);
1310 NTSTATUS WINAPI ZwQueryKey(HANDLE,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
1311 NTSTATUS WINAPI ZwQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
1312 NTSTATUS WINAPI ZwQuerySecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,ULONG,PULONG);
1313 NTSTATUS WINAPI ZwQuerySection(HANDLE,SECTION_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1314 NTSTATUS WINAPI ZwQuerySymbolicLinkObject(HANDLE,PUNICODE_STRING,PULONG);
1315 NTSTATUS WINAPI ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1316 NTSTATUS WINAPI ZwQueryTimerResolution(PULONG,PULONG,PULONG);
1317 NTSTATUS WINAPI ZwQueryValueKey(HANDLE,const UNICODE_STRING *,KEY_VALUE_INFORMATION_CLASS,void *,DWORD,DWORD *);
1318 NTSTATUS WINAPI ZwQueryVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FS_INFORMATION_CLASS);
1319 NTSTATUS WINAPI ZwReadFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,PLARGE_INTEGER,PULONG);
1320 NTSTATUS WINAPI ZwReplaceKey(POBJECT_ATTRIBUTES,HANDLE,POBJECT_ATTRIBUTES);
1321 NTSTATUS WINAPI ZwRequestWaitReplyPort(HANDLE,PLPC_MESSAGE,PLPC_MESSAGE);
1322 NTSTATUS WINAPI ZwResetEvent(HANDLE,PULONG);
1323 NTSTATUS WINAPI ZwRestoreKey(HANDLE,HANDLE,ULONG);
1324 NTSTATUS WINAPI ZwSaveKey(HANDLE,HANDLE);
1325 NTSTATUS WINAPI ZwSecureConnectPort(PHANDLE,PUNICODE_STRING,PSECURITY_QUALITY_OF_SERVICE,PLPC_SECTION_WRITE,PSID,PLPC_SECTION_READ,PULONG,PVOID,PULONG);
1326 NTSTATUS WINAPI ZwSetDefaultLocale(BOOLEAN,LCID);
1327 NTSTATUS WINAPI ZwSetDefaultUILanguage(LANGID);
1328 NTSTATUS WINAPI ZwSetEaFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG);
1329 NTSTATUS WINAPI ZwSetEvent(HANDLE,PULONG);
1330 NTSTATUS WINAPI ZwSetInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS);
1331 NTSTATUS WINAPI ZwSetInformationKey(HANDLE,const int,PVOID,ULONG);
1332 NTSTATUS WINAPI ZwSetInformationObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG);
1333 NTSTATUS WINAPI ZwSetInformationProcess(HANDLE,PROCESS_INFORMATION_CLASS,PVOID,ULONG);
1334 NTSTATUS WINAPI ZwSetInformationThread(HANDLE,THREADINFOCLASS,LPCVOID,ULONG);
1335 NTSTATUS WINAPI ZwSetIoCompletion(HANDLE,ULONG,ULONG,NTSTATUS,ULONG);
1336 NTSTATUS WINAPI ZwSetSecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
1337 NTSTATUS WINAPI ZwSetSystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG);
1338 NTSTATUS WINAPI ZwSetSystemTime(const LARGE_INTEGER*,LARGE_INTEGER*);
1339 NTSTATUS WINAPI ZwSetTimer(HANDLE, const LARGE_INTEGER*, PTIMER_APC_ROUTINE, PVOID, BOOLEAN, ULONG, BOOLEAN*);
1340 NTSTATUS WINAPI ZwSetValueKey(HANDLE,const UNICODE_STRING *,ULONG,ULONG,const void *,ULONG);
1341 NTSTATUS WINAPI ZwSetVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FS_INFORMATION_CLASS);
1342 NTSTATUS WINAPI ZwSuspendThread(HANDLE,PULONG);
1343 NTSTATUS WINAPI ZwTerminateProcess(HANDLE,LONG);
1344 NTSTATUS WINAPI ZwUnloadDriver(const UNICODE_STRING *);
1345 NTSTATUS WINAPI ZwUnloadKey(HANDLE);
1346 NTSTATUS WINAPI ZwUnmapViewOfSection(HANDLE,PVOID);
1347 NTSTATUS WINAPI ZwWaitForSingleObject(HANDLE,BOOLEAN,const LARGE_INTEGER*);
1348 NTSTATUS WINAPI ZwWaitForMultipleObjects(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
1349 NTSTATUS WINAPI ZwWriteFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,const void*,ULONG,PLARGE_INTEGER,PULONG);
1350 NTSTATUS WINAPI ZwYieldExecution(void);
1352 #endif