ntoskrnl: Add ExGetPreviousMode and test.
[wine.git] / include / ddk / wdm.h
blobbf240f4fe532ab1f8e57a3367d305576d6457270
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>
24 #include <devpropdef.h>
26 #ifdef _WIN64
27 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
28 #else
29 #define POINTER_ALIGNMENT
30 #endif
32 /* FIXME: We suppose that page size is 4096 */
33 #undef PAGE_SIZE
34 #undef PAGE_SHIFT
35 #define PAGE_SIZE 0x1000
36 #define PAGE_SHIFT 12
38 #define BYTE_OFFSET(va) ((ULONG)((ULONG_PTR)(va) & (PAGE_SIZE - 1)))
39 #define PAGE_ALIGN(va) ((PVOID)((ULONG_PTR)(va) & ~(PAGE_SIZE - 1)))
40 #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(va, length) \
41 ((BYTE_OFFSET(va) + ((SIZE_T)(length)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)
43 typedef LONG KPRIORITY;
45 typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK;
47 typedef ULONG_PTR ERESOURCE_THREAD;
48 typedef ERESOURCE_THREAD *PERESOURCE_THREAD;
49 typedef struct _FILE_GET_QUOTA_INFORMATION *PFILE_GET_QUOTA_INFORMATION;
51 struct _KDPC;
52 struct _KAPC;
53 struct _IRP;
54 struct _DEVICE_OBJECT;
55 struct _DRIVER_OBJECT;
56 struct _KPROCESS;
58 typedef VOID (WINAPI *PKDEFERRED_ROUTINE)(struct _KDPC *, PVOID, PVOID, PVOID);
59 typedef VOID (WINAPI *PKSTART_ROUTINE)(PVOID);
61 typedef NTSTATUS (WINAPI *PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT *, PUNICODE_STRING);
62 typedef NTSTATUS (WINAPI *PDRIVER_DISPATCH)(struct _DEVICE_OBJECT *, struct _IRP *);
63 typedef void (WINAPI *PDRIVER_STARTIO)(struct _DEVICE_OBJECT *, struct _IRP *);
64 typedef void (WINAPI *PDRIVER_UNLOAD)(struct _DRIVER_OBJECT *);
65 typedef NTSTATUS (WINAPI *PDRIVER_ADD_DEVICE)(struct _DRIVER_OBJECT *, struct _DEVICE_OBJECT *);
67 typedef struct _DISPATCHER_HEADER {
68 UCHAR Type;
69 UCHAR Absolute;
70 UCHAR Size;
71 UCHAR Inserted;
72 LONG SignalState;
73 LIST_ENTRY WaitListHead;
74 } DISPATCHER_HEADER, *PDISPATCHER_HEADER;
76 typedef struct _KEVENT {
77 DISPATCHER_HEADER Header;
78 } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
80 typedef struct _KSEMAPHORE {
81 DISPATCHER_HEADER Header;
82 LONG Limit;
83 } KSEMAPHORE, *PKSEMAPHORE, *PRKSEMAPHORE;
85 typedef struct _KDPC {
86 CSHORT Type;
87 UCHAR Number;
88 UCHAR Importance;
89 LIST_ENTRY DpcListEntry;
90 PKDEFERRED_ROUTINE DeferredRoutine;
91 PVOID DeferredContext;
92 PVOID SystemArgument1;
93 PVOID SystemArgument2;
94 PULONG_PTR Lock;
95 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
97 typedef enum _KDPC_IMPORTANCE {
98 LowImportance,
99 MediumImportance,
100 HighImportance,
101 MediumHighImportance
102 } KDPC_IMPORTANCE;
104 typedef struct _KDEVICE_QUEUE_ENTRY {
105 LIST_ENTRY DeviceListEntry;
106 ULONG SortKey;
107 BOOLEAN Inserted;
108 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
109 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
111 typedef struct _KDEVICE_QUEUE {
112 CSHORT Type;
113 CSHORT Size;
114 LIST_ENTRY DeviceListHead;
115 KSPIN_LOCK Lock;
116 BOOLEAN Busy;
117 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
119 typedef struct _KMUTANT {
120 DISPATCHER_HEADER Header;
121 LIST_ENTRY MutantListEntry;
122 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
123 BOOLEAN Abandoned;
124 UCHAR ApcDisable;
125 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
127 typedef struct _DEFERRED_REVERSE_BARRIER
129 ULONG Barrier;
130 ULONG TotalProcessors;
131 } DEFERRED_REVERSE_BARRIER;
133 typedef enum _KWAIT_REASON
135 Executive,
136 FreePage,
137 PageIn,
138 PoolAllocation,
139 DelayExecution,
140 Suspended,
141 UserRequest,
142 WrExecutive,
143 WrFreePage,
144 WrPageIn,
145 WrDelayExecution,
146 WrSuspended,
147 WrUserRequest,
148 WrQueue,
149 WrLpcReceive,
150 WrLpcReply,
151 WrVirtualMemory,
152 WrPageOut,
153 WrRendezvous,
154 Spare2,
155 Spare3,
156 Spare4,
157 Spare5,
158 Spare6,
159 WrKernel,
160 MaximumWaitReason,
161 } KWAIT_REASON;
163 typedef struct _KWAIT_BLOCK {
164 LIST_ENTRY WaitListEntry;
165 struct _KTHREAD *RESTRICTED_POINTER Thread;
166 PVOID Object;
167 struct _KWAIT_BLOCK *RESTRICTED_POINTER NextWaitBlock;
168 USHORT WaitKey;
169 USHORT WaitType;
170 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
172 typedef struct _OWNER_ENTRY
174 ERESOURCE_THREAD OwnerThread;
175 union
177 struct
179 ULONG IoPriorityBoosted : 1;
180 ULONG OwnerReferenced : 1;
181 ULONG IoQoSPriorityBoosted : 1;
182 ULONG OwnerCount : 29;
184 ULONG TableSize;
186 } OWNER_ENTRY, *POWNER_ENTRY;
188 #define ResourceNeverExclusive 0x0010
189 #define ResourceReleaseByOtherThread 0x0020
190 #define ResourceOwnedExclusive 0x0080
192 typedef struct _ERESOURCE
194 LIST_ENTRY SystemResourcesList;
195 OWNER_ENTRY *OwnerTable;
196 SHORT ActiveCount;
197 union
199 USHORT Flag;
200 struct
202 UCHAR ReservedLowFlags;
203 UCHAR WaiterPriority;
206 KSEMAPHORE *SharedWaiters;
207 KEVENT *ExclusiveWaiters;
208 OWNER_ENTRY OwnerEntry;
209 ULONG ActiveEntries;
210 ULONG ContentionCount;
211 ULONG NumberOfSharedWaiters;
212 ULONG NumberOfExclusiveWaiters;
213 #ifdef _WIN64
214 void *Reserved2;
215 #endif
216 union
218 void *Address;
219 ULONG_PTR CreatorBackTraceIndex;
221 KSPIN_LOCK SpinLock;
222 } ERESOURCE, *PERESOURCE;
224 typedef struct _IO_TIMER *PIO_TIMER;
225 typedef struct _IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE;
226 typedef struct _ETHREAD *PETHREAD;
227 typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD;
228 typedef struct _EPROCESS *PEPROCESS;
229 typedef struct _KPROCESS KPROCESS, *PKPROCESS, *PRKPROCESS;
230 typedef struct _IO_WORKITEM *PIO_WORKITEM;
231 typedef struct _OBJECT_TYPE *POBJECT_TYPE;
232 typedef struct _OBJECT_HANDLE_INFORMATION *POBJECT_HANDLE_INFORMATION;
233 typedef struct _ZONE_HEADER *PZONE_HEADER;
234 typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX;
236 typedef struct _KAPC_STATE
238 LIST_ENTRY ApcListHead[2];
239 PKPROCESS Process;
240 UCHAR KernelApcInProgress;
241 UCHAR KernelApcPending;
242 UCHAR UserApcPending;
243 } KAPC_STATE, *PKAPC_STATE;
245 #define FM_LOCK_BIT 0x1
247 typedef struct _FAST_MUTEX
249 LONG Count;
250 PKTHREAD Owner;
251 ULONG Contention;
252 KEVENT Event;
253 ULONG OldIrql;
254 } FAST_MUTEX, *PFAST_MUTEX;
256 typedef struct _KGUARDED_MUTEX
258 LONG Count;
259 PKTHREAD Owner;
260 ULONG Contention;
261 KEVENT Event;
262 union
264 struct
266 SHORT KernelApcDisable;
267 SHORT SpecialApcDisable;
269 ULONG CombinedApcDisable;
271 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
273 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
275 typedef struct _VPB {
276 CSHORT Type;
277 CSHORT Size;
278 USHORT Flags;
279 USHORT VolumeLabelLength;
280 struct _DEVICE_OBJECT *DeviceObject;
281 struct _DEVICE_OBJECT *RealDevice;
282 ULONG SerialNumber;
283 ULONG ReferenceCount;
284 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
285 } VPB, *PVPB;
287 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 0x0008
288 #define POOL_RAISE_IF_ALLOCATION_FAILURE 0x0010
289 #define POOL_COLD_ALLOCATION 0x0100
290 #define POOL_NX_ALLOCATION 0x0200
292 typedef enum _POOL_TYPE {
293 NonPagedPool,
294 PagedPool,
295 NonPagedPoolMustSucceed,
296 DontUseThisType,
297 NonPagedPoolCacheAligned,
298 PagedPoolCacheAligned,
299 NonPagedPoolCacheAlignedMustS,
300 MaxPoolType
301 } POOL_TYPE;
303 typedef struct _WAIT_CONTEXT_BLOCK {
304 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
305 struct _DRIVER_CONTROL *DeviceRoutine;
306 PVOID DeviceContext;
307 ULONG NumberOfMapRegisters;
308 PVOID DeviceObject;
309 PVOID CurrentIrp;
310 PKDPC BufferChainingDpc;
311 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
313 #define DO_BUFFERED_IO 0x00000004
314 #define DO_EXCLUSIVE 0x00000008
315 #define DO_DIRECT_IO 0x00000010
316 #define DO_MAP_IO_BUFFER 0x00000020
317 #define DO_DEVICE_INITIALIZING 0x00000080
318 #define DO_SHUTDOWN_REGISTERED 0x00000800
319 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
320 #define DO_POWER_PAGABLE 0x00002000
321 #define DO_POWER_INRUSH 0x00004000
323 #define IO_NO_INCREMENT 0
324 #define IO_CD_ROM_INCREMENT 1
325 #define IO_DISK_INCREMENT 1
326 #define IO_KEYBOARD_INCREMENT 6
327 #define IO_MAILSLOT_INCREMENT 2
328 #define IO_MOUSE_INCREMENT 6
329 #define IO_NAMED_PIPE_INCREMENT 2
330 #define IO_NETWORK_INCREMENT 2
331 #define IO_PARALLEL_INCREMENT 1
332 #define IO_SERIAL_INCREMENT 2
333 #define IO_SOUND_INCREMENT 8
334 #define IO_VIDEO_INCREMENT 1
336 #ifndef DEVICE_TYPE
337 #define DEVICE_TYPE ULONG
338 #endif
339 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
340 #define IRP_MJ_CREATE 0x00
341 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
342 #define IRP_MJ_CLOSE 0x02
343 #define IRP_MJ_READ 0x03
344 #define IRP_MJ_WRITE 0x04
345 #define IRP_MJ_QUERY_INFORMATION 0x05
346 #define IRP_MJ_SET_INFORMATION 0x06
347 #define IRP_MJ_QUERY_EA 0x07
348 #define IRP_MJ_SET_EA 0x08
349 #define IRP_MJ_FLUSH_BUFFERS 0x09
350 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
351 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
352 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
353 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
354 #define IRP_MJ_DEVICE_CONTROL 0x0e
355 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
356 #define IRP_MJ_SHUTDOWN 0x10
357 #define IRP_MJ_LOCK_CONTROL 0x11
358 #define IRP_MJ_CLEANUP 0x12
359 #define IRP_MJ_CREATE_MAILSLOT 0x13
360 #define IRP_MJ_QUERY_SECURITY 0x14
361 #define IRP_MJ_SET_SECURITY 0x15
362 #define IRP_MJ_POWER 0x16
363 #define IRP_MJ_SYSTEM_CONTROL 0x17
364 #define IRP_MJ_DEVICE_CHANGE 0x18
365 #define IRP_MJ_QUERY_QUOTA 0x19
366 #define IRP_MJ_SET_QUOTA 0x1a
367 #define IRP_MJ_PNP 0x1b
369 #define IRP_MN_START_DEVICE 0x00
370 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
371 #define IRP_MN_REMOVE_DEVICE 0x02
372 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
373 #define IRP_MN_STOP_DEVICE 0x04
374 #define IRP_MN_QUERY_STOP_DEVICE 0x05
375 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
376 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
377 #define IRP_MN_QUERY_INTERFACE 0x08
378 #define IRP_MN_QUERY_CAPABILITIES 0x09
379 #define IRP_MN_QUERY_RESOURCES 0x0A
380 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
381 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
382 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
383 #define IRP_MN_READ_CONFIG 0x0F
384 #define IRP_MN_WRITE_CONFIG 0x10
385 #define IRP_MN_EJECT 0x11
386 #define IRP_MN_SET_LOCK 0x12
387 #define IRP_MN_QUERY_ID 0x13
388 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
389 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
390 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
391 #define IRP_MN_SURPRISE_REMOVAL 0x17
392 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
394 #define IRP_MN_WAIT_WAKE 0x00
395 #define IRP_MN_POWER_SEQUENCE 0x01
396 #define IRP_MN_SET_POWER 0x02
397 #define IRP_MN_QUERY_POWER 0x03
399 #define IRP_QUOTA_CHARGED 0x01
400 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
401 #define IRP_ALLOCATED_FIXED_SIZE 0x04
402 #define IRP_LOOKASIDE_ALLOCATION 0x08
404 #define IO_TYPE_ADAPTER 0x01
405 #define IO_TYPE_CONTROLLER 0x02
406 #define IO_TYPE_DEVICE 0x03
407 #define IO_TYPE_DRIVER 0x04
408 #define IO_TYPE_FILE 0x05
409 #define IO_TYPE_IRP 0x06
410 #define IO_TYPE_MASTER_ADAPTER 0x07
411 #define IO_TYPE_OPEN_PACKET 0x08
412 #define IO_TYPE_TIMER 0x09
413 #define IO_TYPE_VPB 0x0a
414 #define IO_TYPE_ERROR_LOG 0x0b
415 #define IO_TYPE_ERROR_MESSAGE 0x0c
416 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 0x0d
417 #define IO_TYPE_DEVICE_QUEUE 0x14
419 typedef struct _DEVICE_OBJECT {
420 CSHORT Type;
421 USHORT Size;
422 LONG ReferenceCount;
423 struct _DRIVER_OBJECT *DriverObject;
424 struct _DEVICE_OBJECT *NextDevice;
425 struct _DEVICE_OBJECT *AttachedDevice;
426 struct _IRP *CurrentIrp;
427 PIO_TIMER Timer;
428 ULONG Flags;
429 ULONG Characteristics;
430 PVPB Vpb;
431 PVOID DeviceExtension;
432 DEVICE_TYPE DeviceType;
433 CCHAR StackSize;
434 union {
435 LIST_ENTRY ListEntry;
436 WAIT_CONTEXT_BLOCK Wcb;
437 } Queue;
438 ULONG AlignmentRequirement;
439 KDEVICE_QUEUE DeviceQueue;
440 KDPC Dpc;
441 ULONG ActiveThreadCount;
442 PSECURITY_DESCRIPTOR SecurityDescriptor;
443 KEVENT DeviceLock;
444 USHORT SectorSize;
445 USHORT Spare1;
446 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
447 PVOID Reserved;
448 } DEVICE_OBJECT;
449 typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT;
451 typedef struct _DEVICE_RELATIONS {
452 ULONG Count;
453 PDEVICE_OBJECT Objects[1];
454 } DEVICE_RELATIONS;
455 typedef struct _DEVICE_RELATIONS *PDEVICE_RELATIONS;
457 typedef struct _DRIVER_EXTENSION {
458 struct _DRIVER_OBJECT *DriverObject;
459 PDRIVER_ADD_DEVICE AddDevice;
460 ULONG Count;
461 UNICODE_STRING ServiceKeyName;
462 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
464 typedef struct _DRIVER_OBJECT {
465 CSHORT Type;
466 CSHORT Size;
467 PDEVICE_OBJECT DeviceObject;
468 ULONG Flags;
469 PVOID DriverStart;
470 ULONG DriverSize;
471 PVOID DriverSection;
472 PDRIVER_EXTENSION DriverExtension;
473 UNICODE_STRING DriverName;
474 PUNICODE_STRING HardwareDatabase;
475 PVOID FastIoDispatch;
476 PDRIVER_INITIALIZE DriverInit;
477 PDRIVER_STARTIO DriverStartIo;
478 PDRIVER_UNLOAD DriverUnload;
479 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
480 } DRIVER_OBJECT;
481 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
483 /* Irp definitions */
484 typedef UCHAR KIRQL, *PKIRQL;
485 typedef CCHAR KPROCESSOR_MODE;
486 typedef enum _KAPC_ENVIRONMENT
488 OriginalApcEnvironment,
489 AttachedApcEnvironment,
490 CurrentApcEnvironment,
491 InsertApcEnvironment
492 } KAPC_ENVIRONMENT, *PKAPC_ENVIRONMENT;
494 typedef VOID (WINAPI *PDRIVER_CANCEL)(
495 IN struct _DEVICE_OBJECT *DeviceObject,
496 IN struct _IRP *Irp);
498 typedef VOID (WINAPI *PKNORMAL_ROUTINE)(
499 IN PVOID NormalContext,
500 IN PVOID SystemArgument1,
501 IN PVOID SystemArgument2);
503 typedef VOID (WINAPI *PKKERNEL_ROUTINE)(
504 IN struct _KAPC *Apc,
505 IN OUT PKNORMAL_ROUTINE *NormalRoutine,
506 IN OUT PVOID *NormalContext,
507 IN OUT PVOID *SystemArgument1,
508 IN OUT PVOID *SystemArgument2);
510 typedef VOID (WINAPI *PKRUNDOWN_ROUTINE)(
511 IN struct _KAPC *Apc);
513 typedef struct _KAPC {
514 CSHORT Type;
515 CSHORT Size;
516 ULONG Spare0;
517 struct _KTHREAD *Thread;
518 LIST_ENTRY ApcListEntry;
519 PKKERNEL_ROUTINE KernelRoutine;
520 PKRUNDOWN_ROUTINE RundownRoutine;
521 PKNORMAL_ROUTINE NormalRoutine;
522 PVOID NormalContext;
523 PVOID SystemArgument1;
524 PVOID SystemArgument2;
525 CCHAR ApcStateIndex;
526 KPROCESSOR_MODE ApcMode;
527 BOOLEAN Inserted;
528 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
530 typedef struct _IRP {
531 CSHORT Type;
532 USHORT Size;
533 struct _MDL *MdlAddress;
534 ULONG Flags;
535 union {
536 struct _IRP *MasterIrp;
537 LONG IrpCount;
538 PVOID SystemBuffer;
539 } AssociatedIrp;
540 LIST_ENTRY ThreadListEntry;
541 IO_STATUS_BLOCK IoStatus;
542 KPROCESSOR_MODE RequestorMode;
543 BOOLEAN PendingReturned;
544 CHAR StackCount;
545 CHAR CurrentLocation;
546 BOOLEAN Cancel;
547 KIRQL CancelIrql;
548 CCHAR ApcEnvironment;
549 UCHAR AllocationFlags;
550 PIO_STATUS_BLOCK UserIosb;
551 PKEVENT UserEvent;
552 union {
553 struct {
554 PIO_APC_ROUTINE UserApcRoutine;
555 PVOID UserApcContext;
556 } AsynchronousParameters;
557 LARGE_INTEGER AllocationSize;
558 } Overlay;
559 PDRIVER_CANCEL CancelRoutine;
560 PVOID UserBuffer;
561 union {
562 struct {
563 union {
564 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
565 struct {
566 PVOID DriverContext[4];
567 } DUMMYSTRUCTNAME;
568 } DUMMYUNIONNAME1;
569 PETHREAD Thread;
570 PCHAR AuxiliaryBuffer;
571 struct {
572 LIST_ENTRY ListEntry;
573 union {
574 struct _IO_STACK_LOCATION *CurrentStackLocation;
575 ULONG PacketType;
576 } DUMMYUNIONNAME2;
577 } DUMMYSTRUCTNAME;
578 struct _FILE_OBJECT *OriginalFileObject;
579 } Overlay;
580 KAPC Apc;
581 PVOID CompletionKey;
582 } Tail;
583 } IRP;
584 typedef struct _IRP *PIRP;
586 #define IRP_NOCACHE 0x0001
587 #define IRP_PAGING_IO 0x0002
588 #define IRP_MOUNT_COMPLETION 0x0002
589 #define IRP_SYNCHRONOUS_API 0x0004
590 #define IRP_ASSOCIATED_IRP 0x0008
591 #define IRP_BUFFERED_IO 0x0010
592 #define IRP_DEALLOCATE_BUFFER 0x0020
593 #define IRP_INPUT_OPERATION 0x0040
594 #define IRP_SYNCHRONOUS_PAGING_IO 0x0040
595 #define IRP_CREATE_OPERATION 0x0080
596 #define IRP_READ_OPERATION 0x0100
597 #define IRP_WRITE_OPERATION 0x0200
598 #define IRP_CLOSE_OPERATION 0x0400
599 #define IRP_DEFER_IO_COMPLETION 0x0800
600 #define IRP_OB_QUERY_NAME 0x1000
601 #define IRP_HOLD_DEVICE_QUEUE 0x2000
603 typedef VOID (WINAPI *PINTERFACE_REFERENCE)(
604 PVOID Context);
606 typedef VOID (WINAPI *PINTERFACE_DEREFERENCE)(
607 PVOID Context);
609 typedef struct _INTERFACE {
610 USHORT Size;
611 USHORT Version;
612 PVOID Context;
613 PINTERFACE_REFERENCE InterfaceReference;
614 PINTERFACE_DEREFERENCE InterfaceDereference;
615 } INTERFACE, *PINTERFACE;
617 typedef struct _SECTION_OBJECT_POINTERS {
618 PVOID DataSectionObject;
619 PVOID SharedCacheMap;
620 PVOID ImageSectionObject;
621 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
623 typedef struct _IO_COMPLETION_CONTEXT {
624 PVOID Port;
625 PVOID Key;
626 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
628 typedef enum _DEVICE_RELATION_TYPE {
629 BusRelations,
630 EjectionRelations,
631 PowerRelations,
632 RemovalRelations,
633 TargetDeviceRelation,
634 SingleBusRelations
635 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
637 typedef struct _FILE_OBJECT {
638 CSHORT Type;
639 CSHORT Size;
640 PDEVICE_OBJECT DeviceObject;
641 PVPB Vpb;
642 PVOID FsContext;
643 PVOID FsContext2;
644 PSECTION_OBJECT_POINTERS SectionObjectPointer;
645 PVOID PrivateCacheMap;
646 NTSTATUS FinalStatus;
647 struct _FILE_OBJECT *RelatedFileObject;
648 BOOLEAN LockOperation;
649 BOOLEAN DeletePending;
650 BOOLEAN ReadAccess;
651 BOOLEAN WriteAccess;
652 BOOLEAN DeleteAccess;
653 BOOLEAN SharedRead;
654 BOOLEAN SharedWrite;
655 BOOLEAN SharedDelete;
656 ULONG Flags;
657 UNICODE_STRING FileName;
658 LARGE_INTEGER CurrentByteOffset;
659 ULONG Waiters;
660 ULONG Busy;
661 PVOID LastLock;
662 KEVENT Lock;
663 KEVENT Event;
664 PIO_COMPLETION_CONTEXT CompletionContext;
665 } FILE_OBJECT;
666 typedef struct _FILE_OBJECT *PFILE_OBJECT;
668 #define INITIAL_PRIVILEGE_COUNT 3
670 typedef struct _INITIAL_PRIVILEGE_SET {
671 ULONG PrivilegeCount;
672 ULONG Control;
673 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
674 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
676 typedef struct _SECURITY_SUBJECT_CONTEXT {
677 PACCESS_TOKEN ClientToken;
678 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
679 PACCESS_TOKEN PrimaryToken;
680 PVOID ProcessAuditId;
681 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
683 typedef struct _ACCESS_STATE {
684 LUID OperationID;
685 BOOLEAN SecurityEvaluated;
686 BOOLEAN GenerateAudit;
687 BOOLEAN GenerateOnClose;
688 BOOLEAN PrivilegesAllocated;
689 ULONG Flags;
690 ACCESS_MASK RemainingDesiredAccess;
691 ACCESS_MASK PreviouslyGrantedAccess;
692 ACCESS_MASK OriginalDesiredAccess;
693 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
694 PSECURITY_DESCRIPTOR SecurityDescriptor;
695 PVOID AuxData;
696 union {
697 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
698 PRIVILEGE_SET PrivilegeSet;
699 } Privileges;
701 BOOLEAN AuditPrivileges;
702 UNICODE_STRING ObjectName;
703 UNICODE_STRING ObjectTypeName;
704 } ACCESS_STATE, *PACCESS_STATE;
706 typedef struct _IO_SECURITY_CONTEXT {
707 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
708 PACCESS_STATE AccessState;
709 ACCESS_MASK DesiredAccess;
710 ULONG FullCreateOptions;
711 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
713 typedef struct _DEVICE_CAPABILITIES {
714 USHORT Size;
715 USHORT Version;
716 ULONG DeviceD1 : 1;
717 ULONG DeviceD2 : 1;
718 ULONG LockSupported : 1;
719 ULONG EjectSupported : 1;
720 ULONG Removable : 1;
721 ULONG DockDevice : 1;
722 ULONG UniqueID : 1;
723 ULONG SilentInstall : 1;
724 ULONG RawDeviceOK : 1;
725 ULONG SurpriseRemovalOK : 1;
726 ULONG WakeFromD0 : 1;
727 ULONG WakeFromD1 : 1;
728 ULONG WakeFromD2 : 1;
729 ULONG WakeFromD3 : 1;
730 ULONG HardwareDisabled : 1;
731 ULONG NonDynamic : 1;
732 ULONG WarmEjectSupported : 1;
733 ULONG NoDisplayInUI : 1;
734 ULONG Reserved : 14;
735 ULONG Address;
736 ULONG UINumber;
737 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
738 SYSTEM_POWER_STATE SystemWake;
739 DEVICE_POWER_STATE DeviceWake;
740 ULONG D1Latency;
741 ULONG D2Latency;
742 ULONG D3Latency;
743 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
745 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
746 USHORT Version;
747 USHORT Size;
748 GUID Event;
749 GUID InterfaceClassGuid;
750 PUNICODE_STRING SymbolicLinkName;
751 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
753 typedef enum _INTERFACE_TYPE {
754 InterfaceTypeUndefined = -1,
755 Internal,
756 Isa,
757 Eisa,
758 MicroChannel,
759 TurboChannel,
760 PCIBus,
761 VMEBus,
762 NuBus,
763 PCMCIABus,
764 CBus,
765 MPIBus,
766 MPSABus,
767 ProcessorInternal,
768 InternalPowerBus,
769 PNPISABus,
770 PNPBus,
771 MaximumInterfaceType
772 } INTERFACE_TYPE, *PINTERFACE_TYPE;
774 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
776 #define IO_RESOURCE_PREFERRED 0x01
777 #define IO_RESOURCE_DEFAULT 0x02
778 #define IO_RESOURCE_ALTERNATIVE 0x08
780 typedef struct _IO_RESOURCE_DESCRIPTOR {
781 UCHAR Option;
782 UCHAR Type;
783 UCHAR ShareDisposition;
784 UCHAR Spare1;
785 USHORT Flags;
786 USHORT Spare2;
787 union {
788 struct {
789 ULONG Length;
790 ULONG Alignment;
791 PHYSICAL_ADDRESS MinimumAddress;
792 PHYSICAL_ADDRESS MaximumAddress;
793 } Port;
794 struct {
795 ULONG Length;
796 ULONG Alignment;
797 PHYSICAL_ADDRESS MinimumAddress;
798 PHYSICAL_ADDRESS MaximumAddress;
799 } Memory;
800 struct {
801 ULONG MinimumVector;
802 ULONG MaximumVector;
803 } Interrupt;
804 struct {
805 ULONG MinimumChannel;
806 ULONG MaximumChannel;
807 } Dma;
808 struct {
809 ULONG Length;
810 ULONG Alignment;
811 PHYSICAL_ADDRESS MinimumAddress;
812 PHYSICAL_ADDRESS MaximumAddress;
813 } Generic;
814 struct {
815 ULONG Data[3];
816 } DevicePrivate;
817 struct {
818 ULONG Length;
819 ULONG MinBusNumber;
820 ULONG MaxBusNumber;
821 ULONG Reserved;
822 } BusNumber;
823 struct {
824 ULONG Priority;
825 ULONG Reserved1;
826 ULONG Reserved2;
827 } ConfigData;
828 } u;
829 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
831 typedef struct _IO_RESOURCE_LIST {
832 USHORT Version;
833 USHORT Revision;
834 ULONG Count;
835 IO_RESOURCE_DESCRIPTOR Descriptors[1];
836 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
838 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
839 ULONG ListSize;
840 INTERFACE_TYPE InterfaceType;
841 ULONG BusNumber;
842 ULONG SlotNumber;
843 ULONG Reserved[3];
844 ULONG AlternativeLists;
845 IO_RESOURCE_LIST List[1];
846 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
848 typedef enum _BUS_QUERY_ID_TYPE {
849 BusQueryDeviceID,
850 BusQueryHardwareIDs,
851 BusQueryCompatibleIDs,
852 BusQueryInstanceID,
853 BusQueryDeviceSerialNumber,
854 BusQueryContainerID,
855 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
857 typedef enum _CREATE_FILE_TYPE {
858 CreateFileTypeNone,
859 CreateFileTypeNamedPipe,
860 CreateFileTypeMailslot
861 } CREATE_FILE_TYPE;
863 typedef enum {
864 DevicePropertyDeviceDescription,
865 DevicePropertyHardwareID,
866 DevicePropertyCompatibleIDs,
867 DevicePropertyBootConfiguration,
868 DevicePropertyBootConfigurationTranslated,
869 DevicePropertyClassName,
870 DevicePropertyClassGuid,
871 DevicePropertyDriverKeyName,
872 DevicePropertyManufacturer,
873 DevicePropertyFriendlyName,
874 DevicePropertyLocationInformation,
875 DevicePropertyPhysicalDeviceObjectName,
876 DevicePropertyBusTypeGuid,
877 DevicePropertyLegacyBusType,
878 DevicePropertyBusNumber,
879 DevicePropertyEnumeratorName,
880 DevicePropertyAddress,
881 DevicePropertyUINumber,
882 DevicePropertyInstallState,
883 DevicePropertyRemovalPolicy
884 } DEVICE_REGISTRY_PROPERTY;
886 typedef enum _DEVICE_TEXT_TYPE {
887 DeviceTextDescription,
888 DeviceTextLocationInformation
889 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
891 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
892 DeviceUsageTypeUndefined,
893 DeviceUsageTypePaging,
894 DeviceUsageTypeHibernation,
895 DeviceUsageTypeDumpFile
896 } DEVICE_USAGE_NOTIFICATION_TYPE;
898 typedef struct _POWER_SEQUENCE {
899 ULONG SequenceD1;
900 ULONG SequenceD2;
901 ULONG SequenceD3;
902 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
904 typedef enum _POWER_STATE_TYPE {
905 SystemPowerState,
906 DevicePowerState
907 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
909 typedef union _POWER_STATE {
910 SYSTEM_POWER_STATE SystemState;
911 DEVICE_POWER_STATE DeviceState;
912 } POWER_STATE, *PPOWER_STATE;
914 typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
915 UCHAR Type;
916 UCHAR ShareDisposition;
917 USHORT Flags;
918 union {
919 struct {
920 PHYSICAL_ADDRESS Start;
921 ULONG Length;
922 } Generic;
923 struct {
924 PHYSICAL_ADDRESS Start;
925 ULONG Length;
926 } Port;
927 struct {
928 ULONG Level;
929 ULONG Vector;
930 ULONG Affinity;
931 } Interrupt;
932 struct {
933 PHYSICAL_ADDRESS Start;
934 ULONG Length;
935 } Memory;
936 struct {
937 ULONG Channel;
938 ULONG Port;
939 ULONG Reserved1;
940 } Dma;
941 struct {
942 ULONG Data[3];
943 } DevicePrivate;
944 struct {
945 ULONG Start;
946 ULONG Length;
947 ULONG Reserved;
948 } BusNumber;
949 struct {
950 ULONG DataSize;
951 ULONG Reserved1;
952 ULONG Reserved2;
953 } DeviceSpecificData;
954 } u;
955 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
957 typedef struct _CM_PARTIAL_RESOURCE_LIST {
958 USHORT Version;
959 USHORT Revision;
960 ULONG Count;
961 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
962 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
964 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
965 INTERFACE_TYPE InterfaceType;
966 ULONG BusNumber;
967 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
968 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
970 typedef struct _CM_RESOURCE_LIST {
971 ULONG Count;
972 CM_FULL_RESOURCE_DESCRIPTOR List[1];
973 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
975 typedef NTSTATUS (WINAPI *PIO_COMPLETION_ROUTINE)(
976 IN struct _DEVICE_OBJECT *DeviceObject,
977 IN struct _IRP *Irp,
978 IN PVOID Context);
980 #define SL_PENDING_RETURNED 0x01
981 #define SL_INVOKE_ON_CANCEL 0x20
982 #define SL_INVOKE_ON_SUCCESS 0x40
983 #define SL_INVOKE_ON_ERROR 0x80
985 #if !defined(_WIN64)
986 #include <pshpack4.h>
987 #endif
988 typedef struct _IO_STACK_LOCATION {
989 UCHAR MajorFunction;
990 UCHAR MinorFunction;
991 UCHAR Flags;
992 UCHAR Control;
993 union {
994 struct {
995 PIO_SECURITY_CONTEXT SecurityContext;
996 ULONG Options;
997 USHORT POINTER_ALIGNMENT FileAttributes;
998 USHORT ShareAccess;
999 ULONG POINTER_ALIGNMENT EaLength;
1000 } Create;
1001 struct {
1002 ULONG Length;
1003 ULONG POINTER_ALIGNMENT Key;
1004 LARGE_INTEGER ByteOffset;
1005 } Read;
1006 struct {
1007 ULONG Length;
1008 ULONG POINTER_ALIGNMENT Key;
1009 LARGE_INTEGER ByteOffset;
1010 } Write;
1011 struct {
1012 ULONG Length;
1013 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
1014 } QueryFile;
1015 struct {
1016 ULONG Length;
1017 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
1018 PFILE_OBJECT FileObject;
1019 union {
1020 struct {
1021 BOOLEAN ReplaceIfExists;
1022 BOOLEAN AdvanceOnly;
1023 } DUMMYSTRUCTNAME;
1024 ULONG ClusterCount;
1025 HANDLE DeleteHandle;
1026 } DUMMYUNIONNAME;
1027 } SetFile;
1028 struct {
1029 ULONG Length;
1030 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
1031 } QueryVolume;
1032 struct {
1033 ULONG OutputBufferLength;
1034 ULONG POINTER_ALIGNMENT InputBufferLength;
1035 ULONG POINTER_ALIGNMENT IoControlCode;
1036 PVOID Type3InputBuffer;
1037 } DeviceIoControl;
1038 struct {
1039 SECURITY_INFORMATION SecurityInformation;
1040 ULONG POINTER_ALIGNMENT Length;
1041 } QuerySecurity;
1042 struct {
1043 SECURITY_INFORMATION SecurityInformation;
1044 PSECURITY_DESCRIPTOR SecurityDescriptor;
1045 } SetSecurity;
1046 struct {
1047 PVPB Vpb;
1048 PDEVICE_OBJECT DeviceObject;
1049 } MountVolume;
1050 struct {
1051 PVPB Vpb;
1052 PDEVICE_OBJECT DeviceObject;
1053 } VerifyVolume;
1054 struct {
1055 struct _SCSI_REQUEST_BLOCK *Srb;
1056 } Scsi;
1057 struct {
1058 DEVICE_RELATION_TYPE Type;
1059 } QueryDeviceRelations;
1060 struct {
1061 const GUID *InterfaceType;
1062 USHORT Size;
1063 USHORT Version;
1064 PINTERFACE Interface;
1065 PVOID InterfaceSpecificData;
1066 } QueryInterface;
1067 struct {
1068 PDEVICE_CAPABILITIES Capabilities;
1069 } DeviceCapabilities;
1070 struct {
1071 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
1072 } FilterResourceRequirements;
1073 struct {
1074 ULONG WhichSpace;
1075 PVOID Buffer;
1076 ULONG Offset;
1077 ULONG POINTER_ALIGNMENT Length;
1078 } ReadWriteConfig;
1079 struct {
1080 BOOLEAN Lock;
1081 } SetLock;
1082 struct {
1083 BUS_QUERY_ID_TYPE IdType;
1084 } QueryId;
1085 struct {
1086 DEVICE_TEXT_TYPE DeviceTextType;
1087 LCID POINTER_ALIGNMENT LocaleId;
1088 } QueryDeviceText;
1089 struct {
1090 BOOLEAN InPath;
1091 BOOLEAN Reserved[3];
1092 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
1093 } UsageNotification;
1094 struct {
1095 SYSTEM_POWER_STATE PowerState;
1096 } WaitWake;
1097 struct {
1098 PPOWER_SEQUENCE PowerSequence;
1099 } PowerSequence;
1100 struct {
1101 ULONG SystemContext;
1102 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
1103 POWER_STATE POINTER_ALIGNMENT State;
1104 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
1105 } Power;
1106 struct {
1107 PCM_RESOURCE_LIST AllocatedResources;
1108 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
1109 } StartDevice;
1110 struct {
1111 ULONG_PTR ProviderId;
1112 PVOID DataPath;
1113 ULONG BufferSize;
1114 PVOID Buffer;
1115 } WMI;
1116 struct {
1117 PVOID Argument1;
1118 PVOID Argument2;
1119 PVOID Argument3;
1120 PVOID Argument4;
1121 } Others;
1122 } Parameters;
1123 PDEVICE_OBJECT DeviceObject;
1124 PFILE_OBJECT FileObject;
1125 PIO_COMPLETION_ROUTINE CompletionRoutine;
1126 PVOID Context;
1127 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
1128 #if !defined(_WIN64)
1129 #include <poppack.h>
1130 #endif
1132 /* MDL definitions */
1134 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
1135 #define MDL_PAGES_LOCKED 0x0002
1136 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
1137 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
1138 #define MDL_PARTIAL 0x0010
1139 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
1140 #define MDL_IO_PAGE_READ 0x0040
1141 #define MDL_WRITE_OPERATION 0x0080
1142 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
1143 #define MDL_FREE_EXTRA_PTES 0x0200
1144 #define MDL_DESCRIBES_AWE 0x0400
1145 #define MDL_IO_SPACE 0x0800
1146 #define MDL_NETWORK_HEADER 0x1000
1147 #define MDL_MAPPING_CAN_FAIL 0x2000
1148 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
1149 #define MDL_INTERNAL 0x8000
1151 #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
1152 MDL_PAGES_LOCKED | \
1153 MDL_SOURCE_IS_NONPAGED_POOL | \
1154 MDL_PARTIAL_HAS_BEEN_MAPPED | \
1155 MDL_PARENT_MAPPED_SYSTEM_VA | \
1156 MDL_SYSTEM_VA | \
1157 MDL_IO_SPACE )
1159 typedef struct _MDL {
1160 struct _MDL *Next;
1161 CSHORT Size;
1162 CSHORT MdlFlags;
1163 struct _EPROCESS *Process;
1164 PVOID MappedSystemVa;
1165 PVOID StartVa;
1166 ULONG ByteCount;
1167 ULONG ByteOffset;
1168 } MDL, *PMDL;
1170 typedef MDL *PMDLX;
1171 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
1173 static inline void MmInitializeMdl(MDL *mdl, void *va, SIZE_T length)
1175 mdl->Next = NULL;
1176 mdl->Size = sizeof(MDL) + sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(va, length);
1177 mdl->MdlFlags = 0;
1178 mdl->StartVa = (void *)PAGE_ALIGN(va);
1179 mdl->ByteOffset = BYTE_OFFSET(va);
1180 mdl->ByteCount = length;
1183 typedef struct _KTIMER {
1184 DISPATCHER_HEADER Header;
1185 ULARGE_INTEGER DueTime;
1186 LIST_ENTRY TimerListEntry;
1187 struct _KDPC *Dpc;
1188 LONG Period;
1189 } KTIMER, *PKTIMER;
1191 typedef struct _KSYSTEM_TIME {
1192 ULONG LowPart;
1193 LONG High1Time;
1194 LONG High2Time;
1195 } KSYSTEM_TIME, *PKSYSTEM_TIME;
1197 typedef enum _NT_PRODUCT_TYPE {
1198 NtProductWinNt = 1,
1199 NtProductLanManNt,
1200 NtProductServer
1201 } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
1203 #define PROCESSOR_FEATURE_MAX 64
1205 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
1207 StandardDesign,
1208 NEC98x86,
1209 EndAlternatives
1210 } ALTERNATIVE_ARCHITECTURE_TYPE;
1212 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
1213 #define NX_SUPPORT_POLICY_ALWAYSON 1
1214 #define NX_SUPPORT_POLICY_OPTIN 2
1215 #define NX_SUPPORT_POLICY_OPTOUT 3
1217 typedef struct _KUSER_SHARED_DATA {
1218 ULONG TickCountLowDeprecated; /* 0x000 */
1219 ULONG TickCountMultiplier; /* 0x004 */
1220 volatile KSYSTEM_TIME InterruptTime; /* 0x008 */
1221 volatile KSYSTEM_TIME SystemTime; /* 0x014 */
1222 volatile KSYSTEM_TIME TimeZoneBias; /* 0x020 */
1223 USHORT ImageNumberLow; /* 0x02c */
1224 USHORT ImageNumberHigh; /* 0x02e */
1225 WCHAR NtSystemRoot[260]; /* 0x030 */
1226 ULONG MaxStackTraceDepth; /* 0x238 */
1227 ULONG CryptoExponent; /* 0x23c */
1228 ULONG TimeZoneId; /* 0x240 */
1229 ULONG LargePageMinimum; /* 0x244 */
1230 ULONG AitSamplingValue; /* 0x248 */
1231 ULONG AppCompatFlag; /* 0x24c */
1232 ULONGLONG RNGSeedVersion; /* 0x250 */
1233 ULONG GlobalValidationRunLevel; /* 0x258 */
1234 volatile ULONG TimeZoneBiasStamp; /* 0x25c */
1235 ULONG NtBuildNumber; /* 0x260 */
1236 NT_PRODUCT_TYPE NtProductType; /* 0x264 */
1237 BOOLEAN ProductTypeIsValid; /* 0x268 */
1238 USHORT NativeProcessorArchitecture; /* 0x26a */
1239 ULONG NtMajorVersion; /* 0x26c */
1240 ULONG NtMinorVersion; /* 0x270 */
1241 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; /* 0x274 */
1242 ULONG Reserved1; /* 0x2b4 */
1243 ULONG Reserved3; /* 0x2b8 */
1244 volatile ULONG TimeSlip; /* 0x2bc */
1245 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; /* 0x2c0 */
1246 ULONG BootId; /* 0x2c4 */
1247 LARGE_INTEGER SystemExpirationDate; /* 0x2c8 */
1248 ULONG SuiteMask; /* 0x2d0 */
1249 BOOLEAN KdDebuggerEnabled; /* 0x2d4 */
1250 UCHAR NXSupportPolicy; /* 0x2d5 */
1251 USHORT CyclesPerYield; /* 0x2d6 */
1252 volatile ULONG ActiveConsoleId; /* 0x2d8 */
1253 volatile ULONG DismountCount; /* 0x2dc */
1254 ULONG ComPlusPackage; /* 0x2e0 */
1255 ULONG LastSystemRITEventTickCount; /* 0x2e4 */
1256 ULONG NumberOfPhysicalPages; /* 0x2e8 */
1257 BOOLEAN SafeBootMode; /* 0x2ec */
1258 UCHAR VirtualizationFlags; /* 0x2ed */
1259 union {
1260 ULONG SharedDataFlags; /* 0x2f0 */
1261 struct {
1262 ULONG DbgErrorPortPresent : 1;
1263 ULONG DbgElevationEnabed : 1;
1264 ULONG DbgVirtEnabled : 1;
1265 ULONG DbgInstallerDetectEnabled : 1;
1266 ULONG DbgLkgEnabled : 1;
1267 ULONG DbgDynProcessorEnabled : 1;
1268 ULONG DbgConsoleBrokerEnabled : 1;
1269 ULONG DbgSecureBootEnabled : 1;
1270 ULONG DbgMultiSessionSku : 1;
1271 ULONG DbgMultiUsersInSessionSku : 1;
1272 ULONG DbgStateSeparationEnabled : 1;
1273 ULONG SpareBits : 21;
1274 } DUMMYSTRUCTNAME2;
1275 } DUMMYUNIONNAME2;
1276 ULONG DataFlagsPad[1]; /* 0x2f4 */
1277 ULONGLONG TestRetInstruction; /* 0x2f8 */
1278 LONGLONG QpcFrequency; /* 0x300 */
1279 ULONG SystemCall; /* 0x308 */
1280 union {
1281 ULONG AllFlags; /* 0x30c */
1282 struct {
1283 ULONG Win32Process : 1;
1284 ULONG Sgx2Enclave : 1;
1285 ULONG VbsBasicEnclave : 1;
1286 ULONG SpareBits : 29;
1287 } DUMMYSTRUCTNAME;
1288 } UserCetAvailableEnvironments;
1289 ULONGLONG SystemCallPad[2]; /* 0x310 */
1290 union {
1291 volatile KSYSTEM_TIME TickCount; /* 0x320 */
1292 volatile ULONG64 TickCountQuad;
1293 } DUMMYUNIONNAME;
1294 ULONG Cookie; /* 0x330 */
1295 ULONG CookiePad[1]; /* 0x334 */
1296 LONGLONG ConsoleSessionForegroundProcessId; /* 0x338 */
1297 ULONGLONG TimeUpdateLock; /* 0x340 */
1298 ULONGLONG BaselineSystemTimeQpc; /* 0x348 */
1299 ULONGLONG BaselineInterruptTimeQpc; /* 0x350 */
1300 ULONGLONG QpcSystemTimeIncrement; /* 0x358 */
1301 ULONGLONG QpcInterruptTimeIncrement; /* 0x360 */
1302 UCHAR QpcSystemTimeIncrementShift; /* 0x368 */
1303 UCHAR QpcInterruptTimeIncrementShift; /* 0x369 */
1304 USHORT UnparkedProcessorCount; /* 0x36a */
1305 ULONG EnclaveFeatureMask[4]; /* 0x36c */
1306 ULONG TelemetryCoverageRound; /* 0x37c */
1307 USHORT UserModeGlobalLogger[16]; /* 0x380 */
1308 ULONG ImageFileExecutionOptions; /* 0x3a0 */
1309 ULONG LangGenerationCount; /* 0x3a4 */
1310 ULONG ActiveProcessorAffinity; /* 0x3a8 */
1311 volatile ULONGLONG InterruptTimeBias; /* 0x3b0 */
1312 volatile ULONGLONG QpcBias; /* 0x3b8 */
1313 ULONG ActiveProcessorCount; /* 0x3c0 */
1314 volatile UCHAR ActiveGroupCount; /* 0x3c4 */
1315 union {
1316 USHORT QpcData; /* 0x3c6 */
1317 struct {
1318 UCHAR volatile QpcBypassEnabled;
1319 UCHAR QpcShift;
1320 } DUMMYSTRUCTNAME;
1321 } DUMMYUNIONNAME3;
1322 LARGE_INTEGER TimeZoneBiasEffectiveStart; /* 0x3c8 */
1323 LARGE_INTEGER TimeZoneBiasEffectiveEnd; /* 0x3d0 */
1324 XSTATE_CONFIGURATION XState; /* 0x3d8 */
1325 } KSHARED_USER_DATA, *PKSHARED_USER_DATA;
1327 #define SHARED_GLOBAL_FLAGS_QPC_BYPASS_ENABLED 0x01
1328 #define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_HV_PAGE 0x02
1329 #define SHARED_GLOBAL_FLAGS_QPC_BYPASS_DISABLE_32BIT 0x04
1330 #define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_MFENCE 0x10
1331 #define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_LFENCE 0x20
1332 #define SHARED_GLOBAL_FLAGS_QPC_BYPASS_A73_ERRATA 0x40
1333 #define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_RDTSCP 0x80
1335 typedef enum _MEMORY_CACHING_TYPE {
1336 MmNonCached = 0,
1337 MmCached = 1,
1338 MmWriteCombined = 2,
1339 MmHardwareCoherentCached = 3,
1340 MmNonCachedUnordered = 4,
1341 MmUSWCCached = 5,
1342 MmMaximumCacheType = 6
1343 } MEMORY_CACHING_TYPE;
1345 typedef enum _MM_PAGE_PRIORITY {
1346 LowPagePriority,
1347 NormalPagePriority = 16,
1348 HighPagePriority = 32
1349 } MM_PAGE_PRIORITY;
1351 typedef enum _MM_SYSTEM_SIZE
1353 MmSmallSystem,
1354 MmMediumSystem,
1355 MmLargeSystem
1356 } MM_SYSTEMSIZE;
1358 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
1359 BOOLEAN Removed;
1360 BOOLEAN Reserved[3];
1361 LONG IoCount;
1362 KEVENT RemoveEvent;
1363 } IO_REMOVE_LOCK_COMMON_BLOCK;
1365 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK *PIO_REMOVE_LOCK_TRACKING_BLOCK;
1367 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
1368 LONG Signature;
1369 LONG HighWatermark;
1370 LONGLONG MaxLockedTicks;
1371 LONG AllocateTag;
1372 LIST_ENTRY LockList;
1373 KSPIN_LOCK Spin;
1374 LONG LowMemoryCount;
1375 ULONG Reserved1[4];
1376 PVOID Reserved2;
1377 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
1378 } IO_REMOVE_LOCK_DBG_BLOCK;
1380 typedef struct _IO_REMOVE_LOCK {
1381 IO_REMOVE_LOCK_COMMON_BLOCK Common;
1382 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
1383 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
1385 typedef enum {
1386 IoReadAccess,
1387 IoWriteAccess,
1388 IoModifyAccess
1389 } LOCK_OPERATION;
1391 typedef struct _CALLBACK_OBJECT
1393 ULONG Signature;
1394 KSPIN_LOCK Lock;
1395 LIST_ENTRY RegisteredCallbacks;
1396 BOOLEAN AllowMultipleCallbacks;
1397 UCHAR reserved[3];
1398 } CALLBACK_OBJECT, *PCALLBACK_OBJECT;
1400 typedef struct _KSPIN_LOCK_QUEUE {
1401 struct _KSPIN_LOCK_QUEUE * volatile Next;
1402 volatile PKSPIN_LOCK Lock;
1403 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
1405 typedef struct _KLOCK_QUEUE_HANDLE {
1406 KSPIN_LOCK_QUEUE LockQueue;
1407 KIRQL OldIrql;
1408 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
1410 typedef void * (NTAPI *PALLOCATE_FUNCTION)(POOL_TYPE, SIZE_T, ULONG);
1411 typedef void * (NTAPI *PALLOCATE_FUNCTION_EX)(POOL_TYPE, SIZE_T, ULONG, PLOOKASIDE_LIST_EX);
1412 typedef void (NTAPI *PFREE_FUNCTION)(void *);
1413 typedef void (NTAPI *PFREE_FUNCTION_EX)(void *, PLOOKASIDE_LIST_EX);
1414 typedef void (NTAPI *PCALLBACK_FUNCTION)(void *, void *, void *);
1416 #ifdef _WIN64
1417 #define LOOKASIDE_ALIGN DECLSPEC_CACHEALIGN
1418 #else
1419 #define LOOKASIDE_ALIGN
1420 #endif
1422 #define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD(SLIST_ENTRY, Next))
1424 #define GENERAL_LOOKASIDE_LAYOUT \
1425 union \
1427 SLIST_HEADER ListHead; \
1428 SINGLE_LIST_ENTRY SingleListHead; \
1429 } DUMMYUNIONNAME; \
1430 USHORT Depth; \
1431 USHORT MaximumDepth; \
1432 ULONG TotalAllocates; \
1433 union \
1435 ULONG AllocateMisses; \
1436 ULONG AllocateHits; \
1437 } DUMMYUNIONNAME2; \
1438 ULONG TotalFrees; \
1439 union \
1441 ULONG FreeMisses; \
1442 ULONG FreeHits; \
1443 } DUMMYUNIONNAME3; \
1444 POOL_TYPE Type; \
1445 ULONG Tag; \
1446 ULONG Size; \
1447 union \
1449 PALLOCATE_FUNCTION_EX AllocateEx; \
1450 PALLOCATE_FUNCTION Allocate; \
1451 } DUMMYUNIONNAME4; \
1452 union \
1454 PFREE_FUNCTION_EX FreeEx; \
1455 PFREE_FUNCTION Free; \
1456 } DUMMYUNIONNAME5; \
1457 LIST_ENTRY ListEntry; \
1458 ULONG LastTotalAllocates; \
1459 union \
1461 ULONG LastAllocateMisses; \
1462 ULONG LastAllocateHits; \
1463 } DUMMYUNIONNAME6; \
1464 ULONG Future[2];
1466 typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE
1468 GENERAL_LOOKASIDE_LAYOUT
1469 } GENERAL_LOOKASIDE;
1471 typedef struct _GENERAL_LOOKASIDE_POOL
1473 GENERAL_LOOKASIDE_LAYOUT
1474 } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL;
1476 typedef struct _LOOKASIDE_LIST_EX
1478 GENERAL_LOOKASIDE_POOL L;
1479 } LOOKASIDE_LIST_EX;
1481 typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST
1483 GENERAL_LOOKASIDE L;
1484 #if defined(__i386__)
1485 KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
1486 #endif
1487 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
1489 typedef struct LOOKASIDE_ALIGN _PAGED_LOOKASIDE_LIST
1491 GENERAL_LOOKASIDE L;
1492 #if defined(__i386__)
1493 FAST_MUTEX Lock__ObsoleteButDoNotDelete;
1494 #endif
1495 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
1497 typedef NTSTATUS (NTAPI EX_CALLBACK_FUNCTION)(void *CallbackContext, void *Argument1, void *Argument2);
1498 typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION;
1500 typedef ULONG OB_OPERATION;
1502 typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION {
1503 ACCESS_MASK DesiredAccess;
1504 ACCESS_MASK OriginalDesiredAccess;
1505 } OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION;
1507 typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION {
1508 ACCESS_MASK DesiredAccess;
1509 ACCESS_MASK OriginalDesiredAccess;
1510 PVOID SourceProcess;
1511 PVOID TargetProcess;
1512 } OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION;
1514 typedef union _OB_PRE_OPERATION_PARAMETERS {
1515 OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation;
1516 OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation;
1517 } OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS;
1519 typedef struct _OB_PRE_OPERATION_INFORMATION {
1520 OB_OPERATION Operation;
1521 union {
1522 ULONG Flags;
1523 struct {
1524 ULONG KernelHandle:1;
1525 ULONG Reserved:31;
1526 } DUMMYSTRUCTNAME;
1527 } DUMMYUNIONNAME;
1528 PVOID Object;
1529 POBJECT_TYPE ObjectType;
1530 PVOID CallContext;
1531 POB_PRE_OPERATION_PARAMETERS Parameters;
1532 } OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION;
1534 typedef struct _OB_POST_CREATE_HANDLE_INFORMATION {
1535 ACCESS_MASK GrantedAccess;
1536 } OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION;
1538 typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION {
1539 ACCESS_MASK GrantedAccess;
1540 } OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION;
1542 typedef union _OB_POST_OPERATION_PARAMETERS {
1543 OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation;
1544 OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation;
1545 } OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS;
1547 typedef struct _OB_POST_OPERATION_INFORMATION {
1548 OB_OPERATION Operation;
1549 union {
1550 ULONG Flags;
1551 struct {
1552 ULONG KernelHandle:1;
1553 ULONG Reserved:31;
1554 } DUMMYSTRUCTNAME;
1555 } DUMMYUNIONNAME;
1556 PVOID Object;
1557 POBJECT_TYPE ObjectType;
1558 PVOID CallContext;
1559 NTSTATUS ReturnStatus;
1560 POB_POST_OPERATION_PARAMETERS Parameters;
1561 } OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION;
1563 typedef enum _OB_PREOP_CALLBACK_STATUS {
1564 OB_PREOP_SUCCESS
1565 } OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS;
1567 typedef OB_PREOP_CALLBACK_STATUS (WINAPI *POB_PRE_OPERATION_CALLBACK)(void *context, POB_PRE_OPERATION_INFORMATION information);
1568 typedef void (WINAPI *POB_POST_OPERATION_CALLBACK)(void *context, POB_POST_OPERATION_INFORMATION information);
1570 typedef struct _OB_OPERATION_REGISTRATION {
1571 POBJECT_TYPE *ObjectType;
1572 OB_OPERATION Operations;
1573 POB_PRE_OPERATION_CALLBACK PreOperation;
1574 POB_POST_OPERATION_CALLBACK PostOperation;
1575 } OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION;
1577 typedef struct _OB_CALLBACK_REGISTRATION {
1578 USHORT Version;
1579 USHORT OperationRegistrationCount;
1580 UNICODE_STRING Altitude;
1581 PVOID RegistrationContext;
1582 OB_OPERATION_REGISTRATION *OperationRegistration;
1583 } OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION;
1585 #define OB_FLT_REGISTRATION_VERSION_0100 0x0100
1586 #define OB_FLT_REGISTRATION_VERSION OB_FLT_REGISTRATION_VERSION_0100
1588 typedef enum _DIRECTORY_NOTIFY_INFORMATION_CLASS {
1589 DirectoryNotifyInformation = 1,
1590 DirectoryNotifyExtendedInformation
1591 } DIRECTORY_NOTIFY_INFORMATION_CLASS, *PDIRECTORY_NOTIFY_INFORMATION_CLASS;
1593 typedef enum _WORK_QUEUE_TYPE {
1594 CriticalWorkQueue,
1595 DelayedWorkQueue,
1596 HyperCriticalWorkQueue,
1597 MaximumWorkQueue
1598 } WORK_QUEUE_TYPE;
1600 typedef void (WINAPI *PIO_WORKITEM_ROUTINE)(PDEVICE_OBJECT,void*);
1602 NTSTATUS WINAPI ObCloseHandle(IN HANDLE handle);
1604 #ifdef NONAMELESSUNION
1605 # ifdef NONAMELESSSTRUCT
1606 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.u2.CurrentStackLocation)
1607 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.u2.CurrentStackLocation - 1)
1608 static inline void IoSkipCurrentIrpStackLocation(IRP *irp) {irp->Tail.Overlay.s.u2.CurrentStackLocation++; irp->CurrentLocation++;}
1609 # else
1610 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.u2.CurrentStackLocation)
1611 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.u2.CurrentStackLocation - 1)
1612 static inline void IoSkipCurrentIrpStackLocation(IRP *irp) {irp->Tail.Overlay.u2.CurrentStackLocation++; irp->CurrentLocation++;}
1613 # endif
1614 #else
1615 # ifdef NONAMELESSSTRUCT
1616 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.CurrentStackLocation)
1617 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.CurrentStackLocation - 1)
1618 static inline void IoSkipCurrentIrpStackLocation(IRP *irp) {irp->Tail.Overlay.s.CurrentStackLocation++; irp->CurrentLocation++;}
1619 # else
1620 # define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation)
1621 # define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation - 1)
1622 static inline void IoSkipCurrentIrpStackLocation(IRP *irp) {irp->Tail.Overlay.CurrentStackLocation++; irp->CurrentLocation++;}
1623 # endif
1624 #endif
1626 #define IoSetCancelRoutine(irp, routine) \
1627 ((PDRIVER_CANCEL)InterlockedExchangePointer((void **)&(irp)->CancelRoutine, routine))
1629 static inline void IoSetCompletionRoutine(IRP *irp, PIO_COMPLETION_ROUTINE routine, void *context,
1630 BOOLEAN on_success, BOOLEAN on_error, BOOLEAN on_cancel)
1632 IO_STACK_LOCATION *irpsp = IoGetNextIrpStackLocation(irp);
1633 irpsp->CompletionRoutine = routine;
1634 irpsp->Context = context;
1635 irpsp->Control = 0;
1636 if (on_success) irpsp->Control |= SL_INVOKE_ON_SUCCESS;
1637 if (on_error) irpsp->Control |= SL_INVOKE_ON_ERROR;
1638 if (on_cancel) irpsp->Control |= SL_INVOKE_ON_CANCEL;
1641 static inline void IoMarkIrpPending(IRP *irp)
1643 IoGetCurrentIrpStackLocation(irp)->Control |= SL_PENDING_RETURNED;
1646 static inline void IoCopyCurrentIrpStackLocationToNext(IRP *irp)
1648 IO_STACK_LOCATION *current = IoGetCurrentIrpStackLocation(irp);
1649 IO_STACK_LOCATION *next = IoGetNextIrpStackLocation(irp);
1650 memcpy(next, current, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine));
1651 next->Control = 0;
1654 #define KernelMode 0
1655 #define UserMode 1
1657 /* directory object access rights */
1658 #define DIRECTORY_QUERY 0x0001
1659 #define DIRECTORY_TRAVERSE 0x0002
1660 #define DIRECTORY_CREATE_OBJECT 0x0004
1661 #define DIRECTORY_CREATE_SUBDIRECTORY 0x0008
1662 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
1664 /* symbolic link access rights */
1665 #define SYMBOLIC_LINK_QUERY 0x0001
1666 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
1668 NTSTATUS WINAPI DbgQueryDebugFilterState(ULONG, ULONG);
1670 void FASTCALL ExAcquireFastMutex(FAST_MUTEX*);
1671 void FASTCALL ExAcquireFastMutexUnsafe(PFAST_MUTEX);
1672 BOOLEAN WINAPI ExAcquireResourceExclusiveLite(ERESOURCE*,BOOLEAN);
1673 BOOLEAN WINAPI ExAcquireResourceSharedLite(ERESOURCE*,BOOLEAN);
1674 BOOLEAN WINAPI ExAcquireSharedStarveExclusive(ERESOURCE*,BOOLEAN);
1675 BOOLEAN WINAPI ExAcquireSharedWaitForExclusive(ERESOURCE*,BOOLEAN);
1676 void WINAPI ExFreePool(PVOID);
1677 PVOID WINAPI ExAllocatePool(POOL_TYPE,SIZE_T) __WINE_ALLOC_SIZE(2) __WINE_DEALLOC(ExFreePool) __WINE_MALLOC;
1678 PVOID WINAPI ExAllocatePoolWithQuota(POOL_TYPE,SIZE_T) __WINE_ALLOC_SIZE(2) __WINE_DEALLOC(ExFreePool) __WINE_MALLOC;
1679 void WINAPI ExFreePoolWithTag(PVOID,ULONG);
1680 PVOID WINAPI ExAllocatePoolWithTag(POOL_TYPE,SIZE_T,ULONG) __WINE_ALLOC_SIZE(2) __WINE_DEALLOC(ExFreePoolWithTag) __WINE_MALLOC;
1681 PVOID WINAPI ExAllocatePoolWithQuotaTag(POOL_TYPE,SIZE_T,ULONG) __WINE_ALLOC_SIZE(2) __WINE_DEALLOC(ExFreePoolWithTag) __WINE_MALLOC;
1682 void WINAPI ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST);
1683 void WINAPI ExDeletePagedLookasideList(PPAGED_LOOKASIDE_LIST);
1684 NTSTATUS WINAPI ExDeleteResourceLite(ERESOURCE*);
1685 ULONG WINAPI ExGetExclusiveWaiterCount(ERESOURCE*);
1686 KPROCESSOR_MODE WINAPI ExGetPreviousMode(void);
1687 ULONG WINAPI ExGetSharedWaiterCount(ERESOURCE*);
1688 void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST,PALLOCATE_FUNCTION,PFREE_FUNCTION,ULONG,SIZE_T,ULONG,USHORT);
1689 void WINAPI ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST,PALLOCATE_FUNCTION,PFREE_FUNCTION,ULONG,SIZE_T,ULONG,USHORT);
1690 NTSTATUS WINAPI ExInitializeResourceLite(ERESOURCE*);
1691 PSLIST_ENTRY WINAPI ExInterlockedFlushSList(PSLIST_HEADER);
1692 PSLIST_ENTRY WINAPI ExInterlockedPopEntrySList(PSLIST_HEADER,PKSPIN_LOCK);
1693 PSLIST_ENTRY WINAPI ExInterlockedPushEntrySList(PSLIST_HEADER,PSLIST_ENTRY,PKSPIN_LOCK);
1694 LIST_ENTRY * WINAPI ExInterlockedRemoveHeadList(LIST_ENTRY*,KSPIN_LOCK*);
1695 BOOLEAN WINAPI ExIsResourceAcquiredExclusiveLite(ERESOURCE*);
1696 ULONG WINAPI ExIsResourceAcquiredSharedLite(ERESOURCE*);
1697 void * WINAPI ExRegisterCallback(PCALLBACK_OBJECT,PCALLBACK_FUNCTION,void*);
1698 void FASTCALL ExReleaseFastMutex(FAST_MUTEX*);
1699 void FASTCALL ExReleaseFastMutexUnsafe(PFAST_MUTEX);
1700 void WINAPI ExReleaseResourceForThreadLite(ERESOURCE*,ERESOURCE_THREAD);
1701 ULONG WINAPI ExSetTimerResolution(ULONG,BOOLEAN);
1702 void WINAPI ExUnregisterCallback(void*);
1704 #define PLUGPLAY_PROPERTY_PERSISTENT 0x0001
1706 void WINAPI IoAcquireCancelSpinLock(KIRQL*);
1707 NTSTATUS WINAPI IoAcquireRemoveLockEx(IO_REMOVE_LOCK*,void*,const char*,ULONG, ULONG);
1708 NTSTATUS WINAPI IoAllocateDriverObjectExtension(PDRIVER_OBJECT,PVOID,ULONG,PVOID*);
1709 PVOID WINAPI IoAllocateErrorLogEntry(PVOID,UCHAR);
1710 PIRP WINAPI IoAllocateIrp(CCHAR,BOOLEAN);
1711 PMDL WINAPI IoAllocateMdl(PVOID,ULONG,BOOLEAN,BOOLEAN,IRP*);
1712 PIO_WORKITEM WINAPI IoAllocateWorkItem(PDEVICE_OBJECT);
1713 void WINAPI IoDetachDevice(PDEVICE_OBJECT);
1714 PDEVICE_OBJECT WINAPI IoAttachDeviceToDeviceStack(PDEVICE_OBJECT,PDEVICE_OBJECT);
1715 PIRP WINAPI IoBuildAsynchronousFsdRequest(ULONG,DEVICE_OBJECT*,void*,ULONG,LARGE_INTEGER*,IO_STATUS_BLOCK*);
1716 PIRP WINAPI IoBuildDeviceIoControlRequest(ULONG,DEVICE_OBJECT*,PVOID,ULONG,PVOID,ULONG,BOOLEAN,PKEVENT,IO_STATUS_BLOCK*);
1717 PIRP WINAPI IoBuildSynchronousFsdRequest(ULONG,DEVICE_OBJECT*,PVOID,ULONG,PLARGE_INTEGER,PKEVENT,IO_STATUS_BLOCK*);
1718 NTSTATUS WINAPI IoCallDriver(DEVICE_OBJECT*,IRP*);
1719 BOOLEAN WINAPI IoCancelIrp(IRP*);
1720 VOID WINAPI IoCompleteRequest(IRP*,UCHAR);
1721 NTSTATUS WINAPI IoCreateDevice(DRIVER_OBJECT*,ULONG,UNICODE_STRING*,DEVICE_TYPE,ULONG,BOOLEAN,DEVICE_OBJECT**);
1722 NTSTATUS WINAPI IoCreateDeviceSecure(DRIVER_OBJECT*,ULONG,UNICODE_STRING*,DEVICE_TYPE,ULONG,BOOLEAN,PCUNICODE_STRING,LPCGUID,DEVICE_OBJECT**);
1723 NTSTATUS WINAPI IoCreateDriver(UNICODE_STRING*,PDRIVER_INITIALIZE);
1724 NTSTATUS WINAPI IoCreateSymbolicLink(UNICODE_STRING*,UNICODE_STRING*);
1725 PKEVENT WINAPI IoCreateSynchronizationEvent(UNICODE_STRING*,HANDLE*);
1726 void WINAPI IoDeleteDevice(DEVICE_OBJECT*);
1727 void WINAPI IoDeleteDriver(DRIVER_OBJECT*);
1728 NTSTATUS WINAPI IoDeleteSymbolicLink(UNICODE_STRING*);
1729 void WINAPI IoFreeIrp(IRP*);
1730 void WINAPI IoFreeMdl(MDL*);
1731 void WINAPI IoFreeWorkItem(PIO_WORKITEM);
1732 DEVICE_OBJECT * WINAPI IoGetAttachedDeviceReference(DEVICE_OBJECT*);
1733 PEPROCESS WINAPI IoGetCurrentProcess(void);
1734 NTSTATUS WINAPI IoGetDeviceInterfaces(const GUID*,PDEVICE_OBJECT,ULONG,PWSTR*);
1735 NTSTATUS WINAPI IoGetDeviceObjectPointer(UNICODE_STRING*,ACCESS_MASK,PFILE_OBJECT*,PDEVICE_OBJECT*);
1736 NTSTATUS WINAPI IoGetDeviceProperty(PDEVICE_OBJECT,DEVICE_REGISTRY_PROPERTY,ULONG,PVOID,PULONG);
1737 PVOID WINAPI IoGetDriverObjectExtension(PDRIVER_OBJECT,PVOID);
1738 PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject(PFILE_OBJECT);
1739 void WINAPI IoGetStackLimits(ULONG_PTR*,ULONG_PTR*);
1740 void WINAPI IoInitializeIrp(IRP*,USHORT,CCHAR);
1741 VOID WINAPI IoInitializeRemoveLockEx(PIO_REMOVE_LOCK,ULONG,ULONG,ULONG,ULONG);
1742 void WINAPI IoInvalidateDeviceRelations(PDEVICE_OBJECT,DEVICE_RELATION_TYPE);
1743 #ifdef _WIN64
1744 BOOLEAN WINAPI IoIs32bitProcess(IRP*);
1745 #endif
1746 NTSTATUS WINAPI IoOpenDeviceRegistryKey(DEVICE_OBJECT*,ULONG,ACCESS_MASK,HANDLE*);
1747 void WINAPI IoQueueWorkItem(PIO_WORKITEM,PIO_WORKITEM_ROUTINE,WORK_QUEUE_TYPE,void*);
1748 NTSTATUS WINAPI IoRegisterDeviceInterface(PDEVICE_OBJECT,const GUID*,PUNICODE_STRING,PUNICODE_STRING);
1749 void WINAPI IoReleaseCancelSpinLock(KIRQL);
1750 void WINAPI IoReleaseRemoveLockAndWaitEx(IO_REMOVE_LOCK*,void*,ULONG);
1751 void WINAPI IoReleaseRemoveLockEx(IO_REMOVE_LOCK*,void*,ULONG);
1752 void WINAPI IoReuseIrp(IRP*,NTSTATUS);
1753 NTSTATUS WINAPI IoSetDeviceInterfaceState(UNICODE_STRING*,BOOLEAN);
1754 NTSTATUS WINAPI IoSetDevicePropertyData(DEVICE_OBJECT*,const DEVPROPKEY*,LCID,ULONG,DEVPROPTYPE,ULONG,void*);
1755 NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
1757 void FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel(KSPIN_LOCK*,KLOCK_QUEUE_HANDLE*);
1758 #ifdef __i386__
1759 void WINAPI KeAcquireSpinLock(KSPIN_LOCK*,KIRQL*);
1760 #else
1761 #define KeAcquireSpinLock( lock, irql ) *(irql) = KeAcquireSpinLockRaiseToDpc( lock )
1762 KIRQL WINAPI KeAcquireSpinLockRaiseToDpc(KSPIN_LOCK*);
1763 #endif
1764 void WINAPI KeAcquireSpinLockAtDpcLevel(KSPIN_LOCK*);
1765 void WINAPI DECLSPEC_NORETURN KeBugCheckEx(ULONG,ULONG_PTR,ULONG_PTR,ULONG_PTR,ULONG_PTR);
1766 BOOLEAN WINAPI KeCancelTimer(KTIMER*);
1767 void WINAPI KeClearEvent(PRKEVENT);
1768 NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
1769 void WINAPI KeEnterCriticalRegion(void);
1770 void WINAPI KeGenericCallDpc(PKDEFERRED_ROUTINE,PVOID);
1771 ULONG WINAPI KeGetCurrentProcessorNumber(void);
1772 PKTHREAD WINAPI KeGetCurrentThread(void);
1773 void WINAPI KeInitializeDeviceQueue(KDEVICE_QUEUE*);
1774 void WINAPI KeInitializeDpc(KDPC*,PKDEFERRED_ROUTINE,void*);
1775 void WINAPI KeInitializeEvent(PRKEVENT,EVENT_TYPE,BOOLEAN);
1776 void WINAPI KeInitializeMutex(PRKMUTEX,ULONG);
1777 void WINAPI KeInitializeSemaphore(PRKSEMAPHORE,LONG,LONG);
1778 static FORCEINLINE void WINAPI KeInitializeSpinLock( KSPIN_LOCK *lock )
1780 *lock = 0;
1782 void WINAPI KeInitializeTimerEx(PKTIMER,TIMER_TYPE);
1783 void WINAPI KeInitializeTimer(KTIMER*);
1784 BOOLEAN WINAPI KeInsertDeviceQueue(KDEVICE_QUEUE*,KDEVICE_QUEUE_ENTRY*);
1785 void WINAPI KeLeaveCriticalRegion(void);
1786 ULONG WINAPI KeQueryActiveProcessorCountEx(USHORT);
1787 KAFFINITY WINAPI KeQueryActiveProcessors(void);
1788 void WINAPI KeQuerySystemTime(LARGE_INTEGER*);
1789 void WINAPI KeQueryTickCount(LARGE_INTEGER*);
1790 ULONG WINAPI KeQueryTimeIncrement(void);
1791 LONG WINAPI KeReadStateEvent(PRKEVENT);
1792 void FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(KLOCK_QUEUE_HANDLE*);
1793 LONG WINAPI KeReleaseMutex(PRKMUTEX,BOOLEAN);
1794 LONG WINAPI KeReleaseSemaphore(PRKSEMAPHORE,KPRIORITY,LONG,BOOLEAN);
1795 void WINAPI KeReleaseSpinLock(KSPIN_LOCK*,KIRQL);
1796 void WINAPI KeReleaseSpinLockFromDpcLevel(KSPIN_LOCK*);
1797 KDEVICE_QUEUE_ENTRY * WINAPI KeRemoveDeviceQueue(KDEVICE_QUEUE*);
1798 LONG WINAPI KeResetEvent(PRKEVENT);
1799 void WINAPI KeRevertToUserAffinityThread(void);
1800 void WINAPI KeRevertToUserAffinityThreadEx(KAFFINITY affinity);
1801 LONG WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN);
1802 KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
1803 void WINAPI KeSetSystemAffinityThread(KAFFINITY);
1804 KAFFINITY WINAPI KeSetSystemAffinityThreadEx(KAFFINITY affinity);
1805 BOOLEAN WINAPI KeSetTimer(KTIMER*,LARGE_INTEGER,KDPC*);
1806 BOOLEAN WINAPI KeSetTimerEx(KTIMER*,LARGE_INTEGER,LONG,KDPC*);
1807 void WINAPI KeSignalCallDpcDone(void*);
1808 BOOLEAN WINAPI KeSignalCallDpcSynchronize(void*);
1809 NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG,void*[],WAIT_TYPE,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*,KWAIT_BLOCK*);
1810 NTSTATUS WINAPI KeWaitForSingleObject(void*,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
1812 PVOID WINAPI MmAllocateContiguousMemory(SIZE_T,PHYSICAL_ADDRESS) __WINE_ALLOC_SIZE(1) __WINE_MALLOC;
1813 void WINAPI MmFreeNonCachedMemory(PVOID,SIZE_T);
1814 PVOID WINAPI MmAllocateNonCachedMemory(SIZE_T) __WINE_ALLOC_SIZE(1) __WINE_DEALLOC(MmFreeNonCachedMemory) __WINE_MALLOC;
1815 PMDL WINAPI MmAllocatePagesForMdl(PHYSICAL_ADDRESS,PHYSICAL_ADDRESS,PHYSICAL_ADDRESS,SIZE_T);
1816 void WINAPI MmBuildMdlForNonPagedPool(MDL*);
1817 NTSTATUS WINAPI MmCopyVirtualMemory(PEPROCESS,void*,PEPROCESS,void*,SIZE_T,KPROCESSOR_MODE,SIZE_T*);
1818 void * WINAPI MmGetSystemRoutineAddress(UNICODE_STRING*);
1819 PVOID WINAPI MmMapLockedPagesSpecifyCache(PMDLX,KPROCESSOR_MODE,MEMORY_CACHING_TYPE,PVOID,ULONG,MM_PAGE_PRIORITY);
1820 MM_SYSTEMSIZE WINAPI MmQuerySystemSize(void);
1821 void WINAPI MmProbeAndLockPages(PMDLX, KPROCESSOR_MODE, LOCK_OPERATION);
1822 void WINAPI MmUnmapLockedPages(void*, PMDL);
1824 static inline void *MmGetSystemAddressForMdlSafe(MDL *mdl, ULONG priority)
1826 if (mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | MDL_SOURCE_IS_NONPAGED_POOL))
1827 return mdl->MappedSystemVa;
1828 else
1829 return MmMapLockedPagesSpecifyCache(mdl, KernelMode, MmCached, NULL, FALSE, priority);
1832 void FASTCALL ObfReferenceObject(void*);
1833 void WINAPI ObDereferenceObject(void*);
1834 USHORT WINAPI ObGetFilterVersion(void);
1835 NTSTATUS WINAPI ObRegisterCallbacks(POB_CALLBACK_REGISTRATION, void**);
1836 NTSTATUS WINAPI ObReferenceObjectByHandle(HANDLE,ACCESS_MASK,POBJECT_TYPE,KPROCESSOR_MODE,PVOID*,POBJECT_HANDLE_INFORMATION);
1837 NTSTATUS WINAPI ObReferenceObjectByName(UNICODE_STRING*,ULONG,ACCESS_STATE*,ACCESS_MASK,POBJECT_TYPE,KPROCESSOR_MODE,void*,void**);
1838 NTSTATUS WINAPI ObReferenceObjectByPointer(void*,ACCESS_MASK,POBJECT_TYPE,KPROCESSOR_MODE);
1839 void WINAPI ObUnRegisterCallbacks(void*);
1841 NTSTATUS WINAPI PoCallDriver(DEVICE_OBJECT*,IRP*);
1842 POWER_STATE WINAPI PoSetPowerState(PDEVICE_OBJECT,POWER_STATE_TYPE,POWER_STATE);
1843 void WINAPI PoStartNextPowerIrp(IRP*);
1845 NTSTATUS WINAPI PsCreateSystemThread(PHANDLE,ULONG,POBJECT_ATTRIBUTES,HANDLE,PCLIENT_ID,PKSTART_ROUTINE,PVOID);
1846 #define PsGetCurrentProcess() IoGetCurrentProcess()
1847 #define PsGetCurrentThread() ((PETHREAD)KeGetCurrentThread())
1848 HANDLE WINAPI PsGetCurrentProcessId(void);
1849 HANDLE WINAPI PsGetCurrentThreadId(void);
1850 HANDLE WINAPI PsGetProcessInheritedFromUniqueProcessId(PEPROCESS);
1851 BOOLEAN WINAPI PsGetVersion(ULONG*,ULONG*,ULONG*,UNICODE_STRING*);
1852 NTSTATUS WINAPI PsTerminateSystemThread(NTSTATUS);
1854 #ifdef __x86_64__
1855 void WINAPI RtlCopyMemoryNonTemporal(void*,const void*,SIZE_T);
1856 #else
1857 #define RtlCopyMemoryNonTemporal RtlCopyMemory
1858 #endif
1859 BOOLEAN WINAPI RtlIsNtDdiVersionAvailable(ULONG);
1861 NTSTATUS WINAPI ZwAddBootEntry(PUNICODE_STRING,PUNICODE_STRING);
1862 NTSTATUS WINAPI ZwAccessCheckAndAuditAlarm(PUNICODE_STRING,HANDLE,PUNICODE_STRING,PUNICODE_STRING,PSECURITY_DESCRIPTOR,ACCESS_MASK,PGENERIC_MAPPING,BOOLEAN,PACCESS_MASK,PBOOLEAN,PBOOLEAN);
1863 NTSTATUS WINAPI ZwAdjustPrivilegesToken(HANDLE,BOOLEAN,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
1864 NTSTATUS WINAPI ZwAlertThread(HANDLE ThreadHandle);
1865 NTSTATUS WINAPI ZwAllocateVirtualMemory(HANDLE,PVOID*,ULONG,SIZE_T*,ULONG,ULONG);
1866 NTSTATUS WINAPI ZwCancelIoFile(HANDLE,PIO_STATUS_BLOCK);
1867 NTSTATUS WINAPI ZwCancelTimer(HANDLE, BOOLEAN*);
1868 NTSTATUS WINAPI ZwClearEvent(HANDLE);
1869 NTSTATUS WINAPI ZwClose(HANDLE);
1870 NTSTATUS WINAPI ZwCloseObjectAuditAlarm(PUNICODE_STRING,HANDLE,BOOLEAN);
1871 NTSTATUS WINAPI ZwConnectPort(PHANDLE,PUNICODE_STRING,PSECURITY_QUALITY_OF_SERVICE,PLPC_SECTION_WRITE,PLPC_SECTION_READ,PULONG,PVOID,PULONG);
1872 NTSTATUS WINAPI ZwCreateDirectoryObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1873 NTSTATUS WINAPI ZwCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
1874 NTSTATUS WINAPI ZwCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG);
1875 NTSTATUS WINAPI ZwCreateKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG);
1876 NTSTATUS WINAPI ZwCreateSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const LARGE_INTEGER*,ULONG,ULONG,HANDLE);
1877 NTSTATUS WINAPI ZwCreateSymbolicLinkObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PUNICODE_STRING);
1878 NTSTATUS WINAPI ZwCreateTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*, TIMER_TYPE);
1879 NTSTATUS WINAPI ZwDeleteAtom(RTL_ATOM);
1880 NTSTATUS WINAPI ZwDeleteFile(POBJECT_ATTRIBUTES);
1881 NTSTATUS WINAPI ZwDeleteKey(HANDLE);
1882 NTSTATUS WINAPI ZwDeleteValueKey(HANDLE,const UNICODE_STRING *);
1883 NTSTATUS WINAPI ZwDeviceIoControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
1884 NTSTATUS WINAPI ZwDisplayString(PUNICODE_STRING);
1885 NTSTATUS WINAPI ZwDuplicateObject(HANDLE,HANDLE,HANDLE,PHANDLE,ACCESS_MASK,ULONG,ULONG);
1886 NTSTATUS WINAPI ZwDuplicateToken(HANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,SECURITY_IMPERSONATION_LEVEL,TOKEN_TYPE,PHANDLE);
1887 NTSTATUS WINAPI ZwEnumerateKey(HANDLE,ULONG,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
1888 NTSTATUS WINAPI ZwEnumerateValueKey(HANDLE,ULONG,KEY_VALUE_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1889 NTSTATUS WINAPI ZwFlushInstructionCache(HANDLE,LPCVOID,SIZE_T);
1890 NTSTATUS WINAPI ZwFlushKey(HANDLE);
1891 NTSTATUS WINAPI ZwFlushVirtualMemory(HANDLE,LPCVOID*,SIZE_T*,ULONG);
1892 NTSTATUS WINAPI ZwFreeVirtualMemory(HANDLE,PVOID*,SIZE_T*,ULONG);
1893 NTSTATUS WINAPI ZwFsControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
1894 NTSTATUS WINAPI ZwInitiatePowerAction(POWER_ACTION,SYSTEM_POWER_STATE,ULONG,BOOLEAN);
1895 NTSTATUS WINAPI ZwLoadDriver(const UNICODE_STRING *);
1896 NTSTATUS WINAPI ZwLoadKey(const OBJECT_ATTRIBUTES *,OBJECT_ATTRIBUTES *);
1897 NTSTATUS WINAPI ZwLockVirtualMemory(HANDLE,PVOID*,SIZE_T*,ULONG);
1898 NTSTATUS WINAPI ZwMakeTemporaryObject(HANDLE);
1899 NTSTATUS WINAPI ZwMapViewOfSection(HANDLE,HANDLE,PVOID*,ULONG,SIZE_T,const LARGE_INTEGER*,SIZE_T*,SECTION_INHERIT,ULONG,ULONG);
1900 NTSTATUS WINAPI ZwNotifyChangeKey(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN);
1901 NTSTATUS WINAPI ZwOpenDirectoryObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1902 NTSTATUS WINAPI ZwOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
1903 NTSTATUS WINAPI ZwOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG);
1904 NTSTATUS WINAPI ZwOpenKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
1905 NTSTATUS WINAPI ZwOpenProcess(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
1906 NTSTATUS WINAPI ZwOpenProcessToken(HANDLE,DWORD,HANDLE *);
1907 NTSTATUS WINAPI ZwOpenSection(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
1908 NTSTATUS WINAPI ZwOpenSymbolicLinkObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
1909 NTSTATUS WINAPI ZwOpenThread(HANDLE*,ACCESS_MASK,const OBJECT_ATTRIBUTES*,const CLIENT_ID*);
1910 NTSTATUS WINAPI ZwOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *);
1911 NTSTATUS WINAPI ZwOpenTimer(HANDLE*, ACCESS_MASK, const OBJECT_ATTRIBUTES*);
1912 NTSTATUS WINAPI ZwPowerInformation(POWER_INFORMATION_LEVEL,PVOID,ULONG,PVOID,ULONG);
1913 NTSTATUS WINAPI ZwPulseEvent(HANDLE,PULONG);
1914 NTSTATUS WINAPI ZwQueryDefaultLocale(BOOLEAN,LCID*);
1915 NTSTATUS WINAPI ZwQueryDefaultUILanguage(LANGID*);
1916 NTSTATUS WINAPI ZwQueryDirectoryFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS,BOOLEAN,PUNICODE_STRING,BOOLEAN);
1917 NTSTATUS WINAPI ZwQueryDirectoryObject(HANDLE,PDIRECTORY_BASIC_INFORMATION,ULONG,BOOLEAN,BOOLEAN,PULONG,PULONG);
1918 NTSTATUS WINAPI ZwQueryEaFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,BOOLEAN,PVOID,ULONG,PVOID,BOOLEAN);
1919 NTSTATUS WINAPI ZwQueryFullAttributesFile(const OBJECT_ATTRIBUTES*,FILE_NETWORK_OPEN_INFORMATION*);
1920 NTSTATUS WINAPI ZwQueryInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,LONG,FILE_INFORMATION_CLASS);
1921 NTSTATUS WINAPI ZwQueryInformationThread(HANDLE,THREADINFOCLASS,PVOID,ULONG,PULONG);
1922 NTSTATUS WINAPI ZwQueryInformationToken(HANDLE,DWORD,PVOID,DWORD,LPDWORD);
1923 NTSTATUS WINAPI ZwQueryInstallUILanguage(LANGID*);
1924 NTSTATUS WINAPI ZwQueryKey(HANDLE,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
1925 NTSTATUS WINAPI ZwQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
1926 NTSTATUS WINAPI ZwQuerySecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,ULONG,PULONG);
1927 NTSTATUS WINAPI ZwQuerySection(HANDLE,SECTION_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1928 NTSTATUS WINAPI ZwQuerySymbolicLinkObject(HANDLE,PUNICODE_STRING,PULONG);
1929 NTSTATUS WINAPI ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
1930 NTSTATUS WINAPI ZwQueryTimerResolution(PULONG,PULONG,PULONG);
1931 NTSTATUS WINAPI ZwQueryValueKey(HANDLE,const UNICODE_STRING *,KEY_VALUE_INFORMATION_CLASS,void *,DWORD,DWORD *);
1932 NTSTATUS WINAPI ZwQueryVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FS_INFORMATION_CLASS);
1933 NTSTATUS WINAPI ZwReadFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,PLARGE_INTEGER,PULONG);
1934 NTSTATUS WINAPI ZwReplaceKey(POBJECT_ATTRIBUTES,HANDLE,POBJECT_ATTRIBUTES);
1935 NTSTATUS WINAPI ZwRequestWaitReplyPort(HANDLE,PLPC_MESSAGE,PLPC_MESSAGE);
1936 NTSTATUS WINAPI ZwResetEvent(HANDLE,PULONG);
1937 NTSTATUS WINAPI ZwRestoreKey(HANDLE,HANDLE,ULONG);
1938 NTSTATUS WINAPI ZwSaveKey(HANDLE,HANDLE);
1939 NTSTATUS WINAPI ZwSecureConnectPort(PHANDLE,PUNICODE_STRING,PSECURITY_QUALITY_OF_SERVICE,PLPC_SECTION_WRITE,PSID,PLPC_SECTION_READ,PULONG,PVOID,PULONG);
1940 NTSTATUS WINAPI ZwSetDefaultLocale(BOOLEAN,LCID);
1941 NTSTATUS WINAPI ZwSetDefaultUILanguage(LANGID);
1942 NTSTATUS WINAPI ZwSetEaFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG);
1943 NTSTATUS WINAPI ZwSetEvent(HANDLE,PULONG);
1944 NTSTATUS WINAPI ZwSetInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS);
1945 NTSTATUS WINAPI ZwSetInformationKey(HANDLE,const int,PVOID,ULONG);
1946 NTSTATUS WINAPI ZwSetInformationObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG);
1947 NTSTATUS WINAPI ZwSetInformationProcess(HANDLE,PROCESSINFOCLASS,PVOID,ULONG);
1948 NTSTATUS WINAPI ZwSetInformationThread(HANDLE,THREADINFOCLASS,LPCVOID,ULONG);
1949 NTSTATUS WINAPI ZwSetIoCompletion(HANDLE,ULONG,ULONG,NTSTATUS,ULONG);
1950 NTSTATUS WINAPI ZwSetLdtEntries(ULONG,ULONG,ULONG,ULONG,ULONG,ULONG);
1951 NTSTATUS WINAPI ZwSetSecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
1952 NTSTATUS WINAPI ZwSetSystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG);
1953 NTSTATUS WINAPI ZwSetSystemTime(const LARGE_INTEGER*,LARGE_INTEGER*);
1954 NTSTATUS WINAPI ZwSetTimer(HANDLE, const LARGE_INTEGER*, PTIMER_APC_ROUTINE, PVOID, BOOLEAN, ULONG, BOOLEAN*);
1955 NTSTATUS WINAPI ZwSetValueKey(HANDLE,const UNICODE_STRING *,ULONG,ULONG,const void *,ULONG);
1956 NTSTATUS WINAPI ZwSetVolumeInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FS_INFORMATION_CLASS);
1957 NTSTATUS WINAPI ZwSuspendThread(HANDLE,PULONG);
1958 NTSTATUS WINAPI ZwTerminateProcess(HANDLE,LONG);
1959 NTSTATUS WINAPI ZwUnloadDriver(const UNICODE_STRING *);
1960 NTSTATUS WINAPI ZwUnloadKey(HANDLE);
1961 NTSTATUS WINAPI ZwUnmapViewOfSection(HANDLE,PVOID);
1962 NTSTATUS WINAPI ZwWaitForSingleObject(HANDLE,BOOLEAN,const LARGE_INTEGER*);
1963 NTSTATUS WINAPI ZwWaitForMultipleObjects(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
1964 NTSTATUS WINAPI ZwWriteFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,const void*,ULONG,PLARGE_INTEGER,PULONG);
1965 NTSTATUS WINAPI ZwYieldExecution(void);
1967 static inline void ExInitializeFastMutex( FAST_MUTEX *mutex )
1969 mutex->Count = FM_LOCK_BIT;
1970 mutex->Owner = NULL;
1971 mutex->Contention = 0;
1972 KeInitializeEvent( &mutex->Event, SynchronizationEvent, FALSE );
1975 #endif