4eb9ba6120702b11a154716e4860d7be0d386cca
[reactos.git] / include / ddk / winddk.h
1 /*
2 * winddk.h
3 *
4 * Windows Device Driver Kit
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23 #ifndef __WINDDK_H
24 #define __WINDDK_H
25
26 /* Helper macro to enable gcc's extension. */
27 #ifndef __GNU_EXTENSION
28 #ifdef __GNUC__
29 #define __GNU_EXTENSION __extension__
30 #else
31 #define __GNU_EXTENSION
32 #endif
33 #endif
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #include <excpt.h>
40 #include <ntdef.h>
41 #include <ntstatus.h>
42
43 #include "intrin.h"
44
45 #if !defined(_NTHAL_)
46 #define NTHALAPI DECLSPEC_IMPORT
47 #else
48 #define NTHALAPI
49 #endif
50
51 /* Pseudo modifiers for parameters */
52 #ifndef IN
53 #define IN
54 #endif
55 #ifndef OUT
56 #define OUT
57 #endif
58 #ifndef OPTIONAL
59 #define OPTIONAL
60 #endif
61 #ifndef UNALLIGNED
62 #define UNALLIGNED
63 #endif
64
65 #define CONST const
66
67 #define RESTRICTED_POINTER
68
69 #if defined(_WIN64)
70 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
71 #else
72 #define POINTER_ALIGNMENT
73 #endif
74
75 #define DECLSPEC_ADDRSAFE
76
77 #ifdef NONAMELESSUNION
78 # define _DDK_DUMMYUNION_MEMBER(name) DUMMYUNIONNAME.name
79 # define _DDK_DUMMYUNION_N_MEMBER(n, name) DUMMYUNIONNAME##n.name
80 #else
81 # define _DDK_DUMMYUNION_MEMBER(name) name
82 # define _DDK_DUMMYUNION_N_MEMBER(n, name) name
83 #endif
84
85 /*
86 ** Forward declarations
87 */
88
89 struct _KPCR;
90 struct _KPRCB;
91 struct _KTSS;
92 struct _DRIVE_LAYOUT_INFORMATION_EX;
93 struct _LOADER_PARAMETER_BLOCK;
94
95
96 #if 1
97 /* FIXME: Unknown definitions */
98 struct _SET_PARTITION_INFORMATION_EX;
99 typedef ULONG WAIT_TYPE;
100 #define WaitAll 0
101 #define WaitAny 1
102 typedef HANDLE TRACEHANDLE;
103 typedef PVOID PWMILIB_CONTEXT;
104 typedef ULONG LOGICAL;
105 #endif
106
107 /*
108 ** WmiLib specific structure
109 */
110 typedef enum
111 {
112 IrpProcessed, // Irp was processed and possibly completed
113 IrpNotCompleted, // Irp was process and NOT completed
114 IrpNotWmi, // Irp is not a WMI irp
115 IrpForward // Irp is wmi irp, but targeted at another device object
116 } SYSCTL_IRP_DISPOSITION, *PSYSCTL_IRP_DISPOSITION;
117
118 //
119 // Forwarder
120 //
121 struct _COMPRESSED_DATA_INFO;
122
123 #define KERNEL_STACK_SIZE 12288
124 #define KERNEL_LARGE_STACK_SIZE 61440
125 #define KERNEL_LARGE_STACK_COMMIT 12288
126
127 #define EXCEPTION_READ_FAULT 0
128 #define EXCEPTION_WRITE_FAULT 1
129 #define EXCEPTION_EXECUTE_FAULT 8
130
131 #define DPFLTR_ERROR_LEVEL 0
132 #define DPFLTR_WARNING_LEVEL 1
133 #define DPFLTR_TRACE_LEVEL 2
134 #define DPFLTR_INFO_LEVEL 3
135 #define DPFLTR_MASK 0x80000000
136
137 typedef enum _DPFLTR_TYPE
138 {
139 DPFLTR_SYSTEM_ID = 0,
140 DPFLTR_SMSS_ID = 1,
141 DPFLTR_SETUP_ID = 2,
142 DPFLTR_NTFS_ID = 3,
143 DPFLTR_FSTUB_ID = 4,
144 DPFLTR_CRASHDUMP_ID = 5,
145 DPFLTR_CDAUDIO_ID = 6,
146 DPFLTR_CDROM_ID = 7,
147 DPFLTR_CLASSPNP_ID = 8,
148 DPFLTR_DISK_ID = 9,
149 DPFLTR_REDBOOK_ID = 10,
150 DPFLTR_STORPROP_ID = 11,
151 DPFLTR_SCSIPORT_ID = 12,
152 DPFLTR_SCSIMINIPORT_ID = 13,
153 DPFLTR_CONFIG_ID = 14,
154 DPFLTR_I8042PRT_ID = 15,
155 DPFLTR_SERMOUSE_ID = 16,
156 DPFLTR_LSERMOUS_ID = 17,
157 DPFLTR_KBDHID_ID = 18,
158 DPFLTR_MOUHID_ID = 19,
159 DPFLTR_KBDCLASS_ID = 20,
160 DPFLTR_MOUCLASS_ID = 21,
161 DPFLTR_TWOTRACK_ID = 22,
162 DPFLTR_WMILIB_ID = 23,
163 DPFLTR_ACPI_ID = 24,
164 DPFLTR_AMLI_ID = 25,
165 DPFLTR_HALIA64_ID = 26,
166 DPFLTR_VIDEO_ID = 27,
167 DPFLTR_SVCHOST_ID = 28,
168 DPFLTR_VIDEOPRT_ID = 29,
169 DPFLTR_TCPIP_ID = 30,
170 DPFLTR_DMSYNTH_ID = 31,
171 DPFLTR_NTOSPNP_ID = 32,
172 DPFLTR_FASTFAT_ID = 33,
173 DPFLTR_SAMSS_ID = 34,
174 DPFLTR_PNPMGR_ID = 35,
175 DPFLTR_NETAPI_ID = 36,
176 DPFLTR_SCSERVER_ID = 37,
177 DPFLTR_SCCLIENT_ID = 38,
178 DPFLTR_SERIAL_ID = 39,
179 DPFLTR_SERENUM_ID = 40,
180 DPFLTR_UHCD_ID = 41,
181 DPFLTR_BOOTOK_ID = 42,
182 DPFLTR_BOOTVRFY_ID = 43,
183 DPFLTR_RPCPROXY_ID = 44,
184 DPFLTR_AUTOCHK_ID = 45,
185 DPFLTR_DCOMSS_ID = 46,
186 DPFLTR_UNIMODEM_ID = 47,
187 DPFLTR_SIS_ID = 48,
188 DPFLTR_FLTMGR_ID = 49,
189 DPFLTR_WMICORE_ID = 50,
190 DPFLTR_BURNENG_ID = 51,
191 DPFLTR_IMAPI_ID = 52,
192 DPFLTR_SXS_ID = 53,
193 DPFLTR_FUSION_ID = 54,
194 DPFLTR_IDLETASK_ID = 55,
195 DPFLTR_SOFTPCI_ID = 56,
196 DPFLTR_TAPE_ID = 57,
197 DPFLTR_MCHGR_ID = 58,
198 DPFLTR_IDEP_ID = 59,
199 DPFLTR_PCIIDE_ID = 60,
200 DPFLTR_FLOPPY_ID = 61,
201 DPFLTR_FDC_ID = 62,
202 DPFLTR_TERMSRV_ID = 63,
203 DPFLTR_W32TIME_ID = 64,
204 DPFLTR_PREFETCHER_ID = 65,
205 DPFLTR_RSFILTER_ID = 66,
206 DPFLTR_FCPORT_ID = 67,
207 DPFLTR_PCI_ID = 68,
208 DPFLTR_DMIO_ID = 69,
209 DPFLTR_DMCONFIG_ID = 70,
210 DPFLTR_DMADMIN_ID = 71,
211 DPFLTR_WSOCKTRANSPORT_ID = 72,
212 DPFLTR_VSS_ID = 73,
213 DPFLTR_PNPMEM_ID = 74,
214 DPFLTR_PROCESSOR_ID = 75,
215 DPFLTR_DMSERVER_ID = 76,
216 DPFLTR_SR_ID = 77,
217 DPFLTR_INFINIBAND_ID = 78,
218 DPFLTR_IHVDRIVER_ID = 79,
219 DPFLTR_IHVVIDEO_ID = 80,
220 DPFLTR_IHVAUDIO_ID = 81,
221 DPFLTR_IHVNETWORK_ID = 82,
222 DPFLTR_IHVSTREAMING_ID = 83,
223 DPFLTR_IHVBUS_ID = 84,
224 DPFLTR_HPS_ID = 85,
225 DPFLTR_RTLTHREADPOOL_ID = 86,
226 DPFLTR_LDR_ID = 87,
227 DPFLTR_TCPIP6_ID = 88,
228 DPFLTR_ISAPNP_ID = 89,
229 DPFLTR_SHPC_ID = 90,
230 DPFLTR_STORPORT_ID = 91,
231 DPFLTR_STORMINIPORT_ID = 92,
232 DPFLTR_PRINTSPOOLER_ID = 93,
233 DPFLTR_VDS_ID = 94,
234 DPFLTR_VDSBAS_ID = 95,
235 DPFLTR_VDSDYNDR_ID = 96,
236 DPFLTR_VDSUTIL_ID = 97,
237 DPFLTR_DFRGIFC_ID = 98,
238 DPFLTR_DEFAULT_ID = 99,
239 DPFLTR_MM_ID = 100,
240 DPFLTR_DFSC_ID = 101,
241 DPFLTR_WOW64_ID = 102,
242 DPFLTR_ENDOFTABLE_ID
243 } DPFLTR_TYPE;
244
245 /* also in winnt.h */
246
247 #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
248 #define FILE_STRUCTURED_STORAGE 0x00000441
249
250 /* end winnt.h */
251
252 #define THREAD_ALERT (0x0004)
253
254 /* Exported object types */
255 extern POBJECT_TYPE NTSYSAPI ExDesktopObjectType;
256 extern POBJECT_TYPE NTSYSAPI ExEventObjectType;
257 extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType;
258 extern POBJECT_TYPE NTSYSAPI ExWindowStationObjectType;
259 extern ULONG NTSYSAPI IoDeviceHandlerObjectSize;
260 extern POBJECT_TYPE NTSYSAPI IoDeviceHandlerObjectType;
261 extern POBJECT_TYPE NTSYSAPI IoDeviceObjectType;
262 extern POBJECT_TYPE NTSYSAPI IoDriverObjectType;
263 extern POBJECT_TYPE NTSYSAPI IoFileObjectType;
264 extern POBJECT_TYPE NTSYSAPI PsThreadType;
265 extern POBJECT_TYPE NTSYSAPI LpcPortObjectType;
266 extern POBJECT_TYPE NTSYSAPI SeTokenObjectType;
267 extern POBJECT_TYPE NTSYSAPI PsProcessType;
268
269 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
270 extern volatile CCHAR NTSYSAPI KeNumberProcessors;
271 #else
272 #if (NTDDI_VERSION >= NTDDI_WINXP)
273 extern CCHAR NTSYSAPI KeNumberProcessors;
274 #else
275 //extern PCCHAR KeNumberProcessors;
276 extern NTSYSAPI CCHAR KeNumberProcessors; //FIXME: Note to Alex: I won't fix this atm, since I prefer to discuss this with you first.
277 #endif
278 #endif
279
280 #define MAX_WOW64_SHARED_ENTRIES 16
281
282 extern volatile KSYSTEM_TIME KeTickCount;
283
284 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
285 #define NX_SUPPORT_POLICY_ALWAYSON 1
286 #define NX_SUPPORT_POLICY_OPTIN 2
287 #define NX_SUPPORT_POLICY_OPTOUT 3
288
289 typedef struct _KUSER_SHARED_DATA
290 {
291 ULONG TickCountLowDeprecated;
292 ULONG TickCountMultiplier;
293 volatile KSYSTEM_TIME InterruptTime;
294 volatile KSYSTEM_TIME SystemTime;
295 volatile KSYSTEM_TIME TimeZoneBias;
296 USHORT ImageNumberLow;
297 USHORT ImageNumberHigh;
298 WCHAR NtSystemRoot[260];
299 ULONG MaxStackTraceDepth;
300 ULONG CryptoExponent;
301 ULONG TimeZoneId;
302 ULONG LargePageMinimum;
303 ULONG Reserved2[7];
304 NT_PRODUCT_TYPE NtProductType;
305 BOOLEAN ProductTypeIsValid;
306 ULONG NtMajorVersion;
307 ULONG NtMinorVersion;
308 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
309 ULONG Reserved1;
310 ULONG Reserved3;
311 volatile ULONG TimeSlip;
312 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
313 LARGE_INTEGER SystemExpirationDate;
314 ULONG SuiteMask;
315 BOOLEAN KdDebuggerEnabled;
316 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
317 UCHAR NXSupportPolicy;
318 #endif
319 volatile ULONG ActiveConsoleId;
320 volatile ULONG DismountCount;
321 ULONG ComPlusPackage;
322 ULONG LastSystemRITEventTickCount;
323 ULONG NumberOfPhysicalPages;
324 BOOLEAN SafeBootMode;
325 ULONG TraceLogging;
326 ULONG Fill0;
327 ULONGLONG TestRetInstruction;
328 ULONG SystemCall;
329 ULONG SystemCallReturn;
330 ULONGLONG SystemCallPad[3];
331 __GNU_EXTENSION union {
332 volatile KSYSTEM_TIME TickCount;
333 volatile ULONG64 TickCountQuad;
334 };
335 ULONG Cookie;
336 #if (NTDDI_VERSION >= NTDDI_WS03)
337 LONGLONG ConsoleSessionForegroundProcessId;
338 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
339 #endif
340 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
341 USHORT UserModeGlobalLogger[8];
342 ULONG HeapTracingPid[2];
343 ULONG CritSecTracingPid[2];
344 __GNU_EXTENSION union
345 {
346 ULONG SharedDataFlags;
347 __GNU_EXTENSION struct
348 {
349 ULONG DbgErrorPortPresent:1;
350 ULONG DbgElevationEnabled:1;
351 ULONG DbgVirtEnabled:1;
352 ULONG DbgInstallerDetectEnabled:1;
353 ULONG SpareBits:28;
354 };
355 };
356 ULONG ImageFileExecutionOptions;
357 KAFFINITY ActiveProcessorAffinity;
358 #endif
359 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
360
361 /*
362 ** IRP function codes
363 */
364
365 #define IRP_MN_QUERY_DIRECTORY 0x01
366 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
367
368 #define IRP_MN_USER_FS_REQUEST 0x00
369 #define IRP_MN_MOUNT_VOLUME 0x01
370 #define IRP_MN_VERIFY_VOLUME 0x02
371 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
372 #define IRP_MN_TRACK_LINK 0x04
373 #define IRP_MN_KERNEL_CALL 0x04
374
375 #define IRP_MN_LOCK 0x01
376 #define IRP_MN_UNLOCK_SINGLE 0x02
377 #define IRP_MN_UNLOCK_ALL 0x03
378 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
379
380 #define IRP_MN_NORMAL 0x00
381 #define IRP_MN_DPC 0x01
382 #define IRP_MN_MDL 0x02
383 #define IRP_MN_COMPLETE 0x04
384 #define IRP_MN_COMPRESSED 0x08
385
386 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
387 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
388 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
389
390 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
391
392 typedef EXCEPTION_DISPOSITION
393 (DDKAPI *PEXCEPTION_ROUTINE)(
394 IN struct _EXCEPTION_RECORD *ExceptionRecord,
395 IN PVOID EstablisherFrame,
396 IN OUT struct _CONTEXT *ContextRecord,
397 IN OUT PVOID DispatcherContext);
398
399 typedef NTSTATUS
400 (DDKAPI *PDRIVER_ENTRY)(
401 IN struct _DRIVER_OBJECT *DriverObject,
402 IN PUNICODE_STRING RegistryPath);
403
404 typedef VOID
405 (DDKAPI *PDRIVER_REINITIALIZE)(
406 IN struct _DRIVER_OBJECT *DriverObject,
407 IN PVOID Context,
408 IN ULONG Count);
409
410 typedef enum _BUS_QUERY_ID_TYPE {
411 BusQueryDeviceID,
412 BusQueryHardwareIDs,
413 BusQueryCompatibleIDs,
414 BusQueryInstanceID,
415 BusQueryDeviceSerialNumber
416 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
417
418 typedef enum _DEVICE_TEXT_TYPE {
419 DeviceTextDescription,
420 DeviceTextLocationInformation
421 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
422
423 typedef BOOLEAN
424 (DDKAPI *PKTRANSFER_ROUTINE)(
425 VOID);
426
427 #define ASSERT_GATE(object) \
428 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
429 (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
430
431 #define TIMER_TABLE_SIZE 512
432 #define TIMER_TABLE_SHIFT 9
433
434 #define ASSERT_TIMER(E) \
435 ASSERT(((E)->Header.Type == TimerNotificationObject) || \
436 ((E)->Header.Type == TimerSynchronizationObject))
437
438 #define ASSERT_MUTANT(E) \
439 ASSERT((E)->Header.Type == MutantObject)
440
441 #define ASSERT_SEMAPHORE(E) \
442 ASSERT((E)->Header.Type == SemaphoreObject)
443
444 #define ASSERT_EVENT(E) \
445 ASSERT(((E)->Header.Type == NotificationEvent) || \
446 ((E)->Header.Type == SynchronizationEvent))
447
448
449 typedef enum _TIMER_TYPE {
450 NotificationTimer,
451 SynchronizationTimer
452 } TIMER_TYPE;
453
454 #define KEYBOARD_INSERT_ON 0x08
455 #define KEYBOARD_CAPS_LOCK_ON 0x04
456 #define KEYBOARD_NUM_LOCK_ON 0x02
457 #define KEYBOARD_SCROLL_LOCK_ON 0x01
458 #define KEYBOARD_ALT_KEY_DOWN 0x80
459 #define KEYBOARD_CTRL_KEY_DOWN 0x40
460 #define KEYBOARD_LEFT_SHIFT_DOWN 0x20
461 #define KEYBOARD_RIGHT_SHIFT_DOWN 0x10
462
463 typedef struct _IO_COUNTERS {
464 ULONGLONG ReadOperationCount;
465 ULONGLONG WriteOperationCount;
466 ULONGLONG OtherOperationCount;
467 ULONGLONG ReadTransferCount;
468 ULONGLONG WriteTransferCount;
469 ULONGLONG OtherTransferCount;
470 } IO_COUNTERS, *PIO_COUNTERS;
471
472 typedef struct _VM_COUNTERS
473 {
474 SIZE_T PeakVirtualSize;
475 SIZE_T VirtualSize;
476 ULONG PageFaultCount;
477 SIZE_T PeakWorkingSetSize;
478 SIZE_T WorkingSetSize;
479 SIZE_T QuotaPeakPagedPoolUsage;
480 SIZE_T QuotaPagedPoolUsage;
481 SIZE_T QuotaPeakNonPagedPoolUsage;
482 SIZE_T QuotaNonPagedPoolUsage;
483 SIZE_T PagefileUsage;
484 SIZE_T PeakPagefileUsage;
485 } VM_COUNTERS, *PVM_COUNTERS;
486
487 typedef struct _VM_COUNTERS_EX
488 {
489 SIZE_T PeakVirtualSize;
490 SIZE_T VirtualSize;
491 ULONG PageFaultCount;
492 SIZE_T PeakWorkingSetSize;
493 SIZE_T WorkingSetSize;
494 SIZE_T QuotaPeakPagedPoolUsage;
495 SIZE_T QuotaPagedPoolUsage;
496 SIZE_T QuotaPeakNonPagedPoolUsage;
497 SIZE_T QuotaNonPagedPoolUsage;
498 SIZE_T PagefileUsage;
499 SIZE_T PeakPagefileUsage;
500 SIZE_T PrivateUsage;
501 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
502
503 typedef struct _POOLED_USAGE_AND_LIMITS
504 {
505 SIZE_T PeakPagedPoolUsage;
506 SIZE_T PagedPoolUsage;
507 SIZE_T PagedPoolLimit;
508 SIZE_T PeakNonPagedPoolUsage;
509 SIZE_T NonPagedPoolUsage;
510 SIZE_T NonPagedPoolLimit;
511 SIZE_T PeakPagefileUsage;
512 SIZE_T PagefileUsage;
513 SIZE_T PagefileLimit;
514 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
515
516 typedef struct _CONTROLLER_OBJECT {
517 CSHORT Type;
518 CSHORT Size;
519 PVOID ControllerExtension;
520 KDEVICE_QUEUE DeviceWaitQueue;
521 ULONG Spare1;
522 LARGE_INTEGER Spare2;
523 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
524
525 /* DEVICE_OBJECT.Flags */
526
527 #define DO_DEVICE_HAS_NAME 0x00000040
528 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
529 #define DO_LONG_TERM_REQUESTS 0x00000200
530 #define DO_NEVER_LAST_DEVICE 0x00000400
531 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
532 #define DO_XIP 0x00020000
533
534 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
535 #define MDL_PAGES_LOCKED 0x0002
536 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
537 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
538 #define MDL_PARTIAL 0x0010
539 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
540 #define MDL_IO_PAGE_READ 0x0040
541 #define MDL_WRITE_OPERATION 0x0080
542 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
543 #define MDL_FREE_EXTRA_PTES 0x0200
544 #define MDL_DESCRIBES_AWE 0x0400
545 #define MDL_IO_SPACE 0x0800
546 #define MDL_NETWORK_HEADER 0x1000
547 #define MDL_MAPPING_CAN_FAIL 0x2000
548 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
549 #define MDL_INTERNAL 0x8000
550
551
552 #define MDL_MAPPING_FLAGS ( \
553 MDL_MAPPED_TO_SYSTEM_VA | \
554 MDL_PAGES_LOCKED | \
555 MDL_SOURCE_IS_NONPAGED_POOL | \
556 MDL_PARTIAL_HAS_BEEN_MAPPED | \
557 MDL_PARENT_MAPPED_SYSTEM_VA | \
558 MDL_SYSTEM_VA | \
559 MDL_IO_SPACE)
560
561 typedef struct _DRIVER_EXTENSION {
562 struct _DRIVER_OBJECT *DriverObject;
563 PDRIVER_ADD_DEVICE AddDevice;
564 ULONG Count;
565 UNICODE_STRING ServiceKeyName;
566 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
567
568 #define DRVO_UNLOAD_INVOKED 0x00000001
569 #define DRVO_LEGACY_DRIVER 0x00000002
570 #define DRVO_BUILTIN_DRIVER 0x00000004
571 #define DRVO_REINIT_REGISTERED 0x00000008
572 #define DRVO_INITIALIZED 0x00000010
573 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
574 #define DRVO_LEGACY_RESOURCES 0x00000040
575
576 typedef struct _DRIVER_OBJECT {
577 CSHORT Type;
578 CSHORT Size;
579 PDEVICE_OBJECT DeviceObject;
580 ULONG Flags;
581 PVOID DriverStart;
582 ULONG DriverSize;
583 PVOID DriverSection;
584 PDRIVER_EXTENSION DriverExtension;
585 UNICODE_STRING DriverName;
586 PUNICODE_STRING HardwareDatabase;
587 struct _FAST_IO_DISPATCH *FastIoDispatch;
588 PDRIVER_INITIALIZE DriverInit;
589 PDRIVER_STARTIO DriverStartIo;
590 PDRIVER_UNLOAD DriverUnload;
591 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
592 } DRIVER_OBJECT;
593 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
594
595 typedef struct _DMA_ADAPTER {
596 USHORT Version;
597 USHORT Size;
598 struct _DMA_OPERATIONS* DmaOperations;
599 } DMA_ADAPTER, *PDMA_ADAPTER;
600
601 typedef VOID
602 (DDKAPI *PPUT_DMA_ADAPTER)(
603 IN PDMA_ADAPTER DmaAdapter);
604
605 typedef PVOID
606 (DDKAPI *PALLOCATE_COMMON_BUFFER)(
607 IN PDMA_ADAPTER DmaAdapter,
608 IN ULONG Length,
609 OUT PPHYSICAL_ADDRESS LogicalAddress,
610 IN BOOLEAN CacheEnabled);
611
612 typedef VOID
613 (DDKAPI *PFREE_COMMON_BUFFER)(
614 IN PDMA_ADAPTER DmaAdapter,
615 IN ULONG Length,
616 IN PHYSICAL_ADDRESS LogicalAddress,
617 IN PVOID VirtualAddress,
618 IN BOOLEAN CacheEnabled);
619
620 typedef NTSTATUS
621 (DDKAPI *PALLOCATE_ADAPTER_CHANNEL)(
622 IN PDMA_ADAPTER DmaAdapter,
623 IN PDEVICE_OBJECT DeviceObject,
624 IN ULONG NumberOfMapRegisters,
625 IN PDRIVER_CONTROL ExecutionRoutine,
626 IN PVOID Context);
627
628 typedef BOOLEAN
629 (DDKAPI *PFLUSH_ADAPTER_BUFFERS)(
630 IN PDMA_ADAPTER DmaAdapter,
631 IN PMDL Mdl,
632 IN PVOID MapRegisterBase,
633 IN PVOID CurrentVa,
634 IN ULONG Length,
635 IN BOOLEAN WriteToDevice);
636
637 typedef VOID
638 (DDKAPI *PFREE_ADAPTER_CHANNEL)(
639 IN PDMA_ADAPTER DmaAdapter);
640
641 typedef VOID
642 (DDKAPI *PFREE_MAP_REGISTERS)(
643 IN PDMA_ADAPTER DmaAdapter,
644 PVOID MapRegisterBase,
645 ULONG NumberOfMapRegisters);
646
647 typedef PHYSICAL_ADDRESS
648 (DDKAPI *PMAP_TRANSFER)(
649 IN PDMA_ADAPTER DmaAdapter,
650 IN PMDL Mdl,
651 IN PVOID MapRegisterBase,
652 IN PVOID CurrentVa,
653 IN OUT PULONG Length,
654 IN BOOLEAN WriteToDevice);
655
656 typedef ULONG
657 (DDKAPI *PGET_DMA_ALIGNMENT)(
658 IN PDMA_ADAPTER DmaAdapter);
659
660 typedef ULONG
661 (DDKAPI *PREAD_DMA_COUNTER)(
662 IN PDMA_ADAPTER DmaAdapter);
663
664 typedef NTSTATUS
665 (DDKAPI *PGET_SCATTER_GATHER_LIST)(
666 IN PDMA_ADAPTER DmaAdapter,
667 IN PDEVICE_OBJECT DeviceObject,
668 IN PMDL Mdl,
669 IN PVOID CurrentVa,
670 IN ULONG Length,
671 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
672 IN PVOID Context,
673 IN BOOLEAN WriteToDevice);
674
675 typedef VOID
676 (DDKAPI *PPUT_SCATTER_GATHER_LIST)(
677 IN PDMA_ADAPTER DmaAdapter,
678 IN PSCATTER_GATHER_LIST ScatterGather,
679 IN BOOLEAN WriteToDevice);
680
681 typedef NTSTATUS
682 (DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
683 IN PDMA_ADAPTER DmaAdapter,
684 IN PMDL Mdl OPTIONAL,
685 IN PVOID CurrentVa,
686 IN ULONG Length,
687 OUT PULONG ScatterGatherListSize,
688 OUT PULONG pNumberOfMapRegisters OPTIONAL);
689
690 typedef NTSTATUS
691 (DDKAPI *PBUILD_SCATTER_GATHER_LIST)(
692 IN PDMA_ADAPTER DmaAdapter,
693 IN PDEVICE_OBJECT DeviceObject,
694 IN PMDL Mdl,
695 IN PVOID CurrentVa,
696 IN ULONG Length,
697 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
698 IN PVOID Context,
699 IN BOOLEAN WriteToDevice,
700 IN PVOID ScatterGatherBuffer,
701 IN ULONG ScatterGatherLength);
702
703 typedef NTSTATUS
704 (DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
705 IN PDMA_ADAPTER DmaAdapter,
706 IN PSCATTER_GATHER_LIST ScatterGather,
707 IN PMDL OriginalMdl,
708 OUT PMDL *TargetMdl);
709
710 typedef struct _DMA_OPERATIONS {
711 ULONG Size;
712 PPUT_DMA_ADAPTER PutDmaAdapter;
713 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
714 PFREE_COMMON_BUFFER FreeCommonBuffer;
715 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
716 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
717 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
718 PFREE_MAP_REGISTERS FreeMapRegisters;
719 PMAP_TRANSFER MapTransfer;
720 PGET_DMA_ALIGNMENT GetDmaAlignment;
721 PREAD_DMA_COUNTER ReadDmaCounter;
722 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
723 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
724 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
725 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
726 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
727 } DMA_OPERATIONS, *PDMA_OPERATIONS;
728
729 typedef enum _ARBITER_REQUEST_SOURCE {
730 ArbiterRequestUndefined = -1,
731 ArbiterRequestLegacyReported,
732 ArbiterRequestHalReported,
733 ArbiterRequestLegacyAssigned,
734 ArbiterRequestPnpDetected,
735 ArbiterRequestPnpEnumerated
736 } ARBITER_REQUEST_SOURCE;
737
738 typedef enum _ARBITER_RESULT {
739 ArbiterResultUndefined = -1,
740 ArbiterResultSuccess,
741 ArbiterResultExternalConflict,
742 ArbiterResultNullRequest
743 } ARBITER_RESULT;
744
745 typedef enum _ARBITER_ACTION {
746 ArbiterActionTestAllocation,
747 ArbiterActionRetestAllocation,
748 ArbiterActionCommitAllocation,
749 ArbiterActionRollbackAllocation,
750 ArbiterActionQueryAllocatedResources,
751 ArbiterActionWriteReservedResources,
752 ArbiterActionQueryConflict,
753 ArbiterActionQueryArbitrate,
754 ArbiterActionAddReserved,
755 ArbiterActionBootAllocation
756 } ARBITER_ACTION, *PARBITER_ACTION;
757
758 typedef struct _ARBITER_CONFLICT_INFO {
759 PDEVICE_OBJECT OwningObject;
760 ULONGLONG Start;
761 ULONGLONG End;
762 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
763
764 typedef struct _ARBITER_PARAMETERS {
765 union {
766 struct {
767 IN OUT PLIST_ENTRY ArbitrationList;
768 IN ULONG AllocateFromCount;
769 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
770 } TestAllocation;
771
772 struct {
773 IN OUT PLIST_ENTRY ArbitrationList;
774 IN ULONG AllocateFromCount;
775 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
776 } RetestAllocation;
777
778 struct {
779 IN OUT PLIST_ENTRY ArbitrationList;
780 } BootAllocation;
781
782 struct {
783 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
784 } QueryAllocatedResources;
785
786 struct {
787 IN PDEVICE_OBJECT PhysicalDeviceObject;
788 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
789 OUT PULONG ConflictCount;
790 OUT PARBITER_CONFLICT_INFO *Conflicts;
791 } QueryConflict;
792
793 struct {
794 IN PLIST_ENTRY ArbitrationList;
795 } QueryArbitrate;
796
797 struct {
798 IN PDEVICE_OBJECT ReserveDevice;
799 } AddReserved;
800 } Parameters;
801 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
802
803 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
804
805 typedef struct _ARBITER_LIST_ENTRY {
806 LIST_ENTRY ListEntry;
807 ULONG AlternativeCount;
808 PIO_RESOURCE_DESCRIPTOR Alternatives;
809 PDEVICE_OBJECT PhysicalDeviceObject;
810 ARBITER_REQUEST_SOURCE RequestSource;
811 ULONG Flags;
812 LONG_PTR WorkSpace;
813 INTERFACE_TYPE InterfaceType;
814 ULONG SlotNumber;
815 ULONG BusNumber;
816 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
817 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
818 ARBITER_RESULT Result;
819 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
820
821 typedef NTSTATUS
822 (DDKAPI *PARBITER_HANDLER)(
823 IN PVOID Context,
824 IN ARBITER_ACTION Action,
825 IN OUT PARBITER_PARAMETERS Parameters);
826
827 #define ARBITER_PARTIAL 0x00000001
828
829 typedef struct _ARBITER_INTERFACE {
830 USHORT Size;
831 USHORT Version;
832 PVOID Context;
833 PINTERFACE_REFERENCE InterfaceReference;
834 PINTERFACE_DEREFERENCE InterfaceDereference;
835 PARBITER_HANDLER ArbiterHandler;
836 ULONG Flags;
837 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
838
839 typedef enum _KPROFILE_SOURCE {
840 ProfileTime,
841 ProfileAlignmentFixup,
842 ProfileTotalIssues,
843 ProfilePipelineDry,
844 ProfileLoadInstructions,
845 ProfilePipelineFrozen,
846 ProfileBranchInstructions,
847 ProfileTotalNonissues,
848 ProfileDcacheMisses,
849 ProfileIcacheMisses,
850 ProfileCacheMisses,
851 ProfileBranchMispredictions,
852 ProfileStoreInstructions,
853 ProfileFpInstructions,
854 ProfileIntegerInstructions,
855 Profile2Issue,
856 Profile3Issue,
857 Profile4Issue,
858 ProfileSpecialInstructions,
859 ProfileTotalCycles,
860 ProfileIcacheIssues,
861 ProfileDcacheAccesses,
862 ProfileMemoryBarrierCycles,
863 ProfileLoadLinkedIssues,
864 ProfileMaximum
865 } KPROFILE_SOURCE;
866
867 typedef enum _HAL_QUERY_INFORMATION_CLASS {
868 HalInstalledBusInformation,
869 HalProfileSourceInformation,
870 HalInformationClassUnused1,
871 HalPowerInformation,
872 HalProcessorSpeedInformation,
873 HalCallbackInformation,
874 HalMapRegisterInformation,
875 HalMcaLogInformation,
876 HalFrameBufferCachingInformation,
877 HalDisplayBiosInformation,
878 HalProcessorFeatureInformation,
879 HalNumaTopologyInterface,
880 HalErrorInformation,
881 HalCmcLogInformation,
882 HalCpeLogInformation,
883 HalQueryMcaInterface,
884 HalQueryAMLIIllegalIOPortAddresses,
885 HalQueryMaxHotPlugMemoryAddress,
886 HalPartitionIpiInterface,
887 HalPlatformInformation,
888 HalQueryProfileSourceList
889 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
890
891 typedef enum _HAL_SET_INFORMATION_CLASS {
892 HalProfileSourceInterval,
893 HalProfileSourceInterruptHandler,
894 HalMcaRegisterDriver,
895 HalKernelErrorHandler,
896 HalCmcRegisterDriver,
897 HalCpeRegisterDriver,
898 HalMcaLog,
899 HalCmcLog,
900 HalCpeLog,
901 HalGenerateCmcInterrupt
902 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
903
904 typedef struct _HAL_PROFILE_SOURCE_INTERVAL
905 {
906 KPROFILE_SOURCE Source;
907 ULONG_PTR Interval;
908 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
909
910 typedef struct _HAL_PROFILE_SOURCE_INFORMATION
911 {
912 KPROFILE_SOURCE Source;
913 BOOLEAN Supported;
914 ULONG Interval;
915 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
916
917 typedef struct _MAP_REGISTER_ENTRY
918 {
919 PVOID MapRegister;
920 BOOLEAN WriteToDevice;
921 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
922
923 typedef struct
924 {
925 UCHAR Type;
926 BOOLEAN Valid;
927 UCHAR Reserved[2];
928 PUCHAR TranslatedAddress;
929 ULONG Length;
930 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
931
932 typedef struct
933 {
934 PHYSICAL_ADDRESS Start;
935 PHYSICAL_ADDRESS MaxEnd;
936 PVOID VirtualAddress;
937 ULONG Length;
938 BOOLEAN Cached;
939 BOOLEAN Aligned;
940 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
941
942 typedef struct
943 {
944 ULONG Bus;
945 ULONG Slot;
946 USHORT VendorID;
947 USHORT DeviceID;
948 UCHAR BaseClass;
949 UCHAR SubClass;
950 UCHAR ProgIf;
951 BOOLEAN Initialized;
952 DEBUG_DEVICE_ADDRESS BaseAddress[6];
953 DEBUG_MEMORY_REQUIREMENTS Memory;
954 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
955
956 typedef enum _KD_OPTION {
957 KD_OPTION_SET_BLOCK_ENABLE,
958 } KD_OPTION;
959
960 /* Function Type Defintions for Dispatch Functions */
961 struct _DEVICE_CONTROL_CONTEXT;
962
963 typedef VOID
964 (DDKAPI *PDEVICE_CONTROL_COMPLETION)(
965 IN struct _DEVICE_CONTROL_CONTEXT *ControlContext);
966
967 typedef struct _DEVICE_CONTROL_CONTEXT {
968 NTSTATUS Status;
969 PDEVICE_HANDLER_OBJECT DeviceHandler;
970 PDEVICE_OBJECT DeviceObject;
971 ULONG ControlCode;
972 PVOID Buffer;
973 PULONG BufferLength;
974 PVOID Context;
975 } DEVICE_CONTROL_CONTEXT, *PDEVICE_CONTROL_CONTEXT;
976
977 typedef struct _PM_DISPATCH_TABLE {
978 ULONG Signature;
979 ULONG Version;
980 PVOID Function[1];
981 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
982
983 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
984 TranslateChildToParent,
985 TranslateParentToChild
986 } RESOURCE_TRANSLATION_DIRECTION;
987
988 typedef NTSTATUS
989 (DDKAPI *PTRANSLATE_RESOURCE_HANDLER)(
990 IN PVOID Context,
991 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
992 IN RESOURCE_TRANSLATION_DIRECTION Direction,
993 IN ULONG AlternativesCount,
994 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
995 IN PDEVICE_OBJECT PhysicalDeviceObject,
996 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
997
998 typedef NTSTATUS
999 (DDKAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
1000 IN PVOID Context,
1001 IN PIO_RESOURCE_DESCRIPTOR Source,
1002 IN PDEVICE_OBJECT PhysicalDeviceObject,
1003 OUT PULONG TargetCount,
1004 OUT PIO_RESOURCE_DESCRIPTOR *Target);
1005
1006 typedef struct _TRANSLATOR_INTERFACE {
1007 USHORT Size;
1008 USHORT Version;
1009 PVOID Context;
1010 PINTERFACE_REFERENCE InterfaceReference;
1011 PINTERFACE_DEREFERENCE InterfaceDereference;
1012 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
1013 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
1014 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
1015
1016 typedef NTSTATUS
1017 (DDKAPI *pHalDeviceControl)(
1018 IN PDEVICE_HANDLER_OBJECT DeviceHandler,
1019 IN PDEVICE_OBJECT DeviceObject,
1020 IN ULONG ControlCode,
1021 IN OUT PVOID Buffer OPTIONAL,
1022 IN OUT PULONG BufferLength OPTIONAL,
1023 IN PVOID Context,
1024 IN PDEVICE_CONTROL_COMPLETION CompletionRoutine);
1025
1026 typedef VOID
1027 (FASTCALL *pHalExamineMBR)(
1028 IN PDEVICE_OBJECT DeviceObject,
1029 IN ULONG SectorSize,
1030 IN ULONG MBRTypeIdentifier,
1031 OUT PVOID *Buffer);
1032
1033 typedef VOID
1034 (FASTCALL *pHalIoAssignDriveLetters)(
1035 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1036 IN PSTRING NtDeviceName,
1037 OUT PUCHAR NtSystemPath,
1038 OUT PSTRING NtSystemPathString);
1039
1040 typedef NTSTATUS
1041 (FASTCALL *pHalIoReadPartitionTable)(
1042 IN PDEVICE_OBJECT DeviceObject,
1043 IN ULONG SectorSize,
1044 IN BOOLEAN ReturnRecognizedPartitions,
1045 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
1046
1047 typedef NTSTATUS
1048 (FASTCALL *pHalIoSetPartitionInformation)(
1049 IN PDEVICE_OBJECT DeviceObject,
1050 IN ULONG SectorSize,
1051 IN ULONG PartitionNumber,
1052 IN ULONG PartitionType);
1053
1054 typedef NTSTATUS
1055 (FASTCALL *pHalIoWritePartitionTable)(
1056 IN PDEVICE_OBJECT DeviceObject,
1057 IN ULONG SectorSize,
1058 IN ULONG SectorsPerTrack,
1059 IN ULONG NumberOfHeads,
1060 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
1061
1062 typedef PBUS_HANDLER
1063 (FASTCALL *pHalHandlerForBus)(
1064 IN INTERFACE_TYPE InterfaceType,
1065 IN ULONG BusNumber);
1066
1067 typedef VOID
1068 (FASTCALL *pHalReferenceBusHandler)(
1069 IN PBUS_HANDLER BusHandler);
1070
1071 typedef NTSTATUS
1072 (DDKAPI *pHalQuerySystemInformation)(
1073 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
1074 IN ULONG BufferSize,
1075 IN OUT PVOID Buffer,
1076 OUT PULONG ReturnedLength);
1077
1078 typedef NTSTATUS
1079 (DDKAPI *pHalSetSystemInformation)(
1080 IN HAL_SET_INFORMATION_CLASS InformationClass,
1081 IN ULONG BufferSize,
1082 IN PVOID Buffer);
1083
1084 typedef NTSTATUS
1085 (DDKAPI *pHalQueryBusSlots)(
1086 IN PBUS_HANDLER BusHandler,
1087 IN ULONG BufferSize,
1088 OUT PULONG SlotNumbers,
1089 OUT PULONG ReturnedLength);
1090
1091 typedef NTSTATUS
1092 (DDKAPI *pHalInitPnpDriver)(
1093 VOID);
1094
1095 typedef NTSTATUS
1096 (DDKAPI *pHalInitPowerManagement)(
1097 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
1098 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
1099
1100 typedef struct _DMA_ADAPTER*
1101 (DDKAPI *pHalGetDmaAdapter)(
1102 IN PVOID Context,
1103 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
1104 OUT PULONG NumberOfMapRegisters);
1105
1106 typedef NTSTATUS
1107 (DDKAPI *pHalGetInterruptTranslator)(
1108 IN INTERFACE_TYPE ParentInterfaceType,
1109 IN ULONG ParentBusNumber,
1110 IN INTERFACE_TYPE BridgeInterfaceType,
1111 IN USHORT Size,
1112 IN USHORT Version,
1113 OUT PTRANSLATOR_INTERFACE Translator,
1114 OUT PULONG BridgeBusNumber);
1115
1116 typedef NTSTATUS
1117 (DDKAPI *pHalStartMirroring)(
1118 VOID);
1119
1120 typedef NTSTATUS
1121 (DDKAPI *pHalEndMirroring)(
1122 IN ULONG PassNumber);
1123
1124 typedef NTSTATUS
1125 (DDKAPI *pHalMirrorPhysicalMemory)(
1126 IN PHYSICAL_ADDRESS PhysicalAddress,
1127 IN LARGE_INTEGER NumberOfBytes);
1128
1129 typedef NTSTATUS
1130 (DDKAPI *pHalMirrorVerify)(
1131 IN PHYSICAL_ADDRESS PhysicalAddress,
1132 IN LARGE_INTEGER NumberOfBytes);
1133
1134 typedef VOID
1135 (DDKAPI *pHalEndOfBoot)(
1136 VOID);
1137
1138 typedef
1139 BOOLEAN
1140 (DDKAPI *pHalTranslateBusAddress)(
1141 IN INTERFACE_TYPE InterfaceType,
1142 IN ULONG BusNumber,
1143 IN PHYSICAL_ADDRESS BusAddress,
1144 IN OUT PULONG AddressSpace,
1145 OUT PPHYSICAL_ADDRESS TranslatedAddress
1146 );
1147
1148 typedef
1149 NTSTATUS
1150 (DDKAPI *pHalAssignSlotResources)(
1151 IN PUNICODE_STRING RegistryPath,
1152 IN PUNICODE_STRING DriverClassName OPTIONAL,
1153 IN PDRIVER_OBJECT DriverObject,
1154 IN PDEVICE_OBJECT DeviceObject,
1155 IN INTERFACE_TYPE BusType,
1156 IN ULONG BusNumber,
1157 IN ULONG SlotNumber,
1158 IN OUT PCM_RESOURCE_LIST *AllocatedResources
1159 );
1160
1161 typedef
1162 VOID
1163 (DDKAPI *pHalHaltSystem)(
1164 VOID
1165 );
1166
1167 typedef
1168 BOOLEAN
1169 (DDKAPI *pHalResetDisplay)(
1170 VOID
1171 );
1172
1173 typedef
1174 UCHAR
1175 (DDKAPI *pHalVectorToIDTEntry)(
1176 ULONG Vector
1177 );
1178
1179 typedef
1180 BOOLEAN
1181 (DDKAPI *pHalFindBusAddressTranslation)(
1182 IN PHYSICAL_ADDRESS BusAddress,
1183 IN OUT PULONG AddressSpace,
1184 OUT PPHYSICAL_ADDRESS TranslatedAddress,
1185 IN OUT PULONG_PTR Context,
1186 IN BOOLEAN NextBus
1187 );
1188
1189 typedef
1190 NTSTATUS
1191 (DDKAPI *pKdSetupPciDeviceForDebugging)(
1192 IN PVOID LoaderBlock OPTIONAL,
1193 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
1194 );
1195
1196 typedef
1197 NTSTATUS
1198 (DDKAPI *pKdReleasePciDeviceForDebugging)(
1199 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
1200 );
1201
1202 typedef
1203 PVOID
1204 (DDKAPI *pKdGetAcpiTablePhase0)(
1205 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
1206 IN ULONG Signature
1207 );
1208
1209 typedef
1210 VOID
1211 (DDKAPI *pKdCheckPowerButton)(
1212 VOID
1213 );
1214
1215 typedef
1216 ULONG
1217 (DDKAPI *pHalGetInterruptVector)(
1218 IN INTERFACE_TYPE InterfaceType,
1219 IN ULONG BusNumber,
1220 IN ULONG BusInterruptLevel,
1221 IN ULONG BusInterruptVector,
1222 OUT PKIRQL Irql,
1223 OUT PKAFFINITY Affinity
1224 );
1225
1226 typedef
1227 NTSTATUS
1228 (DDKAPI *pHalGetVectorInput)(
1229 IN ULONG Vector,
1230 IN KAFFINITY Affinity,
1231 OUT PULONG Input,
1232 OUT PKINTERRUPT_POLARITY Polarity
1233 );
1234
1235 typedef
1236 PVOID
1237 (DDKAPI *pKdMapPhysicalMemory64)(
1238 IN PHYSICAL_ADDRESS PhysicalAddress,
1239 IN ULONG NumberPages
1240 );
1241
1242 typedef
1243 VOID
1244 (DDKAPI *pKdUnmapVirtualAddress)(
1245 IN PVOID VirtualAddress,
1246 IN ULONG NumberPages
1247 );
1248
1249 typedef
1250 ULONG
1251 (DDKAPI *pKdGetPciDataByOffset)(
1252 IN ULONG BusNumber,
1253 IN ULONG SlotNumber,
1254 OUT PVOID Buffer,
1255 IN ULONG Offset,
1256 IN ULONG Length
1257 );
1258
1259 typedef
1260 ULONG
1261 (DDKAPI *pKdSetPciDataByOffset)(
1262 IN ULONG BusNumber,
1263 IN ULONG SlotNumber,
1264 IN PVOID Buffer,
1265 IN ULONG Offset,
1266 IN ULONG Length
1267 );
1268
1269 typedef BOOLEAN
1270 (DDKAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
1271 ULONG Columns, ULONG Rows);
1272
1273 typedef struct {
1274 ULONG Version;
1275 pHalQuerySystemInformation HalQuerySystemInformation;
1276 pHalSetSystemInformation HalSetSystemInformation;
1277 pHalQueryBusSlots HalQueryBusSlots;
1278 ULONG Spare1;
1279 pHalExamineMBR HalExamineMBR;
1280 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
1281 pHalIoReadPartitionTable HalIoReadPartitionTable;
1282 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
1283 pHalIoWritePartitionTable HalIoWritePartitionTable;
1284 pHalHandlerForBus HalReferenceHandlerForBus;
1285 pHalReferenceBusHandler HalReferenceBusHandler;
1286 pHalReferenceBusHandler HalDereferenceBusHandler;
1287 pHalInitPnpDriver HalInitPnpDriver;
1288 pHalInitPowerManagement HalInitPowerManagement;
1289 pHalGetDmaAdapter HalGetDmaAdapter;
1290 pHalGetInterruptTranslator HalGetInterruptTranslator;
1291 pHalStartMirroring HalStartMirroring;
1292 pHalEndMirroring HalEndMirroring;
1293 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
1294 pHalEndOfBoot HalEndOfBoot;
1295 pHalMirrorVerify HalMirrorVerify;
1296 } HAL_DISPATCH, *PHAL_DISPATCH;
1297
1298 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTHAL_)
1299 extern NTSYSAPI PHAL_DISPATCH HalDispatchTable;
1300 #define HALDISPATCH ((PHAL_DISPATCH)&HalDispatchTable)
1301 #else
1302 extern __declspec(dllexport) HAL_DISPATCH HalDispatchTable;
1303 #define HALDISPATCH (&HalDispatchTable)
1304 #endif
1305
1306 #define HAL_DISPATCH_VERSION 3
1307 #define HalDispatchTableVersion HALDISPATCH->Version
1308 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
1309 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
1310 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
1311 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
1312 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
1313 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
1314 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
1315 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
1316 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
1317 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
1318 #define HalStartMirroring HALDISPATCH->HalStartMirroring
1319 #define HalEndMirroring HALDISPATCH->HalEndMirroring
1320 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
1321 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
1322 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
1323
1324 typedef enum _FILE_INFORMATION_CLASS {
1325 FileDirectoryInformation = 1,
1326 FileFullDirectoryInformation,
1327 FileBothDirectoryInformation,
1328 FileBasicInformation,
1329 FileStandardInformation,
1330 FileInternalInformation,
1331 FileEaInformation,
1332 FileAccessInformation,
1333 FileNameInformation,
1334 FileRenameInformation,
1335 FileLinkInformation,
1336 FileNamesInformation,
1337 FileDispositionInformation,
1338 FilePositionInformation,
1339 FileFullEaInformation,
1340 FileModeInformation,
1341 FileAlignmentInformation,
1342 FileAllInformation,
1343 FileAllocationInformation,
1344 FileEndOfFileInformation,
1345 FileAlternateNameInformation,
1346 FileStreamInformation,
1347 FilePipeInformation,
1348 FilePipeLocalInformation,
1349 FilePipeRemoteInformation,
1350 FileMailslotQueryInformation,
1351 FileMailslotSetInformation,
1352 FileCompressionInformation,
1353 FileObjectIdInformation,
1354 FileCompletionInformation,
1355 FileMoveClusterInformation,
1356 FileQuotaInformation,
1357 FileReparsePointInformation,
1358 FileNetworkOpenInformation,
1359 FileAttributeTagInformation,
1360 FileTrackingInformation,
1361 FileIdBothDirectoryInformation,
1362 FileIdFullDirectoryInformation,
1363 FileValidDataLengthInformation,
1364 FileShortNameInformation,
1365 FileMaximumInformation
1366 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
1367
1368 typedef struct _FILE_POSITION_INFORMATION {
1369 LARGE_INTEGER CurrentByteOffset;
1370 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
1371
1372 typedef struct _FILE_ALIGNMENT_INFORMATION {
1373 ULONG AlignmentRequirement;
1374 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
1375
1376 typedef struct _FILE_NAME_INFORMATION {
1377 ULONG FileNameLength;
1378 WCHAR FileName[1];
1379 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
1380
1381 #include <pshpack8.h>
1382 typedef struct _FILE_BASIC_INFORMATION {
1383 LARGE_INTEGER CreationTime;
1384 LARGE_INTEGER LastAccessTime;
1385 LARGE_INTEGER LastWriteTime;
1386 LARGE_INTEGER ChangeTime;
1387 ULONG FileAttributes;
1388 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
1389 #include <poppack.h>
1390
1391 typedef struct _FILE_STANDARD_INFORMATION {
1392 LARGE_INTEGER AllocationSize;
1393 LARGE_INTEGER EndOfFile;
1394 ULONG NumberOfLinks;
1395 BOOLEAN DeletePending;
1396 BOOLEAN Directory;
1397 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
1398
1399 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
1400 LARGE_INTEGER CreationTime;
1401 LARGE_INTEGER LastAccessTime;
1402 LARGE_INTEGER LastWriteTime;
1403 LARGE_INTEGER ChangeTime;
1404 LARGE_INTEGER AllocationSize;
1405 LARGE_INTEGER EndOfFile;
1406 ULONG FileAttributes;
1407 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
1408
1409 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
1410 ULONG FileAttributes;
1411 ULONG ReparseTag;
1412 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
1413
1414 typedef struct _FILE_DISPOSITION_INFORMATION {
1415 BOOLEAN DeleteFile;
1416 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
1417
1418 typedef struct _FILE_END_OF_FILE_INFORMATION {
1419 LARGE_INTEGER EndOfFile;
1420 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
1421
1422 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
1423 LARGE_INTEGER ValidDataLength;
1424 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
1425
1426 typedef union _FILE_SEGMENT_ELEMENT {
1427 PVOID64 Buffer;
1428 ULONGLONG Alignment;
1429 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
1430
1431 typedef enum _FSINFOCLASS {
1432 FileFsVolumeInformation = 1,
1433 FileFsLabelInformation,
1434 FileFsSizeInformation,
1435 FileFsDeviceInformation,
1436 FileFsAttributeInformation,
1437 FileFsControlInformation,
1438 FileFsFullSizeInformation,
1439 FileFsObjectIdInformation,
1440 FileFsDriverPathInformation,
1441 FileFsMaximumInformation
1442 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
1443
1444 typedef struct _FILE_FS_DEVICE_INFORMATION {
1445 DEVICE_TYPE DeviceType;
1446 ULONG Characteristics;
1447 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
1448
1449 typedef struct _FILE_FULL_EA_INFORMATION {
1450 ULONG NextEntryOffset;
1451 UCHAR Flags;
1452 UCHAR EaNameLength;
1453 USHORT EaValueLength;
1454 CHAR EaName[1];
1455 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
1456
1457 /* ERESOURCE.Flag */
1458
1459 #define ResourceNeverExclusive 0x0010
1460 #define ResourceReleaseByOtherThread 0x0020
1461 #define ResourceOwnedExclusive 0x0080
1462
1463 #define RESOURCE_HASH_TABLE_SIZE 64
1464
1465 typedef struct _DEVOBJ_EXTENSION
1466 {
1467 CSHORT Type;
1468 USHORT Size;
1469 PDEVICE_OBJECT DeviceObject;
1470 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
1471
1472 typedef BOOLEAN
1473 (DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
1474 IN struct _FILE_OBJECT *FileObject,
1475 IN PLARGE_INTEGER FileOffset,
1476 IN ULONG Length,
1477 IN BOOLEAN Wait,
1478 IN ULONG LockKey,
1479 IN BOOLEAN CheckForReadOperation,
1480 OUT PIO_STATUS_BLOCK IoStatus,
1481 IN struct _DEVICE_OBJECT *DeviceObject);
1482
1483 typedef BOOLEAN
1484 (DDKAPI *PFAST_IO_READ)(
1485 IN struct _FILE_OBJECT *FileObject,
1486 IN PLARGE_INTEGER FileOffset,
1487 IN ULONG Length,
1488 IN BOOLEAN Wait,
1489 IN ULONG LockKey,
1490 OUT PVOID Buffer,
1491 OUT PIO_STATUS_BLOCK IoStatus,
1492 IN struct _DEVICE_OBJECT *DeviceObject);
1493
1494 typedef BOOLEAN
1495 (DDKAPI *PFAST_IO_WRITE)(
1496 IN struct _FILE_OBJECT *FileObject,
1497 IN PLARGE_INTEGER FileOffset,
1498 IN ULONG Length,
1499 IN BOOLEAN Wait,
1500 IN ULONG LockKey,
1501 IN PVOID Buffer,
1502 OUT PIO_STATUS_BLOCK IoStatus,
1503 IN struct _DEVICE_OBJECT *DeviceObject);
1504
1505 typedef BOOLEAN
1506 (DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
1507 IN struct _FILE_OBJECT *FileObject,
1508 IN BOOLEAN Wait,
1509 OUT PFILE_BASIC_INFORMATION Buffer,
1510 OUT PIO_STATUS_BLOCK IoStatus,
1511 IN struct _DEVICE_OBJECT *DeviceObject);
1512
1513 typedef BOOLEAN
1514 (DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
1515 IN struct _FILE_OBJECT *FileObject,
1516 IN BOOLEAN Wait,
1517 OUT PFILE_STANDARD_INFORMATION Buffer,
1518 OUT PIO_STATUS_BLOCK IoStatus,
1519 IN struct _DEVICE_OBJECT *DeviceObject);
1520
1521 typedef BOOLEAN
1522 (DDKAPI *PFAST_IO_LOCK)(
1523 IN struct _FILE_OBJECT *FileObject,
1524 IN PLARGE_INTEGER FileOffset,
1525 IN PLARGE_INTEGER Length,
1526 PEPROCESS ProcessId,
1527 ULONG Key,
1528 BOOLEAN FailImmediately,
1529 BOOLEAN ExclusiveLock,
1530 OUT PIO_STATUS_BLOCK IoStatus,
1531 IN struct _DEVICE_OBJECT *DeviceObject);
1532
1533 typedef BOOLEAN
1534 (DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
1535 IN struct _FILE_OBJECT *FileObject,
1536 IN PLARGE_INTEGER FileOffset,
1537 IN PLARGE_INTEGER Length,
1538 PEPROCESS ProcessId,
1539 ULONG Key,
1540 OUT PIO_STATUS_BLOCK IoStatus,
1541 IN struct _DEVICE_OBJECT *DeviceObject);
1542
1543 typedef BOOLEAN
1544 (DDKAPI *PFAST_IO_UNLOCK_ALL)(
1545 IN struct _FILE_OBJECT *FileObject,
1546 PEPROCESS ProcessId,
1547 OUT PIO_STATUS_BLOCK IoStatus,
1548 IN struct _DEVICE_OBJECT *DeviceObject);
1549
1550 typedef BOOLEAN
1551 (DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
1552 IN struct _FILE_OBJECT *FileObject,
1553 PVOID ProcessId,
1554 ULONG Key,
1555 OUT PIO_STATUS_BLOCK IoStatus,
1556 IN struct _DEVICE_OBJECT *DeviceObject);
1557
1558 typedef BOOLEAN
1559 (DDKAPI *PFAST_IO_DEVICE_CONTROL)(
1560 IN struct _FILE_OBJECT *FileObject,
1561 IN BOOLEAN Wait,
1562 IN PVOID InputBuffer OPTIONAL,
1563 IN ULONG InputBufferLength,
1564 OUT PVOID OutputBuffer OPTIONAL,
1565 IN ULONG OutputBufferLength,
1566 IN ULONG IoControlCode,
1567 OUT PIO_STATUS_BLOCK IoStatus,
1568 IN struct _DEVICE_OBJECT *DeviceObject);
1569
1570 typedef VOID
1571 (DDKAPI *PFAST_IO_ACQUIRE_FILE)(
1572 IN struct _FILE_OBJECT *FileObject);
1573
1574 typedef VOID
1575 (DDKAPI *PFAST_IO_RELEASE_FILE)(
1576 IN struct _FILE_OBJECT *FileObject);
1577
1578 typedef VOID
1579 (DDKAPI *PFAST_IO_DETACH_DEVICE)(
1580 IN struct _DEVICE_OBJECT *SourceDevice,
1581 IN struct _DEVICE_OBJECT *TargetDevice);
1582
1583 typedef BOOLEAN
1584 (DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
1585 IN struct _FILE_OBJECT *FileObject,
1586 IN BOOLEAN Wait,
1587 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
1588 OUT struct _IO_STATUS_BLOCK *IoStatus,
1589 IN struct _DEVICE_OBJECT *DeviceObject);
1590
1591 typedef NTSTATUS
1592 (DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
1593 IN struct _FILE_OBJECT *FileObject,
1594 IN PLARGE_INTEGER EndingOffset,
1595 OUT struct _ERESOURCE **ResourceToRelease,
1596 IN struct _DEVICE_OBJECT *DeviceObject);
1597
1598 typedef BOOLEAN
1599 (DDKAPI *PFAST_IO_MDL_READ)(
1600 IN struct _FILE_OBJECT *FileObject,
1601 IN PLARGE_INTEGER FileOffset,
1602 IN ULONG Length,
1603 IN ULONG LockKey,
1604 OUT PMDL *MdlChain,
1605 OUT PIO_STATUS_BLOCK IoStatus,
1606 IN struct _DEVICE_OBJECT *DeviceObject);
1607
1608 typedef BOOLEAN
1609 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
1610 IN struct _FILE_OBJECT *FileObject,
1611 IN PMDL MdlChain,
1612 IN struct _DEVICE_OBJECT *DeviceObject);
1613
1614 typedef BOOLEAN
1615 (DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
1616 IN struct _FILE_OBJECT *FileObject,
1617 IN PLARGE_INTEGER FileOffset,
1618 IN ULONG Length,
1619 IN ULONG LockKey,
1620 OUT PMDL *MdlChain,
1621 OUT PIO_STATUS_BLOCK IoStatus,
1622 IN struct _DEVICE_OBJECT *DeviceObject);
1623
1624 typedef BOOLEAN
1625 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
1626 IN struct _FILE_OBJECT *FileObject,
1627 IN PLARGE_INTEGER FileOffset,
1628 IN PMDL MdlChain,
1629 IN struct _DEVICE_OBJECT *DeviceObject);
1630
1631 typedef BOOLEAN
1632 (DDKAPI *PFAST_IO_READ_COMPRESSED)(
1633 IN struct _FILE_OBJECT *FileObject,
1634 IN PLARGE_INTEGER FileOffset,
1635 IN ULONG Length,
1636 IN ULONG LockKey,
1637 OUT PVOID Buffer,
1638 OUT PMDL *MdlChain,
1639 OUT PIO_STATUS_BLOCK IoStatus,
1640 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1641 IN ULONG CompressedDataInfoLength,
1642 IN struct _DEVICE_OBJECT *DeviceObject);
1643
1644 typedef BOOLEAN
1645 (DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
1646 IN struct _FILE_OBJECT *FileObject,
1647 IN PLARGE_INTEGER FileOffset,
1648 IN ULONG Length,
1649 IN ULONG LockKey,
1650 IN PVOID Buffer,
1651 OUT PMDL *MdlChain,
1652 OUT PIO_STATUS_BLOCK IoStatus,
1653 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1654 IN ULONG CompressedDataInfoLength,
1655 IN struct _DEVICE_OBJECT *DeviceObject);
1656
1657 typedef BOOLEAN
1658 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
1659 IN struct _FILE_OBJECT *FileObject,
1660 IN PMDL MdlChain,
1661 IN struct _DEVICE_OBJECT *DeviceObject);
1662
1663 typedef BOOLEAN
1664 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
1665 IN struct _FILE_OBJECT *FileObject,
1666 IN PLARGE_INTEGER FileOffset,
1667 IN PMDL MdlChain,
1668 IN struct _DEVICE_OBJECT *DeviceObject);
1669
1670 typedef BOOLEAN
1671 (DDKAPI *PFAST_IO_QUERY_OPEN)(
1672 IN struct _IRP *Irp,
1673 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
1674 IN struct _DEVICE_OBJECT *DeviceObject);
1675
1676 typedef NTSTATUS
1677 (DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
1678 IN struct _FILE_OBJECT *FileObject,
1679 IN struct _ERESOURCE *ResourceToRelease,
1680 IN struct _DEVICE_OBJECT *DeviceObject);
1681
1682 typedef NTSTATUS
1683 (DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
1684 IN struct _FILE_OBJECT *FileObject,
1685 IN struct _DEVICE_OBJECT *DeviceObject);
1686
1687 typedef NTSTATUS
1688 (DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
1689 IN struct _FILE_OBJECT *FileObject,
1690 IN struct _DEVICE_OBJECT *DeviceObject);
1691
1692 typedef struct _FAST_IO_DISPATCH {
1693 ULONG SizeOfFastIoDispatch;
1694 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
1695 PFAST_IO_READ FastIoRead;
1696 PFAST_IO_WRITE FastIoWrite;
1697 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
1698 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
1699 PFAST_IO_LOCK FastIoLock;
1700 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
1701 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
1702 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
1703 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
1704 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
1705 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
1706 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
1707 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
1708 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
1709 PFAST_IO_MDL_READ MdlRead;
1710 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
1711 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
1712 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
1713 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
1714 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
1715 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
1716 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
1717 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
1718 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
1719 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
1720 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
1721 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
1722
1723 typedef struct _SECTION_OBJECT_POINTERS {
1724 PVOID DataSectionObject;
1725 PVOID SharedCacheMap;
1726 PVOID ImageSectionObject;
1727 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
1728
1729 typedef struct _IO_COMPLETION_CONTEXT {
1730 PVOID Port;
1731 PVOID Key;
1732 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
1733
1734 /* FILE_OBJECT.Flags */
1735
1736 #define FO_FILE_OPEN 0x00000001
1737 #define FO_SYNCHRONOUS_IO 0x00000002
1738 #define FO_ALERTABLE_IO 0x00000004
1739 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
1740 #define FO_WRITE_THROUGH 0x00000010
1741 #define FO_SEQUENTIAL_ONLY 0x00000020
1742 #define FO_CACHE_SUPPORTED 0x00000040
1743 #define FO_NAMED_PIPE 0x00000080
1744 #define FO_STREAM_FILE 0x00000100
1745 #define FO_MAILSLOT 0x00000200
1746 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
1747 #define FO_DIRECT_DEVICE_OPEN 0x00000800
1748 #define FO_FILE_MODIFIED 0x00001000
1749 #define FO_FILE_SIZE_CHANGED 0x00002000
1750 #define FO_CLEANUP_COMPLETE 0x00004000
1751 #define FO_TEMPORARY_FILE 0x00008000
1752 #define FO_DELETE_ON_CLOSE 0x00010000
1753 #define FO_OPENED_CASE_SENSITIVE 0x00020000
1754 #define FO_HANDLE_CREATED 0x00040000
1755 #define FO_FILE_FAST_IO_READ 0x00080000
1756 #define FO_RANDOM_ACCESS 0x00100000
1757 #define FO_FILE_OPEN_CANCELLED 0x00200000
1758 #define FO_VOLUME_OPEN 0x00400000
1759 #define FO_REMOTE_ORIGIN 0x01000000
1760
1761 typedef struct _FILE_OBJECT
1762 {
1763 CSHORT Type;
1764 CSHORT Size;
1765 PDEVICE_OBJECT DeviceObject;
1766 PVPB Vpb;
1767 PVOID FsContext;
1768 PVOID FsContext2;
1769 PSECTION_OBJECT_POINTERS SectionObjectPointer;
1770 PVOID PrivateCacheMap;
1771 NTSTATUS FinalStatus;
1772 struct _FILE_OBJECT *RelatedFileObject;
1773 BOOLEAN LockOperation;
1774 BOOLEAN DeletePending;
1775 BOOLEAN ReadAccess;
1776 BOOLEAN WriteAccess;
1777 BOOLEAN DeleteAccess;
1778 BOOLEAN SharedRead;
1779 BOOLEAN SharedWrite;
1780 BOOLEAN SharedDelete;
1781 ULONG Flags;
1782 UNICODE_STRING FileName;
1783 LARGE_INTEGER CurrentByteOffset;
1784 volatile ULONG Waiters;
1785 volatile ULONG Busy;
1786 PVOID LastLock;
1787 KEVENT Lock;
1788 KEVENT Event;
1789 volatile PIO_COMPLETION_CONTEXT CompletionContext;
1790 KSPIN_LOCK IrpListLock;
1791 LIST_ENTRY IrpList;
1792 volatile PVOID FileObjectExtension;
1793 } FILE_OBJECT;
1794 typedef struct _FILE_OBJECT *PFILE_OBJECT;
1795
1796 typedef enum _SECURITY_OPERATION_CODE {
1797 SetSecurityDescriptor,
1798 QuerySecurityDescriptor,
1799 DeleteSecurityDescriptor,
1800 AssignSecurityDescriptor
1801 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
1802
1803 #define INITIAL_PRIVILEGE_COUNT 3
1804
1805 typedef struct _INITIAL_PRIVILEGE_SET {
1806 ULONG PrivilegeCount;
1807 ULONG Control;
1808 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
1809 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
1810
1811 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
1812 #define SE_CREATE_TOKEN_PRIVILEGE 2
1813 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
1814 #define SE_LOCK_MEMORY_PRIVILEGE 4
1815 #define SE_INCREASE_QUOTA_PRIVILEGE 5
1816 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
1817 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
1818 #define SE_TCB_PRIVILEGE 7
1819 #define SE_SECURITY_PRIVILEGE 8
1820 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
1821 #define SE_LOAD_DRIVER_PRIVILEGE 10
1822 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
1823 #define SE_SYSTEMTIME_PRIVILEGE 12
1824 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
1825 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
1826 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
1827 #define SE_CREATE_PERMANENT_PRIVILEGE 16
1828 #define SE_BACKUP_PRIVILEGE 17
1829 #define SE_RESTORE_PRIVILEGE 18
1830 #define SE_SHUTDOWN_PRIVILEGE 19
1831 #define SE_DEBUG_PRIVILEGE 20
1832 #define SE_AUDIT_PRIVILEGE 21
1833 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
1834 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
1835 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
1836 #define SE_UNDOCK_PRIVILEGE 25
1837 #define SE_SYNC_AGENT_PRIVILEGE 26
1838 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
1839 #define SE_MANAGE_VOLUME_PRIVILEGE 28
1840 #define SE_IMPERSONATE_PRIVILEGE 29
1841 #define SE_CREATE_GLOBAL_PRIVILEGE 30
1842 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_GLOBAL_PRIVILEGE
1843
1844 typedef struct _SECURITY_SUBJECT_CONTEXT {
1845 PACCESS_TOKEN ClientToken;
1846 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
1847 PACCESS_TOKEN PrimaryToken;
1848 PVOID ProcessAuditId;
1849 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
1850
1851 #include <pshpack4.h>
1852 typedef struct _ACCESS_STATE {
1853 LUID OperationID;
1854 BOOLEAN SecurityEvaluated;
1855 BOOLEAN GenerateAudit;
1856 BOOLEAN GenerateOnClose;
1857 BOOLEAN PrivilegesAllocated;
1858 ULONG Flags;
1859 ACCESS_MASK RemainingDesiredAccess;
1860 ACCESS_MASK PreviouslyGrantedAccess;
1861 ACCESS_MASK OriginalDesiredAccess;
1862 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
1863 PSECURITY_DESCRIPTOR SecurityDescriptor;
1864 PVOID AuxData;
1865 union {
1866 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
1867 PRIVILEGE_SET PrivilegeSet;
1868 } Privileges;
1869
1870 BOOLEAN AuditPrivileges;
1871 UNICODE_STRING ObjectName;
1872 UNICODE_STRING ObjectTypeName;
1873 } ACCESS_STATE, *PACCESS_STATE;
1874 #include <poppack.h>
1875
1876 typedef struct _IO_SECURITY_CONTEXT {
1877 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
1878 PACCESS_STATE AccessState;
1879 ACCESS_MASK DesiredAccess;
1880 ULONG FullCreateOptions;
1881 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
1882
1883 #define IO_TYPE_ADAPTER 1
1884 #define IO_TYPE_CONTROLLER 2
1885 #define IO_TYPE_DEVICE 3
1886 #define IO_TYPE_DRIVER 4
1887 #define IO_TYPE_FILE 5
1888 #define IO_TYPE_IRP 6
1889 #define IO_TYPE_MASTER_ADAPTER 7
1890 #define IO_TYPE_OPEN_PACKET 8
1891 #define IO_TYPE_TIMER 9
1892 #define IO_TYPE_VPB 10
1893 #define IO_TYPE_ERROR_LOG 11
1894 #define IO_TYPE_ERROR_MESSAGE 12
1895 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
1896
1897 #define IO_TYPE_CSQ_IRP_CONTEXT 1
1898 #define IO_TYPE_CSQ 2
1899
1900 struct _IO_CSQ;
1901
1902 typedef struct _IO_CSQ_IRP_CONTEXT {
1903 ULONG Type;
1904 struct _IRP *Irp;
1905 struct _IO_CSQ *Csq;
1906 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
1907
1908 typedef VOID
1909 (DDKAPI *PIO_CSQ_INSERT_IRP)(
1910 IN struct _IO_CSQ *Csq,
1911 IN PIRP Irp);
1912
1913 typedef VOID
1914 (DDKAPI *PIO_CSQ_REMOVE_IRP)(
1915 IN struct _IO_CSQ *Csq,
1916 IN PIRP Irp);
1917
1918 typedef PIRP
1919 (DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)(
1920 IN struct _IO_CSQ *Csq,
1921 IN PIRP Irp,
1922 IN PVOID PeekContext);
1923
1924 typedef VOID
1925 (DDKAPI *PIO_CSQ_ACQUIRE_LOCK)(
1926 IN struct _IO_CSQ *Csq,
1927 OUT PKIRQL Irql);
1928
1929 typedef VOID
1930 (DDKAPI *PIO_CSQ_RELEASE_LOCK)(
1931 IN struct _IO_CSQ *Csq,
1932 IN KIRQL Irql);
1933
1934 typedef VOID
1935 (DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
1936 IN struct _IO_CSQ *Csq,
1937 IN PIRP Irp);
1938
1939 typedef struct _IO_CSQ {
1940 ULONG Type;
1941 PIO_CSQ_INSERT_IRP CsqInsertIrp;
1942 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
1943 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
1944 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
1945 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
1946 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
1947 PVOID ReservePointer;
1948 } IO_CSQ, *PIO_CSQ;
1949
1950 #if !defined(_ALPHA_)
1951 #include <pshpack4.h>
1952 #endif
1953 typedef struct _IO_STACK_LOCATION {
1954 UCHAR MajorFunction;
1955 UCHAR MinorFunction;
1956 UCHAR Flags;
1957 UCHAR Control;
1958 union {
1959 struct {
1960 PIO_SECURITY_CONTEXT SecurityContext;
1961 ULONG Options;
1962 USHORT POINTER_ALIGNMENT FileAttributes;
1963 USHORT ShareAccess;
1964 ULONG POINTER_ALIGNMENT EaLength;
1965 } Create;
1966 struct {
1967 ULONG Length;
1968 ULONG POINTER_ALIGNMENT Key;
1969 LARGE_INTEGER ByteOffset;
1970 } Read;
1971 struct {
1972 ULONG Length;
1973 ULONG POINTER_ALIGNMENT Key;
1974 LARGE_INTEGER ByteOffset;
1975 } Write;
1976 struct {
1977 ULONG Length;
1978 PUNICODE_STRING FileName;
1979 FILE_INFORMATION_CLASS FileInformationClass;
1980 ULONG FileIndex;
1981 } QueryDirectory;
1982 struct {
1983 ULONG Length;
1984 ULONG CompletionFilter;
1985 } NotifyDirectory;
1986 struct {
1987 ULONG Length;
1988 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
1989 } QueryFile;
1990 struct {
1991 ULONG Length;
1992 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
1993 PFILE_OBJECT FileObject;
1994 _ANONYMOUS_UNION union {
1995 _ANONYMOUS_STRUCT struct {
1996 BOOLEAN ReplaceIfExists;
1997 BOOLEAN AdvanceOnly;
1998 } DUMMYSTRUCTNAME;
1999 ULONG ClusterCount;
2000 HANDLE DeleteHandle;
2001 } DUMMYUNIONNAME;
2002 } SetFile;
2003 struct {
2004 ULONG Length;
2005 PVOID EaList;
2006 ULONG EaListLength;
2007 ULONG EaIndex;
2008 } QueryEa;
2009 struct {
2010 ULONG Length;
2011 } SetEa;
2012 struct {
2013 ULONG Length;
2014 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
2015 } QueryVolume;
2016 struct {
2017 ULONG Length;
2018 FS_INFORMATION_CLASS FsInformationClass;
2019 } SetVolume;
2020 struct {
2021 ULONG OutputBufferLength;
2022 ULONG InputBufferLength;
2023 ULONG FsControlCode;
2024 PVOID Type3InputBuffer;
2025 } FileSystemControl;
2026 struct {
2027 PLARGE_INTEGER Length;
2028 ULONG Key;
2029 LARGE_INTEGER ByteOffset;
2030 } LockControl;
2031 struct {
2032 ULONG OutputBufferLength;
2033 ULONG POINTER_ALIGNMENT InputBufferLength;
2034 ULONG POINTER_ALIGNMENT IoControlCode;
2035 PVOID Type3InputBuffer;
2036 } DeviceIoControl;
2037 struct {
2038 SECURITY_INFORMATION SecurityInformation;
2039 ULONG POINTER_ALIGNMENT Length;
2040 } QuerySecurity;
2041 struct {
2042 SECURITY_INFORMATION SecurityInformation;
2043 PSECURITY_DESCRIPTOR SecurityDescriptor;
2044 } SetSecurity;
2045 struct {
2046 PVPB Vpb;
2047 PDEVICE_OBJECT DeviceObject;
2048 } MountVolume;
2049 struct {
2050 PVPB Vpb;
2051 PDEVICE_OBJECT DeviceObject;
2052 } VerifyVolume;
2053 struct {
2054 struct _SCSI_REQUEST_BLOCK *Srb;
2055 } Scsi;
2056 struct {
2057 ULONG Length;
2058 PSID StartSid;
2059 struct _FILE_GET_QUOTA_INFORMATION *SidList;
2060 ULONG SidListLength;
2061 } QueryQuota;
2062 struct {
2063 ULONG Length;
2064 } SetQuota;
2065 struct {
2066 DEVICE_RELATION_TYPE Type;
2067 } QueryDeviceRelations;
2068 struct {
2069 CONST GUID *InterfaceType;
2070 USHORT Size;
2071 USHORT Version;
2072 PINTERFACE Interface;
2073 PVOID InterfaceSpecificData;
2074 } QueryInterface;
2075 struct {
2076 PDEVICE_CAPABILITIES Capabilities;
2077 } DeviceCapabilities;
2078 struct {
2079 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
2080 } FilterResourceRequirements;
2081 struct {
2082 ULONG WhichSpace;
2083 PVOID Buffer;
2084 ULONG Offset;
2085 ULONG POINTER_ALIGNMENT Length;
2086 } ReadWriteConfig;
2087 struct {
2088 BOOLEAN Lock;
2089 } SetLock;
2090 struct {
2091 BUS_QUERY_ID_TYPE IdType;
2092 } QueryId;
2093 struct {
2094 DEVICE_TEXT_TYPE DeviceTextType;
2095 LCID POINTER_ALIGNMENT LocaleId;
2096 } QueryDeviceText;
2097 struct {
2098 BOOLEAN InPath;
2099 BOOLEAN Reserved[3];
2100 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
2101 } UsageNotification;
2102 struct {
2103 SYSTEM_POWER_STATE PowerState;
2104 } WaitWake;
2105 struct {
2106 PPOWER_SEQUENCE PowerSequence;
2107 } PowerSequence;
2108 struct {
2109 ULONG SystemContext;
2110 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
2111 POWER_STATE POINTER_ALIGNMENT State;
2112 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
2113 } Power;
2114 struct {
2115 PCM_RESOURCE_LIST AllocatedResources;
2116 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
2117 } StartDevice;
2118 struct {
2119 ULONG_PTR ProviderId;
2120 PVOID DataPath;
2121 ULONG BufferSize;
2122 PVOID Buffer;
2123 } WMI;
2124 struct {
2125 PVOID Argument1;
2126 PVOID Argument2;
2127 PVOID Argument3;
2128 PVOID Argument4;
2129 } Others;
2130 } Parameters;
2131 PDEVICE_OBJECT DeviceObject;
2132 PFILE_OBJECT FileObject;
2133 PIO_COMPLETION_ROUTINE CompletionRoutine;
2134 PVOID Context;
2135 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
2136 #if !defined(_ALPHA_)
2137 #include <poppack.h>
2138 #endif
2139
2140 /* IO_STACK_LOCATION.Control */
2141
2142 #define SL_PENDING_RETURNED 0x01
2143 #define SL_ERROR_RETURNED 0x02
2144 #define SL_INVOKE_ON_CANCEL 0x20
2145 #define SL_INVOKE_ON_SUCCESS 0x40
2146 #define SL_INVOKE_ON_ERROR 0x80
2147
2148 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
2149
2150 #define PCI_WHICHSPACE_CONFIG 0x0
2151 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
2152
2153 typedef enum _KEY_INFORMATION_CLASS {
2154 KeyBasicInformation,
2155 KeyNodeInformation,
2156 KeyFullInformation,
2157 KeyNameInformation,
2158 KeyCachedInformation,
2159 KeyFlagsInformation
2160 } KEY_INFORMATION_CLASS;
2161
2162 typedef struct _KEY_BASIC_INFORMATION {
2163 LARGE_INTEGER LastWriteTime;
2164 ULONG TitleIndex;
2165 ULONG NameLength;
2166 WCHAR Name[1];
2167 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
2168
2169 typedef struct _KEY_FULL_INFORMATION {
2170 LARGE_INTEGER LastWriteTime;
2171 ULONG TitleIndex;
2172 ULONG ClassOffset;
2173 ULONG ClassLength;
2174 ULONG SubKeys;
2175 ULONG MaxNameLen;
2176 ULONG MaxClassLen;
2177 ULONG Values;
2178 ULONG MaxValueNameLen;
2179 ULONG MaxValueDataLen;
2180 WCHAR Class[1];
2181 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
2182
2183 typedef struct _KEY_NODE_INFORMATION {
2184 LARGE_INTEGER LastWriteTime;
2185 ULONG TitleIndex;
2186 ULONG ClassOffset;
2187 ULONG ClassLength;
2188 ULONG NameLength;
2189 WCHAR Name[1];
2190 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
2191
2192 typedef struct _KEY_VALUE_BASIC_INFORMATION {
2193 ULONG TitleIndex;
2194 ULONG Type;
2195 ULONG NameLength;
2196 WCHAR Name[1];
2197 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
2198
2199 typedef struct _KEY_VALUE_FULL_INFORMATION {
2200 ULONG TitleIndex;
2201 ULONG Type;
2202 ULONG DataOffset;
2203 ULONG DataLength;
2204 ULONG NameLength;
2205 WCHAR Name[1];
2206 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
2207
2208 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
2209 ULONG TitleIndex;
2210 ULONG Type;
2211 ULONG DataLength;
2212 UCHAR Data[1];
2213 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
2214
2215 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
2216 ULONG Type;
2217 ULONG DataLength;
2218 UCHAR Data[1];
2219 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
2220
2221 typedef struct _KEY_VALUE_ENTRY {
2222 PUNICODE_STRING ValueName;
2223 ULONG DataLength;
2224 ULONG DataOffset;
2225 ULONG Type;
2226 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
2227
2228 typedef enum _KEY_VALUE_INFORMATION_CLASS {
2229 KeyValueBasicInformation,
2230 KeyValueFullInformation,
2231 KeyValuePartialInformation,
2232 KeyValueFullInformationAlign64,
2233 KeyValuePartialInformationAlign64
2234 } KEY_VALUE_INFORMATION_CLASS;
2235
2236 typedef struct _KEY_WRITE_TIME_INFORMATION {
2237 LARGE_INTEGER LastWriteTime;
2238 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
2239
2240 typedef struct _KEY_USER_FLAGS_INFORMATION {
2241 ULONG UserFlags;
2242 } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
2243
2244 typedef enum _KEY_SET_INFORMATION_CLASS {
2245 KeyWriteTimeInformation,
2246 KeyUserFlagsInformation,
2247 MaxKeySetInfoClass
2248 } KEY_SET_INFORMATION_CLASS;
2249
2250 /* KEY_VALUE_Xxx.Type */
2251
2252 #define REG_NONE 0
2253 #define REG_SZ 1
2254 #define REG_EXPAND_SZ 2
2255 #define REG_BINARY 3
2256 #define REG_DWORD 4
2257 #define REG_DWORD_LITTLE_ENDIAN 4
2258 #define REG_DWORD_BIG_ENDIAN 5
2259 #define REG_LINK 6
2260 #define REG_MULTI_SZ 7
2261 #define REG_RESOURCE_LIST 8
2262 #define REG_FULL_RESOURCE_DESCRIPTOR 9
2263 #define REG_RESOURCE_REQUIREMENTS_LIST 10
2264 #define REG_QWORD 11
2265 #define REG_QWORD_LITTLE_ENDIAN 11
2266
2267 #define PCI_TYPE0_ADDRESSES 6
2268 #define PCI_TYPE1_ADDRESSES 2
2269 #define PCI_TYPE2_ADDRESSES 5
2270
2271 typedef struct _PCI_COMMON_CONFIG {
2272 USHORT VendorID;
2273 USHORT DeviceID;
2274 USHORT Command;
2275 USHORT Status;
2276 UCHAR RevisionID;
2277 UCHAR ProgIf;
2278 UCHAR SubClass;
2279 UCHAR BaseClass;
2280 UCHAR CacheLineSize;
2281 UCHAR LatencyTimer;
2282 UCHAR HeaderType;
2283 UCHAR BIST;
2284 union {
2285 struct _PCI_HEADER_TYPE_0 {
2286 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
2287 ULONG CIS;
2288 USHORT SubVendorID;
2289 USHORT SubSystemID;
2290 ULONG ROMBaseAddress;
2291 UCHAR CapabilitiesPtr;
2292 UCHAR Reserved1[3];
2293 ULONG Reserved2;
2294 UCHAR InterruptLine;
2295 UCHAR InterruptPin;
2296 UCHAR MinimumGrant;
2297 UCHAR MaximumLatency;
2298 } type0;
2299 struct _PCI_HEADER_TYPE_1 {
2300 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
2301 UCHAR PrimaryBus;
2302 UCHAR SecondaryBus;
2303 UCHAR SubordinateBus;
2304 UCHAR SecondaryLatency;
2305 UCHAR IOBase;
2306 UCHAR IOLimit;
2307 USHORT SecondaryStatus;
2308 USHORT MemoryBase;
2309 USHORT MemoryLimit;
2310 USHORT PrefetchBase;
2311 USHORT PrefetchLimit;
2312 ULONG PrefetchBaseUpper32;
2313 ULONG PrefetchLimitUpper32;
2314 USHORT IOBaseUpper16;
2315 USHORT IOLimitUpper16;
2316 UCHAR CapabilitiesPtr;
2317 UCHAR Reserved1[3];
2318 ULONG ROMBaseAddress;
2319 UCHAR InterruptLine;
2320 UCHAR InterruptPin;
2321 USHORT BridgeControl;
2322 } type1;
2323 struct _PCI_HEADER_TYPE_2 {
2324 ULONG SocketRegistersBaseAddress;
2325 UCHAR CapabilitiesPtr;
2326 UCHAR Reserved;
2327 USHORT SecondaryStatus;
2328 UCHAR PrimaryBus;
2329 UCHAR SecondaryBus;
2330 UCHAR SubordinateBus;
2331 UCHAR SecondaryLatency;
2332 struct {
2333 ULONG Base;
2334 ULONG Limit;
2335 } Range[PCI_TYPE2_ADDRESSES - 1];
2336 UCHAR InterruptLine;
2337 UCHAR InterruptPin;
2338 USHORT BridgeControl;
2339 } type2;
2340 } u;
2341 UCHAR DeviceSpecific[192];
2342 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
2343
2344 /* PCI_COMMON_CONFIG.Command */
2345
2346 #define PCI_ENABLE_IO_SPACE 0x0001
2347 #define PCI_ENABLE_MEMORY_SPACE 0x0002
2348 #define PCI_ENABLE_BUS_MASTER 0x0004
2349 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
2350 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
2351 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
2352 #define PCI_ENABLE_PARITY 0x0040
2353 #define PCI_ENABLE_WAIT_CYCLE 0x0080
2354 #define PCI_ENABLE_SERR 0x0100
2355 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
2356
2357 /* PCI_COMMON_CONFIG.Status */
2358
2359 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
2360 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
2361 #define PCI_STATUS_UDF_SUPPORTED 0x0040
2362 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
2363 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
2364 #define PCI_STATUS_DEVSEL 0x0600
2365 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
2366 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
2367 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
2368 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
2369 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
2370
2371 /* PCI_COMMON_CONFIG.HeaderType */
2372
2373 #define PCI_MULTIFUNCTION 0x80
2374 #define PCI_DEVICE_TYPE 0x00
2375 #define PCI_BRIDGE_TYPE 0x01
2376 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
2377
2378 #define PCI_CONFIGURATION_TYPE(PciData) \
2379 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
2380
2381 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
2382 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
2383
2384 /* PCI device classes */
2385
2386 #define PCI_CLASS_PRE_20 0x00
2387 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
2388 #define PCI_CLASS_NETWORK_CTLR 0x02
2389 #define PCI_CLASS_DISPLAY_CTLR 0x03
2390 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
2391 #define PCI_CLASS_MEMORY_CTLR 0x05
2392 #define PCI_CLASS_BRIDGE_DEV 0x06
2393 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
2394 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
2395 #define PCI_CLASS_INPUT_DEV 0x09
2396 #define PCI_CLASS_DOCKING_STATION 0x0a
2397 #define PCI_CLASS_PROCESSOR 0x0b
2398 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
2399
2400 /* PCI device subclasses for class 0 */
2401
2402 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
2403 #define PCI_SUBCLASS_PRE_20_VGA 0x01
2404
2405 /* PCI device subclasses for class 1 (mass storage controllers)*/
2406
2407 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
2408 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
2409 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
2410 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
2411 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
2412 #define PCI_SUBCLASS_MSC_OTHER 0x80
2413
2414 /* PCI device subclasses for class 2 (network controllers)*/
2415
2416 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
2417 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
2418 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
2419 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
2420 #define PCI_SUBCLASS_NET_OTHER 0x80
2421
2422 /* PCI device subclasses for class 3 (display controllers)*/
2423
2424 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
2425 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
2426 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
2427 #define PCI_SUBCLASS_VID_OTHER 0x80
2428
2429 /* PCI device subclasses for class 4 (multimedia device)*/
2430
2431 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
2432 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
2433 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
2434 #define PCI_SUBCLASS_MM_OTHER 0x80
2435
2436 /* PCI device subclasses for class 5 (memory controller)*/
2437
2438 #define PCI_SUBCLASS_MEM_RAM 0x00
2439 #define PCI_SUBCLASS_MEM_FLASH 0x01
2440 #define PCI_SUBCLASS_MEM_OTHER 0x80
2441
2442 /* PCI device subclasses for class 6 (bridge device)*/
2443
2444 #define PCI_SUBCLASS_BR_HOST 0x00
2445 #define PCI_SUBCLASS_BR_ISA 0x01
2446 #define PCI_SUBCLASS_BR_EISA 0x02
2447 #define PCI_SUBCLASS_BR_MCA 0x03
2448 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
2449 #define PCI_SUBCLASS_BR_PCMCIA 0x05
2450 #define PCI_SUBCLASS_BR_NUBUS 0x06
2451 #define PCI_SUBCLASS_BR_CARDBUS 0x07
2452 #define PCI_SUBCLASS_BR_OTHER 0x80
2453
2454 /* PCI device subclasses for class C (serial bus controller)*/
2455
2456 #define PCI_SUBCLASS_SB_IEEE1394 0x00
2457 #define PCI_SUBCLASS_SB_ACCESS 0x01
2458 #define PCI_SUBCLASS_SB_SSA 0x02
2459 #define PCI_SUBCLASS_SB_USB 0x03
2460 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
2461 #define PCI_SUBCLASS_SB_SMBUS 0x05
2462
2463 #define PCI_MAX_DEVICES 32
2464 #define PCI_MAX_FUNCTION 8
2465 #define PCI_MAX_BRIDGE_NUMBER 0xFF
2466 #define PCI_INVALID_VENDORID 0xFFFF
2467 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
2468
2469 #define PCI_ADDRESS_MEMORY_SPACE 0x00000000
2470 #define PCI_ADDRESS_IO_SPACE 0x00000001
2471 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
2472 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
2473 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
2474 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
2475 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
2476
2477 #define PCI_TYPE_32BIT 0
2478 #define PCI_TYPE_20BIT 2
2479 #define PCI_TYPE_64BIT 4
2480
2481 typedef struct _PCI_SLOT_NUMBER {
2482 union {
2483 struct {
2484 ULONG DeviceNumber : 5;
2485 ULONG FunctionNumber : 3;
2486 ULONG Reserved : 24;
2487 } bits;
2488 ULONG AsULONG;
2489 } u;
2490 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
2491
2492 #define POOL_COLD_ALLOCATION 256
2493 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8
2494 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16
2495
2496 typedef struct _OSVERSIONINFOA {
2497 ULONG dwOSVersionInfoSize;
2498 ULONG dwMajorVersion;
2499 ULONG dwMinorVersion;
2500 ULONG dwBuildNumber;
2501 ULONG dwPlatformId;
2502 CHAR szCSDVersion[128];
2503 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
2504
2505 typedef struct _OSVERSIONINFOW {
2506 ULONG dwOSVersionInfoSize;
2507 ULONG dwMajorVersion;
2508 ULONG dwMinorVersion;
2509 ULONG dwBuildNumber;
2510 ULONG dwPlatformId;
2511 WCHAR szCSDVersion[128];
2512 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
2513
2514 #ifdef UNICODE
2515 typedef OSVERSIONINFOW OSVERSIONINFO;
2516 typedef POSVERSIONINFOW POSVERSIONINFO;
2517 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
2518 #else
2519 typedef OSVERSIONINFOA OSVERSIONINFO;
2520 typedef POSVERSIONINFOA POSVERSIONINFO;
2521 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
2522 #endif // UNICODE
2523
2524 typedef struct _OSVERSIONINFOEXA {
2525 ULONG dwOSVersionInfoSize;
2526 ULONG dwMajorVersion;
2527 ULONG dwMinorVersion;
2528 ULONG dwBuildNumber;
2529 ULONG dwPlatformId;
2530 CHAR szCSDVersion[128];
2531 USHORT wServicePackMajor;
2532 USHORT wServicePackMinor;
2533 USHORT wSuiteMask;
2534 UCHAR wProductType;
2535 UCHAR wReserved;
2536 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
2537
2538 typedef struct _OSVERSIONINFOEXW {
2539 ULONG dwOSVersionInfoSize;
2540 ULONG dwMajorVersion;
2541 ULONG dwMinorVersion;
2542 ULONG dwBuildNumber;
2543 ULONG dwPlatformId;
2544 WCHAR szCSDVersion[128];
2545 USHORT wServicePackMajor;
2546 USHORT wServicePackMinor;
2547 USHORT wSuiteMask;
2548 UCHAR wProductType;
2549 UCHAR wReserved;
2550 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
2551
2552 #ifdef UNICODE
2553 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
2554 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
2555 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
2556 #else
2557 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
2558 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
2559 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
2560 #endif // UNICODE
2561
2562 NTSYSAPI
2563 ULONGLONG
2564 DDKAPI
2565 VerSetConditionMask(
2566 IN ULONGLONG ConditionMask,
2567 IN ULONG TypeMask,
2568 IN UCHAR Condition);
2569
2570 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
2571 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
2572 (TypeBitMask), (ComparisonType)))
2573
2574 /* RtlVerifyVersionInfo() TypeMask */
2575
2576 #define VER_MINORVERSION 0x0000001
2577 #define VER_MAJORVERSION 0x0000002
2578 #define VER_BUILDNUMBER 0x0000004
2579 #define VER_PLATFORMID 0x0000008
2580 #define VER_SERVICEPACKMINOR 0x0000010
2581 #define VER_SERVICEPACKMAJOR 0x0000020
2582 #define VER_SUITENAME 0x0000040
2583 #define VER_PRODUCT_TYPE 0x0000080
2584
2585 /* RtlVerifyVersionInfo() ComparisonType */
2586
2587 #define VER_EQUAL 1
2588 #define VER_GREATER 2
2589 #define VER_GREATER_EQUAL 3
2590 #define VER_LESS 4
2591 #define VER_LESS_EQUAL 5
2592 #define VER_AND 6
2593 #define VER_OR 7
2594
2595 #define VER_CONDITION_MASK 7
2596 #define VER_NUM_BITS_PER_CONDITION_MASK 3
2597
2598 struct _RTL_RANGE;
2599
2600 typedef BOOLEAN
2601 (NTAPI *PRTL_CONFLICT_RANGE_CALLBACK) (
2602 PVOID Context,
2603 struct _RTL_RANGE *Range
2604 );
2605
2606 typedef enum _EVENT_TYPE {
2607 NotificationEvent,
2608 SynchronizationEvent
2609 } EVENT_TYPE;
2610
2611 typedef enum _KWAIT_REASON {
2612 Executive,
2613 FreePage,
2614 PageIn,
2615 PoolAllocation,
2616 DelayExecution,
2617 Suspended,
2618 UserRequest,
2619 WrExecutive,
2620 WrFreePage,
2621 WrPageIn,
2622 WrPoolAllocation,
2623 WrDelayExecution,
2624 WrSuspended,
2625 WrUserRequest,
2626 WrEventPair,
2627 WrQueue,
2628 WrLpcReceive,
2629 WrLpcReply,
2630 WrVirtualMemory,
2631 WrPageOut,
2632 WrRendezvous,
2633 Spare2,
2634 WrGuardedMutex,
2635 Spare4,
2636 Spare5,
2637 Spare6,
2638 WrKernel,
2639 WrResource,
2640 WrPushLock,
2641 WrMutex,
2642 WrQuantumEnd,
2643 WrDispatchInt,
2644 WrPreempted,
2645 WrYieldExecution,
2646 MaximumWaitReason
2647 } KWAIT_REASON;
2648
2649 typedef struct _KWAIT_BLOCK {
2650 LIST_ENTRY WaitListEntry;
2651 struct _KTHREAD * RESTRICTED_POINTER Thread;
2652 PVOID Object;
2653 struct _KWAIT_BLOCK * RESTRICTED_POINTER NextWaitBlock;
2654 USHORT WaitKey;
2655 UCHAR WaitType;
2656 UCHAR SpareByte;
2657 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
2658
2659 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
2660
2661 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
2662 BOOLEAN Removed;
2663 BOOLEAN Reserved[3];
2664 volatile LONG IoCount;
2665 KEVENT RemoveEvent;
2666 } IO_REMOVE_LOCK_COMMON_BLOCK;
2667
2668 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
2669 LONG Signature;
2670 LONG HighWatermark;
2671 LONGLONG MaxLockedTicks;
2672 LONG AllocateTag;
2673 LIST_ENTRY LockList;
2674 KSPIN_LOCK Spin;
2675 volatile LONG LowMemoryCount;
2676 ULONG Reserved1[4];
2677 PVOID Reserved2;
2678 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
2679 } IO_REMOVE_LOCK_DBG_BLOCK;
2680
2681 typedef struct _IO_REMOVE_LOCK {
2682 IO_REMOVE_LOCK_COMMON_BLOCK Common;
2683 #if DBG
2684 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
2685 #endif
2686 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
2687
2688 typedef struct _IO_WORKITEM *PIO_WORKITEM;
2689
2690 typedef VOID
2691 (DDKAPI IO_WORKITEM_ROUTINE)(
2692 IN PDEVICE_OBJECT DeviceObject,
2693 IN PVOID Context);
2694 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
2695
2696 typedef struct _SHARE_ACCESS {
2697 ULONG OpenCount;
2698 ULONG Readers;
2699 ULONG Writers;
2700 ULONG Deleters;
2701 ULONG SharedRead;
2702 ULONG SharedWrite;
2703 ULONG SharedDelete;
2704 } SHARE_ACCESS, *PSHARE_ACCESS;
2705
2706 typedef enum _KINTERRUPT_MODE {
2707 LevelSensitive,
2708 Latched
2709 } KINTERRUPT_MODE;
2710
2711 #define THREAD_WAIT_OBJECTS 3
2712
2713 typedef VOID
2714 (DDKAPI *PKINTERRUPT_ROUTINE)(
2715 VOID);
2716
2717 typedef enum _CREATE_FILE_TYPE {
2718 CreateFileTypeNone,
2719 CreateFileTypeNamedPipe,
2720 CreateFileTypeMailslot
2721 } CREATE_FILE_TYPE;
2722
2723 typedef struct _CONFIGURATION_INFORMATION {
2724 ULONG DiskCount;
2725 ULONG FloppyCount;
2726 ULONG CdRomCount;
2727 ULONG TapeCount;
2728 ULONG ScsiPortCount;
2729 ULONG SerialCount;
2730 ULONG ParallelCount;
2731 BOOLEAN AtDiskPrimaryAddressClaimed;
2732 BOOLEAN AtDiskSecondaryAddressClaimed;
2733 ULONG Version;
2734 ULONG MediumChangerCount;
2735 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
2736
2737 typedef enum _CONFIGURATION_TYPE {
2738 ArcSystem,
2739 CentralProcessor,
2740 FloatingPointProcessor,
2741 PrimaryIcache,
2742 PrimaryDcache,
2743 SecondaryIcache,
2744 SecondaryDcache,
2745 SecondaryCache,
2746 EisaAdapter,
2747 TcAdapter,
2748 ScsiAdapter,
2749 DtiAdapter,
2750 MultiFunctionAdapter,
2751 DiskController,
2752 TapeController,
2753 CdromController,
2754 WormController,
2755 SerialController,
2756 NetworkController,
2757 DisplayController,
2758 ParallelController,
2759 PointerController,
2760 KeyboardController,
2761 AudioController,
2762 OtherController,
2763 DiskPeripheral,
2764 FloppyDiskPeripheral,
2765 TapePeripheral,
2766 ModemPeripheral,
2767 MonitorPeripheral,
2768 PrinterPeripheral,
2769 PointerPeripheral,
2770 KeyboardPeripheral,
2771 TerminalPeripheral,
2772 OtherPeripheral,
2773 LinePeripheral,
2774 NetworkPeripheral,
2775 SystemMemory,
2776 DockingInformation,
2777 RealModeIrqRoutingTable,
2778 RealModePCIEnumeration,
2779 MaximumType
2780 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
2781
2782 #define IO_FORCE_ACCESS_CHECK 0x001
2783 #define IO_NO_PARAMETER_CHECKING 0x100
2784
2785 #define IO_REPARSE 0x0
2786 #define IO_REMOUNT 0x1
2787
2788 typedef NTSTATUS
2789 (DDKAPI *PIO_QUERY_DEVICE_ROUTINE)(
2790 IN PVOID Context,
2791 IN PUNICODE_STRING PathName,
2792 IN INTERFACE_TYPE BusType,
2793 IN ULONG BusNumber,
2794 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
2795 IN CONFIGURATION_TYPE ControllerType,
2796 IN ULONG ControllerNumber,
2797 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
2798 IN CONFIGURATION_TYPE PeripheralType,
2799 IN ULONG PeripheralNumber,
2800 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
2801
2802 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
2803 IoQueryDeviceIdentifier = 0,
2804 IoQueryDeviceConfigurationData,
2805 IoQueryDeviceComponentInformation,
2806 IoQueryDeviceMaxData
2807 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
2808
2809 typedef enum _KBUGCHECK_CALLBACK_REASON {
2810 KbCallbackInvalid,
2811 KbCallbackReserved1,
2812 KbCallbackSecondaryDumpData,
2813 KbCallbackDumpIo,
2814 } KBUGCHECK_CALLBACK_REASON;
2815
2816 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
2817
2818 typedef VOID
2819 (DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)(
2820 IN KBUGCHECK_CALLBACK_REASON Reason,
2821 IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
2822 IN OUT PVOID ReasonSpecificData,
2823 IN ULONG ReasonSpecificDataLength);
2824
2825 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
2826 LIST_ENTRY Entry;
2827 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
2828 PUCHAR Component;
2829 ULONG_PTR Checksum;
2830 KBUGCHECK_CALLBACK_REASON Reason;
2831 UCHAR State;
2832 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
2833
2834 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
2835 BufferEmpty,
2836 BufferInserted,
2837 BufferStarted,
2838 BufferFinished,
2839 BufferIncomplete
2840 } KBUGCHECK_BUFFER_DUMP_STATE;
2841
2842 typedef VOID
2843 (DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)(
2844 IN PVOID Buffer,
2845 IN ULONG Length);
2846
2847 typedef struct _KBUGCHECK_CALLBACK_RECORD {
2848 LIST_ENTRY Entry;
2849 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
2850 PVOID Buffer;
2851 ULONG Length;
2852 PUCHAR Component;
2853 ULONG_PTR Checksum;
2854 UCHAR State;
2855 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
2856
2857 typedef BOOLEAN
2858 (DDKAPI *PNMI_CALLBACK)(
2859 IN PVOID Context,
2860 IN BOOLEAN Handled);
2861
2862 /*
2863 * VOID
2864 * KeInitializeCallbackRecord(
2865 * IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
2866 */
2867 #define KeInitializeCallbackRecord(CallbackRecord) \
2868 CallbackRecord->State = BufferEmpty;
2869
2870 typedef enum _KDPC_IMPORTANCE {
2871 LowImportance,
2872 MediumImportance,
2873 HighImportance
2874 } KDPC_IMPORTANCE;
2875
2876 typedef enum _MEMORY_CACHING_TYPE_ORIG {
2877 MmFrameBufferCached = 2
2878 } MEMORY_CACHING_TYPE_ORIG;
2879
2880 typedef enum _MEMORY_CACHING_TYPE {
2881 MmNonCached = FALSE,
2882 MmCached = TRUE,
2883 MmWriteCombined = MmFrameBufferCached,
2884 MmHardwareCoherentCached,
2885 MmNonCachedUnordered,
2886 MmUSWCCached,
2887 MmMaximumCacheType
2888 } MEMORY_CACHING_TYPE;
2889
2890 typedef enum _MM_PAGE_PRIORITY {
2891 LowPagePriority,
2892 NormalPagePriority = 16,
2893 HighPagePriority = 32
2894 } MM_PAGE_PRIORITY;
2895
2896 typedef enum _LOCK_OPERATION {
2897 IoReadAccess,
2898 IoWriteAccess,
2899 IoModifyAccess
2900 } LOCK_OPERATION;
2901
2902 #define FLUSH_MULTIPLE_MAXIMUM 32
2903
2904 typedef enum _MM_SYSTEM_SIZE {
2905 MmSmallSystem,
2906 MmMediumSystem,
2907 MmLargeSystem
2908 } MM_SYSTEMSIZE;
2909
2910 typedef struct _OBJECT_HANDLE_INFORMATION {
2911 ULONG HandleAttributes;
2912 ACCESS_MASK GrantedAccess;
2913 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
2914
2915 typedef struct _CLIENT_ID {
2916 HANDLE UniqueProcess;
2917 HANDLE UniqueThread;
2918 } CLIENT_ID, *PCLIENT_ID;
2919
2920 typedef VOID
2921 (DDKAPI *PKSTART_ROUTINE)(
2922 IN PVOID StartContext);
2923
2924 typedef VOID
2925 (DDKAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
2926 IN HANDLE ParentId,
2927 IN HANDLE ProcessId,
2928 IN BOOLEAN Create);
2929
2930 typedef VOID
2931 (DDKAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
2932 IN HANDLE ProcessId,
2933 IN HANDLE ThreadId,
2934 IN BOOLEAN Create);
2935
2936 typedef struct _IMAGE_INFO {
2937 _ANONYMOUS_UNION union {
2938 ULONG Properties;
2939 _ANONYMOUS_STRUCT struct {
2940 ULONG ImageAddressingMode : 8;
2941 ULONG SystemModeImage : 1;
2942 ULONG ImageMappedToAllPids : 1;
2943 ULONG Reserved : 22;
2944 } DUMMYSTRUCTNAME;
2945 } DUMMYUNIONNAME;
2946 PVOID ImageBase;
2947 ULONG ImageSelector;
2948 SIZE_T ImageSize;
2949 ULONG ImageSectionNumber;
2950 } IMAGE_INFO, *PIMAGE_INFO;
2951
2952 #define IMAGE_ADDRESSING_MODE_32BIT 3
2953
2954 typedef VOID
2955 (DDKAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
2956 IN PUNICODE_STRING FullImageName,
2957 IN HANDLE ProcessId,
2958 IN PIMAGE_INFO ImageInfo);
2959
2960 #pragma pack(push,4)
2961 typedef enum _BUS_DATA_TYPE {
2962 ConfigurationSpaceUndefined = -1,
2963 Cmos,
2964 EisaConfiguration,
2965 Pos,
2966 CbusConfiguration,
2967 PCIConfiguration,
2968 VMEConfiguration,
2969 NuBusConfiguration,
2970 PCMCIAConfiguration,
2971 MPIConfiguration,
2972 MPSAConfiguration,
2973 PNPISAConfiguration,
2974 SgiInternalConfiguration,
2975 MaximumBusDataType
2976 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
2977 #pragma pack(pop)
2978
2979 typedef struct _NT_TIB {
2980 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
2981 PVOID StackBase;
2982 PVOID StackLimit;
2983 PVOID SubSystemTib;
2984 _ANONYMOUS_UNION union {
2985 PVOID FiberData;
2986 ULONG Version;
2987 } DUMMYUNIONNAME;
2988 PVOID ArbitraryUserPointer;
2989 struct _NT_TIB *Self;
2990 } NT_TIB, *PNT_TIB;
2991
2992 typedef struct _NT_TIB32 {
2993 ULONG ExceptionList;
2994 ULONG StackBase;
2995 ULONG StackLimit;
2996 ULONG SubSystemTib;
2997 __GNU_EXTENSION union {
2998 ULONG FiberData;
2999 ULONG Version;
3000 };
3001 ULONG ArbitraryUserPointer;
3002 ULONG Self;
3003 } NT_TIB32,*PNT_TIB32;
3004
3005 typedef struct _NT_TIB64 {
3006 ULONG64 ExceptionList;
3007 ULONG64 StackBase;
3008 ULONG64 StackLimit;
3009 ULONG64 SubSystemTib;
3010 __GNU_EXTENSION union {
3011 ULONG64 FiberData;
3012 ULONG Version;
3013 };
3014 ULONG64 ArbitraryUserPointer;
3015 ULONG64 Self;
3016 } NT_TIB64,*PNT_TIB64;
3017
3018 typedef enum _PROCESSINFOCLASS {
3019 ProcessBasicInformation,
3020 ProcessQuotaLimits,
3021 ProcessIoCounters,
3022 ProcessVmCounters,
3023 ProcessTimes,
3024 ProcessBasePriority,
3025 ProcessRaisePriority,
3026 ProcessDebugPort,
3027 ProcessExceptionPort,
3028 ProcessAccessToken,
3029 ProcessLdtInformation,
3030 ProcessLdtSize,
3031 ProcessDefaultHardErrorMode,
3032 ProcessIoPortHandlers,
3033 ProcessPooledUsageAndLimits,
3034 ProcessWorkingSetWatch,
3035 ProcessUserModeIOPL,
3036 ProcessEnableAlignmentFaultFixup,
3037 ProcessPriorityClass,
3038 ProcessWx86Information,
3039 ProcessHandleCount,
3040 ProcessAffinityMask,
3041 ProcessPriorityBoost,
3042 ProcessDeviceMap,
3043 ProcessSessionInformation,
3044 ProcessForegroundInformation,
3045 ProcessWow64Information,
3046 ProcessImageFileName,
3047 ProcessLUIDDeviceMapsEnabled,
3048 ProcessBreakOnTermination,
3049 ProcessDebugObjectHandle,
3050 ProcessDebugFlags,
3051 ProcessHandleTracing,
3052 ProcessIoPriority,
3053 ProcessExecuteFlags,
3054 ProcessTlsInformation,
3055 ProcessCookie,
3056 ProcessImageInformation,
3057 ProcessCycleTime,
3058 ProcessPagePriority,
3059 ProcessInstrumentationCallback,
3060 MaxProcessInfoClass
3061 } PROCESSINFOCLASS;
3062
3063 typedef enum _THREADINFOCLASS {
3064 ThreadBasicInformation,
3065 ThreadTimes,
3066 ThreadPriority,
3067 ThreadBasePriority,
3068 ThreadAffinityMask,
3069 ThreadImpersonationToken,
3070 ThreadDescriptorTableEntry,
3071 ThreadEnableAlignmentFaultFixup,
3072 ThreadEventPair_Reusable,
3073 ThreadQuerySetWin32StartAddress,
3074 ThreadZeroTlsCell,
3075 ThreadPerformanceCount,
3076 ThreadAmILastThread,
3077 ThreadIdealProcessor,
3078 ThreadPriorityBoost,
3079 ThreadSetTlsArrayAddress,
3080 ThreadIsIoPending,
3081 ThreadHideFromDebugger,
3082 ThreadBreakOnTermination,
3083 ThreadSwitchLegacyState,
3084 ThreadIsTerminated,
3085 ThreadLastSystemCall,
3086 ThreadIoPriority,
3087 ThreadCycleTime,
3088 ThreadPagePriority,
3089 ThreadActualBasePriority,
3090 MaxThreadInfoClass
3091 } THREADINFOCLASS;
3092
3093 typedef struct _PROCESS_BASIC_INFORMATION
3094 {
3095 NTSTATUS ExitStatus;
3096 struct _PEB *PebBaseAddress;
3097 ULONG_PTR AffinityMask;
3098 KPRIORITY BasePriority;
3099 ULONG_PTR UniqueProcessId;
3100 ULONG_PTR InheritedFromUniqueProcessId;
3101 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
3102
3103 typedef struct _PROCESS_WS_WATCH_INFORMATION
3104 {
3105 PVOID FaultingPc;
3106 PVOID FaultingVa;
3107 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
3108
3109 typedef struct _PROCESS_DEVICEMAP_INFORMATION
3110 {
3111 __GNU_EXTENSION union
3112 {
3113 struct
3114 {
3115 HANDLE DirectoryHandle;
3116 } Set;
3117 struct
3118 {
3119 ULONG DriveMap;
3120 UCHAR DriveType[32];
3121 } Query;
3122 };
3123 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
3124
3125 typedef struct _KERNEL_USER_TIMES
3126 {
3127 LARGE_INTEGER CreateTime;
3128 LARGE_INTEGER ExitTime;
3129 LARGE_INTEGER KernelTime;
3130 LARGE_INTEGER UserTime;
3131 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
3132
3133 typedef struct _PROCESS_ACCESS_TOKEN
3134 {
3135 HANDLE Token;
3136 HANDLE Thread;
3137 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
3138
3139 typedef struct _PROCESS_SESSION_INFORMATION
3140 {
3141 ULONG SessionId;
3142 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
3143
3144 typedef VOID
3145 (DDKAPI *PREQUEST_POWER_COMPLETE)(
3146 IN PDEVICE_OBJECT DeviceObject,
3147 IN UCHAR MinorFunction,
3148 IN POWER_STATE PowerState,
3149 IN PVOID Context,
3150 IN PIO_STATUS_BLOCK IoStatus);
3151
3152 typedef enum _TRACE_INFORMATION_CLASS {
3153 TraceIdClass,
3154 TraceHandleClass,
3155 TraceEnableFlagsClass,
3156 TraceEnableLevelClass,
3157 GlobalLoggerHandleClass,
3158 EventLoggerHandleClass,
3159 AllLoggerHandlesClass,
3160 TraceHandleByNameClass
3161 } TRACE_INFORMATION_CLASS;
3162
3163 typedef enum _REG_NOTIFY_CLASS
3164 {
3165 RegNtDeleteKey,
3166 RegNtPreDeleteKey = RegNtDeleteKey,
3167 RegNtSetValueKey,
3168 RegNtPreSetValueKey = RegNtSetValueKey,
3169 RegNtDeleteValueKey,
3170 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
3171 RegNtSetInformationKey,
3172 RegNtPreSetInformationKey = RegNtSetInformationKey,
3173 RegNtRenameKey,
3174 RegNtPreRenameKey = RegNtRenameKey,
3175 RegNtEnumerateKey,
3176 RegNtPreEnumerateKey = RegNtEnumerateKey,
3177 RegNtEnumerateValueKey,
3178 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
3179 RegNtQueryKey,
3180 RegNtPreQueryKey = RegNtQueryKey,
3181 RegNtQueryValueKey,
3182 RegNtPreQueryValueKey = RegNtQueryValueKey,
3183 RegNtQueryMultipleValueKey,
3184 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
3185 RegNtPreCreateKey,
3186 RegNtPostCreateKey,
3187 RegNtPreOpenKey,
3188 RegNtPostOpenKey,
3189 RegNtKeyHandleClose,
3190 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
3191 RegNtPostDeleteKey,
3192 RegNtPostSetValueKey,
3193 RegNtPostDeleteValueKey,
3194 RegNtPostSetInformationKey,
3195 RegNtPostRenameKey,
3196 RegNtPostEnumerateKey,
3197 RegNtPostEnumerateValueKey,
3198 RegNtPostQueryKey,
3199 RegNtPostQueryValueKey,
3200 RegNtPostQueryMultipleValueKey,
3201 RegNtPostKeyHandleClose,
3202 RegNtPreCreateKeyEx,
3203 RegNtPostCreateKeyEx,
3204 RegNtPreOpenKeyEx,
3205 RegNtPostOpenKeyEx
3206 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
3207
3208 typedef NTSTATUS
3209 (NTAPI *PEX_CALLBACK_FUNCTION)(
3210 IN PVOID CallbackContext,
3211 IN PVOID Argument1,
3212 IN PVOID Argument2
3213 );
3214
3215 typedef struct _REG_DELETE_KEY_INFORMATION
3216 {
3217 PVOID Object;
3218 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION;
3219
3220 typedef struct _REG_SET_VALUE_KEY_INFORMATION
3221 {
3222 PVOID Object;
3223 PUNICODE_STRING ValueName;
3224 ULONG TitleIndex;
3225 ULONG Type;
3226 PVOID Data;
3227 ULONG DataSize;
3228 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
3229
3230 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION
3231 {
3232 PVOID Object;
3233 PUNICODE_STRING ValueName;
3234 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
3235
3236 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION
3237 {
3238 PVOID Object;
3239 KEY_SET_INFORMATION_CLASS KeySetInformationClass;
3240 PVOID KeySetInformation;
3241 ULONG KeySetInformationLength;
3242 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
3243
3244 typedef struct _REG_ENUMERATE_KEY_INFORMATION
3245 {
3246 PVOID Object;
3247 ULONG Index;
3248 KEY_INFORMATION_CLASS KeyInformationClass;
3249 PVOID KeyInformation;
3250 ULONG Length;
3251 PULONG ResultLength;
3252 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
3253
3254 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION
3255 {
3256 PVOID Object;
3257 ULONG Index;
3258 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
3259 PVOID KeyValueInformation;
3260 ULONG Length;
3261 PULONG ResultLength;
3262 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
3263
3264 typedef struct _REG_QUERY_KEY_INFORMATION
3265 {
3266 PVOID Object;
3267 KEY_INFORMATION_CLASS KeyInformationClass;
3268 PVOID KeyInformation;
3269 ULONG Length;
3270 PULONG ResultLength;
3271 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
3272
3273 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION
3274 {
3275 PVOID Object;
3276 PUNICODE_STRING ValueName;
3277 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
3278 PVOID KeyValueInformation;
3279 ULONG Length;
3280 PULONG ResultLength;
3281 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
3282
3283 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION
3284 {
3285 PVOID Object;
3286 PKEY_VALUE_ENTRY ValueEntries;
3287 ULONG EntryCount;
3288 PVOID ValueBuffer;
3289 PULONG BufferLength;
3290 PULONG RequiredBufferLength;
3291 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
3292
3293 typedef struct _REG_PRE_CREATE_KEY_INFORMATION
3294 {
3295 PUNICODE_STRING CompleteName;
3296 } REG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_CREATE_KEY_INFORMATION;
3297
3298 typedef struct _REG_POST_CREATE_KEY_INFORMATION
3299 {
3300 PUNICODE_STRING CompleteName;
3301 PVOID Object;
3302 NTSTATUS Status;
3303 } REG_POST_CREATE_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION;
3304
3305 typedef struct _REG_PRE_OPEN_KEY_INFORMATION
3306 {
3307 PUNICODE_STRING CompleteName;
3308 } REG_PRE_OPEN_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;
3309
3310 typedef struct _REG_POST_OPEN_KEY_INFORMATION
3311 {
3312 PUNICODE_STRING CompleteName;
3313 PVOID Object;
3314 NTSTATUS Status;
3315 } REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
3316
3317 typedef struct _REG_POST_OPERATION_INFORMATION
3318 {
3319 PVOID Object;
3320 NTSTATUS Status;
3321 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
3322
3323 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION
3324 {
3325 PVOID Object;
3326 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
3327
3328 /*
3329 ** Storage structures
3330 */
3331 typedef enum _PARTITION_STYLE {
3332 PARTITION_STYLE_MBR,
3333 PARTITION_STYLE_GPT,
3334 PARTITION_STYLE_RAW
3335 } PARTITION_STYLE;
3336
3337 typedef struct _CREATE_DISK_MBR {
3338 ULONG Signature;
3339 } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
3340
3341 typedef struct _CREATE_DISK_GPT {
3342 GUID DiskId;
3343 ULONG MaxPartitionCount;
3344 } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
3345
3346 typedef struct _CREATE_DISK {
3347 PARTITION_STYLE PartitionStyle;
3348 _ANONYMOUS_UNION union {
3349 CREATE_DISK_MBR Mbr;
3350 CREATE_DISK_GPT Gpt;
3351 } DUMMYUNIONNAME;
3352 } CREATE_DISK, *PCREATE_DISK;
3353
3354 typedef struct _DISK_SIGNATURE {
3355 ULONG PartitionStyle;
3356 _ANONYMOUS_UNION union {
3357 struct {
3358 ULONG Signature;
3359 ULONG CheckSum;
3360 } Mbr;
3361 struct {
3362 GUID DiskId;
3363 } Gpt;
3364 } DUMMYUNIONNAME;
3365 } DISK_SIGNATURE, *PDISK_SIGNATURE;
3366
3367 typedef VOID
3368 (FASTCALL*PTIME_UPDATE_NOTIFY_ROUTINE)(
3369 IN HANDLE ThreadId,
3370 IN KPROCESSOR_MODE Mode);
3371
3372 #define DBG_STATUS_CONTROL_C 1
3373 #define DBG_STATUS_SYSRQ 2
3374 #define DBG_STATUS_BUGCHECK_FIRST 3
3375 #define DBG_STATUS_BUGCHECK_SECOND 4
3376 #define DBG_STATUS_FATAL 5
3377 #define DBG_STATUS_DEBUG_CONTROL 6
3378 #define DBG_STATUS_WORKER 7
3379
3380 typedef struct _PHYSICAL_MEMORY_RANGE {
3381 PHYSICAL_ADDRESS BaseAddress;
3382 LARGE_INTEGER NumberOfBytes;
3383 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
3384
3385 typedef ULONG_PTR
3386 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
3387 IN PVOID Context);
3388
3389 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
3390 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
3391 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
3392 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
3393
3394 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
3395 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
3396 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
3397 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
3398 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
3399
3400 #define HASH_STRING_ALGORITHM_DEFAULT 0
3401 #define HASH_STRING_ALGORITHM_X65599 1
3402 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
3403
3404 typedef VOID
3405 (DDKAPI *PTIMER_APC_ROUTINE)(
3406 IN PVOID TimerContext,
3407 IN ULONG TimerLowValue,
3408 IN LONG TimerHighValue);
3409
3410
3411
3412 /*
3413 ** WMI structures
3414 */
3415
3416 typedef VOID
3417 (DDKAPI *WMI_NOTIFICATION_CALLBACK)(
3418 PVOID Wnode,
3419 PVOID Context);
3420
3421
3422 /*
3423 ** Architecture specific structures
3424 */
3425 #define PCR_MINOR_VERSION 1
3426 #define PCR_MAJOR_VERSION 1
3427
3428 #ifdef _X86_
3429
3430 #define SIZE_OF_80387_REGISTERS 80
3431 #define CONTEXT_i386 0x10000
3432 #define CONTEXT_i486 0x10000
3433 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
3434 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
3435 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
3436 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
3437 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
3438 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
3439 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
3440 #define MAXIMUM_SUPPORTED_EXTENSION 512
3441
3442 typedef struct _FLOATING_SAVE_AREA {
3443 ULONG ControlWord;
3444 ULONG StatusWord;
3445 ULONG TagWord;
3446 ULONG ErrorOffset;
3447 ULONG ErrorSelector;
3448 ULONG DataOffset;
3449 ULONG DataSelector;
3450 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
3451 ULONG Cr0NpxState;
3452 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
3453
3454 typedef struct _CONTEXT {
3455 ULONG ContextFlags;
3456 ULONG Dr0;
3457 ULONG Dr1;
3458 ULONG Dr2;
3459 ULONG Dr3;
3460 ULONG Dr6;
3461 ULONG Dr7;
3462 FLOATING_SAVE_AREA FloatSave;
3463 ULONG SegGs;
3464 ULONG SegFs;
3465 ULONG SegEs;
3466 ULONG SegDs;
3467 ULONG Edi;
3468 ULONG Esi;
3469 ULONG Ebx;
3470 ULONG Edx;
3471 ULONG Ecx;
3472 ULONG Eax;
3473 ULONG Ebp;
3474 ULONG Eip;
3475 ULONG SegCs;
3476 ULONG EFlags;
3477 ULONG Esp;
3478 ULONG SegSs;
3479 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
3480 } CONTEXT;
3481
3482 //
3483 // Used to contain PFNs and PFN counts
3484 //
3485 typedef ULONG PFN_COUNT;
3486 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
3487 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
3488
3489 #define PASSIVE_LEVEL 0
3490 #define LOW_LEVEL 0
3491 #define APC_LEVEL 1
3492 #define DISPATCH_LEVEL 2
3493 #define PROFILE_LEVEL 27
3494 #define CLOCK1_LEVEL 28
3495 #define CLOCK2_LEVEL 28
3496 #define IPI_LEVEL 29
3497 #define POWER_LEVEL 30
3498 #define HIGH_LEVEL 31
3499
3500 typedef struct _KPCR_TIB {
3501 PVOID ExceptionList; /* 00 */
3502 PVOID StackBase; /* 04 */
3503 PVOID StackLimit; /* 08 */
3504 PVOID SubSystemTib; /* 0C */
3505 _ANONYMOUS_UNION union {
3506 PVOID FiberData; /* 10 */
3507 ULONG Version; /* 10 */
3508 } DUMMYUNIONNAME;
3509 PVOID ArbitraryUserPointer; /* 14 */
3510 struct _KPCR_TIB *Self; /* 18 */
3511 } KPCR_TIB, *PKPCR_TIB; /* 1C */
3512
3513 typedef struct _KPCR {
3514 KPCR_TIB Tib; /* 00 */
3515 struct _KPCR *Self; /* 1C */
3516 struct _KPRCB *Prcb; /* 20 */
3517 KIRQL Irql; /* 24 */
3518 ULONG IRR; /* 28 */
3519 ULONG IrrActive; /* 2C */
3520 ULONG IDR; /* 30 */
3521 PVOID KdVersionBlock; /* 34 */
3522 PUSHORT IDT; /* 38 */
3523 PUSHORT GDT; /* 3C */
3524 struct _KTSS *TSS; /* 40 */
3525 USHORT MajorVersion; /* 44 */
3526 USHORT MinorVersion; /* 46 */
3527 KAFFINITY SetMember; /* 48 */
3528 ULONG StallScaleFactor; /* 4C */
3529 UCHAR SpareUnused; /* 50 */
3530 UCHAR Number; /* 51 */
3531 UCHAR Spare0;
3532 UCHAR SecondLevelCacheAssociativity;
3533 ULONG VdmAlert;
3534 ULONG KernelReserved[14]; // For use by the kernel
3535 ULONG SecondLevelCacheSize;
3536 ULONG HalReserved[16]; // For use by Hal
3537 } KPCR, *PKPCR; /* 54 */
3538
3539 #define KeGetPcr() PCR
3540
3541 typedef struct _KFLOATING_SAVE {
3542 ULONG ControlWord;
3543 ULONG StatusWord;
3544 ULONG ErrorOffset;
3545 ULONG ErrorSelector;
3546 ULONG DataOffset;
3547 ULONG DataSelector;
3548 ULONG Cr0NpxState;
3549 ULONG Spare1;
3550 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3551
3552 FORCEINLINE
3553 ULONG
3554 KeGetCurrentProcessorNumber(VOID)
3555 {
3556 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
3557 }
3558
3559 NTHALAPI
3560 KIRQL
3561 DDKAPI
3562 KeGetCurrentIrql(
3563 VOID);
3564
3565 NTKERNELAPI
3566 PRKTHREAD
3567 NTAPI
3568 KeGetCurrentThread(
3569 VOID);
3570
3571 #define KI_USER_SHARED_DATA 0xffdf0000
3572
3573 #define PAGE_SIZE 0x1000
3574 #define PAGE_SHIFT 12L
3575
3576 #define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA)
3577
3578 extern NTKERNELAPI PVOID MmHighestUserAddress;
3579 extern NTKERNELAPI PVOID MmSystemRangeStart;
3580 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
3581
3582 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3583 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3584 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3585 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3586 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
3587
3588 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
3589 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
3590
3591 #elif defined(__x86_64__)
3592
3593 #define CONTEXT_AMD64 0x100000
3594 #if !defined(RC_INVOKED)
3595 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
3596 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
3597 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
3598 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
3599 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
3600
3601 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
3602 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
3603
3604 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
3605 #define CONTEXT_SERVICE_ACTIVE 0x10000000
3606 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
3607 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
3608 #endif
3609
3610 typedef struct DECLSPEC_ALIGN(16) _M128A {
3611 ULONGLONG Low;
3612 LONGLONG High;
3613 } M128A, *PM128A;
3614
3615 typedef struct _XMM_SAVE_AREA32 {
3616 USHORT ControlWord;
3617 USHORT StatusWord;
3618 UCHAR TagWord;
3619 UCHAR Reserved1;
3620 USHORT ErrorOpcode;
3621 ULONG ErrorOffset;
3622 USHORT ErrorSelector;
3623 USHORT Reserved2;
3624 ULONG DataOffset;
3625 USHORT DataSelector;
3626 USHORT Reserved3;
3627 ULONG MxCsr;
3628 ULONG MxCsr_Mask;
3629 M128A FloatRegisters[8];
3630 M128A XmmRegisters[16];
3631 UCHAR Reserved4[96];
3632 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
3633
3634 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
3635 ULONG64 P1Home;
3636 ULONG64 P2Home;
3637 ULONG64 P3Home;
3638 ULONG64 P4Home;
3639 ULONG64 P5Home;
3640 ULONG64 P6Home;
3641
3642 /* Control flags */
3643 ULONG ContextFlags;
3644 ULONG MxCsr;
3645
3646 /* Segment */
3647 USHORT SegCs;
3648 USHORT SegDs;
3649 USHORT SegEs;
3650 USHORT SegFs;
3651 USHORT SegGs;
3652 USHORT SegSs;
3653 ULONG EFlags;
3654
3655 /* Debug */
3656 ULONG64 Dr0;
3657 ULONG64 Dr1;
3658 ULONG64 Dr2;
3659 ULONG64 Dr3;
3660 ULONG64 Dr6;
3661 ULONG64 Dr7;
3662
3663 /* Integer */
3664 ULONG64 Rax;
3665 ULONG64 Rcx;
3666 ULONG64 Rdx;
3667 ULONG64 Rbx;
3668 ULONG64 Rsp;
3669 ULONG64 Rbp;
3670 ULONG64 Rsi;
3671 ULONG64 Rdi;
3672 ULONG64 R8;
3673 ULONG64 R9;
3674 ULONG64 R10;
3675 ULONG64 R11;
3676 ULONG64 R12;
3677 ULONG64 R13;
3678 ULONG64 R14;
3679 ULONG64 R15;
3680
3681 /* Counter */
3682 ULONG64 Rip;
3683
3684 /* Floating point */
3685 union {
3686 XMM_SAVE_AREA32 FltSave;
3687 struct {
3688 M128A Header[2];
3689 M128A Legacy[8];
3690 M128A Xmm0;
3691 M128A Xmm1;
3692 M128A Xmm2;
3693 M128A Xmm3;
3694 M128A Xmm4;
3695 M128A Xmm5;
3696 M128A Xmm6;
3697 M128A Xmm7;
3698 M128A Xmm8;
3699 M128A Xmm9;
3700 M128A Xmm10;
3701 M128A Xmm11;
3702 M128A Xmm12;
3703 M128A Xmm13;
3704 M128A Xmm14;
3705 M128A Xmm15;
3706 } DUMMYSTRUCTNAME;
3707 } DUMMYUNIONNAME;
3708
3709 /* Vector */
3710 M128A VectorRegister[26];
3711 ULONG64 VectorControl;
3712
3713 /* Debug control */
3714 ULONG64 DebugControl;
3715 ULONG64 LastBranchToRip;
3716 ULONG64 LastBranchFromRip;
3717 ULONG64 LastExceptionToRip;
3718 ULONG64 LastExceptionFromRip;
3719 } CONTEXT;
3720
3721 //
3722 // Used to contain PFNs and PFN counts
3723 //
3724 typedef ULONG PFN_COUNT;
3725 typedef ULONG64 PFN_NUMBER, *PPFN_NUMBER;
3726 typedef LONG64 SPFN_NUMBER, *PSPFN_NUMBER;
3727
3728 #define PASSIVE_LEVEL 0
3729 #define LOW_LEVEL 0
3730 #define APC_LEVEL 1
3731 #define DISPATCH_LEVEL 2
3732 #define CLOCK_LEVEL 13
3733 #define IPI_LEVEL 14
3734 #define POWER_LEVEL 14
3735 #define PROFILE_LEVEL 15
3736 #define HIGH_LEVEL 15
3737
3738 #define PAGE_SIZE 0x1000
3739 #define PAGE_SHIFT 12L
3740 #define PTI_SHIFT 12L
3741 #define PDI_SHIFT 21L
3742 #define PPI_SHIFT 30L
3743 #define PXI_SHIFT 39L
3744 #define PTE_PER_PAGE 512
3745 #define PDE_PER_PAGE 512
3746 #define PPE_PER_PAGE 512
3747 #define PXE_PER_PAGE 512
3748 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
3749 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
3750 #define PPI_MASK (PPE_PER_PAGE - 1)
3751 #define PXI_MASK (PXE_PER_PAGE - 1)
3752
3753 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
3754 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
3755 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
3756 #define PDE_BASE 0xFFFFF6FB40000000ULL
3757 #define PTE_BASE 0xFFFFF68000000000ULL
3758 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
3759 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
3760 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
3761 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
3762
3763 extern NTKERNELAPI PVOID MmHighestUserAddress;
3764 extern NTKERNELAPI PVOID MmSystemRangeStart;
3765 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
3766
3767 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
3768 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
3769 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
3770 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
3771 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
3772 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
3773
3774 #define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA)
3775 #define SharedInterruptTime (&SharedUserData->InterruptTime)
3776 #define SharedSystemTime (&SharedUserData->SystemTime)
3777 #define SharedTickCount (&SharedUserData->TickCount)
3778
3779 #define KeQueryInterruptTime() \
3780 (*(volatile ULONG64*)SharedInterruptTime)
3781 #define KeQuerySystemTime(CurrentCount) \
3782 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
3783 #define KeQueryTickCount(CurrentCount) \
3784 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
3785
3786 typedef struct _KPCR
3787 {
3788 __GNU_EXTENSION union
3789 {
3790 NT_TIB NtTib;
3791 __GNU_EXTENSION struct
3792 {
3793 union _KGDTENTRY64 *GdtBase;
3794 struct _KTSS64 *TssBase;
3795 ULONG64 UserRsp;
3796 struct _KPCR *Self;
3797 struct _KPRCB *CurrentPrcb;
3798 PKSPIN_LOCK_QUEUE LockArray;
3799 PVOID Used_Self;
3800 };
3801 };
3802 union _KIDTENTRY64 *IdtBase;
3803 ULONG64 Unused[2];
3804 KIRQL Irql;
3805 UCHAR SecondLevelCacheAssociativity;
3806 UCHAR ObsoleteNumber;
3807 UCHAR Fill0;
3808 ULONG Unused0[3];
3809 USHORT MajorVersion;
3810 USHORT MinorVersion;
3811 ULONG StallScaleFactor;
3812 PVOID Unused1[3];
3813 ULONG KernelReserved[15];
3814 ULONG SecondLevelCacheSize;
3815 ULONG HalReserved[16];
3816 ULONG Unused2;
3817 PVOID KdVersionBlock;
3818 PVOID Unused3;
3819 ULONG PcrAlign1[24];
3820 } KPCR, *PKPCR;
3821
3822 typedef struct _KFLOATING_SAVE {
3823 ULONG Dummy;
3824 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3825
3826 NTKERNELAPI
3827 PRKTHREAD
3828 NTAPI
3829 KeGetCurrentThread(
3830 VOID);
3831
3832 FORCEINLINE
3833 PKPCR
3834 KeGetPcr(VOID)
3835 {
3836 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
3837 }
3838
3839 FORCEINLINE
3840 ULONG
3841 KeGetCurrentProcessorNumber(VOID)
3842 {
3843 return (ULONG)__readgsword(0x184);
3844 }
3845
3846 #elif defined(__PowerPC__)
3847
3848 //
3849 // Used to contain PFNs and PFN counts
3850 //
3851 typedef ULONG PFN_COUNT;
3852 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
3853 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
3854
3855 #define PASSIVE_LEVEL 0
3856 #define LOW_LEVEL 0
3857 #define APC_LEVEL 1
3858 #define DISPATCH_LEVEL 2
3859 #define PROFILE_LEVEL 27
3860 #define CLOCK1_LEVEL 28
3861 #define CLOCK2_LEVEL 28
3862 #define IPI_LEVEL 29
3863 #define POWER_LEVEL 30
3864 #define HIGH_LEVEL 31
3865
3866 typedef struct _KFLOATING_SAVE {
3867 ULONG Dummy;
3868 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3869
3870 typedef struct _KPCR_TIB {
3871 PVOID ExceptionList; /* 00 */
3872 PVOID StackBase; /* 04 */
3873 PVOID StackLimit; /* 08 */
3874 PVOID SubSystemTib; /* 0C */
3875 _ANONYMOUS_UNION union {
3876 PVOID FiberData; /* 10 */
3877 ULONG Version; /* 10 */
3878 } DUMMYUNIONNAME;
3879 PVOID ArbitraryUserPointer; /* 14 */
3880 struct _KPCR_TIB *Self; /* 18 */
3881 } KPCR_TIB, *PKPCR_TIB; /* 1C */
3882
3883 #define PCR_MINOR_VERSION 1
3884 #define PCR_MAJOR_VERSION 1
3885
3886 typedef struct _KPCR {
3887 KPCR_TIB Tib; /* 00 */
3888 struct _KPCR *Self; /* 1C */
3889 struct _KPRCB *Prcb; /* 20 */
3890 KIRQL Irql; /* 24 */
3891 ULONG IRR; /* 28 */
3892 ULONG IrrActive; /* 2C */
3893 ULONG IDR; /* 30 */
3894 PVOID KdVersionBlock; /* 34 */
3895 PUSHORT IDT; /* 38 */
3896 PUSHORT GDT; /* 3C */
3897 struct _KTSS *TSS; /* 40 */
3898 USHORT MajorVersion; /* 44 */
3899 USHORT MinorVersion; /* 46 */
3900 KAFFINITY SetMember; /* 48 */
3901 ULONG StallScaleFactor; /* 4C */
3902 UCHAR SpareUnused; /* 50 */
3903 UCHAR Number; /* 51 */
3904 } KPCR, *PKPCR; /* 54 */
3905
3906 #define KeGetPcr() PCR
3907
3908 static __inline
3909 ULONG
3910 DDKAPI
3911 KeGetCurrentProcessorNumber(VOID)
3912 {
3913 ULONG Number;
3914 __asm__ __volatile__ (
3915 "lwz %0, %c1(12)\n"
3916 : "=r" (Number)
3917 : "i" (FIELD_OFFSET(KPCR, Number))
3918 );
3919 return Number;
3920 }
3921
3922 #elif defined(_MIPS_)
3923
3924 #error MIPS Headers are totally incorrect
3925
3926 //
3927 // Used to contain PFNs and PFN counts
3928 //
3929 typedef ULONG PFN_COUNT;
3930 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
3931 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
3932
3933 #define PASSIVE_LEVEL 0
3934 #define APC_LEVEL 1
3935 #define DISPATCH_LEVEL 2
3936 #define PROFILE_LEVEL 27
3937 #define IPI_LEVEL 29
3938 #define HIGH_LEVEL 31
3939
3940 typedef struct _KPCR {
3941 struct _KPRCB *Prcb; /* 20 */
3942 KIRQL Irql; /* 24 */
3943 ULONG IRR; /* 28 */
3944 ULONG IDR; /* 30 */
3945 } KPCR, *PKPCR;
3946
3947 #define KeGetPcr() PCR
3948
3949 typedef struct _KFLOATING_SAVE {
3950 } KFLOATING_SAVE, *PKFLOATING_SAVE;
3951
3952 static __inline
3953 ULONG
3954 DDKAPI
3955 KeGetCurrentProcessorNumber(VOID)
3956 {
3957 return 0;
3958 }
3959
3960 #elif defined(_M_ARM)
3961
3962 //
3963 // NT-ARM is not documented, need DDK-ARM
3964 //
3965 #include <armddk.h>
3966
3967 #else
3968 #error Unknown architecture
3969 #endif
3970
3971 #define MM_DONT_ZERO_ALLOCATION 0x00000001
3972 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
3973
3974
3975 #define EFLAG_SIGN 0x8000
3976 #define EFLAG_ZERO 0x4000
3977 #define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO)
3978
3979 #define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
3980 #define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
3981 #define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
3982
3983 typedef enum _INTERLOCKED_RESULT {
3984 ResultNegative = RESULT_NEGATIVE,
3985 ResultZero = RESULT_ZERO,
3986 ResultPositive = RESULT_POSITIVE
3987 } INTERLOCKED_RESULT;
3988
3989 typedef VOID
3990 (NTAPI *PciPin2Line)(
3991 IN struct _BUS_HANDLER *BusHandler,
3992 IN struct _BUS_HANDLER *RootHandler,
3993 IN PCI_SLOT_NUMBER SlotNumber,
3994 IN PPCI_COMMON_CONFIG PciData
3995 );
3996
3997 typedef VOID
3998 (NTAPI *PciLine2Pin)(
3999 IN struct _BUS_HANDLER *BusHandler,
4000 IN struct _BUS_HANDLER *RootHandler,
4001 IN PCI_SLOT_NUMBER SlotNumber,
4002 IN PPCI_COMMON_CONFIG PciNewData,
4003 IN PPCI_COMMON_CONFIG PciOldData
4004 );
4005
4006 typedef VOID
4007 (NTAPI *PciReadWriteConfig)(
4008 IN struct _BUS_HANDLER *BusHandler,
4009 IN PCI_SLOT_NUMBER Slot,
4010 IN PVOID Buffer,
4011 IN ULONG Offset,
4012 IN ULONG Length
4013 );
4014
4015 #define PCI_DATA_TAG ' ICP'
4016 #define PCI_DATA_VERSION 1
4017
4018 typedef struct _PCIBUSDATA
4019 {
4020 ULONG Tag;
4021 ULONG Version;
4022 PciReadWriteConfig ReadConfig;
4023 PciReadWriteConfig WriteConfig;
4024 PciPin2Line Pin2Line;
4025 PciLine2Pin Line2Pin;
4026 PCI_SLOT_NUMBER ParentSlot;
4027 PVOID Reserved[4];
4028 } PCIBUSDATA, *PPCIBUSDATA;
4029
4030
4031 /** SPINLOCK FUNCTIONS ********************************************************/
4032
4033 NTKERNELAPI
4034 BOOLEAN
4035 FASTCALL
4036 KeTryToAcquireSpinLockAtDpcLevel(
4037 IN OUT PKSPIN_LOCK SpinLock
4038 );
4039
4040 NTKERNELAPI
4041 BOOLEAN
4042 FASTCALL
4043 KeTestSpinLock(
4044 IN PKSPIN_LOCK SpinLock
4045 );
4046
4047 #if defined (_X86_)
4048
4049 #if defined(WIN9X_COMPAT_SPINLOCK)
4050
4051 NTKERNELAPI
4052 VOID
4053 NTAPI
4054 KeInitializeSpinLock(
4055 IN PKSPIN_LOCK SpinLock
4056 );
4057
4058 #else
4059
4060 FORCEINLINE
4061 VOID
4062 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
4063 {
4064 /* Clear the lock */
4065 *SpinLock = 0;
4066 }
4067
4068 #endif
4069
4070 NTHALAPI
4071 KIRQL
4072 FASTCALL
4073 KfAcquireSpinLock(
4074 IN PKSPIN_LOCK SpinLock);
4075
4076 NTHALAPI
4077 VOID
4078 FASTCALL
4079 KfReleaseSpinLock(
4080 IN PKSPIN_LOCK SpinLock,
4081 IN KIRQL NewIrql);
4082
4083 NTKERNELAPI
4084 VOID
4085 FASTCALL
4086 KefAcquireSpinLockAtDpcLevel(
4087 IN PKSPIN_LOCK SpinLock);
4088
4089 NTKERNELAPI
4090 VOID
4091 FASTCALL
4092 KefReleaseSpinLockFromDpcLevel(
4093 IN PKSPIN_LOCK SpinLock);
4094
4095 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
4096 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
4097 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
4098 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
4099
4100 #define KeGetDcacheFillSize() 1L
4101
4102 #elif defined(_M_ARM) // !defined (_X86_)
4103
4104 FORCEINLINE
4105 VOID
4106 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
4107 {
4108 /* Clear the lock */
4109 *SpinLock = 0;
4110 }
4111
4112 NTHALAPI
4113 KIRQL
4114 FASTCALL
4115 KfAcquireSpinLock(
4116 IN PKSPIN_LOCK SpinLock);
4117
4118 NTHALAPI
4119 VOID
4120 FASTCALL
4121 KfReleaseSpinLock(
4122 IN PKSPIN_LOCK SpinLock,
4123 IN KIRQL NewIrql);
4124
4125
4126 NTKERNELAPI
4127 VOID
4128 FASTCALL
4129 KefAcquireSpinLockAtDpcLevel(
4130 IN PKSPIN_LOCK SpinLock);
4131
4132 NTKERNELAPI
4133 VOID
4134 FASTCALL
4135 KefReleaseSpinLockFromDpcLevel(
4136 IN PKSPIN_LOCK SpinLock);
4137
4138
4139 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
4140 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
4141 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
4142 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
4143
4144 NTKERNELAPI
4145 VOID
4146 NTAPI
4147 KeInitializeSpinLock(
4148 IN PKSPIN_LOCK SpinLock);
4149
4150 #else
4151
4152 FORCEINLINE
4153 VOID
4154 NTAPI
4155 KeInitializeSpinLock(
4156 PKSPIN_LOCK SpinLock)
4157 {
4158 *SpinLock = 0;
4159 }
4160
4161 NTKERNELAPI
4162 VOID
4163 KeReleaseSpinLock(
4164 IN PKSPIN_LOCK SpinLock,
4165 IN KIRQL NewIrql);
4166
4167 NTKERNELAPI
4168 VOID
4169 KeAcquireSpinLockAtDpcLevel(
4170 IN PKSPIN_LOCK SpinLock);
4171
4172 NTKERNELAPI
4173 VOID
4174 KeReleaseSpinLockFromDpcLevel(
4175 IN PKSPIN_LOCK SpinLock);
4176
4177 NTKERNELAPI
4178 KIRQL
4179 KeAcquireSpinLockRaiseToDpc(
4180 IN PKSPIN_LOCK SpinLock);
4181
4182 #define KeAcquireSpinLock(SpinLock, OldIrql) \
4183 *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
4184
4185 #endif // !defined (_X86_)
4186
4187 /*
4188 ** Utillity functions
4189 */
4190
4191 #define ARGUMENT_PRESENT(ArgumentPointer) \
4192 ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
4193
4194 /*
4195 * ULONG
4196 * BYTE_OFFSET(
4197 * IN PVOID Va)
4198 */
4199 #define BYTE_OFFSET(Va) \
4200 ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
4201
4202 /*
4203 * ULONG
4204 * BYTES_TO_PAGES(
4205 * IN ULONG Size)
4206 */
4207 #define BYTES_TO_PAGES(Size) \
4208 ((ULONG) ((ULONG_PTR) (Size) >> PAGE_SHIFT) + (((ULONG) (Size) & (PAGE_SIZE - 1)) != 0))
4209
4210 /*
4211 * PVOID
4212 * PAGE_ALIGN(
4213 * IN PVOID Va)
4214 */
4215 #define PAGE_ALIGN(Va) \
4216 ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
4217
4218 /*
4219 * ULONG_PTR
4220 * ROUND_TO_PAGES(
4221 * IN ULONG_PTR Size)
4222 */
4223 #define ROUND_TO_PAGES(Size) \
4224 ((ULONG_PTR) (((ULONG_PTR) Size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))
4225
4226
4227
4228 #if defined(_X86_) || defined(_AMD64_)
4229
4230 //
4231 // x86 and x64 performs a 0x2C interrupt
4232 //
4233 #define DbgRaiseAssertionFailure __int2c
4234
4235 #elif defined(_ARM_)
4236
4237 //
4238 // TODO
4239 //
4240
4241 #else
4242 #error Unsupported Architecture
4243 #endif
4244
4245 #if DBG
4246
4247 #define ASSERT(exp) \
4248 (VOID)((!(exp)) ? \
4249 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
4250
4251 #define ASSERTMSG(msg, exp) \
4252 (VOID)((!(exp)) ? \
4253 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE)
4254
4255 #define RTL_SOFT_ASSERT(exp) \
4256 (VOID)((!(exp)) ? \
4257 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
4258
4259 #define RTL_SOFT_ASSERTMSG(msg, exp) \
4260 (VOID)((!(exp)) ? \
4261 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
4262
4263 #define RTL_VERIFY(exp) ASSERT(exp)
4264 #define RTL_VERIFYMSG(msg, exp) ASSERT(msg, exp)
4265
4266 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
4267 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
4268
4269 #if defined(_MSC_VER)
4270
4271 #define NT_ASSERT(exp) \
4272 ((!(exp)) ? \
4273 (__annotation(L"Debug", L"AssertFail", L#exp), \
4274 DbgRaiseAssertionFailure(), FALSE) : TRUE)
4275
4276 #define NT_ASSERTMSG(msg, exp) \
4277 ((!(exp)) ? \
4278 (__annotation(L"Debug", L"AssertFail", L##msg), \
4279 DbgRaiseAssertionFailure(), FALSE) : TRUE)
4280
4281 #define NT_ASSERTMSGW(msg, exp) \
4282 ((!(exp)) ? \
4283 (__annotation(L"Debug", L"AssertFail", msg), \
4284 DbgRaiseAssertionFailure(), FALSE) : TRUE)
4285
4286 #else
4287
4288 //
4289 // GCC doesn't support __annotation (nor PDB)
4290 //
4291 #define NT_ASSERT(exp) \
4292 (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
4293
4294 #define NT_ASSERTMSG NT_ASSERT
4295 #define NT_ASSERTMSGW NT_ASSERT
4296
4297 #endif
4298
4299 #else /* !DBG */
4300
4301 #define ASSERT(exp) ((VOID) 0)
4302 #define ASSERTMSG(msg, exp) ((VOID) 0)
4303
4304 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
4305 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
4306
4307 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
4308 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
4309
4310 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
4311 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
4312
4313 #define NT_ASSERT(exp) ((VOID)0)
4314 #define NT_ASSERTMSG(exp) ((VOID)0)
4315 #define NT_ASSERTMSGW(exp) ((VOID)0)
4316
4317 #endif /* DBG */
4318
4319 /* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
4320 #if defined(_NTSYSTEM_) || defined(__GNUC__)
4321 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
4322 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
4323 #else
4324 #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
4325 #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
4326 #endif /* _NT_SYSTEM */
4327
4328 extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG;
4329 extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG;
4330
4331 /*
4332 ** Driver support routines
4333 */
4334
4335 /** Runtime library routines **/
4336
4337 static __inline VOID
4338 InitializeListHead(
4339 IN PLIST_ENTRY ListHead)
4340 {
4341 ListHead->Flink = ListHead->Blink = ListHead;
4342 }
4343
4344 static __inline VOID
4345 InsertHeadList(
4346 IN PLIST_ENTRY ListHead,
4347 IN PLIST_ENTRY Entry)
4348 {
4349 PLIST_ENTRY OldFlink;
4350 OldFlink = ListHead->Flink;
4351 Entry->Flink = OldFlink;
4352 Entry->Blink = ListHead;
4353 OldFlink->Blink = Entry;
4354 ListHead->Flink = Entry;
4355 }
4356
4357 static __inline VOID
4358 InsertTailList(
4359 IN PLIST_ENTRY ListHead,
4360 IN PLIST_ENTRY Entry)
4361 {
4362 PLIST_ENTRY OldBlink;
4363 OldBlink = ListHead->Blink;
4364 Entry->Flink = ListHead;
4365 Entry->Blink = OldBlink;
4366 OldBlink->Flink = Entry;
4367 ListHead->Blink = Entry;
4368 }
4369
4370 /*
4371 * BOOLEAN
4372 * IsListEmpty(
4373 * IN PLIST_ENTRY ListHead)
4374 */
4375 #define IsListEmpty(_ListHead) \
4376 ((_ListHead)->Flink == (_ListHead))
4377
4378 /*
4379 * PSINGLE_LIST_ENTRY
4380 * PopEntryList(
4381 * IN PSINGLE_LIST_ENTRY ListHead)
4382 */
4383 #define PopEntryList(ListHead) \
4384 (ListHead)->Next; \
4385 { \
4386 PSINGLE_LIST_ENTRY _FirstEntry; \
4387 _FirstEntry = (ListHead)->Next; \
4388 if (_FirstEntry != NULL) \
4389 (ListHead)->Next = _FirstEntry->Next; \
4390 }
4391
4392 /*
4393 * VOID
4394 * PushEntryList(
4395 * IN PSINGLE_LIST_ENTRY ListHead,
4396 * IN PSINGLE_LIST_ENTRY Entry)
4397 */
4398 #define PushEntryList(_ListHead, _Entry) \
4399 (_Entry)->Next = (_ListHead)->Next; \
4400 (_ListHead)->Next = (_Entry); \
4401
4402 static __inline BOOLEAN
4403 RemoveEntryList(
4404 IN PLIST_ENTRY Entry)
4405 {
4406 PLIST_ENTRY OldFlink;
4407 PLIST_ENTRY OldBlink;
4408
4409 OldFlink = Entry->Flink;
4410 OldBlink = Entry->Blink;
4411 OldFlink->Blink = OldBlink;
4412 OldBlink->Flink = OldFlink;
4413 return (BOOLEAN)(OldFlink == OldBlink);
4414 }
4415
4416 static __inline PLIST_ENTRY
4417 RemoveHeadList(
4418 IN PLIST_ENTRY ListHead)
4419 {
4420 PLIST_ENTRY Flink;
4421 PLIST_ENTRY Entry;
4422
4423 Entry = ListHead->Flink;
4424 Flink = Entry->Flink;
4425 ListHead->Flink = Flink;
4426 Flink->Blink = ListHead;
4427 return Entry;
4428 }
4429
4430 static __inline PLIST_ENTRY
4431 RemoveTailList(
4432 IN PLIST_ENTRY ListHead)
4433 {
4434 PLIST_ENTRY Blink;
4435 PLIST_ENTRY Entry;
4436
4437 Entry = ListHead->Blink;
4438 Blink = Entry->Blink;
4439 ListHead->Blink = Blink;
4440 Blink->Flink = ListHead;
4441 return Entry;
4442 }
4443
4444 NTSYSAPI
4445 NTSTATUS
4446 NTAPI
4447 RtlCharToInteger(
4448 IN PCSZ String,
4449 IN ULONG Base OPTIONAL,
4450 IN OUT PULONG Value);
4451
4452 NTSYSAPI
4453 LONG
4454 NTAPI
4455 RtlCompareString(
4456 IN PSTRING String1,
4457 IN PSTRING String2,
4458 BOOLEAN CaseInSensitive);
4459
4460 #if !defined(MIDL_PASS)
4461
4462 FORCEINLINE
4463 LUID
4464 NTAPI
4465 RtlConvertLongToLuid(
4466 IN LONG Val)
4467 {
4468 LUID Luid;
4469 LARGE_INTEGER Temp;
4470
4471 Temp.QuadPart = Val;
4472 Luid.LowPart = Temp.u.LowPart;
4473 Luid.HighPart = Temp.u.HighPart;
4474
4475 return Luid;
4476 }
4477
4478 FORCEINLINE
4479 LUID
4480 NTAPI
4481 RtlConvertUlongToLuid(
4482 IN ULONG Val)
4483 {
4484 LUID Luid;
4485
4486 Luid.LowPart = Val;
4487 Luid.HighPart = 0;
4488
4489 return Luid;
4490 }
4491 #endif
4492
4493
4494 NTSYSAPI
4495 VOID
4496 NTAPI
4497 RtlCopyMemory32(
4498 IN VOID UNALIGNED *Destination,
4499 IN CONST VOID UNALIGNED *Source,
4500 IN ULONG Length);
4501
4502 NTSYSAPI
4503 VOID
4504 NTAPI
4505 RtlCopyString(
4506 IN OUT PSTRING DestinationString,
4507 IN PSTRING SourceString OPTIONAL);
4508
4509 NTSYSAPI
4510 BOOLEAN
4511 NTAPI
4512 RtlEqualString(
4513 IN PSTRING String1,
4514 IN PSTRING String2,
4515 IN BOOLEAN CaseInSensitive);
4516
4517 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
4518 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
4519 *CallersAddress = (PVOID)_ReturnAddress(); \
4520 *CallersCaller = NULL;
4521 #else
4522 NTSYSAPI
4523 VOID
4524 NTAPI
4525 RtlGetCallersAddress(
4526 OUT PVOID *CallersAddress,
4527 OUT PVOID *CallersCaller);
4528 #endif
4529
4530 NTSYSAPI
4531 NTSTATUS
4532 NTAPI
4533 RtlGetVersion(
4534 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
4535
4536 NTSYSAPI
4537 VOID
4538 NTAPI
4539 RtlMapGenericMask(
4540 IN OUT PACCESS_MASK AccessMask,
4541 IN PGENERIC_MAPPING GenericMapping);
4542
4543 NTSYSAPI
4544 BOOLEAN
4545 NTAPI
4546 RtlPrefixUnicodeString(
4547 IN PCUNICODE_STRING String1,
4548 IN PCUNICODE_STRING String2,
4549 IN BOOLEAN CaseInSensitive);
4550
4551 NTSYSAPI
4552 NTSTATUS
4553 NTAPI
4554 RtlUpcaseUnicodeString(
4555 IN OUT PUNICODE_STRING DestinationString OPTIONAL,
4556 IN PCUNICODE_STRING SourceString,
4557 IN BOOLEAN AllocateDestinationString);
4558
4559 NTSYSAPI
4560 CHAR
4561 NTAPI
4562 RtlUpperChar(
4563 IN CHAR Character);
4564
4565 NTSYSAPI
4566 VOID
4567 NTAPI
4568 RtlUpperString(
4569 IN OUT PSTRING DestinationString,
4570 IN PSTRING SourceString);
4571
4572 NTSYSAPI
4573 NTSTATUS
4574 NTAPI
4575 RtlVerifyVersionInfo(
4576 IN PRTL_OSVERSIONINFOEXW VersionInfo,
4577 IN ULONG TypeMask,
4578 IN ULONGLONG ConditionMask);
4579
4580 NTSYSAPI
4581 NTSTATUS
4582 NTAPI
4583 RtlVolumeDeviceToDosName(
4584 IN PVOID VolumeDeviceObject,
4585 OUT PUNICODE_STRING DosName);
4586
4587 NTSYSAPI
4588 ULONG
4589 NTAPI
4590 RtlWalkFrameChain(
4591 OUT PVOID *Callers,
4592 IN ULONG Count,
4593 IN ULONG Flags);
4594
4595 NTKERNELAPI
4596 BOOLEAN
4597 NTAPI
4598 KeAreAllApcsDisabled(
4599 VOID
4600 );
4601
4602 /* Guarded Mutex routines */
4603
4604 NTKERNELAPI
4605 VOID
4606 FASTCALL
4607 KeAcquireGuardedMutex(
4608 IN OUT PKGUARDED_MUTEX GuardedMutex
4609 );
4610
4611 NTKERNELAPI
4612 VOID
4613 FASTCALL
4614 KeAcquireGuardedMutexUnsafe(
4615 IN OUT PKGUARDED_MUTEX GuardedMutex
4616 );
4617
4618 NTKERNELAPI
4619 VOID
4620 NTAPI
4621 KeEnterGuardedRegion(
4622 VOID
4623 );
4624
4625 NTKERNELAPI
4626 VOID
4627 NTAPI
4628 KeLeaveGuardedRegion(
4629 VOID
4630 );
4631
4632 NTKERNELAPI
4633 VOID
4634 FASTCALL
4635 KeInitializeGuardedMutex(
4636 OUT PKGUARDED_MUTEX GuardedMutex
4637 );
4638
4639 NTKERNELAPI
4640 VOID
4641 FASTCALL
4642 KeReleaseGuardedMutexUnsafe(
4643 IN OUT PKGUARDED_MUTEX GuardedMutex
4644 );
4645
4646 NTKERNELAPI
4647 VOID
4648 FASTCALL
4649 KeReleaseGuardedMutex(
4650 IN OUT PKGUARDED_MUTEX GuardedMutex
4651 );
4652
4653 NTKERNELAPI
4654 BOOLEAN
4655 FASTCALL
4656 KeTryToAcquireGuardedMutex(
4657 IN OUT PKGUARDED_MUTEX GuardedMutex
4658 );
4659
4660 /* Fast Mutex */
4661 #define ExInitializeFastMutex(_FastMutex) \
4662 { \
4663 (_FastMutex)->Count = FM_LOCK_BIT; \
4664 (_FastMutex)->Owner = NULL; \
4665 (_FastMutex)->Contention = 0; \
4666 KeInitializeEvent(&(_FastMutex)->Gate, SynchronizationEvent, FALSE); \
4667 }
4668
4669 NTKERNELAPI
4670 VOID
4671 NTAPI
4672 KeInitializeEvent(
4673 IN PRKEVENT Event,
4674 IN EVENT_TYPE Type,
4675 IN BOOLEAN State);
4676 </