03b37ba801b48bc5cff29bd9a466e2c7f170a137
[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 #define IN
53 #define OUT
54 #define OPTIONAL
55 #define UNALLIGNED
56
57 #define CONST const
58
59 #define RESTRICTED_POINTER
60
61 #if defined(_WIN64)
62 #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
63 #else
64 #define POINTER_ALIGNMENT
65 #endif
66
67 #define DECLSPEC_ADDRSAFE
68
69 #ifdef NONAMELESSUNION
70 # define _DDK_DUMMYUNION_MEMBER(name) DUMMYUNIONNAME.name
71 # define _DDK_DUMMYUNION_N_MEMBER(n, name) DUMMYUNIONNAME##n.name
72 #else
73 # define _DDK_DUMMYUNION_MEMBER(name) name
74 # define _DDK_DUMMYUNION_N_MEMBER(n, name) name
75 #endif
76
77 /*
78 ** Forward declarations
79 */
80
81 struct _KPCR;
82 struct _KPRCB;
83 struct _KTSS;
84 struct _DRIVE_LAYOUT_INFORMATION_EX;
85 struct _LOADER_PARAMETER_BLOCK;
86
87
88 #if 1
89 /* FIXME: Unknown definitions */
90 struct _SET_PARTITION_INFORMATION_EX;
91 typedef ULONG WAIT_TYPE;
92 #define WaitAll 0
93 #define WaitAny 1
94 typedef HANDLE TRACEHANDLE;
95 typedef PVOID PWMILIB_CONTEXT;
96 typedef ULONG LOGICAL;
97 #endif
98
99 /*
100 ** WmiLib specific structure
101 */
102 typedef enum
103 {
104 IrpProcessed, // Irp was processed and possibly completed
105 IrpNotCompleted, // Irp was process and NOT completed
106 IrpNotWmi, // Irp is not a WMI irp
107 IrpForward // Irp is wmi irp, but targeted at another device object
108 } SYSCTL_IRP_DISPOSITION, *PSYSCTL_IRP_DISPOSITION;
109
110 //
111 // Forwarder
112 //
113 struct _COMPRESSED_DATA_INFO;
114
115 #define KERNEL_STACK_SIZE 12288
116 #define KERNEL_LARGE_STACK_SIZE 61440
117 #define KERNEL_LARGE_STACK_COMMIT 12288
118
119 #define EXCEPTION_READ_FAULT 0
120 #define EXCEPTION_WRITE_FAULT 1
121 #define EXCEPTION_EXECUTE_FAULT 8
122
123 #define DPFLTR_ERROR_LEVEL 0
124 #define DPFLTR_WARNING_LEVEL 1
125 #define DPFLTR_TRACE_LEVEL 2
126 #define DPFLTR_INFO_LEVEL 3
127 #define DPFLTR_MASK 0x80000000
128
129 typedef enum _DPFLTR_TYPE
130 {
131 DPFLTR_SYSTEM_ID = 0,
132 DPFLTR_SMSS_ID = 1,
133 DPFLTR_SETUP_ID = 2,
134 DPFLTR_NTFS_ID = 3,
135 DPFLTR_FSTUB_ID = 4,
136 DPFLTR_CRASHDUMP_ID = 5,
137 DPFLTR_CDAUDIO_ID = 6,
138 DPFLTR_CDROM_ID = 7,
139 DPFLTR_CLASSPNP_ID = 8,
140 DPFLTR_DISK_ID = 9,
141 DPFLTR_REDBOOK_ID = 10,
142 DPFLTR_STORPROP_ID = 11,
143 DPFLTR_SCSIPORT_ID = 12,
144 DPFLTR_SCSIMINIPORT_ID = 13,
145 DPFLTR_CONFIG_ID = 14,
146 DPFLTR_I8042PRT_ID = 15,
147 DPFLTR_SERMOUSE_ID = 16,
148 DPFLTR_LSERMOUS_ID = 17,
149 DPFLTR_KBDHID_ID = 18,
150 DPFLTR_MOUHID_ID = 19,
151 DPFLTR_KBDCLASS_ID = 20,
152 DPFLTR_MOUCLASS_ID = 21,
153 DPFLTR_TWOTRACK_ID = 22,
154 DPFLTR_WMILIB_ID = 23,
155 DPFLTR_ACPI_ID = 24,
156 DPFLTR_AMLI_ID = 25,
157 DPFLTR_HALIA64_ID = 26,
158 DPFLTR_VIDEO_ID = 27,
159 DPFLTR_SVCHOST_ID = 28,
160 DPFLTR_VIDEOPRT_ID = 29,
161 DPFLTR_TCPIP_ID = 30,
162 DPFLTR_DMSYNTH_ID = 31,
163 DPFLTR_NTOSPNP_ID = 32,
164 DPFLTR_FASTFAT_ID = 33,
165 DPFLTR_SAMSS_ID = 34,
166 DPFLTR_PNPMGR_ID = 35,
167 DPFLTR_NETAPI_ID = 36,
168 DPFLTR_SCSERVER_ID = 37,
169 DPFLTR_SCCLIENT_ID = 38,
170 DPFLTR_SERIAL_ID = 39,
171 DPFLTR_SERENUM_ID = 40,
172 DPFLTR_UHCD_ID = 41,
173 DPFLTR_BOOTOK_ID = 42,
174 DPFLTR_BOOTVRFY_ID = 43,
175 DPFLTR_RPCPROXY_ID = 44,
176 DPFLTR_AUTOCHK_ID = 45,
177 DPFLTR_DCOMSS_ID = 46,
178 DPFLTR_UNIMODEM_ID = 47,
179 DPFLTR_SIS_ID = 48,
180 DPFLTR_FLTMGR_ID = 49,
181 DPFLTR_WMICORE_ID = 50,
182 DPFLTR_BURNENG_ID = 51,
183 DPFLTR_IMAPI_ID = 52,
184 DPFLTR_SXS_ID = 53,
185 DPFLTR_FUSION_ID = 54,
186 DPFLTR_IDLETASK_ID = 55,
187 DPFLTR_SOFTPCI_ID = 56,
188 DPFLTR_TAPE_ID = 57,
189 DPFLTR_MCHGR_ID = 58,
190 DPFLTR_IDEP_ID = 59,
191 DPFLTR_PCIIDE_ID = 60,
192 DPFLTR_FLOPPY_ID = 61,
193 DPFLTR_FDC_ID = 62,
194 DPFLTR_TERMSRV_ID = 63,
195 DPFLTR_W32TIME_ID = 64,
196 DPFLTR_PREFETCHER_ID = 65,
197 DPFLTR_RSFILTER_ID = 66,
198 DPFLTR_FCPORT_ID = 67,
199 DPFLTR_PCI_ID = 68,
200 DPFLTR_DMIO_ID = 69,
201 DPFLTR_DMCONFIG_ID = 70,
202 DPFLTR_DMADMIN_ID = 71,
203 DPFLTR_WSOCKTRANSPORT_ID = 72,
204 DPFLTR_VSS_ID = 73,
205 DPFLTR_PNPMEM_ID = 74,
206 DPFLTR_PROCESSOR_ID = 75,
207 DPFLTR_DMSERVER_ID = 76,
208 DPFLTR_SR_ID = 77,
209 DPFLTR_INFINIBAND_ID = 78,
210 DPFLTR_IHVDRIVER_ID = 79,
211 DPFLTR_IHVVIDEO_ID = 80,
212 DPFLTR_IHVAUDIO_ID = 81,
213 DPFLTR_IHVNETWORK_ID = 82,
214 DPFLTR_IHVSTREAMING_ID = 83,
215 DPFLTR_IHVBUS_ID = 84,
216 DPFLTR_HPS_ID = 85,
217 DPFLTR_RTLTHREADPOOL_ID = 86,
218 DPFLTR_LDR_ID = 87,
219 DPFLTR_TCPIP6_ID = 88,
220 DPFLTR_ISAPNP_ID = 89,
221 DPFLTR_SHPC_ID = 90,
222 DPFLTR_STORPORT_ID = 91,
223 DPFLTR_STORMINIPORT_ID = 92,
224 DPFLTR_PRINTSPOOLER_ID = 93,
225 DPFLTR_VDS_ID = 94,
226 DPFLTR_VDSBAS_ID = 95,
227 DPFLTR_VDSDYNDR_ID = 96,
228 DPFLTR_VDSUTIL_ID = 97,
229 DPFLTR_DFRGIFC_ID = 98,
230 DPFLTR_DEFAULT_ID = 99,
231 DPFLTR_MM_ID = 100,
232 DPFLTR_DFSC_ID = 101,
233 DPFLTR_WOW64_ID = 102,
234 DPFLTR_ENDOFTABLE_ID
235 } DPFLTR_TYPE;
236
237 /* also in winnt.h */
238 #define FILE_LIST_DIRECTORY 0x00000001
239 #define FILE_READ_DATA 0x00000001
240 #define FILE_ADD_FILE 0x00000002
241 #define FILE_WRITE_DATA 0x00000002
242 #define FILE_ADD_SUBDIRECTORY 0x00000004
243 #define FILE_APPEND_DATA 0x00000004
244 #define FILE_CREATE_PIPE_INSTANCE 0x00000004
245 #define FILE_READ_EA 0x00000008
246 #define FILE_WRITE_EA 0x00000010
247 #define FILE_EXECUTE 0x00000020
248 #define FILE_TRAVERSE 0x00000020
249 #define FILE_DELETE_CHILD 0x00000040
250 #define FILE_READ_ATTRIBUTES 0x00000080
251 #define FILE_WRITE_ATTRIBUTES 0x00000100
252
253 #define FILE_SHARE_READ 0x00000001
254 #define FILE_SHARE_WRITE 0x00000002
255 #define FILE_SHARE_DELETE 0x00000004
256 #define FILE_SHARE_VALID_FLAGS 0x00000007
257
258 #define FILE_ATTRIBUTE_READONLY 0x00000001
259 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
260 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
261 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
262 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
263 #define FILE_ATTRIBUTE_DEVICE 0x00000040
264 #define FILE_ATTRIBUTE_NORMAL 0x00000080
265 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
266 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
267 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
268 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
269 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
270 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
271 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
272
273 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
274 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
275
276 #define FILE_COPY_STRUCTURED_STORAGE 0x00000041
277 #define FILE_STRUCTURED_STORAGE 0x00000441
278
279 #define FILE_VALID_OPTION_FLAGS 0x00ffffff
280 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
281 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
282 #define FILE_VALID_SET_FLAGS 0x00000036
283
284 #define FILE_SUPERSEDE 0x00000000
285 #define FILE_OPEN 0x00000001
286 #define FILE_CREATE 0x00000002
287 #define FILE_OPEN_IF 0x00000003
288 #define FILE_OVERWRITE 0x00000004
289 #define FILE_OVERWRITE_IF 0x00000005
290 #define FILE_MAXIMUM_DISPOSITION 0x00000005
291
292 #define FILE_DIRECTORY_FILE 0x00000001
293 #define FILE_WRITE_THROUGH 0x00000002
294 #define FILE_SEQUENTIAL_ONLY 0x00000004
295 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
296 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
297 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
298 #define FILE_NON_DIRECTORY_FILE 0x00000040
299 #define FILE_CREATE_TREE_CONNECTION 0x00000080
300 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
301 #define FILE_NO_EA_KNOWLEDGE 0x00000200
302 #define FILE_OPEN_FOR_RECOVERY 0x00000400
303 #define FILE_RANDOM_ACCESS 0x00000800
304 #define FILE_DELETE_ON_CLOSE 0x00001000
305 #define FILE_OPEN_BY_FILE_ID 0x00002000
306 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
307 #define FILE_NO_COMPRESSION 0x00008000
308 #define FILE_RESERVE_OPFILTER 0x00100000
309 #define FILE_OPEN_REPARSE_POINT 0x00200000
310 #define FILE_OPEN_NO_RECALL 0x00400000
311 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
312
313 #define FILE_ANY_ACCESS 0x00000000
314 #define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS
315 #define FILE_READ_ACCESS 0x00000001
316 #define FILE_WRITE_ACCESS 0x00000002
317
318 #define FILE_ALL_ACCESS \
319 (STANDARD_RIGHTS_REQUIRED | \
320 SYNCHRONIZE | \
321 0x1FF)
322
323 #define FILE_GENERIC_EXECUTE \
324 (STANDARD_RIGHTS_EXECUTE | \
325 FILE_READ_ATTRIBUTES | \
326 FILE_EXECUTE | \
327 SYNCHRONIZE)
328
329 #define FILE_GENERIC_READ \
330 (STANDARD_RIGHTS_READ | \
331 FILE_READ_DATA | \
332 FILE_READ_ATTRIBUTES | \
333 FILE_READ_EA | \
334 SYNCHRONIZE)
335
336 #define FILE_GENERIC_WRITE \
337 (STANDARD_RIGHTS_WRITE | \
338 FILE_WRITE_DATA | \
339 FILE_WRITE_ATTRIBUTES | \
340 FILE_WRITE_EA | \
341 FILE_APPEND_DATA | \
342 SYNCHRONIZE)
343 /* end winnt.h */
344
345 #define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\')
346
347 #define OBJECT_TYPE_CREATE (0x0001)
348 #define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
349
350 #define DIRECTORY_QUERY (0x0001)
351 #define DIRECTORY_TRAVERSE (0x0002)
352 #define DIRECTORY_CREATE_OBJECT (0x0004)
353 #define DIRECTORY_CREATE_SUBDIRECTORY (0x0008)
354 #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
355
356 #define EVENT_QUERY_STATE (0x0001)
357 #define EVENT_MODIFY_STATE (0x0002)
358 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
359
360 #define SEMAPHORE_QUERY_STATE (0x0001)
361 #define SEMAPHORE_MODIFY_STATE (0x0002)
362 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
363
364 #define THREAD_ALERT (0x0004)
365
366 #define FM_LOCK_BIT (0x1)
367 #define FM_LOCK_BIT_V (0x0)
368 #define FM_LOCK_WAITER_WOKEN (0x2)
369 #define FM_LOCK_WAITER_INC (0x4)
370
371 /* Exported object types */
372 extern POBJECT_TYPE NTSYSAPI ExDesktopObjectType;
373 extern POBJECT_TYPE NTSYSAPI ExEventObjectType;
374 extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType;
375 extern POBJECT_TYPE NTSYSAPI ExWindowStationObjectType;
376 extern ULONG NTSYSAPI IoDeviceHandlerObjectSize;
377 extern POBJECT_TYPE NTSYSAPI IoDeviceHandlerObjectType;
378 extern POBJECT_TYPE NTSYSAPI IoDeviceObjectType;
379 extern POBJECT_TYPE NTSYSAPI IoDriverObjectType;
380 extern POBJECT_TYPE NTSYSAPI IoFileObjectType;
381 extern POBJECT_TYPE NTSYSAPI PsThreadType;
382 extern POBJECT_TYPE NTSYSAPI LpcPortObjectType;
383 extern POBJECT_TYPE NTSYSAPI SeTokenObjectType;
384 extern POBJECT_TYPE NTSYSAPI PsProcessType;
385
386 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
387 extern volatile CCHAR NTSYSAPI KeNumberProcessors;
388 #else
389 #if (NTDDI_VERSION >= NTDDI_WINXP)
390 extern CCHAR NTSYSAPI KeNumberProcessors;
391 #else
392 //extern PCCHAR KeNumberProcessors;
393 extern NTSYSAPI CCHAR KeNumberProcessors; //FIXME: Note to Alex: I won't fix this atm, since I prefer to discuss this with you first.
394 #endif
395 #endif
396
397 #define PROCESSOR_FEATURE_MAX 64
398 #define MAX_WOW64_SHARED_ENTRIES 16
399
400 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
401 {
402 StandardDesign,
403 NEC98x86,
404 EndAlternatives
405 } ALTERNATIVE_ARCHITECTURE_TYPE;
406
407 typedef struct _KSYSTEM_TIME
408 {
409 ULONG LowPart;
410 LONG High1Time;
411 LONG High2Time;
412 } KSYSTEM_TIME, *PKSYSTEM_TIME;
413
414 extern volatile KSYSTEM_TIME KeTickCount;
415
416 #define NX_SUPPORT_POLICY_ALWAYSOFF 0
417 #define NX_SUPPORT_POLICY_ALWAYSON 1
418 #define NX_SUPPORT_POLICY_OPTIN 2
419 #define NX_SUPPORT_POLICY_OPTOUT 3
420
421 typedef struct _KUSER_SHARED_DATA
422 {
423 ULONG TickCountLowDeprecated;
424 ULONG TickCountMultiplier;
425 volatile KSYSTEM_TIME InterruptTime;
426 volatile KSYSTEM_TIME SystemTime;
427 volatile KSYSTEM_TIME TimeZoneBias;
428 USHORT ImageNumberLow;
429 USHORT ImageNumberHigh;
430 WCHAR NtSystemRoot[260];
431 ULONG MaxStackTraceDepth;
432 ULONG CryptoExponent;
433 ULONG TimeZoneId;
434 ULONG LargePageMinimum;
435 ULONG Reserved2[7];
436 NT_PRODUCT_TYPE NtProductType;
437 BOOLEAN ProductTypeIsValid;
438 ULONG NtMajorVersion;
439 ULONG NtMinorVersion;
440 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
441 ULONG Reserved1;
442 ULONG Reserved3;
443 volatile ULONG TimeSlip;
444 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
445 LARGE_INTEGER SystemExpirationDate;
446 ULONG SuiteMask;
447 BOOLEAN KdDebuggerEnabled;
448 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
449 UCHAR NXSupportPolicy;
450 #endif
451 volatile ULONG ActiveConsoleId;
452 volatile ULONG DismountCount;
453 ULONG ComPlusPackage;
454 ULONG LastSystemRITEventTickCount;
455 ULONG NumberOfPhysicalPages;
456 BOOLEAN SafeBootMode;
457 ULONG TraceLogging;
458 ULONG Fill0;
459 ULONGLONG TestRetInstruction;
460 ULONG SystemCall;
461 ULONG SystemCallReturn;
462 ULONGLONG SystemCallPad[3];
463 __GNU_EXTENSION union {
464 volatile KSYSTEM_TIME TickCount;
465 volatile ULONG64 TickCountQuad;
466 };
467 ULONG Cookie;
468 #if (NTDDI_VERSION >= NTDDI_WS03)
469 LONGLONG ConsoleSessionForegroundProcessId;
470 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
471 #endif
472 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
473 USHORT UserModeGlobalLogger[8];
474 ULONG HeapTracingPid[2];
475 ULONG CritSecTracingPid[2];
476 __GNU_EXTENSION union
477 {
478 ULONG SharedDataFlags;
479 __GNU_EXTENSION struct
480 {
481 ULONG DbgErrorPortPresent:1;
482 ULONG DbgElevationEnabled:1;
483 ULONG DbgVirtEnabled:1;
484 ULONG DbgInstallerDetectEnabled:1;
485 ULONG SpareBits:28;
486 };
487 };
488 ULONG ImageFileExecutionOptions;
489 KAFFINITY ActiveProcessorAffinity;
490 #endif
491 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
492
493 /*
494 ** IRP function codes
495 */
496
497 #define IRP_MJ_CREATE 0x00
498 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
499 #define IRP_MJ_CLOSE 0x02
500 #define IRP_MJ_READ 0x03
501 #define IRP_MJ_WRITE 0x04
502 #define IRP_MJ_QUERY_INFORMATION 0x05
503 #define IRP_MJ_SET_INFORMATION 0x06
504 #define IRP_MJ_QUERY_EA 0x07
505 #define IRP_MJ_SET_EA 0x08
506 #define IRP_MJ_FLUSH_BUFFERS 0x09
507 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
508 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
509 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
510 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
511 #define IRP_MJ_DEVICE_CONTROL 0x0e
512 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
513 #define IRP_MJ_SCSI 0x0f
514 #define IRP_MJ_SHUTDOWN 0x10
515 #define IRP_MJ_LOCK_CONTROL 0x11
516 #define IRP_MJ_CLEANUP 0x12
517 #define IRP_MJ_CREATE_MAILSLOT 0x13
518 #define IRP_MJ_QUERY_SECURITY 0x14
519 #define IRP_MJ_SET_SECURITY 0x15
520 #define IRP_MJ_POWER 0x16
521 #define IRP_MJ_SYSTEM_CONTROL 0x17
522 #define IRP_MJ_DEVICE_CHANGE 0x18
523 #define IRP_MJ_QUERY_QUOTA 0x19
524 #define IRP_MJ_SET_QUOTA 0x1a
525 #define IRP_MJ_PNP 0x1b
526 #define IRP_MJ_PNP_POWER 0x1b
527 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
528
529 #define IRP_MN_QUERY_DIRECTORY 0x01
530 #define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
531
532 #define IRP_MN_USER_FS_REQUEST 0x00
533 #define IRP_MN_MOUNT_VOLUME 0x01
534 #define IRP_MN_VERIFY_VOLUME 0x02
535 #define IRP_MN_LOAD_FILE_SYSTEM 0x03
536 #define IRP_MN_TRACK_LINK 0x04
537 #define IRP_MN_KERNEL_CALL 0x04
538
539 #define IRP_MN_LOCK 0x01
540 #define IRP_MN_UNLOCK_SINGLE 0x02
541 #define IRP_MN_UNLOCK_ALL 0x03
542 #define IRP_MN_UNLOCK_ALL_BY_KEY 0x04
543
544 #define IRP_MN_NORMAL 0x00
545 #define IRP_MN_DPC 0x01
546 #define IRP_MN_MDL 0x02
547 #define IRP_MN_COMPLETE 0x04
548 #define IRP_MN_COMPRESSED 0x08
549
550 #define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC)
551 #define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL)
552 #define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
553
554 #define IRP_MN_SCSI_CLASS 0x01
555
556 #define IRP_MN_START_DEVICE 0x00
557 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
558 #define IRP_MN_REMOVE_DEVICE 0x02
559 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
560 #define IRP_MN_STOP_DEVICE 0x04
561 #define IRP_MN_QUERY_STOP_DEVICE 0x05
562 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
563
564 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
565 #define IRP_MN_QUERY_INTERFACE 0x08
566 #define IRP_MN_QUERY_CAPABILITIES 0x09
567 #define IRP_MN_QUERY_RESOURCES 0x0A
568 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
569 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
570 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
571
572 #define IRP_MN_READ_CONFIG 0x0F
573 #define IRP_MN_WRITE_CONFIG 0x10
574 #define IRP_MN_EJECT 0x11
575 #define IRP_MN_SET_LOCK 0x12
576 #define IRP_MN_QUERY_ID 0x13
577 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
578 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
579 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
580 #define IRP_MN_SURPRISE_REMOVAL 0x17
581 #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18
582
583 #define IRP_MN_WAIT_WAKE 0x00
584 #define IRP_MN_POWER_SEQUENCE 0x01
585 #define IRP_MN_SET_POWER 0x02
586 #define IRP_MN_QUERY_POWER 0x03
587
588 #define IRP_MN_QUERY_ALL_DATA 0x00
589 #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
590 #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
591 #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
592 #define IRP_MN_ENABLE_EVENTS 0x04
593 #define IRP_MN_DISABLE_EVENTS 0x05
594 #define IRP_MN_ENABLE_COLLECTION 0x06
595 #define IRP_MN_DISABLE_COLLECTION 0x07
596 #define IRP_MN_REGINFO 0x08
597 #define IRP_MN_EXECUTE_METHOD 0x09
598
599 #define IRP_MN_REGINFO_EX 0x0b
600
601 typedef enum _IO_PAGING_PRIORITY
602 {
603 IoPagingPriorityInvalid,
604 IoPagingPriorityNormal,
605 IoPagingPriorityHigh,
606 IoPagingPriorityReserved1,
607 IoPagingPriorityReserved2
608 } IO_PAGING_PRIORITY;
609
610 typedef enum _IO_ALLOCATION_ACTION {
611 KeepObject = 1,
612 DeallocateObject,
613 DeallocateObjectKeepRegisters
614 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
615
616 typedef IO_ALLOCATION_ACTION
617 (DDKAPI *PDRIVER_CONTROL)(
618 IN struct _DEVICE_OBJECT *DeviceObject,
619 IN struct _IRP *Irp,
620 IN PVOID MapRegisterBase,
621 IN PVOID Context);
622
623
624 typedef EXCEPTION_DISPOSITION
625 (DDKAPI *PEXCEPTION_ROUTINE)(
626 IN struct _EXCEPTION_RECORD *ExceptionRecord,
627 IN PVOID EstablisherFrame,
628 IN OUT struct _CONTEXT *ContextRecord,
629 IN OUT PVOID DispatcherContext);
630
631 typedef VOID
632 (DDKAPI *PDRIVER_LIST_CONTROL)(
633 IN struct _DEVICE_OBJECT *DeviceObject,
634 IN struct _IRP *Irp,
635 IN struct _SCATTER_GATHER_LIST *ScatterGather,
636 IN PVOID Context);
637
638 typedef NTSTATUS
639 (DDKAPI DRIVER_ADD_DEVICE)(
640 IN struct _DRIVER_OBJECT *DriverObject,
641 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
642 typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
643
644 typedef NTSTATUS
645 (DDKAPI IO_COMPLETION_ROUTINE)(
646 IN struct _DEVICE_OBJECT *DeviceObject,
647 IN struct _IRP *Irp,
648 IN PVOID Context);
649 typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
650
651 typedef VOID
652 (DDKAPI DRIVER_CANCEL)(
653 IN struct _DEVICE_OBJECT *DeviceObject,
654 IN struct _IRP *Irp);
655 typedef DRIVER_CANCEL *PDRIVER_CANCEL;
656
657 typedef VOID
658 (DDKAPI *PKDEFERRED_ROUTINE)(
659 IN struct _KDPC *Dpc,
660 IN PVOID DeferredContext,
661 IN PVOID SystemArgument1,
662 IN PVOID SystemArgument2);
663
664 typedef NTSTATUS
665 (DDKAPI DRIVER_DISPATCH)(
666 IN struct _DEVICE_OBJECT *DeviceObject,
667 IN struct _IRP *Irp);
668 typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
669
670 typedef VOID
671 (DDKAPI *PIO_DPC_ROUTINE)(
672 IN struct _KDPC *Dpc,
673 IN struct _DEVICE_OBJECT *DeviceObject,
674 IN struct _IRP *Irp,
675 IN PVOID Context);
676
677 typedef NTSTATUS
678 (DDKAPI *PMM_DLL_INITIALIZE)(
679 IN PUNICODE_STRING RegistryPath);
680
681 typedef NTSTATUS
682 (DDKAPI *PMM_DLL_UNLOAD)(
683 VOID);
684
685 typedef NTSTATUS
686 (DDKAPI *PDRIVER_ENTRY)(
687 IN struct _DRIVER_OBJECT *DriverObject,
688 IN PUNICODE_STRING RegistryPath);
689
690 typedef NTSTATUS
691 (DDKAPI DRIVER_INITIALIZE)(
692 IN struct _DRIVER_OBJECT *DriverObject,
693 IN PUNICODE_STRING RegistryPath);
694 typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
695
696 typedef BOOLEAN
697 (DDKAPI KSERVICE_ROUTINE)(
698 IN struct _KINTERRUPT *Interrupt,
699 IN PVOID ServiceContext);
700 typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE;
701
702 typedef VOID
703 (DDKAPI *PIO_TIMER_ROUTINE)(
704 IN struct _DEVICE_OBJECT *DeviceObject,
705 IN PVOID Context);
706
707 typedef VOID
708 (DDKAPI *PDRIVER_REINITIALIZE)(
709 IN struct _DRIVER_OBJECT *DriverObject,
710 IN PVOID Context,
711 IN ULONG Count);
712
713 typedef VOID
714 (DDKAPI DRIVER_STARTIO)(
715 IN struct _DEVICE_OBJECT *DeviceObject,
716 IN struct _IRP *Irp);
717 typedef DRIVER_STARTIO *PDRIVER_STARTIO;
718
719 typedef BOOLEAN
720 (DDKAPI *PKSYNCHRONIZE_ROUTINE)(
721 IN PVOID SynchronizeContext);
722
723 typedef VOID
724 (DDKAPI DRIVER_UNLOAD)(
725 IN struct _DRIVER_OBJECT *DriverObject);
726 typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
727
728
729
730 /*
731 ** Plug and Play structures
732 */
733
734 typedef VOID
735 (DDKAPI *PINTERFACE_REFERENCE)(
736 PVOID Context);
737
738 typedef VOID
739 (DDKAPI *PINTERFACE_DEREFERENCE)(
740 PVOID Context);
741
742 typedef BOOLEAN
743 (DDKAPI *PTRANSLATE_BUS_ADDRESS)(
744 IN PVOID Context,
745 IN PHYSICAL_ADDRESS BusAddress,
746 IN ULONG Length,
747 IN OUT PULONG AddressSpace,
748 OUT PPHYSICAL_ADDRESS TranslatedAddress);
749
750 typedef struct _DMA_ADAPTER*
751 (DDKAPI *PGET_DMA_ADAPTER)(
752 IN PVOID Context,
753 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
754 OUT PULONG NumberOfMapRegisters);
755
756 typedef ULONG
757 (DDKAPI *PGET_SET_DEVICE_DATA)(
758 IN PVOID Context,
759 IN ULONG DataType,
760 IN PVOID Buffer,
761 IN ULONG Offset,
762 IN ULONG Length);
763
764 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
765 #define PCI_USE_SUBSYSTEM_IDS 0x00000001
766 #define PCI_USE_REVISION 0x00000002
767 #define PCI_USE_VENDEV_IDS 0x00000004
768 #define PCI_USE_CLASS_SUBCLASS 0x00000008
769 #define PCI_USE_PROGIF 0x00000010
770 #define PCI_USE_LOCAL_BUS 0x00000020
771 #define PCI_USE_LOCAL_DEVICE 0x00000040
772
773 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
774 ULONG Size;
775 ULONG Flags;
776 USHORT VendorID;
777 USHORT DeviceID;
778 UCHAR RevisionID;
779 USHORT SubVendorID;
780 USHORT SubSystemID;
781 UCHAR BaseClass;
782 UCHAR SubClass;
783 UCHAR ProgIf;
784 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
785
786 typedef BOOLEAN
787 (DDKAPI *PPCI_IS_DEVICE_PRESENT)(
788 IN USHORT VendorID,
789 IN USHORT DeviceID,
790 IN UCHAR RevisionID,
791 IN USHORT SubVendorID,
792 IN USHORT SubSystemID,
793 IN ULONG Flags);
794
795 typedef BOOLEAN
796 (DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)(
797 IN PVOID Context,
798 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
799
800 typedef union _POWER_STATE {
801 SYSTEM_POWER_STATE SystemState;
802 DEVICE_POWER_STATE DeviceState;
803 } POWER_STATE, *PPOWER_STATE;
804
805 typedef enum _POWER_STATE_TYPE {
806 SystemPowerState,
807 DevicePowerState
808 } POWER_STATE_TYPE, *PPOWER_STATE_TYPE;
809
810 typedef struct _BUS_INTERFACE_STANDARD {
811 USHORT Size;
812 USHORT Version;
813 PVOID Context;
814 PINTERFACE_REFERENCE InterfaceReference;
815 PINTERFACE_DEREFERENCE InterfaceDereference;
816 PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
817 PGET_DMA_ADAPTER GetDmaAdapter;
818 PGET_SET_DEVICE_DATA SetBusData;
819 PGET_SET_DEVICE_DATA GetBusData;
820 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
821
822 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
823 USHORT Size;
824 USHORT Version;
825 PVOID Context;
826 PINTERFACE_REFERENCE InterfaceReference;
827 PINTERFACE_DEREFERENCE InterfaceDereference;
828 PPCI_IS_DEVICE_PRESENT IsDevicePresent;
829 PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
830 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
831
832 typedef struct _DEVICE_CAPABILITIES {
833 USHORT Size;
834 USHORT Version;
835 ULONG DeviceD1 : 1;
836 ULONG DeviceD2 : 1;
837 ULONG LockSupported : 1;
838 ULONG EjectSupported : 1;
839 ULONG Removable : 1;
840 ULONG DockDevice : 1;
841 ULONG UniqueID : 1;
842 ULONG SilentInstall : 1;
843 ULONG RawDeviceOK : 1;
844 ULONG SurpriseRemovalOK : 1;
845 ULONG WakeFromD0 : 1;
846 ULONG WakeFromD1 : 1;
847 ULONG WakeFromD2 : 1;
848 ULONG WakeFromD3 : 1;
849 ULONG HardwareDisabled : 1;
850 ULONG NonDynamic : 1;
851 ULONG WarmEjectSupported : 1;
852 ULONG NoDisplayInUI : 1;
853 ULONG Reserved : 14;
854 ULONG Address;
855 ULONG UINumber;
856 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
857 SYSTEM_POWER_STATE SystemWake;
858 DEVICE_POWER_STATE DeviceWake;
859 ULONG D1Latency;
860 ULONG D2Latency;
861 ULONG D3Latency;
862 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
863
864 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
865 USHORT Version;
866 USHORT Size;
867 GUID Event;
868 GUID InterfaceClassGuid;
869 PUNICODE_STRING SymbolicLinkName;
870 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
871
872 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
873 USHORT Version;
874 USHORT Size;
875 GUID Event;
876 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
877
878 #undef INTERFACE
879
880 typedef struct _INTERFACE {
881 USHORT Size;
882 USHORT Version;
883 PVOID Context;
884 PINTERFACE_REFERENCE InterfaceReference;
885 PINTERFACE_DEREFERENCE InterfaceDereference;
886 } INTERFACE, *PINTERFACE;
887
888 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
889 USHORT Version;
890 USHORT Size;
891 GUID Event;
892 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
893
894 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
895
896 /* PNP_DEVICE_STATE */
897
898 #define PNP_DEVICE_DISABLED 0x00000001
899 #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
900 #define PNP_DEVICE_FAILED 0x00000004
901 #define PNP_DEVICE_REMOVED 0x00000008
902 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
903 #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
904
905 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
906 USHORT Version;
907 USHORT Size;
908 GUID Event;
909 struct _FILE_OBJECT *FileObject;
910 LONG NameBufferOffset;
911 UCHAR CustomDataBuffer[1];
912 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
913
914 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
915 USHORT Version;
916 USHORT Size;
917 GUID Event;
918 struct _FILE_OBJECT *FileObject;
919 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
920
921 typedef enum _BUS_QUERY_ID_TYPE {
922 BusQueryDeviceID,
923 BusQueryHardwareIDs,
924 BusQueryCompatibleIDs,
925 BusQueryInstanceID,
926 BusQueryDeviceSerialNumber
927 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
928
929 typedef enum _DEVICE_TEXT_TYPE {
930 DeviceTextDescription,
931 DeviceTextLocationInformation
932 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
933
934 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
935 DeviceUsageTypeUndefined,
936 DeviceUsageTypePaging,
937 DeviceUsageTypeHibernation,
938 DeviceUsageTypeDumpFile
939 } DEVICE_USAGE_NOTIFICATION_TYPE;
940
941 typedef struct _POWER_SEQUENCE {
942 ULONG SequenceD1;
943 ULONG SequenceD2;
944 ULONG SequenceD3;
945 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
946
947 typedef enum {
948 DevicePropertyDeviceDescription,
949 DevicePropertyHardwareID,
950 DevicePropertyCompatibleIDs,
951 DevicePropertyBootConfiguration,
952 DevicePropertyBootConfigurationTranslated,
953 DevicePropertyClassName,
954 DevicePropertyClassGuid,
955 DevicePropertyDriverKeyName,
956 DevicePropertyManufacturer,
957 DevicePropertyFriendlyName,
958 DevicePropertyLocationInformation,
959 DevicePropertyPhysicalDeviceObjectName,
960 DevicePropertyBusTypeGuid,
961 DevicePropertyLegacyBusType,
962 DevicePropertyBusNumber,
963 DevicePropertyEnumeratorName,
964 DevicePropertyAddress,
965 DevicePropertyUINumber,
966 DevicePropertyInstallState,
967 DevicePropertyRemovalPolicy
968 } DEVICE_REGISTRY_PROPERTY;
969
970 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
971 EventCategoryReserved,
972 EventCategoryHardwareProfileChange,
973 EventCategoryDeviceInterfaceChange,
974 EventCategoryTargetDeviceChange
975 } IO_NOTIFICATION_EVENT_CATEGORY;
976
977 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
978
979 typedef NTSTATUS
980 (DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
981 IN PVOID NotificationStructure,
982 IN PVOID Context);
983
984 typedef VOID
985 (DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)(
986 IN PVOID Context);
987
988
989 /*
990 ** System structures
991 */
992
993 #define SYMBOLIC_LINK_QUERY 0x0001
994 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
995
996 /* also in winnt,h */
997 #define DUPLICATE_CLOSE_SOURCE 0x00000001
998 #define DUPLICATE_SAME_ACCESS 0x00000002
999 #define DUPLICATE_SAME_ATTRIBUTES 0x00000004
1000 /* end winnt.h */
1001
1002 typedef struct _OBJECT_NAME_INFORMATION {
1003 UNICODE_STRING Name;
1004 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
1005
1006 typedef struct _IO_STATUS_BLOCK {
1007 _ANONYMOUS_UNION union {
1008 NTSTATUS Status;
1009 PVOID Pointer;
1010 } DUMMYUNIONNAME;
1011 ULONG_PTR Information;
1012 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
1013
1014 typedef VOID
1015 (DDKAPI *PIO_APC_ROUTINE)(
1016 IN PVOID ApcContext,
1017 IN PIO_STATUS_BLOCK IoStatusBlock,
1018 IN ULONG Reserved);
1019
1020 typedef VOID
1021 (DDKAPI *PKNORMAL_ROUTINE)(
1022 IN PVOID NormalContext,
1023 IN PVOID SystemArgument1,
1024 IN PVOID SystemArgument2);
1025
1026 typedef VOID
1027 (DDKAPI *PKKERNEL_ROUTINE)(
1028 IN struct _KAPC *Apc,
1029 IN OUT PKNORMAL_ROUTINE *NormalRoutine,
1030 IN OUT PVOID *NormalContext,
1031 IN OUT PVOID *SystemArgument1,
1032 IN OUT PVOID *SystemArgument2);
1033
1034 typedef VOID
1035 (DDKAPI *PKRUNDOWN_ROUTINE)(
1036 IN struct _KAPC *Apc);
1037
1038 typedef BOOLEAN
1039 (DDKAPI *PKTRANSFER_ROUTINE)(
1040 VOID);
1041
1042 typedef struct _KAPC
1043 {
1044 UCHAR Type;
1045 UCHAR SpareByte0;
1046 UCHAR Size;
1047 UCHAR SpareByte1;
1048 ULONG SpareLong0;
1049 struct _KTHREAD *Thread;
1050 LIST_ENTRY ApcListEntry;
1051 PKKERNEL_ROUTINE KernelRoutine;
1052 PKRUNDOWN_ROUTINE RundownRoutine;
1053 PKNORMAL_ROUTINE NormalRoutine;
1054 PVOID NormalContext;
1055 PVOID SystemArgument1;
1056 PVOID SystemArgument2;
1057 CCHAR ApcStateIndex;
1058 KPROCESSOR_MODE ApcMode;
1059 BOOLEAN Inserted;
1060 } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC;
1061
1062 typedef struct _KDEVICE_QUEUE {
1063 CSHORT Type;
1064 CSHORT Size;
1065 LIST_ENTRY DeviceListHead;
1066 KSPIN_LOCK Lock;
1067 BOOLEAN Busy;
1068 } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE;
1069
1070 typedef struct _KDEVICE_QUEUE_ENTRY {
1071 LIST_ENTRY DeviceListEntry;
1072 ULONG SortKey;
1073 BOOLEAN Inserted;
1074 } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY,
1075 *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY;
1076
1077 #define LOCK_QUEUE_WAIT 1
1078 #define LOCK_QUEUE_OWNER 2
1079 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4
1080 #define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT))
1081
1082 typedef enum _KSPIN_LOCK_QUEUE_NUMBER
1083 {
1084 LockQueueDispatcherLock,
1085 LockQueueExpansionLock,
1086 LockQueuePfnLock,
1087 LockQueueSystemSpaceLock,
1088 LockQueueVacbLock,
1089 LockQueueMasterLock,
1090 LockQueueNonPagedPoolLock,
1091 LockQueueIoCancelLock,
1092 LockQueueWorkQueueLock,
1093 LockQueueIoVpbLock,
1094 LockQueueIoDatabaseLock,
1095 LockQueueIoCompletionLock,
1096 LockQueueNtfsStructLock,
1097 LockQueueAfdWorkQueueLock,
1098 LockQueueBcbLock,
1099 LockQueueMmNonPagedPoolLock,
1100 LockQueueUnusedSpare16,
1101 LockQueueTimerTableLock,
1102 LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS
1103 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
1104
1105 typedef struct _KSPIN_LOCK_QUEUE {
1106 struct _KSPIN_LOCK_QUEUE *volatile Next;
1107 PKSPIN_LOCK volatile Lock;
1108 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
1109
1110 typedef struct _KLOCK_QUEUE_HANDLE {
1111 KSPIN_LOCK_QUEUE LockQueue;
1112 KIRQL OldIrql;
1113 } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
1114
1115 #define DPC_NORMAL 0
1116 #define DPC_THREADED 1
1117
1118 #define ASSERT_APC(Object) \
1119 ASSERT((Object)->Type == ApcObject)
1120
1121 #define ASSERT_DPC(Object) \
1122 ASSERT(((Object)->Type == 0) || \
1123 ((Object)->Type == DpcObject) || \
1124 ((Object)->Type == ThreadedDpcObject))
1125
1126 #define ASSERT_DEVICE_QUEUE(Object) \
1127 ASSERT((Object)->Type == DeviceQueueObject)
1128
1129 typedef struct _KDPC
1130 {
1131 UCHAR Type;
1132 UCHAR Importance;
1133 USHORT Number;
1134 LIST_ENTRY DpcListEntry;
1135 PKDEFERRED_ROUTINE DeferredRoutine;
1136 PVOID DeferredContext;
1137 PVOID SystemArgument1;
1138 PVOID SystemArgument2;
1139 volatile PVOID DpcData;
1140 } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
1141
1142 typedef PVOID PKIPI_CONTEXT;
1143
1144 typedef
1145 VOID
1146 (NTAPI *PKIPI_WORKER)(
1147 IN PKIPI_CONTEXT PacketContext,
1148 IN PVOID Parameter1,
1149 IN PVOID Parameter2,
1150 IN PVOID Parameter3
1151 );
1152
1153 typedef struct _WAIT_CONTEXT_BLOCK {
1154 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
1155 PDRIVER_CONTROL DeviceRoutine;
1156 PVOID DeviceContext;
1157 ULONG NumberOfMapRegisters;
1158 PVOID DeviceObject;
1159 PVOID CurrentIrp;
1160 PKDPC BufferChainingDpc;
1161 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
1162
1163 #define ASSERT_GATE(object) \
1164 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \
1165 (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject))
1166
1167 typedef struct _KGATE
1168 {
1169 DISPATCHER_HEADER Header;
1170 } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE;
1171
1172 #define GM_LOCK_BIT 0x1
1173 #define GM_LOCK_BIT_V 0x0
1174 #define GM_LOCK_WAITER_WOKEN 0x2
1175 #define GM_LOCK_WAITER_INC 0x4
1176
1177 typedef struct _KGUARDED_MUTEX
1178 {
1179 volatile LONG Count;
1180 PKTHREAD Owner;
1181 ULONG Contention;
1182 KGATE Gate;
1183 __GNU_EXTENSION union
1184 {
1185 __GNU_EXTENSION struct
1186 {
1187 SHORT KernelApcDisable;
1188 SHORT SpecialApcDisable;
1189 };
1190 ULONG CombinedApcDisable;
1191 };
1192 } KGUARDED_MUTEX, *PKGUARDED_MUTEX;
1193
1194 #define TIMER_TABLE_SIZE 512
1195 #define TIMER_TABLE_SHIFT 9
1196
1197 typedef struct _KTIMER {
1198 DISPATCHER_HEADER Header;
1199 ULARGE_INTEGER DueTime;
1200 LIST_ENTRY TimerListEntry;
1201 struct _KDPC *Dpc;
1202 LONG Period;
1203 } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
1204
1205 #define ASSERT_TIMER(E) \
1206 ASSERT(((E)->Header.Type == TimerNotificationObject) || \
1207 ((E)->Header.Type == TimerSynchronizationObject))
1208
1209 #define ASSERT_MUTANT(E) \
1210 ASSERT((E)->Header.Type == MutantObject)
1211
1212 #define ASSERT_SEMAPHORE(E) \
1213 ASSERT((E)->Header.Type == SemaphoreObject)
1214
1215 #define ASSERT_EVENT(E) \
1216 ASSERT(((E)->Header.Type == NotificationEvent) || \
1217 ((E)->Header.Type == SynchronizationEvent))
1218
1219 typedef struct _KMUTANT {
1220 DISPATCHER_HEADER Header;
1221 LIST_ENTRY MutantListEntry;
1222 struct _KTHREAD *RESTRICTED_POINTER OwnerThread;
1223 BOOLEAN Abandoned;
1224 UCHAR ApcDisable;
1225 } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX;
1226
1227 typedef enum _TIMER_TYPE {
1228 NotificationTimer,
1229 SynchronizationTimer
1230 } TIMER_TYPE;
1231
1232 #define EVENT_INCREMENT 1
1233 #define IO_NO_INCREMENT 0
1234 #define IO_CD_ROM_INCREMENT 1
1235 #define IO_DISK_INCREMENT 1
1236 #define IO_KEYBOARD_INCREMENT 6
1237 #define IO_MAILSLOT_INCREMENT 2
1238 #define IO_MOUSE_INCREMENT 6
1239 #define IO_NAMED_PIPE_INCREMENT 2
1240 #define IO_NETWORK_INCREMENT 2
1241 #define IO_PARALLEL_INCREMENT 1
1242 #define IO_SERIAL_INCREMENT 2
1243 #define IO_SOUND_INCREMENT 8
1244 #define IO_VIDEO_INCREMENT 1
1245 #define SEMAPHORE_INCREMENT 1
1246
1247 #define MM_MAXIMUM_DISK_IO_SIZE (0x10000)
1248
1249 typedef struct _IRP {
1250 CSHORT Type;
1251 USHORT Size;
1252 struct _MDL *MdlAddress;
1253 ULONG Flags;
1254 union {
1255 struct _IRP *MasterIrp;
1256 volatile LONG IrpCount;
1257 PVOID SystemBuffer;
1258 } AssociatedIrp;
1259 LIST_ENTRY ThreadListEntry;
1260 IO_STATUS_BLOCK IoStatus;
1261 KPROCESSOR_MODE RequestorMode;
1262 BOOLEAN PendingReturned;
1263 CHAR StackCount;
1264 CHAR CurrentLocation;
1265 BOOLEAN Cancel;
1266 KIRQL CancelIrql;
1267 CCHAR ApcEnvironment;
1268 UCHAR AllocationFlags;
1269 PIO_STATUS_BLOCK UserIosb;
1270 PKEVENT UserEvent;
1271 union {
1272 struct {
1273 PIO_APC_ROUTINE UserApcRoutine;
1274 PVOID UserApcContext;
1275 } AsynchronousParameters;
1276 LARGE_INTEGER AllocationSize;
1277 } Overlay;
1278 volatile PDRIVER_CANCEL CancelRoutine;
1279 PVOID UserBuffer;
1280 union {
1281 struct {
1282 _ANONYMOUS_UNION union {
1283 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
1284 _ANONYMOUS_STRUCT struct {
1285 PVOID DriverContext[4];
1286 } DUMMYSTRUCTNAME;
1287 } DUMMYUNIONNAME;
1288 PETHREAD Thread;
1289 PCHAR AuxiliaryBuffer;
1290 _ANONYMOUS_STRUCT struct {
1291 LIST_ENTRY ListEntry;
1292 _ANONYMOUS_UNION union {
1293 struct _IO_STACK_LOCATION *CurrentStackLocation;
1294 ULONG PacketType;
1295 } DUMMYUNIONNAME;
1296 } DUMMYSTRUCTNAME;
1297 struct _FILE_OBJECT *OriginalFileObject;
1298 } Overlay;
1299 KAPC Apc;
1300 PVOID CompletionKey;
1301 } Tail;
1302 } IRP;
1303 typedef struct _IRP *PIRP;
1304
1305 /* IRP.Flags */
1306
1307 #define SL_FORCE_ACCESS_CHECK 0x01
1308 #define SL_OPEN_PAGING_FILE 0x02
1309 #define SL_OPEN_TARGET_DIRECTORY 0x04
1310 #define SL_CASE_SENSITIVE 0x80
1311
1312 #define SL_KEY_SPECIFIED 0x01
1313 #define SL_OVERRIDE_VERIFY_VOLUME 0x02
1314 #define SL_WRITE_THROUGH 0x04
1315 #define SL_FT_SEQUENTIAL_WRITE 0x08
1316
1317 #define SL_FAIL_IMMEDIATELY 0x01
1318 #define SL_EXCLUSIVE_LOCK 0x02
1319
1320 #define SL_RESTART_SCAN 0x01
1321 #define SL_RETURN_SINGLE_ENTRY 0x02
1322 #define SL_INDEX_SPECIFIED 0x04
1323
1324 #define SL_WATCH_TREE 0x01
1325
1326 #define SL_ALLOW_RAW_MOUNT 0x01
1327
1328 #define CTL_CODE(DeviceType, Function, Method, Access)( \
1329 ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1330
1331 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
1332
1333 enum
1334 {
1335 IRP_NOCACHE = 0x1,
1336 IRP_PAGING_IO = 0x2,
1337 IRP_MOUNT_COMPLETION = 0x2,
1338 IRP_SYNCHRONOUS_API = 0x4,
1339 IRP_ASSOCIATED_IRP = 0x8,
1340 IRP_BUFFERED_IO = 0x10,
1341 IRP_DEALLOCATE_BUFFER = 0x20,
1342 IRP_INPUT_OPERATION = 0x40,
1343 IRP_SYNCHRONOUS_PAGING_IO = 0x40,
1344 IRP_CREATE_OPERATION = 0x80,
1345 IRP_READ_OPERATION = 0x100,
1346 IRP_WRITE_OPERATION = 0x200,
1347 IRP_CLOSE_OPERATION = 0x400,
1348 IRP_DEFER_IO_COMPLETION = 0x800,
1349 IRP_OB_QUERY_NAME = 0x1000,
1350 IRP_HOLD_DEVICE_QUEUE = 0x2000,
1351 IRP_RETRY_IO_COMPLETION = 0x4000
1352 };
1353
1354 #define IRP_QUOTA_CHARGED 0x01
1355 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
1356 #define IRP_ALLOCATED_FIXED_SIZE 0x04
1357 #define IRP_LOOKASIDE_ALLOCATION 0x08
1358
1359 typedef struct _BOOTDISK_INFORMATION {
1360 LONGLONG BootPartitionOffset;
1361 LONGLONG SystemPartitionOffset;
1362 ULONG BootDeviceSignature;
1363 ULONG SystemDeviceSignature;
1364 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
1365
1366 typedef struct _BOOTDISK_INFORMATION_EX {
1367 LONGLONG BootPartitionOffset;
1368 LONGLONG SystemPartitionOffset;
1369 ULONG BootDeviceSignature;
1370 ULONG SystemDeviceSignature;
1371 GUID BootDeviceGuid;
1372 GUID SystemDeviceGuid;
1373 BOOLEAN BootDeviceIsGpt;
1374 BOOLEAN SystemDeviceIsGpt;
1375 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
1376
1377 typedef struct _EISA_MEMORY_TYPE {
1378 UCHAR ReadWrite : 1;
1379 UCHAR Cached : 1;
1380 UCHAR Reserved0 : 1;
1381 UCHAR Type : 2;
1382 UCHAR Shared : 1;
1383 UCHAR Reserved1 : 1;
1384 UCHAR MoreEntries : 1;
1385 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
1386
1387 #include <pshpack1.h>
1388 typedef struct _EISA_MEMORY_CONFIGURATION {
1389 EISA_MEMORY_TYPE ConfigurationByte;
1390 UCHAR DataSize;
1391 USHORT AddressLowWord;
1392 UCHAR AddressHighByte;
1393 USHORT MemorySize;
1394 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
1395 #include <poppack.h>
1396
1397 typedef struct _EISA_IRQ_DESCRIPTOR {
1398 UCHAR Interrupt : 4;
1399 UCHAR Reserved : 1;
1400 UCHAR LevelTriggered : 1;
1401 UCHAR Shared : 1;
1402 UCHAR MoreEntries : 1;
1403 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
1404
1405 typedef struct _EISA_IRQ_CONFIGURATION {
1406 EISA_IRQ_DESCRIPTOR ConfigurationByte;
1407 UCHAR Reserved;
1408 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
1409
1410 typedef struct _DMA_CONFIGURATION_BYTE0 {
1411 UCHAR Channel : 3;
1412 UCHAR Reserved : 3;
1413 UCHAR Shared : 1;
1414 UCHAR MoreEntries : 1;
1415 } DMA_CONFIGURATION_BYTE0;
1416
1417 typedef struct _DMA_CONFIGURATION_BYTE1 {
1418 UCHAR Reserved0 : 2;
1419 UCHAR TransferSize : 2;
1420 UCHAR Timing : 2;
1421 UCHAR Reserved1 : 2;
1422 } DMA_CONFIGURATION_BYTE1;
1423
1424 typedef struct _EISA_DMA_CONFIGURATION {
1425 DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
1426 DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
1427 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
1428
1429 #include <pshpack1.h>
1430 typedef struct _EISA_PORT_DESCRIPTOR {
1431 UCHAR NumberPorts : 5;
1432 UCHAR Reserved : 1;
1433 UCHAR Shared : 1;
1434 UCHAR MoreEntries : 1;
1435 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
1436
1437 typedef struct _EISA_PORT_CONFIGURATION {
1438 EISA_PORT_DESCRIPTOR Configuration;
1439 USHORT PortAddress;
1440 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
1441 #include <poppack.h>
1442
1443 typedef struct _CM_EISA_FUNCTION_INFORMATION {
1444 ULONG CompressedId;
1445 UCHAR IdSlotFlags1;
1446 UCHAR IdSlotFlags2;
1447 UCHAR MinorRevision;
1448 UCHAR MajorRevision;
1449 UCHAR Selections[26];
1450 UCHAR FunctionFlags;
1451 UCHAR TypeString[80];
1452 EISA_MEMORY_CONFIGURATION EisaMemory[9];
1453 EISA_IRQ_CONFIGURATION EisaIrq[7];
1454 EISA_DMA_CONFIGURATION EisaDma[4];
1455 EISA_PORT_CONFIGURATION EisaPort[20];
1456 UCHAR InitializationData[60];
1457 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
1458
1459 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
1460
1461 #define EISA_FUNCTION_ENABLED 0x80
1462 #define EISA_FREE_FORM_DATA 0x40
1463 #define EISA_HAS_PORT_INIT_ENTRY 0x20
1464 #define EISA_HAS_PORT_RANGE 0x10
1465 #define EISA_HAS_DMA_ENTRY 0x08
1466 #define EISA_HAS_IRQ_ENTRY 0x04
1467 #define EISA_HAS_MEMORY_ENTRY 0x02
1468 #define EISA_HAS_TYPE_ENTRY 0x01
1469 #define EISA_HAS_INFORMATION \
1470 (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
1471 + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
1472
1473 typedef struct _CM_EISA_SLOT_INFORMATION {
1474 UCHAR ReturnCode;
1475 UCHAR ReturnFlags;
1476 UCHAR MajorRevision;
1477 UCHAR MinorRevision;
1478 USHORT Checksum;
1479 UCHAR NumberFunctions;
1480 UCHAR FunctionInformation;
1481 ULONG CompressedId;
1482 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
1483
1484 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
1485
1486 #define EISA_INVALID_SLOT 0x80
1487 #define EISA_INVALID_FUNCTION 0x81
1488 #define EISA_INVALID_CONFIGURATION 0x82
1489 #define EISA_EMPTY_SLOT 0x83
1490 #define EISA_INVALID_BIOS_CALL 0x86
1491
1492 typedef struct _CM_FLOPPY_DEVICE_DATA {
1493 USHORT Version;
1494 USHORT Revision;
1495 CHAR Size[8];
1496 ULONG MaxDensity;
1497 ULONG MountDensity;
1498 UCHAR StepRateHeadUnloadTime;
1499 UCHAR HeadLoadTime;
1500 UCHAR MotorOffTime;
1501 UCHAR SectorLengthCode;
1502 UCHAR SectorPerTrack;
1503 UCHAR ReadWriteGapLength;
1504 UCHAR DataTransferLength;
1505 UCHAR FormatGapLength;
1506 UCHAR FormatFillCharacter;
1507 UCHAR HeadSettleTime;
1508 UCHAR MotorSettleTime;
1509 UCHAR MaximumTrackValue;
1510 UCHAR DataTransferRate;
1511 } CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA;
1512
1513 typedef struct _PNP_BUS_INFORMATION {
1514 GUID BusTypeGuid;
1515 INTERFACE_TYPE LegacyBusType;
1516 ULONG BusNumber;
1517 } PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION;
1518
1519 #include <pshpack1.h>
1520 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */
1521
1522 #define CmResourceTypeNull 0
1523 #define CmResourceTypePort 1
1524 #define CmResourceTypeInterrupt 2
1525 #define CmResourceTypeMemory 3
1526 #define CmResourceTypeDma 4
1527 #define CmResourceTypeDeviceSpecific 5
1528 #define CmResourceTypeBusNumber 6
1529 #define CmResourceTypeMaximum 7
1530 #define CmResourceTypeNonArbitrated 128
1531 #define CmResourceTypeConfigData 128
1532 #define CmResourceTypeDevicePrivate 129
1533 #define CmResourceTypePcCardConfig 130
1534 #define CmResourceTypeMfCardConfig 131
1535
1536 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */
1537
1538 typedef enum _CM_SHARE_DISPOSITION {
1539 CmResourceShareUndetermined,
1540 CmResourceShareDeviceExclusive,
1541 CmResourceShareDriverExclusive,
1542 CmResourceShareShared
1543 } CM_SHARE_DISPOSITION;
1544
1545 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */
1546
1547 #define CM_RESOURCE_PORT_MEMORY 0x0000
1548 #define CM_RESOURCE_PORT_IO 0x0001
1549 #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
1550 #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
1551 #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
1552 #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
1553 #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
1554 #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
1555
1556 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */
1557
1558 #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
1559 #define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
1560
1561 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */
1562
1563 #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
1564 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
1565 #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
1566 #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
1567 #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
1568 #define CM_RESOURCE_MEMORY_24 0x0010
1569 #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
1570
1571 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */
1572
1573 #define CM_RESOURCE_DMA_8 0x0000
1574 #define CM_RESOURCE_DMA_16 0x0001
1575 #define CM_RESOURCE_DMA_32 0x0002
1576 #define CM_RESOURCE_DMA_8_AND_16 0x0004
1577 #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
1578 #define CM_RESOURCE_DMA_TYPE_A 0x0010
1579 #define CM_RESOURCE_DMA_TYPE_B 0x0020
1580 #define CM_RESOURCE_DMA_TYPE_F 0x0040
1581
1582 typedef struct _CM_PARTIAL_RESOURCE_LIST {
1583 USHORT Version;
1584 USHORT Revision;
1585 ULONG Count;
1586 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
1587 } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
1588
1589 typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
1590 INTERFACE_TYPE InterfaceType;
1591 ULONG BusNumber;
1592 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
1593 } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
1594
1595 typedef struct _CM_RESOURCE_LIST {
1596 ULONG Count;
1597 CM_FULL_RESOURCE_DESCRIPTOR List[1];
1598 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
1599
1600 typedef struct _CM_INT13_DRIVE_PARAMETER {
1601 USHORT DriveSelect;
1602 ULONG MaxCylinders;
1603 USHORT SectorsPerTrack;
1604 USHORT MaxHeads;
1605 USHORT NumberDrives;
1606 } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER;
1607
1608 typedef struct _CM_PNP_BIOS_DEVICE_NODE
1609 {
1610 USHORT Size;
1611 UCHAR Node;
1612 ULONG ProductId;
1613 UCHAR DeviceType[3];
1614 USHORT DeviceAttributes;
1615 } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
1616
1617 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK
1618 {
1619 UCHAR Signature[4];
1620 UCHAR Revision;
1621 UCHAR Length;
1622 USHORT ControlField;
1623 UCHAR Checksum;
1624 ULONG EventFlagAddress;
1625 USHORT RealModeEntryOffset;
1626 USHORT RealModeEntrySegment;
1627 USHORT ProtectedModeEntryOffset;
1628 ULONG ProtectedModeCodeBaseAddress;
1629 ULONG OemDeviceId;
1630 USHORT RealModeDataBaseAddress;
1631 ULONG ProtectedModeDataBaseAddress;
1632 } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
1633
1634 #include <poppack.h>
1635
1636
1637 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA
1638 {
1639 ULONG BytesPerSector;
1640 ULONG NumberOfCylinders;
1641 ULONG SectorsPerTrack;
1642 ULONG NumberOfHeads;
1643 } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA;
1644
1645 typedef struct _CM_KEYBOARD_DEVICE_DATA {
1646 USHORT Version;
1647 USHORT Revision;
1648 UCHAR Type;
1649 UCHAR Subtype;
1650 USHORT KeyboardFlags;
1651 } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA;
1652
1653 #define KEYBOARD_INSERT_ON 0x08
1654 #define KEYBOARD_CAPS_LOCK_ON 0x04
1655 #define KEYBOARD_NUM_LOCK_ON 0x02
1656 #define KEYBOARD_SCROLL_LOCK_ON 0x01
1657 #define KEYBOARD_ALT_KEY_DOWN 0x80
1658 #define KEYBOARD_CTRL_KEY_DOWN 0x40
1659 #define KEYBOARD_LEFT_SHIFT_DOWN 0x20
1660 #define KEYBOARD_RIGHT_SHIFT_DOWN 0x10
1661
1662 typedef struct _CM_MCA_POS_DATA {
1663 USHORT AdapterId;
1664 UCHAR PosData1;
1665 UCHAR PosData2;
1666 UCHAR PosData3;
1667 UCHAR PosData4;
1668 } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
1669
1670 typedef struct CM_Power_Data_s {
1671 ULONG PD_Size;
1672 DEVICE_POWER_STATE PD_MostRecentPowerState;
1673 ULONG PD_Capabilities;
1674 ULONG PD_D1Latency;
1675 ULONG PD_D2Latency;
1676 ULONG PD_D3Latency;
1677 DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
1678 } CM_POWER_DATA, *PCM_POWER_DATA;
1679
1680 #define PDCAP_D0_SUPPORTED 0x00000001
1681 #define PDCAP_D1_SUPPORTED 0x00000002
1682 #define PDCAP_D2_SUPPORTED 0x00000004
1683 #define PDCAP_D3_SUPPORTED 0x00000008
1684 #define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
1685 #define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
1686 #define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
1687 #define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
1688 #define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
1689
1690 typedef struct _CM_SCSI_DEVICE_DATA {
1691 USHORT Version;
1692 USHORT Revision;
1693 UCHAR HostIdentifier;
1694 } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA;
1695
1696 typedef struct _CM_SERIAL_DEVICE_DATA {
1697 USHORT Version;
1698 USHORT Revision;
1699 ULONG BaudClock;
1700 } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA;
1701
1702 typedef struct _IO_COUNTERS {
1703 ULONGLONG ReadOperationCount;
1704 ULONGLONG WriteOperationCount;
1705 ULONGLONG OtherOperationCount;
1706 ULONGLONG ReadTransferCount;
1707 ULONGLONG WriteTransferCount;
1708 ULONGLONG OtherTransferCount;
1709 } IO_COUNTERS, *PIO_COUNTERS;
1710
1711 typedef struct _VM_COUNTERS
1712 {
1713 SIZE_T PeakVirtualSize;
1714 SIZE_T VirtualSize;
1715 ULONG PageFaultCount;
1716 SIZE_T PeakWorkingSetSize;
1717 SIZE_T WorkingSetSize;
1718 SIZE_T QuotaPeakPagedPoolUsage;
1719 SIZE_T QuotaPagedPoolUsage;
1720 SIZE_T QuotaPeakNonPagedPoolUsage;
1721 SIZE_T QuotaNonPagedPoolUsage;
1722 SIZE_T PagefileUsage;
1723 SIZE_T PeakPagefileUsage;
1724 } VM_COUNTERS, *PVM_COUNTERS;
1725
1726 typedef struct _VM_COUNTERS_EX
1727 {
1728 SIZE_T PeakVirtualSize;
1729 SIZE_T VirtualSize;
1730 ULONG PageFaultCount;
1731 SIZE_T PeakWorkingSetSize;
1732 SIZE_T WorkingSetSize;
1733 SIZE_T QuotaPeakPagedPoolUsage;
1734 SIZE_T QuotaPagedPoolUsage;
1735 SIZE_T QuotaPeakNonPagedPoolUsage;
1736 SIZE_T QuotaNonPagedPoolUsage;
1737 SIZE_T PagefileUsage;
1738 SIZE_T PeakPagefileUsage;
1739 SIZE_T PrivateUsage;
1740 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
1741
1742 typedef struct _POOLED_USAGE_AND_LIMITS
1743 {
1744 SIZE_T PeakPagedPoolUsage;
1745 SIZE_T PagedPoolUsage;
1746 SIZE_T PagedPoolLimit;
1747 SIZE_T PeakNonPagedPoolUsage;
1748 SIZE_T NonPagedPoolUsage;
1749 SIZE_T NonPagedPoolLimit;
1750 SIZE_T PeakPagefileUsage;
1751 SIZE_T PagefileUsage;
1752 SIZE_T PagefileLimit;
1753 } POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
1754
1755 typedef enum _KINTERRUPT_POLARITY
1756 {
1757 InterruptPolarityUnknown,
1758 InterruptActiveHigh,
1759 InterruptActiveLow
1760 } KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY;
1761
1762 typedef struct _IO_ERROR_LOG_PACKET {
1763 UCHAR MajorFunctionCode;
1764 UCHAR RetryCount;
1765 USHORT DumpDataSize;
1766 USHORT NumberOfStrings;
1767 USHORT StringOffset;
1768 USHORT EventCategory;
1769 NTSTATUS ErrorCode;
1770 ULONG UniqueErrorValue;
1771 NTSTATUS FinalStatus;
1772 ULONG SequenceNumber;
1773 ULONG IoControlCode;
1774 LARGE_INTEGER DeviceOffset;
1775 ULONG DumpData[1];
1776 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
1777
1778 typedef struct _IO_ERROR_LOG_MESSAGE {
1779 USHORT Type;
1780 USHORT Size;
1781 USHORT DriverNameLength;
1782 LARGE_INTEGER TimeStamp;
1783 ULONG DriverNameOffset;
1784 IO_ERROR_LOG_PACKET EntryData;
1785 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
1786
1787 #define ERROR_LOG_LIMIT_SIZE 240
1788 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
1789 sizeof(IO_ERROR_LOG_PACKET) + \
1790 (sizeof(WCHAR) * 40))
1791 #define ERROR_LOG_MESSAGE_LIMIT_SIZE \
1792 (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
1793 #define IO_ERROR_LOG_MESSAGE_LENGTH \
1794 ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ? \
1795 ERROR_LOG_MESSAGE_LIMIT_SIZE : \
1796 PORT_MAXIMUM_MESSAGE_LENGTH)
1797 #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \
1798 IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
1799
1800 typedef struct _CONTROLLER_OBJECT {
1801 CSHORT Type;
1802 CSHORT Size;
1803 PVOID ControllerExtension;
1804 KDEVICE_QUEUE DeviceWaitQueue;
1805 ULONG Spare1;
1806 LARGE_INTEGER Spare2;
1807 } CONTROLLER_OBJECT, *PCONTROLLER_OBJECT;
1808
1809 typedef enum _DMA_WIDTH {
1810 Width8Bits,
1811 Width16Bits,
1812 Width32Bits,
1813 MaximumDmaWidth
1814 } DMA_WIDTH, *PDMA_WIDTH;
1815
1816 typedef enum _DMA_SPEED {
1817 Compatible,
1818 TypeA,
1819 TypeB,
1820 TypeC,
1821 TypeF,
1822 MaximumDmaSpeed
1823 } DMA_SPEED, *PDMA_SPEED;
1824
1825 /* DEVICE_DESCRIPTION.Version */
1826
1827 #define DEVICE_DESCRIPTION_VERSION 0x0000
1828 #define DEVICE_DESCRIPTION_VERSION1 0x0001
1829 #define DEVICE_DESCRIPTION_VERSION2 0x0002
1830
1831 typedef struct _DEVICE_DESCRIPTION {
1832 ULONG Version;
1833 BOOLEAN Master;
1834 BOOLEAN ScatterGather;
1835 BOOLEAN DemandMode;
1836 BOOLEAN AutoInitialize;
1837 BOOLEAN Dma32BitAddresses;
1838 BOOLEAN IgnoreCount;
1839 BOOLEAN Reserved1;
1840 BOOLEAN Dma64BitAddresses;
1841 ULONG BusNumber;
1842 ULONG DmaChannel;
1843 INTERFACE_TYPE InterfaceType;
1844 DMA_WIDTH DmaWidth;
1845 DMA_SPEED DmaSpeed;
1846 ULONG MaximumLength;
1847 ULONG DmaPort;
1848 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
1849
1850 /* VPB.Flags */
1851 #define VPB_MOUNTED 0x0001
1852 #define VPB_LOCKED 0x0002
1853 #define VPB_PERSISTENT 0x0004
1854 #define VPB_REMOVE_PENDING 0x0008
1855 #define VPB_RAW_MOUNT 0x0010
1856
1857 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
1858
1859 typedef struct _VPB {
1860 CSHORT Type;
1861 CSHORT Size;
1862 USHORT Flags;
1863 USHORT VolumeLabelLength;
1864 struct _DEVICE_OBJECT *DeviceObject;
1865 struct _DEVICE_OBJECT *RealDevice;
1866 ULONG SerialNumber;
1867 ULONG ReferenceCount;
1868 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
1869 } VPB, *PVPB;
1870
1871 /* DEVICE_OBJECT.Flags */
1872
1873 #define DO_VERIFY_VOLUME 0x00000002
1874 #define DO_BUFFERED_IO 0x00000004
1875 #define DO_EXCLUSIVE 0x00000008
1876 #define DO_DIRECT_IO 0x00000010
1877 #define DO_MAP_IO_BUFFER 0x00000020
1878 #define DO_DEVICE_HAS_NAME 0x00000040
1879 #define DO_DEVICE_INITIALIZING 0x00000080
1880 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
1881 #define DO_LONG_TERM_REQUESTS 0x00000200
1882 #define DO_NEVER_LAST_DEVICE 0x00000400
1883 #define DO_SHUTDOWN_REGISTERED 0x00000800
1884 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
1885 #define DO_POWER_PAGABLE 0x00002000
1886 #define DO_POWER_INRUSH 0x00004000
1887 #define DO_LOW_PRIORITY_FILESYSTEM 0x00010000
1888 #define DO_XIP 0x00020000
1889
1890 /* DEVICE_OBJECT.Characteristics */
1891
1892 #define FILE_REMOVABLE_MEDIA 0x00000001
1893 #define FILE_READ_ONLY_DEVICE 0x00000002
1894 #define FILE_FLOPPY_DISKETTE 0x00000004
1895 #define FILE_WRITE_ONCE_MEDIA 0x00000008
1896 #define FILE_REMOTE_DEVICE 0x00000010
1897 #define FILE_DEVICE_IS_MOUNTED 0x00000020
1898 #define FILE_VIRTUAL_VOLUME 0x00000040
1899 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
1900 #define FILE_DEVICE_SECURE_OPEN 0x00000100
1901
1902 /* DEVICE_OBJECT.AlignmentRequirement */
1903
1904 #define FILE_BYTE_ALIGNMENT 0x00000000
1905 #define FILE_WORD_ALIGNMENT 0x00000001
1906 #define FILE_LONG_ALIGNMENT 0x00000003
1907 #define FILE_QUAD_ALIGNMENT 0x00000007
1908 #define FILE_OCTA_ALIGNMENT 0x0000000f
1909 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
1910 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
1911 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
1912 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
1913 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
1914
1915 /* DEVICE_OBJECT.DeviceType */
1916
1917 #define DEVICE_TYPE ULONG
1918
1919 #define FILE_DEVICE_BEEP 0x00000001
1920 #define FILE_DEVICE_CD_ROM 0x00000002
1921 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1922 #define FILE_DEVICE_CONTROLLER 0x00000004
1923 #define FILE_DEVICE_DATALINK 0x00000005
1924 #define FILE_DEVICE_DFS 0x00000006
1925 #define FILE_DEVICE_DISK 0x00000007
1926 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1927 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
1928 #define FILE_DEVICE_INPORT_PORT 0x0000000a
1929 #define FILE_DEVICE_KEYBOARD 0x0000000b
1930 #define FILE_DEVICE_MAILSLOT 0x0000000c
1931 #define FILE_DEVICE_MIDI_IN 0x0000000d
1932 #define FILE_DEVICE_MIDI_OUT 0x0000000e
1933 #define FILE_DEVICE_MOUSE 0x0000000f
1934 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
1935 #define FILE_DEVICE_NAMED_PIPE 0x00000011
1936 #define FILE_DEVICE_NETWORK 0x00000012
1937 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
1938 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1939 #define FILE_DEVICE_NULL 0x00000015
1940 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
1941 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
1942 #define FILE_DEVICE_PRINTER 0x00000018
1943 #define FILE_DEVICE_SCANNER 0x00000019
1944 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
1945 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
1946 #define FILE_DEVICE_SCREEN 0x0000001c
1947 #define FILE_DEVICE_SOUND 0x0000001d
1948 #define FILE_DEVICE_STREAMS 0x0000001e
1949 #define FILE_DEVICE_TAPE 0x0000001f
1950 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1951 #define FILE_DEVICE_TRANSPORT 0x00000021
1952 #define FILE_DEVICE_UNKNOWN 0x00000022
1953 #define FILE_DEVICE_VIDEO 0x00000023
1954 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1955 #define FILE_DEVICE_WAVE_IN 0x00000025
1956 #define FILE_DEVICE_WAVE_OUT 0x00000026
1957 #define FILE_DEVICE_8042_PORT 0x00000027
1958 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1959 #define FILE_DEVICE_BATTERY 0x00000029
1960 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
1961 #define FILE_DEVICE_MODEM 0x0000002b
1962 #define FILE_DEVICE_VDM 0x0000002c
1963 #define FILE_DEVICE_MASS_STORAGE 0x0000002d
1964 #define FILE_DEVICE_SMB 0x0000002e
1965 #define FILE_DEVICE_KS 0x0000002f
1966 #define FILE_DEVICE_CHANGER 0x00000030
1967 #define FILE_DEVICE_SMARTCARD 0x00000031
1968 #define FILE_DEVICE_ACPI 0x00000032
1969 #define FILE_DEVICE_DVD 0x00000033
1970 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
1971 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
1972 #define FILE_DEVICE_DFS_VOLUME 0x00000036
1973 #define FILE_DEVICE_SERENUM 0x00000037
1974 #define FILE_DEVICE_TERMSRV 0x00000038
1975 #define FILE_DEVICE_KSEC 0x00000039
1976 #define FILE_DEVICE_FIPS 0x0000003a
1977
1978 typedef struct _DEVICE_OBJECT {
1979 CSHORT Type;
1980 USHORT Size;
1981 LONG ReferenceCount;
1982 struct _DRIVER_OBJECT *DriverObject;
1983 struct _DEVICE_OBJECT *NextDevice;
1984 struct _DEVICE_OBJECT *AttachedDevice;
1985 struct _IRP *CurrentIrp;
1986 PIO_TIMER Timer;
1987 ULONG Flags;
1988 ULONG Characteristics;
1989 volatile PVPB Vpb;
1990 PVOID DeviceExtension;
1991 DEVICE_TYPE DeviceType;
1992 CCHAR StackSize;
1993 union {
1994 LIST_ENTRY ListEntry;
1995 WAIT_CONTEXT_BLOCK Wcb;
1996 } Queue;
1997 ULONG AlignmentRequirement;
1998 KDEVICE_QUEUE DeviceQueue;
1999 KDPC Dpc;
2000 ULONG ActiveThreadCount;
2001 PSECURITY_DESCRIPTOR SecurityDescriptor;
2002 KEVENT DeviceLock;
2003 USHORT SectorSize;
2004 USHORT Spare1;
2005 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
2006 PVOID Reserved;
2007 } DEVICE_OBJECT, *PDEVICE_OBJECT;
2008
2009 typedef enum _DEVICE_RELATION_TYPE {
2010 BusRelations,
2011 EjectionRelations,
2012 PowerRelations,
2013 RemovalRelations,
2014 TargetDeviceRelation,
2015 SingleBusRelations
2016 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
2017
2018 typedef struct _DEVICE_RELATIONS {
2019 ULONG Count;
2020 PDEVICE_OBJECT Objects[1];
2021 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
2022
2023 typedef struct _SCATTER_GATHER_ELEMENT {
2024 PHYSICAL_ADDRESS Address;
2025 ULONG Length;
2026 ULONG_PTR Reserved;
2027 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
2028
2029 typedef struct _SCATTER_GATHER_LIST {
2030 ULONG NumberOfElements;
2031 ULONG_PTR Reserved;
2032 SCATTER_GATHER_ELEMENT Elements[1];
2033 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2034
2035 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
2036 #define MDL_PAGES_LOCKED 0x0002
2037 #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
2038 #define MDL_ALLOCATED_FIXED_SIZE 0x0008
2039 #define MDL_PARTIAL 0x0010
2040 #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
2041 #define MDL_IO_PAGE_READ 0x0040
2042 #define MDL_WRITE_OPERATION 0x0080
2043 #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
2044 #define MDL_FREE_EXTRA_PTES 0x0200
2045 #define MDL_DESCRIBES_AWE 0x0400
2046 #define MDL_IO_SPACE 0x0800
2047 #define MDL_NETWORK_HEADER 0x1000
2048 #define MDL_MAPPING_CAN_FAIL 0x2000
2049 #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
2050 #define MDL_INTERNAL 0x8000
2051
2052
2053 #define MDL_MAPPING_FLAGS ( \
2054 MDL_MAPPED_TO_SYSTEM_VA | \
2055 MDL_PAGES_LOCKED | \
2056 MDL_SOURCE_IS_NONPAGED_POOL | \
2057 MDL_PARTIAL_HAS_BEEN_MAPPED | \
2058 MDL_PARENT_MAPPED_SYSTEM_VA | \
2059 MDL_SYSTEM_VA | \
2060 MDL_IO_SPACE)
2061
2062 typedef struct _DRIVER_EXTENSION {
2063 struct _DRIVER_OBJECT *DriverObject;
2064 PDRIVER_ADD_DEVICE AddDevice;
2065 ULONG Count;
2066 UNICODE_STRING ServiceKeyName;
2067 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
2068
2069 #define DRVO_UNLOAD_INVOKED 0x00000001
2070 #define DRVO_LEGACY_DRIVER 0x00000002
2071 #define DRVO_BUILTIN_DRIVER 0x00000004
2072 #define DRVO_REINIT_REGISTERED 0x00000008
2073 #define DRVO_INITIALIZED 0x00000010
2074 #define DRVO_BOOTREINIT_REGISTERED 0x00000020
2075 #define DRVO_LEGACY_RESOURCES 0x00000040
2076
2077 typedef struct _DRIVER_OBJECT {
2078 CSHORT Type;
2079 CSHORT Size;
2080 PDEVICE_OBJECT DeviceObject;
2081 ULONG Flags;
2082 PVOID DriverStart;
2083 ULONG DriverSize;
2084 PVOID DriverSection;
2085 PDRIVER_EXTENSION DriverExtension;
2086 UNICODE_STRING DriverName;
2087 PUNICODE_STRING HardwareDatabase;
2088 struct _FAST_IO_DISPATCH *FastIoDispatch;
2089 PDRIVER_INITIALIZE DriverInit;
2090 PDRIVER_STARTIO DriverStartIo;
2091 PDRIVER_UNLOAD DriverUnload;
2092 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
2093 } DRIVER_OBJECT;
2094 typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
2095
2096 typedef struct _DMA_ADAPTER {
2097 USHORT Version;
2098 USHORT Size;
2099 struct _DMA_OPERATIONS* DmaOperations;
2100 } DMA_ADAPTER, *PDMA_ADAPTER;
2101
2102 typedef VOID
2103 (DDKAPI *PPUT_DMA_ADAPTER)(
2104 IN PDMA_ADAPTER DmaAdapter);
2105
2106 typedef PVOID
2107 (DDKAPI *PALLOCATE_COMMON_BUFFER)(
2108 IN PDMA_ADAPTER DmaAdapter,
2109 IN ULONG Length,
2110 OUT PPHYSICAL_ADDRESS LogicalAddress,
2111 IN BOOLEAN CacheEnabled);
2112
2113 typedef VOID
2114 (DDKAPI *PFREE_COMMON_BUFFER)(
2115 IN PDMA_ADAPTER DmaAdapter,
2116 IN ULONG Length,
2117 IN PHYSICAL_ADDRESS LogicalAddress,
2118 IN PVOID VirtualAddress,
2119 IN BOOLEAN CacheEnabled);
2120
2121 typedef NTSTATUS
2122 (DDKAPI *PALLOCATE_ADAPTER_CHANNEL)(
2123 IN PDMA_ADAPTER DmaAdapter,
2124 IN PDEVICE_OBJECT DeviceObject,
2125 IN ULONG NumberOfMapRegisters,
2126 IN PDRIVER_CONTROL ExecutionRoutine,
2127 IN PVOID Context);
2128
2129 typedef BOOLEAN
2130 (DDKAPI *PFLUSH_ADAPTER_BUFFERS)(
2131 IN PDMA_ADAPTER DmaAdapter,
2132 IN PMDL Mdl,
2133 IN PVOID MapRegisterBase,
2134 IN PVOID CurrentVa,
2135 IN ULONG Length,
2136 IN BOOLEAN WriteToDevice);
2137
2138 typedef VOID
2139 (DDKAPI *PFREE_ADAPTER_CHANNEL)(
2140 IN PDMA_ADAPTER DmaAdapter);
2141
2142 typedef VOID
2143 (DDKAPI *PFREE_MAP_REGISTERS)(
2144 IN PDMA_ADAPTER DmaAdapter,
2145 PVOID MapRegisterBase,
2146 ULONG NumberOfMapRegisters);
2147
2148 typedef PHYSICAL_ADDRESS
2149 (DDKAPI *PMAP_TRANSFER)(
2150 IN PDMA_ADAPTER DmaAdapter,
2151 IN PMDL Mdl,
2152 IN PVOID MapRegisterBase,
2153 IN PVOID CurrentVa,
2154 IN OUT PULONG Length,
2155 IN BOOLEAN WriteToDevice);
2156
2157 typedef ULONG
2158 (DDKAPI *PGET_DMA_ALIGNMENT)(
2159 IN PDMA_ADAPTER DmaAdapter);
2160
2161 typedef ULONG
2162 (DDKAPI *PREAD_DMA_COUNTER)(
2163 IN PDMA_ADAPTER DmaAdapter);
2164
2165 typedef NTSTATUS
2166 (DDKAPI *PGET_SCATTER_GATHER_LIST)(
2167 IN PDMA_ADAPTER DmaAdapter,
2168 IN PDEVICE_OBJECT DeviceObject,
2169 IN PMDL Mdl,
2170 IN PVOID CurrentVa,
2171 IN ULONG Length,
2172 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2173 IN PVOID Context,
2174 IN BOOLEAN WriteToDevice);
2175
2176 typedef VOID
2177 (DDKAPI *PPUT_SCATTER_GATHER_LIST)(
2178 IN PDMA_ADAPTER DmaAdapter,
2179 IN PSCATTER_GATHER_LIST ScatterGather,
2180 IN BOOLEAN WriteToDevice);
2181
2182 typedef NTSTATUS
2183 (DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
2184 IN PDMA_ADAPTER DmaAdapter,
2185 IN PMDL Mdl OPTIONAL,
2186 IN PVOID CurrentVa,
2187 IN ULONG Length,
2188 OUT PULONG ScatterGatherListSize,
2189 OUT PULONG pNumberOfMapRegisters OPTIONAL);
2190
2191 typedef NTSTATUS
2192 (DDKAPI *PBUILD_SCATTER_GATHER_LIST)(
2193 IN PDMA_ADAPTER DmaAdapter,
2194 IN PDEVICE_OBJECT DeviceObject,
2195 IN PMDL Mdl,
2196 IN PVOID CurrentVa,
2197 IN ULONG Length,
2198 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2199 IN PVOID Context,
2200 IN BOOLEAN WriteToDevice,
2201 IN PVOID ScatterGatherBuffer,
2202 IN ULONG ScatterGatherLength);
2203
2204 typedef NTSTATUS
2205 (DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
2206 IN PDMA_ADAPTER DmaAdapter,
2207 IN PSCATTER_GATHER_LIST ScatterGather,
2208 IN PMDL OriginalMdl,
2209 OUT PMDL *TargetMdl);
2210
2211 typedef struct _DMA_OPERATIONS {
2212 ULONG Size;
2213 PPUT_DMA_ADAPTER PutDmaAdapter;
2214 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
2215 PFREE_COMMON_BUFFER FreeCommonBuffer;
2216 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
2217 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
2218 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
2219 PFREE_MAP_REGISTERS FreeMapRegisters;
2220 PMAP_TRANSFER MapTransfer;
2221 PGET_DMA_ALIGNMENT GetDmaAlignment;
2222 PREAD_DMA_COUNTER ReadDmaCounter;
2223 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
2224 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
2225 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
2226 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
2227 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
2228 } DMA_OPERATIONS, *PDMA_OPERATIONS;
2229
2230 typedef enum _ARBITER_REQUEST_SOURCE {
2231 ArbiterRequestUndefined = -1,
2232 ArbiterRequestLegacyReported,
2233 ArbiterRequestHalReported,
2234 ArbiterRequestLegacyAssigned,
2235 ArbiterRequestPnpDetected,
2236 ArbiterRequestPnpEnumerated
2237 } ARBITER_REQUEST_SOURCE;
2238
2239 typedef enum _ARBITER_RESULT {
2240 ArbiterResultUndefined = -1,
2241 ArbiterResultSuccess,
2242 ArbiterResultExternalConflict,
2243 ArbiterResultNullRequest
2244 } ARBITER_RESULT;
2245
2246 typedef enum _ARBITER_ACTION {
2247 ArbiterActionTestAllocation,
2248 ArbiterActionRetestAllocation,
2249 ArbiterActionCommitAllocation,
2250 ArbiterActionRollbackAllocation,
2251 ArbiterActionQueryAllocatedResources,
2252 ArbiterActionWriteReservedResources,
2253 ArbiterActionQueryConflict,
2254 ArbiterActionQueryArbitrate,
2255 ArbiterActionAddReserved,
2256 ArbiterActionBootAllocation
2257 } ARBITER_ACTION, *PARBITER_ACTION;
2258
2259 typedef struct _ARBITER_CONFLICT_INFO {
2260 PDEVICE_OBJECT OwningObject;
2261 ULONGLONG Start;
2262 ULONGLONG End;
2263 } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO;
2264
2265 typedef struct _ARBITER_PARAMETERS {
2266 union {
2267 struct {
2268 IN OUT PLIST_ENTRY ArbitrationList;
2269 IN ULONG AllocateFromCount;
2270 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
2271 } TestAllocation;
2272
2273 struct {
2274 IN OUT PLIST_ENTRY ArbitrationList;
2275 IN ULONG AllocateFromCount;
2276 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom;
2277 } RetestAllocation;
2278
2279 struct {
2280 IN OUT PLIST_ENTRY ArbitrationList;
2281 } BootAllocation;
2282
2283 struct {
2284 OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources;
2285 } QueryAllocatedResources;
2286
2287 struct {
2288 IN PDEVICE_OBJECT PhysicalDeviceObject;
2289 IN PIO_RESOURCE_DESCRIPTOR ConflictingResource;
2290 OUT PULONG ConflictCount;
2291 OUT PARBITER_CONFLICT_INFO *Conflicts;
2292 } QueryConflict;
2293
2294 struct {
2295 IN PLIST_ENTRY ArbitrationList;
2296 } QueryArbitrate;
2297
2298 struct {
2299 IN PDEVICE_OBJECT ReserveDevice;
2300 } AddReserved;
2301 } Parameters;
2302 } ARBITER_PARAMETERS, *PARBITER_PARAMETERS;
2303
2304 #define ARBITER_FLAG_BOOT_CONFIG 0x00000001
2305
2306 typedef struct _ARBITER_LIST_ENTRY {
2307 LIST_ENTRY ListEntry;
2308 ULONG AlternativeCount;
2309 PIO_RESOURCE_DESCRIPTOR Alternatives;
2310 PDEVICE_OBJECT PhysicalDeviceObject;
2311 ARBITER_REQUEST_SOURCE RequestSource;
2312 ULONG Flags;
2313 LONG_PTR WorkSpace;
2314 INTERFACE_TYPE InterfaceType;
2315 ULONG SlotNumber;
2316 ULONG BusNumber;
2317 PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment;
2318 PIO_RESOURCE_DESCRIPTOR SelectedAlternative;
2319 ARBITER_RESULT Result;
2320 } ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY;
2321
2322 typedef NTSTATUS
2323 (DDKAPI *PARBITER_HANDLER)(
2324 IN PVOID Context,
2325 IN ARBITER_ACTION Action,
2326 IN OUT PARBITER_PARAMETERS Parameters);
2327
2328 #define ARBITER_PARTIAL 0x00000001
2329
2330 typedef struct _ARBITER_INTERFACE {
2331 USHORT Size;
2332 USHORT Version;
2333 PVOID Context;
2334 PINTERFACE_REFERENCE InterfaceReference;
2335 PINTERFACE_DEREFERENCE InterfaceDereference;
2336 PARBITER_HANDLER ArbiterHandler;
2337 ULONG Flags;
2338 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
2339
2340 typedef enum _KPROFILE_SOURCE {
2341 ProfileTime,
2342 ProfileAlignmentFixup,
2343 ProfileTotalIssues,
2344 ProfilePipelineDry,
2345 ProfileLoadInstructions,
2346 ProfilePipelineFrozen,
2347 ProfileBranchInstructions,
2348 ProfileTotalNonissues,
2349 ProfileDcacheMisses,
2350 ProfileIcacheMisses,
2351 ProfileCacheMisses,
2352 ProfileBranchMispredictions,
2353 ProfileStoreInstructions,
2354 ProfileFpInstructions,
2355 ProfileIntegerInstructions,
2356 Profile2Issue,
2357 Profile3Issue,
2358 Profile4Issue,
2359 ProfileSpecialInstructions,
2360 ProfileTotalCycles,
2361 ProfileIcacheIssues,
2362 ProfileDcacheAccesses,
2363 ProfileMemoryBarrierCycles,
2364 ProfileLoadLinkedIssues,
2365 ProfileMaximum
2366 } KPROFILE_SOURCE;
2367
2368 typedef enum _HAL_QUERY_INFORMATION_CLASS {
2369 HalInstalledBusInformation,
2370 HalProfileSourceInformation,
2371 HalInformationClassUnused1,
2372 HalPowerInformation,
2373 HalProcessorSpeedInformation,
2374 HalCallbackInformation,
2375 HalMapRegisterInformation,
2376 HalMcaLogInformation,
2377 HalFrameBufferCachingInformation,
2378 HalDisplayBiosInformation,
2379 HalProcessorFeatureInformation,
2380 HalNumaTopologyInterface,
2381 HalErrorInformation,
2382 HalCmcLogInformation,
2383 HalCpeLogInformation,
2384 HalQueryMcaInterface,
2385 HalQueryAMLIIllegalIOPortAddresses,
2386 HalQueryMaxHotPlugMemoryAddress,
2387 HalPartitionIpiInterface,
2388 HalPlatformInformation,
2389 HalQueryProfileSourceList
2390 } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
2391
2392 typedef enum _HAL_SET_INFORMATION_CLASS {
2393 HalProfileSourceInterval,
2394 HalProfileSourceInterruptHandler,
2395 HalMcaRegisterDriver,
2396 HalKernelErrorHandler,
2397 HalCmcRegisterDriver,
2398 HalCpeRegisterDriver,
2399 HalMcaLog,
2400 HalCmcLog,
2401 HalCpeLog,
2402 HalGenerateCmcInterrupt
2403 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
2404
2405 typedef struct _HAL_PROFILE_SOURCE_INTERVAL
2406 {
2407 KPROFILE_SOURCE Source;
2408 ULONG_PTR Interval;
2409 } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
2410
2411 typedef struct _HAL_PROFILE_SOURCE_INFORMATION
2412 {
2413 KPROFILE_SOURCE Source;
2414 BOOLEAN Supported;
2415 ULONG Interval;
2416 } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
2417
2418 typedef struct _MAP_REGISTER_ENTRY
2419 {
2420 PVOID MapRegister;
2421 BOOLEAN WriteToDevice;
2422 } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
2423
2424 typedef struct
2425 {
2426 UCHAR Type;
2427 BOOLEAN Valid;
2428 UCHAR Reserved[2];
2429 PUCHAR TranslatedAddress;
2430 ULONG Length;
2431 } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
2432
2433 typedef struct
2434 {
2435 PHYSICAL_ADDRESS Start;
2436 PHYSICAL_ADDRESS MaxEnd;
2437 PVOID VirtualAddress;
2438 ULONG Length;
2439 BOOLEAN Cached;
2440 BOOLEAN Aligned;
2441 } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
2442
2443 typedef struct
2444 {
2445 ULONG Bus;
2446 ULONG Slot;
2447 USHORT VendorID;
2448 USHORT DeviceID;
2449 UCHAR BaseClass;
2450 UCHAR SubClass;
2451 UCHAR ProgIf;
2452 BOOLEAN Initialized;
2453 DEBUG_DEVICE_ADDRESS BaseAddress[6];
2454 DEBUG_MEMORY_REQUIREMENTS Memory;
2455 } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
2456
2457 typedef enum _KD_OPTION {
2458 KD_OPTION_SET_BLOCK_ENABLE,
2459 } KD_OPTION;
2460
2461 /* Function Type Defintions for Dispatch Functions */
2462 struct _DEVICE_CONTROL_CONTEXT;
2463
2464 typedef VOID
2465 (DDKAPI *PDEVICE_CONTROL_COMPLETION)(
2466 IN struct _DEVICE_CONTROL_CONTEXT *ControlContext);
2467
2468 typedef struct _DEVICE_CONTROL_CONTEXT {
2469 NTSTATUS Status;
2470 PDEVICE_HANDLER_OBJECT DeviceHandler;
2471 PDEVICE_OBJECT DeviceObject;
2472 ULONG ControlCode;
2473 PVOID Buffer;
2474 PULONG BufferLength;
2475 PVOID Context;
2476 } DEVICE_CONTROL_CONTEXT, *PDEVICE_CONTROL_CONTEXT;
2477
2478 typedef struct _PM_DISPATCH_TABLE {
2479 ULONG Signature;
2480 ULONG Version;
2481 PVOID Function[1];
2482 } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
2483
2484 typedef enum _RESOURCE_TRANSLATION_DIRECTION {
2485 TranslateChildToParent,
2486 TranslateParentToChild
2487 } RESOURCE_TRANSLATION_DIRECTION;
2488
2489 typedef NTSTATUS
2490 (DDKAPI *PTRANSLATE_RESOURCE_HANDLER)(
2491 IN PVOID Context,
2492 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
2493 IN RESOURCE_TRANSLATION_DIRECTION Direction,
2494 IN ULONG AlternativesCount,
2495 IN IO_RESOURCE_DESCRIPTOR Alternatives[],
2496 IN PDEVICE_OBJECT PhysicalDeviceObject,
2497 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target);
2498
2499 typedef NTSTATUS
2500 (DDKAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(
2501 IN PVOID Context,
2502 IN PIO_RESOURCE_DESCRIPTOR Source,
2503 IN PDEVICE_OBJECT PhysicalDeviceObject,
2504 OUT PULONG TargetCount,
2505 OUT PIO_RESOURCE_DESCRIPTOR *Target);
2506
2507 typedef struct _TRANSLATOR_INTERFACE {
2508 USHORT Size;
2509 USHORT Version;
2510 PVOID Context;
2511 PINTERFACE_REFERENCE InterfaceReference;
2512 PINTERFACE_DEREFERENCE InterfaceDereference;
2513 PTRANSLATE_RESOURCE_HANDLER TranslateResources;
2514 PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements;
2515 } TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE;
2516
2517 typedef NTSTATUS
2518 (DDKAPI *pHalDeviceControl)(
2519 IN PDEVICE_HANDLER_OBJECT DeviceHandler,
2520 IN PDEVICE_OBJECT DeviceObject,
2521 IN ULONG ControlCode,
2522 IN OUT PVOID Buffer OPTIONAL,
2523 IN OUT PULONG BufferLength OPTIONAL,
2524 IN PVOID Context,
2525 IN PDEVICE_CONTROL_COMPLETION CompletionRoutine);
2526
2527 typedef VOID
2528 (FASTCALL *pHalExamineMBR)(
2529 IN PDEVICE_OBJECT DeviceObject,
2530 IN ULONG SectorSize,
2531 IN ULONG MBRTypeIdentifier,
2532 OUT PVOID *Buffer);
2533
2534 typedef VOID
2535 (FASTCALL *pHalIoAssignDriveLetters)(
2536 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2537 IN PSTRING NtDeviceName,
2538 OUT PUCHAR NtSystemPath,
2539 OUT PSTRING NtSystemPathString);
2540
2541 typedef NTSTATUS
2542 (FASTCALL *pHalIoReadPartitionTable)(
2543 IN PDEVICE_OBJECT DeviceObject,
2544 IN ULONG SectorSize,
2545 IN BOOLEAN ReturnRecognizedPartitions,
2546 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2547
2548 typedef NTSTATUS
2549 (FASTCALL *pHalIoSetPartitionInformation)(
2550 IN PDEVICE_OBJECT DeviceObject,
2551 IN ULONG SectorSize,
2552 IN ULONG PartitionNumber,
2553 IN ULONG PartitionType);
2554
2555 typedef NTSTATUS
2556 (FASTCALL *pHalIoWritePartitionTable)(
2557 IN PDEVICE_OBJECT DeviceObject,
2558 IN ULONG SectorSize,
2559 IN ULONG SectorsPerTrack,
2560 IN ULONG NumberOfHeads,
2561 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
2562
2563 typedef PBUS_HANDLER
2564 (FASTCALL *pHalHandlerForBus)(
2565 IN INTERFACE_TYPE InterfaceType,
2566 IN ULONG BusNumber);
2567
2568 typedef VOID
2569 (FASTCALL *pHalReferenceBusHandler)(
2570 IN PBUS_HANDLER BusHandler);
2571
2572 typedef NTSTATUS
2573 (DDKAPI *pHalQuerySystemInformation)(
2574 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
2575 IN ULONG BufferSize,
2576 IN OUT PVOID Buffer,
2577 OUT PULONG ReturnedLength);
2578
2579 typedef NTSTATUS
2580 (DDKAPI *pHalSetSystemInformation)(
2581 IN HAL_SET_INFORMATION_CLASS InformationClass,
2582 IN ULONG BufferSize,
2583 IN PVOID Buffer);
2584
2585 typedef NTSTATUS
2586 (DDKAPI *pHalQueryBusSlots)(
2587 IN PBUS_HANDLER BusHandler,
2588 IN ULONG BufferSize,
2589 OUT PULONG SlotNumbers,
2590 OUT PULONG ReturnedLength);
2591
2592 typedef NTSTATUS
2593 (DDKAPI *pHalInitPnpDriver)(
2594 VOID);
2595
2596 typedef NTSTATUS
2597 (DDKAPI *pHalInitPowerManagement)(
2598 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
2599 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable);
2600
2601 typedef struct _DMA_ADAPTER*
2602 (DDKAPI *pHalGetDmaAdapter)(
2603 IN PVOID Context,
2604 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
2605 OUT PULONG NumberOfMapRegisters);
2606
2607 typedef NTSTATUS
2608 (DDKAPI *pHalGetInterruptTranslator)(
2609 IN INTERFACE_TYPE ParentInterfaceType,
2610 IN ULONG ParentBusNumber,
2611 IN INTERFACE_TYPE BridgeInterfaceType,
2612 IN USHORT Size,
2613 IN USHORT Version,
2614 OUT PTRANSLATOR_INTERFACE Translator,
2615 OUT PULONG BridgeBusNumber);
2616
2617 typedef NTSTATUS
2618 (DDKAPI *pHalStartMirroring)(
2619 VOID);
2620
2621 typedef NTSTATUS
2622 (DDKAPI *pHalEndMirroring)(
2623 IN ULONG PassNumber);
2624
2625 typedef NTSTATUS
2626 (DDKAPI *pHalMirrorPhysicalMemory)(
2627 IN PHYSICAL_ADDRESS PhysicalAddress,
2628 IN LARGE_INTEGER NumberOfBytes);
2629
2630 typedef NTSTATUS
2631 (DDKAPI *pHalMirrorVerify)(
2632 IN PHYSICAL_ADDRESS PhysicalAddress,
2633 IN LARGE_INTEGER NumberOfBytes);
2634
2635 typedef VOID
2636 (DDKAPI *pHalEndOfBoot)(
2637 VOID);
2638
2639 typedef
2640 BOOLEAN
2641 (DDKAPI *pHalTranslateBusAddress)(
2642 IN INTERFACE_TYPE InterfaceType,
2643 IN ULONG BusNumber,
2644 IN PHYSICAL_ADDRESS BusAddress,
2645 IN OUT PULONG AddressSpace,
2646 OUT PPHYSICAL_ADDRESS TranslatedAddress
2647 );
2648
2649 typedef
2650 NTSTATUS
2651 (DDKAPI *pHalAssignSlotResources)(
2652 IN PUNICODE_STRING RegistryPath,
2653 IN PUNICODE_STRING DriverClassName OPTIONAL,
2654 IN PDRIVER_OBJECT DriverObject,
2655 IN PDEVICE_OBJECT DeviceObject,
2656 IN INTERFACE_TYPE BusType,
2657 IN ULONG BusNumber,
2658 IN ULONG SlotNumber,
2659 IN OUT PCM_RESOURCE_LIST *AllocatedResources
2660 );
2661
2662 typedef
2663 VOID
2664 (DDKAPI *pHalHaltSystem)(
2665 VOID
2666 );
2667
2668 typedef
2669 BOOLEAN
2670 (DDKAPI *pHalResetDisplay)(
2671 VOID
2672 );
2673
2674 typedef
2675 UCHAR
2676 (DDKAPI *pHalVectorToIDTEntry)(
2677 ULONG Vector
2678 );
2679
2680 typedef
2681 BOOLEAN
2682 (DDKAPI *pHalFindBusAddressTranslation)(
2683 IN PHYSICAL_ADDRESS BusAddress,
2684 IN OUT PULONG AddressSpace,
2685 OUT PPHYSICAL_ADDRESS TranslatedAddress,
2686 IN OUT PULONG_PTR Context,
2687 IN BOOLEAN NextBus
2688 );
2689
2690 typedef
2691 NTSTATUS
2692 (DDKAPI *pKdSetupPciDeviceForDebugging)(
2693 IN PVOID LoaderBlock OPTIONAL,
2694 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
2695 );
2696
2697 typedef
2698 NTSTATUS
2699 (DDKAPI *pKdReleasePciDeviceForDebugging)(
2700 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
2701 );
2702
2703 typedef
2704 PVOID
2705 (DDKAPI *pKdGetAcpiTablePhase0)(
2706 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
2707 IN ULONG Signature
2708 );
2709
2710 typedef
2711 VOID
2712 (DDKAPI *pKdCheckPowerButton)(
2713 VOID
2714 );
2715
2716 typedef
2717 ULONG
2718 (DDKAPI *pHalGetInterruptVector)(
2719 IN INTERFACE_TYPE InterfaceType,
2720 IN ULONG BusNumber,
2721 IN ULONG BusInterruptLevel,
2722 IN ULONG BusInterruptVector,
2723 OUT PKIRQL Irql,
2724 OUT PKAFFINITY Affinity
2725 );
2726
2727 typedef
2728 NTSTATUS
2729 (DDKAPI *pHalGetVectorInput)(
2730 IN ULONG Vector,
2731 IN KAFFINITY Affinity,
2732 OUT PULONG Input,
2733 OUT PKINTERRUPT_POLARITY Polarity
2734 );
2735
2736 typedef
2737 PVOID
2738 (DDKAPI *pKdMapPhysicalMemory64)(
2739 IN PHYSICAL_ADDRESS PhysicalAddress,
2740 IN ULONG NumberPages
2741 );
2742
2743 typedef
2744 VOID
2745 (DDKAPI *pKdUnmapVirtualAddress)(
2746 IN PVOID VirtualAddress,
2747 IN ULONG NumberPages
2748 );
2749
2750 typedef
2751 ULONG
2752 (DDKAPI *pKdGetPciDataByOffset)(
2753 IN ULONG BusNumber,
2754 IN ULONG SlotNumber,
2755 OUT PVOID Buffer,
2756 IN ULONG Offset,
2757 IN ULONG Length
2758 );
2759
2760 typedef
2761 ULONG
2762 (DDKAPI *pKdSetPciDataByOffset)(
2763 IN ULONG BusNumber,
2764 IN ULONG SlotNumber,
2765 IN PVOID Buffer,
2766 IN ULONG Offset,
2767 IN ULONG Length
2768 );
2769
2770 typedef BOOLEAN
2771 (DDKAPI *PHAL_RESET_DISPLAY_PARAMETERS)(
2772 ULONG Columns, ULONG Rows);
2773
2774 typedef struct {
2775 ULONG Version;
2776 pHalQuerySystemInformation HalQuerySystemInformation;
2777 pHalSetSystemInformation HalSetSystemInformation;
2778 pHalQueryBusSlots HalQueryBusSlots;
2779 ULONG Spare1;
2780 pHalExamineMBR HalExamineMBR;
2781 pHalIoAssignDriveLetters HalIoAssignDriveLetters;
2782 pHalIoReadPartitionTable HalIoReadPartitionTable;
2783 pHalIoSetPartitionInformation HalIoSetPartitionInformation;
2784 pHalIoWritePartitionTable HalIoWritePartitionTable;
2785 pHalHandlerForBus HalReferenceHandlerForBus;
2786 pHalReferenceBusHandler HalReferenceBusHandler;
2787 pHalReferenceBusHandler HalDereferenceBusHandler;
2788 pHalInitPnpDriver HalInitPnpDriver;
2789 pHalInitPowerManagement HalInitPowerManagement;
2790 pHalGetDmaAdapter HalGetDmaAdapter;
2791 pHalGetInterruptTranslator HalGetInterruptTranslator;
2792 pHalStartMirroring HalStartMirroring;
2793 pHalEndMirroring HalEndMirroring;
2794 pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
2795 pHalEndOfBoot HalEndOfBoot;
2796 pHalMirrorVerify HalMirrorVerify;
2797 } HAL_DISPATCH, *PHAL_DISPATCH;
2798
2799 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTHAL_)
2800 extern NTSYSAPI PHAL_DISPATCH HalDispatchTable;
2801 #define HALDISPATCH ((PHAL_DISPATCH)&HalDispatchTable)
2802 #else
2803 extern __declspec(dllexport) HAL_DISPATCH HalDispatchTable;
2804 #define HALDISPATCH (&HalDispatchTable)
2805 #endif
2806
2807 #define HAL_DISPATCH_VERSION 3
2808 #define HalDispatchTableVersion HALDISPATCH->Version
2809 #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
2810 #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
2811 #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
2812 #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
2813 #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
2814 #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
2815 #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
2816 #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
2817 #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
2818 #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
2819 #define HalStartMirroring HALDISPATCH->HalStartMirroring
2820 #define HalEndMirroring HALDISPATCH->HalEndMirroring
2821 #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
2822 #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
2823 #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
2824
2825 typedef enum _FILE_INFORMATION_CLASS {
2826 FileDirectoryInformation = 1,
2827 FileFullDirectoryInformation,
2828 FileBothDirectoryInformation,
2829 FileBasicInformation,
2830 FileStandardInformation,
2831 FileInternalInformation,
2832 FileEaInformation,
2833 FileAccessInformation,
2834 FileNameInformation,
2835 FileRenameInformation,
2836 FileLinkInformation,
2837 FileNamesInformation,
2838 FileDispositionInformation,
2839 FilePositionInformation,
2840 FileFullEaInformation,
2841 FileModeInformation,
2842 FileAlignmentInformation,
2843 FileAllInformation,
2844 FileAllocationInformation,
2845 FileEndOfFileInformation,
2846 FileAlternateNameInformation,
2847 FileStreamInformation,
2848 FilePipeInformation,
2849 FilePipeLocalInformation,
2850 FilePipeRemoteInformation,
2851 FileMailslotQueryInformation,
2852 FileMailslotSetInformation,
2853 FileCompressionInformation,
2854 FileObjectIdInformation,
2855 FileCompletionInformation,
2856 FileMoveClusterInformation,
2857 FileQuotaInformation,
2858 FileReparsePointInformation,
2859 FileNetworkOpenInformation,
2860 FileAttributeTagInformation,
2861 FileTrackingInformation,
2862 FileIdBothDirectoryInformation,
2863 FileIdFullDirectoryInformation,
2864 FileValidDataLengthInformation,
2865 FileShortNameInformation,
2866 FileMaximumInformation
2867 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
2868
2869 typedef struct _FILE_POSITION_INFORMATION {
2870 LARGE_INTEGER CurrentByteOffset;
2871 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
2872
2873 typedef struct _FILE_ALIGNMENT_INFORMATION {
2874 ULONG AlignmentRequirement;
2875 } FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
2876
2877 typedef struct _FILE_NAME_INFORMATION {
2878 ULONG FileNameLength;
2879 WCHAR FileName[1];
2880 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
2881
2882 #include <pshpack8.h>
2883 typedef struct _FILE_BASIC_INFORMATION {
2884 LARGE_INTEGER CreationTime;
2885 LARGE_INTEGER LastAccessTime;
2886 LARGE_INTEGER LastWriteTime;
2887 LARGE_INTEGER ChangeTime;
2888 ULONG FileAttributes;
2889 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
2890 #include <poppack.h>
2891
2892 typedef struct _FILE_STANDARD_INFORMATION {
2893 LARGE_INTEGER AllocationSize;
2894 LARGE_INTEGER EndOfFile;
2895 ULONG NumberOfLinks;
2896 BOOLEAN DeletePending;
2897 BOOLEAN Directory;
2898 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
2899
2900 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
2901 LARGE_INTEGER CreationTime;
2902 LARGE_INTEGER LastAccessTime;
2903 LARGE_INTEGER LastWriteTime;
2904 LARGE_INTEGER ChangeTime;
2905 LARGE_INTEGER AllocationSize;
2906 LARGE_INTEGER EndOfFile;
2907 ULONG FileAttributes;
2908 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
2909
2910 typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION {
2911 ULONG FileAttributes;
2912 ULONG ReparseTag;
2913 } FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION;
2914
2915 typedef struct _FILE_DISPOSITION_INFORMATION {
2916 BOOLEAN DeleteFile;
2917 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
2918
2919 typedef struct _FILE_END_OF_FILE_INFORMATION {
2920 LARGE_INTEGER EndOfFile;
2921 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
2922
2923 typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION {
2924 LARGE_INTEGER ValidDataLength;
2925 } FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
2926
2927 typedef union _FILE_SEGMENT_ELEMENT {
2928 PVOID64 Buffer;
2929 ULONGLONG Alignment;
2930 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
2931
2932 typedef enum _FSINFOCLASS {
2933 FileFsVolumeInformation = 1,
2934 FileFsLabelInformation,
2935 FileFsSizeInformation,
2936 FileFsDeviceInformation,
2937 FileFsAttributeInformation,
2938 FileFsControlInformation,
2939 FileFsFullSizeInformation,
2940 FileFsObjectIdInformation,
2941 FileFsDriverPathInformation,
2942 FileFsMaximumInformation
2943 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
2944
2945 typedef struct _FILE_FS_DEVICE_INFORMATION {
2946 DEVICE_TYPE DeviceType;
2947 ULONG Characteristics;
2948 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
2949
2950 typedef struct _FILE_FULL_EA_INFORMATION {
2951 ULONG NextEntryOffset;
2952 UCHAR Flags;
2953 UCHAR EaNameLength;
2954 USHORT EaValueLength;
2955 CHAR EaName[1];
2956 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
2957
2958 /* ERESOURCE.Flag */
2959
2960 #define ResourceNeverExclusive 0x0010
2961 #define ResourceReleaseByOtherThread 0x0020
2962 #define ResourceOwnedExclusive 0x0080
2963
2964 #define RESOURCE_HASH_TABLE_SIZE 64
2965
2966 typedef struct _DEVOBJ_EXTENSION
2967 {
2968 CSHORT Type;
2969 USHORT Size;
2970 PDEVICE_OBJECT DeviceObject;
2971 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
2972
2973 typedef BOOLEAN
2974 (DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)(
2975 IN struct _FILE_OBJECT *FileObject,
2976 IN PLARGE_INTEGER FileOffset,
2977 IN ULONG Length,
2978 IN BOOLEAN Wait,
2979 IN ULONG LockKey,
2980 IN BOOLEAN CheckForReadOperation,
2981 OUT PIO_STATUS_BLOCK IoStatus,
2982 IN struct _DEVICE_OBJECT *DeviceObject);
2983
2984 typedef BOOLEAN
2985 (DDKAPI *PFAST_IO_READ)(
2986 IN struct _FILE_OBJECT *FileObject,
2987 IN PLARGE_INTEGER FileOffset,
2988 IN ULONG Length,
2989 IN BOOLEAN Wait,
2990 IN ULONG LockKey,
2991 OUT PVOID Buffer,
2992 OUT PIO_STATUS_BLOCK IoStatus,
2993 IN struct _DEVICE_OBJECT *DeviceObject);
2994
2995 typedef BOOLEAN
2996 (DDKAPI *PFAST_IO_WRITE)(
2997 IN struct _FILE_OBJECT *FileObject,
2998 IN PLARGE_INTEGER FileOffset,
2999 IN ULONG Length,
3000 IN BOOLEAN Wait,
3001 IN ULONG LockKey,
3002 IN PVOID Buffer,
3003 OUT PIO_STATUS_BLOCK IoStatus,
3004 IN struct _DEVICE_OBJECT *DeviceObject);
3005
3006 typedef BOOLEAN
3007 (DDKAPI *PFAST_IO_QUERY_BASIC_INFO)(
3008 IN struct _FILE_OBJECT *FileObject,
3009 IN BOOLEAN Wait,
3010 OUT PFILE_BASIC_INFORMATION Buffer,
3011 OUT PIO_STATUS_BLOCK IoStatus,
3012 IN struct _DEVICE_OBJECT *DeviceObject);
3013
3014 typedef BOOLEAN
3015 (DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)(
3016 IN struct _FILE_OBJECT *FileObject,
3017 IN BOOLEAN Wait,
3018 OUT PFILE_STANDARD_INFORMATION Buffer,
3019 OUT PIO_STATUS_BLOCK IoStatus,
3020 IN struct _DEVICE_OBJECT *DeviceObject);
3021
3022 typedef BOOLEAN
3023 (DDKAPI *PFAST_IO_LOCK)(
3024 IN struct _FILE_OBJECT *FileObject,
3025 IN PLARGE_INTEGER FileOffset,
3026 IN PLARGE_INTEGER Length,
3027 PEPROCESS ProcessId,
3028 ULONG Key,
3029 BOOLEAN FailImmediately,
3030 BOOLEAN ExclusiveLock,
3031 OUT PIO_STATUS_BLOCK IoStatus,
3032 IN struct _DEVICE_OBJECT *DeviceObject);
3033
3034 typedef BOOLEAN
3035 (DDKAPI *PFAST_IO_UNLOCK_SINGLE)(
3036 IN struct _FILE_OBJECT *FileObject,
3037 IN PLARGE_INTEGER FileOffset,
3038 IN PLARGE_INTEGER Length,
3039 PEPROCESS ProcessId,
3040 ULONG Key,
3041 OUT PIO_STATUS_BLOCK IoStatus,
3042 IN struct _DEVICE_OBJECT *DeviceObject);
3043
3044 typedef BOOLEAN
3045 (DDKAPI *PFAST_IO_UNLOCK_ALL)(
3046 IN struct _FILE_OBJECT *FileObject,
3047 PEPROCESS ProcessId,
3048 OUT PIO_STATUS_BLOCK IoStatus,
3049 IN struct _DEVICE_OBJECT *DeviceObject);
3050
3051 typedef BOOLEAN
3052 (DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)(
3053 IN struct _FILE_OBJECT *FileObject,
3054 PVOID ProcessId,
3055 ULONG Key,
3056 OUT PIO_STATUS_BLOCK IoStatus,
3057 IN struct _DEVICE_OBJECT *DeviceObject);
3058
3059 typedef BOOLEAN
3060 (DDKAPI *PFAST_IO_DEVICE_CONTROL)(
3061 IN struct _FILE_OBJECT *FileObject,
3062 IN BOOLEAN Wait,
3063 IN PVOID InputBuffer OPTIONAL,
3064 IN ULONG InputBufferLength,
3065 OUT PVOID OutputBuffer OPTIONAL,
3066 IN ULONG OutputBufferLength,
3067 IN ULONG IoControlCode,
3068 OUT PIO_STATUS_BLOCK IoStatus,
3069 IN struct _DEVICE_OBJECT *DeviceObject);
3070
3071 typedef VOID
3072 (DDKAPI *PFAST_IO_ACQUIRE_FILE)(
3073 IN struct _FILE_OBJECT *FileObject);
3074
3075 typedef VOID
3076 (DDKAPI *PFAST_IO_RELEASE_FILE)(
3077 IN struct _FILE_OBJECT *FileObject);
3078
3079 typedef VOID
3080 (DDKAPI *PFAST_IO_DETACH_DEVICE)(
3081 IN struct _DEVICE_OBJECT *SourceDevice,
3082 IN struct _DEVICE_OBJECT *TargetDevice);
3083
3084 typedef BOOLEAN
3085 (DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)(
3086 IN struct _FILE_OBJECT *FileObject,
3087 IN BOOLEAN Wait,
3088 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
3089 OUT struct _IO_STATUS_BLOCK *IoStatus,
3090 IN struct _DEVICE_OBJECT *DeviceObject);
3091
3092 typedef NTSTATUS
3093 (DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(
3094 IN struct _FILE_OBJECT *FileObject,
3095 IN PLARGE_INTEGER EndingOffset,
3096 OUT struct _ERESOURCE **ResourceToRelease,
3097 IN struct _DEVICE_OBJECT *DeviceObject);
3098
3099 typedef BOOLEAN
3100 (DDKAPI *PFAST_IO_MDL_READ)(
3101 IN struct _FILE_OBJECT *FileObject,
3102 IN PLARGE_INTEGER FileOffset,
3103 IN ULONG Length,
3104 IN ULONG LockKey,
3105 OUT PMDL *MdlChain,
3106 OUT PIO_STATUS_BLOCK IoStatus,
3107 IN struct _DEVICE_OBJECT *DeviceObject);
3108
3109 typedef BOOLEAN
3110 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE)(
3111 IN struct _FILE_OBJECT *FileObject,
3112 IN PMDL MdlChain,
3113 IN struct _DEVICE_OBJECT *DeviceObject);
3114
3115 typedef BOOLEAN
3116 (DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)(
3117 IN struct _FILE_OBJECT *FileObject,
3118 IN PLARGE_INTEGER FileOffset,
3119 IN ULONG Length,
3120 IN ULONG LockKey,
3121 OUT PMDL *MdlChain,
3122 OUT PIO_STATUS_BLOCK IoStatus,
3123 IN struct _DEVICE_OBJECT *DeviceObject);
3124
3125 typedef BOOLEAN
3126 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)(
3127 IN struct _FILE_OBJECT *FileObject,
3128 IN PLARGE_INTEGER FileOffset,
3129 IN PMDL MdlChain,
3130 IN struct _DEVICE_OBJECT *DeviceObject);
3131
3132 typedef BOOLEAN
3133 (DDKAPI *PFAST_IO_READ_COMPRESSED)(
3134 IN struct _FILE_OBJECT *FileObject,
3135 IN PLARGE_INTEGER FileOffset,
3136 IN ULONG Length,
3137 IN ULONG LockKey,
3138 OUT PVOID Buffer,
3139 OUT PMDL *MdlChain,
3140 OUT PIO_STATUS_BLOCK IoStatus,
3141 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
3142 IN ULONG CompressedDataInfoLength,
3143 IN struct _DEVICE_OBJECT *DeviceObject);
3144
3145 typedef BOOLEAN
3146 (DDKAPI *PFAST_IO_WRITE_COMPRESSED)(
3147 IN struct _FILE_OBJECT *FileObject,
3148 IN PLARGE_INTEGER FileOffset,
3149 IN ULONG Length,
3150 IN ULONG LockKey,
3151 IN PVOID Buffer,
3152 OUT PMDL *MdlChain,
3153 OUT PIO_STATUS_BLOCK IoStatus,
3154 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
3155 IN ULONG CompressedDataInfoLength,
3156 IN struct _DEVICE_OBJECT *DeviceObject);
3157
3158 typedef BOOLEAN
3159 (DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
3160 IN struct _FILE_OBJECT *FileObject,
3161 IN PMDL MdlChain,
3162 IN struct _DEVICE_OBJECT *DeviceObject);
3163
3164 typedef BOOLEAN
3165 (DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
3166 IN struct _FILE_OBJECT *FileObject,
3167 IN PLARGE_INTEGER FileOffset,
3168 IN PMDL MdlChain,
3169 IN struct _DEVICE_OBJECT *DeviceObject);
3170
3171 typedef BOOLEAN
3172 (DDKAPI *PFAST_IO_QUERY_OPEN)(
3173 IN struct _IRP *Irp,
3174 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
3175 IN struct _DEVICE_OBJECT *DeviceObject);
3176
3177 typedef NTSTATUS
3178 (DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)(
3179 IN struct _FILE_OBJECT *FileObject,
3180 IN struct _ERESOURCE *ResourceToRelease,
3181 IN struct _DEVICE_OBJECT *DeviceObject);
3182
3183 typedef NTSTATUS
3184 (DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)(
3185 IN struct _FILE_OBJECT *FileObject,
3186 IN struct _DEVICE_OBJECT *DeviceObject);
3187
3188 typedef NTSTATUS
3189 (DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) (
3190 IN struct _FILE_OBJECT *FileObject,
3191 IN struct _DEVICE_OBJECT *DeviceObject);
3192
3193 typedef struct _FAST_IO_DISPATCH {
3194 ULONG SizeOfFastIoDispatch;
3195 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
3196 PFAST_IO_READ FastIoRead;
3197 PFAST_IO_WRITE FastIoWrite;
3198 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
3199 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
3200 PFAST_IO_LOCK FastIoLock;
3201 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
3202 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
3203 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
3204 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
3205 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
3206 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
3207 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
3208 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
3209 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
3210 PFAST_IO_MDL_READ MdlRead;
3211 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
3212 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
3213 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
3214 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
3215 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
3216 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
3217 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
3218 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
3219 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
3220 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
3221 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
3222 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
3223
3224 typedef struct _SECTION_OBJECT_POINTERS {
3225 PVOID DataSectionObject;
3226 PVOID SharedCacheMap;
3227 PVOID ImageSectionObject;
3228 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
3229
3230 typedef struct _IO_COMPLETION_CONTEXT {
3231 PVOID Port;
3232 PVOID Key;
3233 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
3234
3235 /* FILE_OBJECT.Flags */
3236
3237 #define FO_FILE_OPEN 0x00000001
3238 #define FO_SYNCHRONOUS_IO 0x00000002
3239 #define FO_ALERTABLE_IO 0x00000004
3240 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
3241 #define FO_WRITE_THROUGH 0x00000010
3242 #define FO_SEQUENTIAL_ONLY 0x00000020
3243 #define FO_CACHE_SUPPORTED 0x00000040
3244 #define FO_NAMED_PIPE 0x00000080
3245 #define FO_STREAM_FILE 0x00000100
3246 #define FO_MAILSLOT 0x00000200
3247 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
3248 #define FO_DIRECT_DEVICE_OPEN 0x00000800
3249 #define FO_FILE_MODIFIED 0x00001000
3250 #define FO_FILE_SIZE_CHANGED 0x00002000
3251 #define FO_CLEANUP_COMPLETE 0x00004000
3252 #define FO_TEMPORARY_FILE 0x00008000
3253 #define FO_DELETE_ON_CLOSE 0x00010000
3254 #define FO_OPENED_CASE_SENSITIVE 0x00020000
3255 #define FO_HANDLE_CREATED 0x00040000
3256 #define FO_FILE_FAST_IO_READ 0x00080000
3257 #define FO_RANDOM_ACCESS 0x00100000
3258 #define FO_FILE_OPEN_CANCELLED 0x00200000
3259 #define FO_VOLUME_OPEN 0x00400000
3260 #define FO_REMOTE_ORIGIN 0x01000000
3261
3262 typedef struct _FILE_OBJECT
3263 {
3264 CSHORT Type;
3265 CSHORT Size;
3266 PDEVICE_OBJECT DeviceObject;
3267 PVPB Vpb;
3268 PVOID FsContext;
3269 PVOID FsContext2;
3270 PSECTION_OBJECT_POINTERS SectionObjectPointer;
3271 PVOID PrivateCacheMap;
3272 NTSTATUS FinalStatus;
3273 struct _FILE_OBJECT *RelatedFileObject;
3274 BOOLEAN LockOperation;
3275 BOOLEAN DeletePending;
3276 BOOLEAN ReadAccess;
3277 BOOLEAN WriteAccess;
3278 BOOLEAN DeleteAccess;
3279 BOOLEAN SharedRead;
3280 BOOLEAN SharedWrite;
3281 BOOLEAN SharedDelete;
3282 ULONG Flags;
3283 UNICODE_STRING FileName;
3284 LARGE_INTEGER CurrentByteOffset;
3285 volatile ULONG Waiters;
3286 volatile ULONG Busy;
3287 PVOID LastLock;
3288 KEVENT Lock;
3289 KEVENT Event;
3290 volatile PIO_COMPLETION_CONTEXT CompletionContext;
3291 KSPIN_LOCK IrpListLock;
3292 LIST_ENTRY IrpList;
3293 volatile PVOID FileObjectExtension;
3294 } FILE_OBJECT;
3295 typedef struct _FILE_OBJECT *PFILE_OBJECT;
3296
3297 typedef enum _SECURITY_OPERATION_CODE {
3298 SetSecurityDescriptor,
3299 QuerySecurityDescriptor,
3300 DeleteSecurityDescriptor,
3301 AssignSecurityDescriptor
3302 } SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE;
3303
3304 #define INITIAL_PRIVILEGE_COUNT 3
3305
3306 typedef struct _INITIAL_PRIVILEGE_SET {
3307 ULONG PrivilegeCount;
3308 ULONG Control;
3309 LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT];
3310 } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET;
3311
3312 #define SE_MIN_WELL_KNOWN_PRIVILEGE 2
3313 #define SE_CREATE_TOKEN_PRIVILEGE 2
3314 #define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3
3315 #define SE_LOCK_MEMORY_PRIVILEGE 4
3316 #define SE_INCREASE_QUOTA_PRIVILEGE 5
3317 #define SE_UNSOLICITED_INPUT_PRIVILEGE 6
3318 #define SE_MACHINE_ACCOUNT_PRIVILEGE 6
3319 #define SE_TCB_PRIVILEGE 7
3320 #define SE_SECURITY_PRIVILEGE 8
3321 #define SE_TAKE_OWNERSHIP_PRIVILEGE 9
3322 #define SE_LOAD_DRIVER_PRIVILEGE 10
3323 #define SE_SYSTEM_PROFILE_PRIVILEGE 11
3324 #define SE_SYSTEMTIME_PRIVILEGE 12
3325 #define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13
3326 #define SE_INC_BASE_PRIORITY_PRIVILEGE 14
3327 #define SE_CREATE_PAGEFILE_PRIVILEGE 15
3328 #define SE_CREATE_PERMANENT_PRIVILEGE 16
3329 #define SE_BACKUP_PRIVILEGE 17
3330 #define SE_RESTORE_PRIVILEGE 18
3331 #define SE_SHUTDOWN_PRIVILEGE 19
3332 #define SE_DEBUG_PRIVILEGE 20
3333 #define SE_AUDIT_PRIVILEGE 21
3334 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22
3335 #define SE_CHANGE_NOTIFY_PRIVILEGE 23
3336 #define SE_REMOTE_SHUTDOWN_PRIVILEGE 24
3337 #define SE_UNDOCK_PRIVILEGE 25
3338 #define SE_SYNC_AGENT_PRIVILEGE 26
3339 #define SE_ENABLE_DELEGATION_PRIVILEGE 27
3340 #define SE_MANAGE_VOLUME_PRIVILEGE 28
3341 #define SE_IMPERSONATE_PRIVILEGE 29
3342 #define SE_CREATE_GLOBAL_PRIVILEGE 30
3343 #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_GLOBAL_PRIVILEGE
3344
3345 typedef struct _SECURITY_SUBJECT_CONTEXT {
3346 PACCESS_TOKEN ClientToken;
3347 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
3348 PACCESS_TOKEN PrimaryToken;
3349 PVOID ProcessAuditId;
3350 } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
3351
3352 #include <pshpack4.h>
3353 typedef struct _ACCESS_STATE {
3354 LUID OperationID;
3355 BOOLEAN SecurityEvaluated;
3356 BOOLEAN GenerateAudit;
3357 BOOLEAN GenerateOnClose;
3358 BOOLEAN PrivilegesAllocated;
3359 ULONG Flags;
3360 ACCESS_MASK RemainingDesiredAccess;
3361 ACCESS_MASK PreviouslyGrantedAccess;
3362 ACCESS_MASK OriginalDesiredAccess;
3363 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
3364 PSECURITY_DESCRIPTOR SecurityDescriptor;
3365 PVOID AuxData;
3366 union {
3367 INITIAL_PRIVILEGE_SET InitialPrivilegeSet;
3368 PRIVILEGE_SET PrivilegeSet;
3369 } Privileges;
3370
3371 BOOLEAN AuditPrivileges;
3372 UNICODE_STRING ObjectName;
3373 UNICODE_STRING ObjectTypeName;
3374 } ACCESS_STATE, *PACCESS_STATE;
3375 #include <poppack.h>
3376
3377 typedef struct _IO_SECURITY_CONTEXT {
3378 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
3379 PACCESS_STATE AccessState;
3380 ACCESS_MASK DesiredAccess;
3381 ULONG FullCreateOptions;
3382 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
3383
3384 #define IO_TYPE_ADAPTER 1
3385 #define IO_TYPE_CONTROLLER 2
3386 #define IO_TYPE_DEVICE 3
3387 #define IO_TYPE_DRIVER 4
3388 #define IO_TYPE_FILE 5
3389 #define IO_TYPE_IRP 6
3390 #define IO_TYPE_MASTER_ADAPTER 7
3391 #define IO_TYPE_OPEN_PACKET 8
3392 #define IO_TYPE_TIMER 9
3393 #define IO_TYPE_VPB 10
3394 #define IO_TYPE_ERROR_LOG 11
3395 #define IO_TYPE_ERROR_MESSAGE 12
3396 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
3397
3398 #define IO_TYPE_CSQ_IRP_CONTEXT 1
3399 #define IO_TYPE_CSQ 2
3400
3401 struct _IO_CSQ;
3402
3403 typedef struct _IO_CSQ_IRP_CONTEXT {
3404 ULONG Type;
3405 struct _IRP *Irp;
3406 struct _IO_CSQ *Csq;
3407 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
3408
3409 typedef VOID
3410 (DDKAPI *PIO_CSQ_INSERT_IRP)(
3411 IN struct _IO_CSQ *Csq,
3412 IN PIRP Irp);
3413
3414 typedef VOID
3415 (DDKAPI *PIO_CSQ_REMOVE_IRP)(
3416 IN struct _IO_CSQ *Csq,
3417 IN PIRP Irp);
3418
3419 typedef PIRP
3420 (DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)(
3421 IN struct _IO_CSQ *Csq,
3422 IN PIRP Irp,
3423 IN PVOID PeekContext);
3424
3425 typedef VOID
3426 (DDKAPI *PIO_CSQ_ACQUIRE_LOCK)(
3427 IN struct _IO_CSQ *Csq,
3428 OUT PKIRQL Irql);
3429
3430 typedef VOID
3431 (DDKAPI *PIO_CSQ_RELEASE_LOCK)(
3432 IN struct _IO_CSQ *Csq,
3433 IN KIRQL Irql);
3434
3435 typedef VOID
3436 (DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
3437 IN struct _IO_CSQ *Csq,
3438 IN PIRP Irp);
3439
3440 typedef struct _IO_CSQ {
3441 ULONG Type;
3442 PIO_CSQ_INSERT_IRP CsqInsertIrp;
3443 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
3444 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
3445 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
3446 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
3447 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
3448 PVOID ReservePointer;
3449 } IO_CSQ, *PIO_CSQ;
3450
3451 #if !defined(_ALPHA_)
3452 #include <pshpack4.h>
3453 #endif
3454 typedef struct _IO_STACK_LOCATION {
3455 UCHAR MajorFunction;
3456 UCHAR MinorFunction;
3457 UCHAR Flags;
3458 UCHAR Control;
3459 union {
3460 struct {
3461 PIO_SECURITY_CONTEXT SecurityContext;
3462 ULONG Options;
3463 USHORT POINTER_ALIGNMENT FileAttributes;
3464 USHORT ShareAccess;
3465 ULONG POINTER_ALIGNMENT EaLength;
3466 } Create;
3467 struct {
3468 ULONG Length;
3469 ULONG POINTER_ALIGNMENT Key;
3470 LARGE_INTEGER ByteOffset;
3471 } Read;
3472 struct {
3473 ULONG Length;
3474 ULONG POINTER_ALIGNMENT Key;
3475 LARGE_INTEGER ByteOffset;
3476 } Write;
3477 struct {
3478 ULONG Length;
3479 PUNICODE_STRING FileName;
3480 FILE_INFORMATION_CLASS FileInformationClass;
3481 ULONG FileIndex;
3482 } QueryDirectory;
3483 struct {
3484 ULONG Length;
3485 ULONG CompletionFilter;
3486 } NotifyDirectory;
3487 struct {
3488 ULONG Length;
3489 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
3490 } QueryFile;
3491 struct {
3492 ULONG Length;
3493 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
3494 PFILE_OBJECT FileObject;
3495 _ANONYMOUS_UNION union {
3496 _ANONYMOUS_STRUCT struct {
3497 BOOLEAN ReplaceIfExists;
3498 BOOLEAN AdvanceOnly;
3499 } DUMMYSTRUCTNAME;
3500 ULONG ClusterCount;
3501 HANDLE DeleteHandle;
3502 } DUMMYUNIONNAME;
3503 } SetFile;
3504 struct {
3505 ULONG Length;
3506 PVOID EaList;
3507 ULONG EaListLength;
3508 ULONG EaIndex;
3509 } QueryEa;
3510 struct {
3511 ULONG Length;
3512 } SetEa;
3513 struct {
3514 ULONG Length;
3515 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
3516 } QueryVolume;
3517 struct {
3518 ULONG Length;
3519 FS_INFORMATION_CLASS FsInformationClass;
3520 } SetVolume;
3521 struct {
3522 ULONG OutputBufferLength;
3523 ULONG InputBufferLength;
3524 ULONG FsControlCode;
3525 PVOID Type3InputBuffer;
3526 } FileSystemControl;
3527 struct {
3528 PLARGE_INTEGER Length;
3529 ULONG Key;
3530 LARGE_INTEGER ByteOffset;
3531 } LockControl;
3532 struct {
3533 ULONG OutputBufferLength;
3534 ULONG POINTER_ALIGNMENT InputBufferLength;
3535 ULONG POINTER_ALIGNMENT IoControlCode;
3536 PVOID Type3InputBuffer;
3537 } DeviceIoControl;
3538 struct {
3539 SECURITY_INFORMATION SecurityInformation;
3540 ULONG POINTER_ALIGNMENT Length;
3541 } QuerySecurity;
3542 struct {
3543 SECURITY_INFORMATION SecurityInformation;
3544 PSECURITY_DESCRIPTOR SecurityDescriptor;
3545 } SetSecurity;
3546 struct {
3547 PVPB Vpb;
3548 PDEVICE_OBJECT DeviceObject;
3549 } MountVolume;
3550 struct {
3551 PVPB Vpb;
3552 PDEVICE_OBJECT DeviceObject;
3553 } VerifyVolume;
3554 struct {
3555 struct _SCSI_REQUEST_BLOCK *Srb;
3556 } Scsi;
3557 struct {
3558 ULONG Length;
3559 PSID StartSid;
3560 struct _FILE_GET_QUOTA_INFORMATION *SidList;
3561 ULONG SidListLength;
3562 } QueryQuota;
3563 struct {
3564 ULONG Length;
3565 } SetQuota;
3566 struct {
3567 DEVICE_RELATION_TYPE Type;
3568 } QueryDeviceRelations;
3569 struct {
3570 CONST GUID *InterfaceType;
3571 USHORT Size;
3572 USHORT Version;
3573 PINTERFACE Interface;
3574 PVOID InterfaceSpecificData;
3575 } QueryInterface;
3576 struct {
3577 PDEVICE_CAPABILITIES Capabilities;
3578 } DeviceCapabilities;
3579 struct {
3580 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
3581 } FilterResourceRequirements;
3582 struct {
3583 ULONG WhichSpace;
3584 PVOID Buffer;
3585 ULONG Offset;
3586 ULONG POINTER_ALIGNMENT Length;
3587 } ReadWriteConfig;
3588 struct {
3589 BOOLEAN Lock;
3590 } SetLock;
3591 struct {
3592 BUS_QUERY_ID_TYPE IdType;
3593 } QueryId;
3594 struct {
3595 DEVICE_TEXT_TYPE DeviceTextType;
3596 LCID POINTER_ALIGNMENT LocaleId;
3597 } QueryDeviceText;
3598 struct {
3599 BOOLEAN InPath;
3600 BOOLEAN Reserved[3];
3601 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
3602 } UsageNotification;
3603 struct {
3604 SYSTEM_POWER_STATE PowerState;
3605 } WaitWake;
3606 struct {
3607 PPOWER_SEQUENCE PowerSequence;
3608 } PowerSequence;
3609 struct {
3610 ULONG SystemContext;
3611 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
3612 POWER_STATE POINTER_ALIGNMENT State;
3613 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
3614 } Power;
3615 struct {
3616 PCM_RESOURCE_LIST AllocatedResources;
3617 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
3618 } StartDevice;
3619 struct {
3620 ULONG_PTR ProviderId;
3621 PVOID DataPath;
3622 ULONG BufferSize;
3623 PVOID Buffer;
3624 } WMI;
3625 struct {
3626 PVOID Argument1;
3627 PVOID Argument2;
3628 PVOID Argument3;
3629 PVOID Argument4;
3630 } Others;
3631 } Parameters;
3632 PDEVICE_OBJECT DeviceObject;
3633 PFILE_OBJECT FileObject;
3634 PIO_COMPLETION_ROUTINE CompletionRoutine;
3635 PVOID Context;
3636 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
3637 #if !defined(_ALPHA_)
3638 #include <poppack.h>
3639 #endif
3640
3641 /* IO_STACK_LOCATION.Control */
3642
3643 #define SL_PENDING_RETURNED 0x01
3644 #define SL_ERROR_RETURNED 0x02
3645 #define SL_INVOKE_ON_CANCEL 0x20
3646 #define SL_INVOKE_ON_SUCCESS 0x40
3647 #define SL_INVOKE_ON_ERROR 0x80
3648
3649 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
3650
3651 #define PCI_WHICHSPACE_CONFIG 0x0
3652 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
3653
3654 typedef enum _KEY_INFORMATION_CLASS {
3655 KeyBasicInformation,
3656 KeyNodeInformation,
3657 KeyFullInformation,
3658 KeyNameInformation,
3659 KeyCachedInformation,
3660 KeyFlagsInformation
3661 } KEY_INFORMATION_CLASS;
3662
3663 typedef struct _KEY_BASIC_INFORMATION {
3664 LARGE_INTEGER LastWriteTime;
3665 ULONG TitleIndex;
3666 ULONG NameLength;
3667 WCHAR Name[1];
3668 } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
3669
3670 typedef struct _KEY_FULL_INFORMATION {
3671 LARGE_INTEGER LastWriteTime;
3672 ULONG TitleIndex;
3673 ULONG ClassOffset;
3674 ULONG ClassLength;
3675 ULONG SubKeys;
3676 ULONG MaxNameLen;
3677 ULONG MaxClassLen;
3678 ULONG Values;
3679 ULONG MaxValueNameLen;
3680 ULONG MaxValueDataLen;
3681 WCHAR Class[1];
3682 } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
3683
3684 typedef struct _KEY_NODE_INFORMATION {
3685 LARGE_INTEGER LastWriteTime;
3686 ULONG TitleIndex;
3687 ULONG ClassOffset;
3688 ULONG ClassLength;
3689 ULONG NameLength;
3690 WCHAR Name[1];
3691 } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
3692
3693 typedef struct _KEY_VALUE_BASIC_INFORMATION {
3694 ULONG TitleIndex;
3695 ULONG Type;
3696 ULONG NameLength;
3697 WCHAR Name[1];
3698 } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
3699
3700 typedef struct _KEY_VALUE_FULL_INFORMATION {
3701 ULONG TitleIndex;
3702 ULONG Type;
3703 ULONG DataOffset;
3704 ULONG DataLength;
3705 ULONG NameLength;
3706 WCHAR Name[1];
3707 } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
3708
3709 typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
3710 ULONG TitleIndex;
3711 ULONG Type;
3712 ULONG DataLength;
3713 UCHAR Data[1];
3714 } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
3715
3716 typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
3717 ULONG Type;
3718 ULONG DataLength;
3719 UCHAR Data[1];
3720 } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
3721
3722 typedef struct _KEY_VALUE_ENTRY {
3723 PUNICODE_STRING ValueName;
3724 ULONG DataLength;
3725 ULONG DataOffset;
3726 ULONG Type;
3727 } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
3728
3729 typedef enum _KEY_VALUE_INFORMATION_CLASS {
3730 KeyValueBasicInformation,
3731 KeyValueFullInformation,
3732 KeyValuePartialInformation,
3733 KeyValueFullInformationAlign64,
3734 KeyValuePartialInformationAlign64
3735 } KEY_VALUE_INFORMATION_CLASS;
3736
3737 typedef struct _KEY_WRITE_TIME_INFORMATION {
3738 LARGE_INTEGER LastWriteTime;
3739 } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
3740
3741 typedef struct _KEY_USER_FLAGS_INFORMATION {
3742 ULONG UserFlags;
3743 } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
3744
3745 typedef enum _KEY_SET_INFORMATION_CLASS {
3746 KeyWriteTimeInformation,
3747 KeyUserFlagsInformation,
3748 MaxKeySetInfoClass
3749 } KEY_SET_INFORMATION_CLASS;
3750
3751 /* KEY_VALUE_Xxx.Type */
3752
3753 #define REG_NONE 0
3754 #define REG_SZ 1
3755 #define REG_EXPAND_SZ 2
3756 #define REG_BINARY 3
3757 #define REG_DWORD 4
3758 #define REG_DWORD_LITTLE_ENDIAN 4
3759 #define REG_DWORD_BIG_ENDIAN 5
3760 #define REG_LINK 6
3761 #define REG_MULTI_SZ 7
3762 #define REG_RESOURCE_LIST 8
3763 #define REG_FULL_RESOURCE_DESCRIPTOR 9
3764 #define REG_RESOURCE_REQUIREMENTS_LIST 10
3765 #define REG_QWORD 11
3766 #define REG_QWORD_LITTLE_ENDIAN 11
3767
3768 #define PCI_TYPE0_ADDRESSES 6
3769 #define PCI_TYPE1_ADDRESSES 2
3770 #define PCI_TYPE2_ADDRESSES 5
3771
3772 typedef struct _PCI_COMMON_CONFIG {
3773 USHORT VendorID;
3774 USHORT DeviceID;
3775 USHORT Command;
3776 USHORT Status;
3777 UCHAR RevisionID;
3778 UCHAR ProgIf;
3779 UCHAR SubClass;
3780 UCHAR BaseClass;
3781 UCHAR CacheLineSize;
3782 UCHAR LatencyTimer;
3783 UCHAR HeaderType;
3784 UCHAR BIST;
3785 union {
3786 struct _PCI_HEADER_TYPE_0 {
3787 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
3788 ULONG CIS;
3789 USHORT SubVendorID;
3790 USHORT SubSystemID;
3791 ULONG ROMBaseAddress;
3792 UCHAR CapabilitiesPtr;
3793 UCHAR Reserved1[3];
3794 ULONG Reserved2;
3795 UCHAR InterruptLine;
3796 UCHAR InterruptPin;
3797 UCHAR MinimumGrant;
3798 UCHAR MaximumLatency;
3799 } type0;
3800 struct _PCI_HEADER_TYPE_1 {
3801 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
3802 UCHAR PrimaryBus;
3803 UCHAR SecondaryBus;
3804 UCHAR SubordinateBus;
3805 UCHAR SecondaryLatency;
3806 UCHAR IOBase;
3807 UCHAR IOLimit;
3808 USHORT SecondaryStatus;
3809 USHORT MemoryBase;
3810 USHORT MemoryLimit;
3811 USHORT PrefetchBase;
3812 USHORT PrefetchLimit;
3813 ULONG PrefetchBaseUpper32;
3814 ULONG PrefetchLimitUpper32;
3815 USHORT IOBaseUpper16;
3816 USHORT IOLimitUpper16;
3817 UCHAR CapabilitiesPtr;
3818 UCHAR Reserved1[3];
3819 ULONG ROMBaseAddress;
3820 UCHAR InterruptLine;
3821 UCHAR InterruptPin;
3822 USHORT BridgeControl;
3823 } type1;
3824 struct _PCI_HEADER_TYPE_2 {
3825 ULONG SocketRegistersBaseAddress;
3826 UCHAR CapabilitiesPtr;
3827 UCHAR Reserved;
3828 USHORT SecondaryStatus;
3829 UCHAR PrimaryBus;
3830 UCHAR SecondaryBus;
3831 UCHAR SubordinateBus;
3832 UCHAR SecondaryLatency;
3833 struct {
3834 ULONG Base;
3835 ULONG Limit;
3836 } Range[PCI_TYPE2_ADDRESSES - 1];
3837 UCHAR InterruptLine;
3838 UCHAR InterruptPin;
3839 USHORT BridgeControl;
3840 } type2;
3841 } u;
3842 UCHAR DeviceSpecific[192];
3843 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3844
3845 /* PCI_COMMON_CONFIG.Command */
3846
3847 #define PCI_ENABLE_IO_SPACE 0x0001
3848 #define PCI_ENABLE_MEMORY_SPACE 0x0002
3849 #define PCI_ENABLE_BUS_MASTER 0x0004
3850 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
3851 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
3852 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
3853 #define PCI_ENABLE_PARITY 0x0040
3854 #define PCI_ENABLE_WAIT_CYCLE 0x0080
3855 #define PCI_ENABLE_SERR 0x0100
3856 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
3857
3858 /* PCI_COMMON_CONFIG.Status */
3859
3860 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
3861 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
3862 #define PCI_STATUS_UDF_SUPPORTED 0x0040
3863 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
3864 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
3865 #define PCI_STATUS_DEVSEL 0x0600
3866 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
3867 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
3868 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
3869 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
3870 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
3871
3872 /* PCI_COMMON_CONFIG.HeaderType */
3873
3874 #define PCI_MULTIFUNCTION 0x80
3875 #define PCI_DEVICE_TYPE 0x00
3876 #define PCI_BRIDGE_TYPE 0x01
3877 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
3878
3879 #define PCI_CONFIGURATION_TYPE(PciData) \
3880 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
3881
3882 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
3883 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
3884
3885 /* PCI device classes */
3886
3887 #define PCI_CLASS_PRE_20 0x00
3888 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
3889 #define PCI_CLASS_NETWORK_CTLR 0x02
3890 #define PCI_CLASS_DISPLAY_CTLR 0x03
3891 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
3892 #define PCI_CLASS_MEMORY_CTLR 0x05
3893 #define PCI_CLASS_BRIDGE_DEV 0x06
3894 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
3895 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
3896 #define PCI_CLASS_INPUT_DEV 0x09
3897 #define PCI_CLASS_DOCKING_STATION 0x0a
3898 #define PCI_CLASS_PROCESSOR 0x0b
3899 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
3900
3901 /* PCI device subclasses for class 0 */
3902
3903 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
3904 #define PCI_SUBCLASS_PRE_20_VGA 0x01
3905
3906 /* PCI device subclasses for class 1 (mass storage controllers)*/
3907
3908 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
3909 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
3910 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
3911 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
3912 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
3913 #define PCI_SUBCLASS_MSC_OTHER 0x80
3914
3915 /* PCI device subclasses for class 2 (network controllers)*/
3916
3917 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
3918 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
3919 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
3920 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
3921 #define PCI_SUBCLASS_NET_OTHER 0x80
3922
3923 /* PCI device subclasses for class 3 (display controllers)*/
3924
3925 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
3926 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
3927 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
3928 #define PCI_SUBCLASS_VID_OTHER 0x80
3929
3930 /* PCI device subclasses for class 4 (multimedia device)*/
3931
3932 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
3933 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
3934 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
3935 #define PCI_SUBCLASS_MM_OTHER 0x80
3936
3937 /* PCI device subclasses for class 5 (memory controller)*/
3938
3939 #define PCI_SUBCLASS_MEM_RAM 0x00
3940 #define PCI_SUBCLASS_MEM_FLASH 0x01
3941 #define PCI_SUBCLASS_MEM_OTHER 0x80
3942
3943 /* PCI device subclasses for class 6 (bridge device)*/
3944
3945 #define PCI_SUBCLASS_BR_HOST 0x00
3946 #define PCI_SUBCLASS_BR_ISA 0x01
3947 #define PCI_SUBCLASS_BR_EISA 0x02
3948 #define PCI_SUBCLASS_BR_MCA 0x03
3949 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
3950 #define PCI_SUBCLASS_BR_PCMCIA 0x05
3951 #define PCI_SUBCLASS_BR_NUBUS 0x06
3952 #define PCI_SUBCLASS_BR_CARDBUS 0x07
3953 #define PCI_SUBCLASS_BR_OTHER 0x80
3954
3955 /* PCI device subclasses for class C (serial bus controller)*/
3956
3957 #define PCI_SUBCLASS_SB_IEEE1394 0x00
3958 #define PCI_SUBCLASS_SB_ACCESS 0x01
3959 #define PCI_SUBCLASS_SB_SSA 0x02
3960 #define PCI_SUBCLASS_SB_USB 0x03
3961 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
3962 #define PCI_SUBCLASS_SB_SMBUS 0x05
3963
3964 #define PCI_MAX_DEVICES 32
3965 #define PCI_MAX_FUNCTION 8
3966 #define PCI_MAX_BRIDGE_NUMBER 0xFF
3967 #define PCI_INVALID_VENDORID 0xFFFF
3968 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
3969
3970 #define PCI_ADDRESS_MEMORY_SPACE 0x00000000
3971 #define PCI_ADDRESS_IO_SPACE 0x00000001
3972 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
3973 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
3974 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
3975 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
3976 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
3977
3978 #define PCI_TYPE_32BIT 0
3979 #define PCI_TYPE_20BIT 2
3980 #define PCI_TYPE_64BIT 4
3981
3982 typedef struct _PCI_SLOT_NUMBER {
3983 union {
3984 struct {
3985 ULONG DeviceNumber : 5;
3986 ULONG FunctionNumber : 3;
3987 ULONG Reserved : 24;
3988 } bits;
3989 ULONG AsULONG;
3990 } u;
3991 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
3992
3993 #define POOL_COLD_ALLOCATION 256
3994 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8
3995 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16
3996
3997 typedef struct _OSVERSIONINFOA {
3998 ULONG dwOSVersionInfoSize;
3999 ULONG dwMajorVersion;
4000 ULONG dwMinorVersion;
4001 ULONG dwBuildNumber;
4002 ULONG dwPlatformId;
4003 CHAR szCSDVersion[128];
4004 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
4005
4006 typedef struct _OSVERSIONINFOW {
4007 ULONG dwOSVersionInfoSize;
4008 ULONG dwMajorVersion;
4009 ULONG dwMinorVersion;
4010 ULONG dwBuildNumber;
4011 ULONG dwPlatformId;
4012 WCHAR szCSDVersion[128];
4013 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
4014
4015 #ifdef UNICODE
4016 typedef OSVERSIONINFOW OSVERSIONINFO;
4017 typedef POSVERSIONINFOW POSVERSIONINFO;
4018 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
4019 #else
4020 typedef OSVERSIONINFOA OSVERSIONINFO;
4021 typedef POSVERSIONINFOA POSVERSIONINFO;
4022 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
4023 #endif // UNICODE
4024
4025 typedef struct _OSVERSIONINFOEXA {
4026 ULONG dwOSVersionInfoSize;
4027 ULONG dwMajorVersion;
4028 ULONG dwMinorVersion;
4029 ULONG dwBuildNumber;
4030 ULONG dwPlatformId;
4031 CHAR szCSDVersion[128];
4032 USHORT wServicePackMajor;
4033 USHORT wServicePackMinor;
4034 USHORT wSuiteMask;
4035 UCHAR wProductType;
4036 UCHAR wReserved;
4037 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
4038
4039 typedef struct _OSVERSIONINFOEXW {
4040 ULONG dwOSVersionInfoSize;
4041 ULONG dwMajorVersion;
4042 ULONG dwMinorVersion;
4043 ULONG dwBuildNumber;
4044 ULONG dwPlatformId;
4045 WCHAR szCSDVersion[128];
4046 USHORT wServicePackMajor;
4047 USHORT wServicePackMinor;
4048 USHORT wSuiteMask;
4049 UCHAR wProductType;
4050 UCHAR wReserved;
4051 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
4052
4053 #ifdef UNICODE
4054 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
4055 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
4056 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
4057 #else
4058 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
4059 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
4060 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
4061 #endif // UNICODE
4062
4063 NTSYSAPI
4064 ULONGLONG
4065 DDKAPI
4066 VerSetConditionMask(
4067 IN ULONGLONG ConditionMask,
4068 IN ULONG TypeMask,
4069 IN UCHAR Condition);
4070
4071 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
4072 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
4073 (TypeBitMask), (ComparisonType)))
4074
4075 /* RtlVerifyVersionInfo() TypeMask */
4076
4077 #define VER_MINORVERSION 0x0000001
4078 #define VER_MAJORVERSION 0x0000002
4079 #define VER_BUILDNUMBER 0x0000004
4080 #define VER_PLATFORMID 0x0000008
4081 #define VER_SERVICEPACKMINOR 0x0000010
4082 #define VER_SERVICEPACKMAJOR 0x0000020
4083 #define VER_SUITENAME 0x0000040
4084 #define VER_PRODUCT_TYPE 0x0000080
4085
4086 /* RtlVerifyVersionInfo() ComparisonType */
4087
4088 #define VER_EQUAL 1
4089 #define VER_GREATER 2
4090 #define VER_GREATER_EQUAL 3
4091 #define VER_LESS 4
4092 #define VER_LESS_EQUAL 5
4093 #define VER_AND 6
4094 #define VER_OR 7
4095
4096 #define VER_CONDITION_MASK 7
4097 #define VER_NUM_BITS_PER_CONDITION_MASK 3
4098
4099 struct _RTL_RANGE;
4100
4101 typedef BOOLEAN
4102 (NTAPI *PRTL_CONFLICT_RANGE_CALLBACK) (
4103 PVOID Context,
4104 struct _RTL_RANGE *Range
4105 );
4106
4107 typedef enum _EVENT_TYPE {
4108 NotificationEvent,
4109 SynchronizationEvent
4110 } EVENT_TYPE;
4111
4112 typedef enum _KWAIT_REASON {
4113 Executive,
4114 FreePage,
4115 PageIn,
4116 PoolAllocation,
4117 DelayExecution,
4118 Suspended,
4119 UserRequest,
4120 WrExecutive,
4121 WrFreePage,
4122 WrPageIn,
4123 WrPoolAllocation,
4124 WrDelayExecution,
4125 WrSuspended,
4126 WrUserRequest,
4127 WrEventPair,
4128 WrQueue,
4129 WrLpcReceive,
4130 WrLpcReply,
4131 WrVirtualMemory,
4132 WrPageOut,
4133 WrRendezvous,
4134 Spare2,
4135 WrGuardedMutex,
4136 Spare4,
4137 Spare5,
4138 Spare6,
4139 WrKernel,
4140 WrResource,
4141 WrPushLock,
4142 WrMutex,
4143 WrQuantumEnd,
4144 WrDispatchInt,
4145 WrPreempted,
4146 WrYieldExecution,
4147 MaximumWaitReason
4148 } KWAIT_REASON;
4149
4150 typedef struct _KWAIT_BLOCK {
4151 LIST_ENTRY WaitListEntry;
4152 struct _KTHREAD * RESTRICTED_POINTER Thread;
4153 PVOID Object;
4154 struct _KWAIT_BLOCK * RESTRICTED_POINTER NextWaitBlock;
4155 USHORT WaitKey;
4156 UCHAR WaitType;
4157 UCHAR SpareByte;
4158 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
4159
4160 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
4161
4162 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
4163 BOOLEAN Removed;
4164 BOOLEAN Reserved[3];
4165 volatile LONG IoCount;
4166 KEVENT RemoveEvent;
4167 } IO_REMOVE_LOCK_COMMON_BLOCK;
4168
4169 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
4170 LONG Signature;
4171 LONG HighWatermark;
4172 LONGLONG MaxLockedTicks;
4173 LONG AllocateTag;
4174 LIST_ENTRY LockList;
4175 KSPIN_LOCK Spin;
4176 volatile LONG LowMemoryCount;
4177 ULONG Reserved1[4];
4178 PVOID Reserved2;
4179 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
4180 } IO_REMOVE_LOCK_DBG_BLOCK;
4181
4182 typedef struct _IO_REMOVE_LOCK {
4183 IO_REMOVE_LOCK_COMMON_BLOCK Common;
4184 #if DBG
4185 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
4186 #endif
4187 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
4188
4189 typedef struct _IO_WORKITEM *PIO_WORKITEM;
4190
4191 typedef VOID
4192 (DDKAPI IO_WORKITEM_ROUTINE)(
4193 IN PDEVICE_OBJECT DeviceObject,
4194 IN PVOID Context);
4195 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
4196
4197 typedef struct _SHARE_ACCESS {
4198 ULONG OpenCount;
4199 ULONG Readers;
4200 ULONG Writers;
4201 ULONG Deleters;
4202 ULONG SharedRead;
4203 ULONG SharedWrite;
4204 ULONG SharedDelete;
4205 } SHARE_ACCESS, *PSHARE_ACCESS;
4206
4207 typedef enum _KINTERRUPT_MODE {
4208 LevelSensitive,
4209 Latched
4210 } KINTERRUPT_MODE;
4211
4212 #define THREAD_WAIT_OBJECTS 3
4213
4214 typedef VOID
4215 (DDKAPI *PKINTERRUPT_ROUTINE)(
4216 VOID);
4217
4218 typedef enum _CREATE_FILE_TYPE {
4219 CreateFileTypeNone,
4220 CreateFileTypeNamedPipe,
4221 CreateFileTypeMailslot
4222 } CREATE_FILE_TYPE;
4223
4224 typedef struct _CONFIGURATION_INFORMATION {
4225 ULONG DiskCount;
4226 ULONG FloppyCount;
4227 ULONG CdRomCount;
4228 ULONG TapeCount;
4229 ULONG ScsiPortCount;
4230 ULONG SerialCount;
4231 ULONG ParallelCount;
4232 BOOLEAN AtDiskPrimaryAddressClaimed;
4233 BOOLEAN AtDiskSecondaryAddressClaimed;
4234 ULONG Version;
4235 ULONG MediumChangerCount;
4236 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
4237
4238 typedef enum _CONFIGURATION_TYPE {
4239 ArcSystem,
4240 CentralProcessor,
4241 FloatingPointProcessor,
4242 PrimaryIcache,
4243 PrimaryDcache,
4244 SecondaryIcache,
4245 SecondaryDcache,
4246 SecondaryCache,
4247 EisaAdapter,
4248 TcAdapter,
4249 ScsiAdapter,
4250 DtiAdapter,
4251 MultiFunctionAdapter,
4252 DiskController,
4253 TapeController,
4254 CdromController,
4255 WormController,
4256 SerialController,
4257 NetworkController,
4258 DisplayController,
4259 ParallelController,
4260 PointerController,
4261 KeyboardController,
4262 AudioController,
4263 OtherController,
4264 DiskPeripheral,
4265 FloppyDiskPeripheral,
4266 TapePeripheral,
4267 ModemPeripheral,
4268 MonitorPeripheral,
4269 PrinterPeripheral,
4270 PointerPeripheral,
4271 KeyboardPeripheral,
4272 TerminalPeripheral,
4273 OtherPeripheral,
4274 LinePeripheral,
4275 NetworkPeripheral,
4276 SystemMemory,
4277 DockingInformation,
4278 RealModeIrqRoutingTable,
4279 RealModePCIEnumeration,
4280 MaximumType
4281 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
4282
4283 #define IO_FORCE_ACCESS_CHECK 0x001
4284 #define IO_NO_PARAMETER_CHECKING 0x100
4285
4286 #define IO_REPARSE 0x0
4287 #define IO_REMOUNT 0x1
4288
4289 typedef NTSTATUS
4290 (DDKAPI *PIO_QUERY_DEVICE_ROUTINE)(
4291 IN PVOID Context,
4292 IN PUNICODE_STRING PathName,
4293 IN INTERFACE_TYPE BusType,
4294 IN ULONG BusNumber,
4295 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
4296 IN CONFIGURATION_TYPE ControllerType,
4297 IN ULONG ControllerNumber,
4298 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
4299 IN CONFIGURATION_TYPE PeripheralType,
4300 IN ULONG PeripheralNumber,
4301 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
4302
4303 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
4304 IoQueryDeviceIdentifier = 0,
4305 IoQueryDeviceConfigurationData,
4306 IoQueryDeviceComponentInformation,
4307 IoQueryDeviceMaxData
4308 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
4309
4310 typedef enum _KBUGCHECK_CALLBACK_REASON {
4311 KbCallbackInvalid,
4312 KbCallbackReserved1,
4313 KbCallbackSecondaryDumpData,
4314 KbCallbackDumpIo,
4315 } KBUGCHECK_CALLBACK_REASON;
4316
4317 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
4318
4319 typedef VOID
4320 (DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)(
4321 IN KBUGCHECK_CALLBACK_REASON Reason,
4322 IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
4323 IN OUT PVOID ReasonSpecificData,
4324 IN ULONG ReasonSpecificDataLength);
4325
4326 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
4327 LIST_ENTRY Entry;
4328 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
4329 PUCHAR Component;
4330 ULONG_PTR Checksum;
4331 KBUGCHECK_CALLBACK_REASON Reason;
4332 UCHAR State;
4333 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
4334
4335 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
4336 BufferEmpty,
4337 BufferInserted,
4338 BufferStarted,
4339 BufferFinished,
4340 BufferIncomplete
4341 } KBUGCHECK_BUFFER_DUMP_STATE;
4342
4343 typedef VOID
4344 (DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)(
4345 IN PVOID Buffer,
4346 IN ULONG Length);
4347
4348 typedef struct _KBUGCHECK_CALLBACK_RECORD {
4349 LIST_ENTRY Entry;
4350 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
4351 PVOID Buffer;
4352 ULONG Length;
4353 PUCHAR Component;
4354 ULONG_PTR Checksum;
4355 UCHAR State;
4356 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
4357
4358 typedef BOOLEAN
4359 (DDKAPI *PNMI_CALLBACK)(
4360 IN PVOID Context,
4361 IN BOOLEAN Handled);
4362
4363 /*
4364 * VOID
4365 * KeInitializeCallbackRecord(
4366 * IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
4367 */
4368 #define KeInitializeCallbackRecord(CallbackRecord) \
4369 CallbackRecord->State = BufferEmpty;
4370
4371 typedef enum _KDPC_IMPORTANCE {
4372 LowImportance,
4373 MediumImportance,
4374 HighImportance
4375 } KDPC_IMPORTANCE;
4376
4377 typedef enum _MEMORY_CACHING_TYPE_ORIG {
4378 MmFrameBufferCached = 2
4379 } MEMORY_CACHING_TYPE_ORIG;
4380
4381 typedef enum _MEMORY_CACHING_TYPE {
4382 MmNonCached = FALSE,
4383 MmCached = TRUE,
4384 MmWriteCombined = MmFrameBufferCached,
4385 MmHardwareCoherentCached,
4386 MmNonCachedUnordered,
4387 MmUSWCCached,
4388 MmMaximumCacheType
4389 } MEMORY_CACHING_TYPE;
4390
4391 typedef enum _MM_PAGE_PRIORITY {
4392 LowPagePriority,
4393 NormalPagePriority = 16,
4394 HighPagePriority = 32
4395 } MM_PAGE_PRIORITY;
4396
4397 typedef enum _LOCK_OPERATION {
4398 IoReadAccess,
4399 IoWriteAccess,
4400 IoModifyAccess
4401 } LOCK_OPERATION;
4402
4403 #define FLUSH_MULTIPLE_MAXIMUM 32
4404
4405 typedef enum _MM_SYSTEM_SIZE {
4406 MmSmallSystem,
4407 MmMediumSystem,
4408 MmLargeSystem
4409 } MM_SYSTEMSIZE;
4410
4411 typedef struct _OBJECT_HANDLE_INFORMATION {
4412 ULONG HandleAttributes;
4413 ACCESS_MASK GrantedAccess;
4414 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
4415
4416 typedef struct _CLIENT_ID {
4417 HANDLE UniqueProcess;
4418 HANDLE UniqueThread;
4419 } CLIENT_ID, *PCLIENT_ID;
4420
4421 typedef VOID
4422 (DDKAPI *PKSTART_ROUTINE)(
4423 IN PVOID StartContext);
4424
4425 typedef VOID
4426 (DDKAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
4427 IN HANDLE ParentId,
4428 IN HANDLE ProcessId,
4429 IN BOOLEAN Create);
4430
4431 typedef VOID
4432 (DDKAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
4433 IN HANDLE ProcessId,
4434 IN HANDLE ThreadId,
4435 IN BOOLEAN Create);
4436
4437 typedef struct _IMAGE_INFO {
4438 _ANONYMOUS_UNION union {
4439 ULONG Properties;
4440 _ANONYMOUS_STRUCT struct {
4441 ULONG ImageAddressingMode : 8;
4442 ULONG SystemModeImage : 1;
4443 ULONG ImageMappedToAllPids : 1;
4444 ULONG Reserved : 22;
4445 } DUMMYSTRUCTNAME;
4446 } DUMMYUNIONNAME;
4447 PVOID ImageBase;
4448 ULONG ImageSelector;
4449 SIZE_T ImageSize;
4450 ULONG ImageSectionNumber;
4451 } IMAGE_INFO, *PIMAGE_INFO;
4452
4453 #define IMAGE_ADDRESSING_MODE_32BIT 3
4454
4455 typedef VOID
4456 (DDKAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
4457 IN PUNICODE_STRING FullImageName,
4458 IN HANDLE ProcessId,
4459 IN PIMAGE_INFO ImageInfo);
4460
4461 #pragma pack(push,4)
4462 typedef enum _BUS_DATA_TYPE {
4463 ConfigurationSpaceUndefined = -1,
4464 Cmos,
4465 EisaConfiguration,
4466 Pos,
4467 CbusConfiguration,
4468 PCIConfiguration,
4469 VMEConfiguration,
4470 NuBusConfiguration,
4471 PCMCIAConfiguration,
4472 MPIConfiguration,
4473 MPSAConfiguration,
4474 PNPISAConfiguration,
4475 SgiInternalConfiguration,
4476 MaximumBusDataType
4477 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
4478 #pragma pack(pop)
4479
4480 typedef struct _NT_TIB {
4481 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
4482 PVOID StackBase;
4483 PVOID StackLimit;
4484 PVOID SubSystemTib;
4485 _ANONYMOUS_UNION union {
4486 PVOID FiberData;
4487 ULONG Version;
4488 } DUMMYUNIONNAME;
4489 PVOID ArbitraryUserPointer;
4490 struct _NT_TIB *Self;
4491 } NT_TIB, *PNT_TIB;
4492
4493 typedef struct _NT_TIB32 {
4494 ULONG ExceptionList;
4495 ULONG StackBase;
4496 ULONG StackLimit;
4497 ULONG SubSystemTib;
4498 __GNU_EXTENSION union {
4499 ULONG FiberData;
4500 ULONG Version;
4501 };
4502 ULONG ArbitraryUserPointer;
4503 ULONG Self;
4504 } NT_TIB32,*PNT_TIB32;
4505
4506 typedef struct _NT_TIB64 {
4507 ULONG64 ExceptionList;
4508 ULONG64 StackBase;
4509 ULONG64 StackLimit;
4510 ULONG64 SubSystemTib;
4511 __GNU_EXTENSION union {
4512 ULONG64 FiberData;
4513 ULONG Version;
4514 };
4515 ULONG64 ArbitraryUserPointer;
4516 ULONG64 Self;
4517 } NT_TIB64,*PNT_TIB64;
4518
4519 typedef enum _PROCESSINFOCLASS {
4520 ProcessBasicInformation,
4521 ProcessQuotaLimits,
4522 ProcessIoCounters,
4523 ProcessVmCounters,
4524 ProcessTimes,
4525 ProcessBasePriority,
4526 ProcessRaisePriority,
4527 ProcessDebugPort,
4528 ProcessExceptionPort,
4529 ProcessAccessToken,
4530 ProcessLdtInformation,
4531 ProcessLdtSize,
4532 ProcessDefaultHardErrorMode,
4533 ProcessIoPortHandlers,
4534 ProcessPooledUsageAndLimits,
4535 ProcessWorkingSetWatch,
4536 ProcessUserModeIOPL,
4537 ProcessEnableAlignmentFaultFixup,
4538 ProcessPriorityClass,
4539 ProcessWx86Information,
4540 ProcessHandleCount,
4541 ProcessAffinityMask,
4542 ProcessPriorityBoost,
4543 ProcessDeviceMap,
4544 ProcessSessionInformation,
4545 ProcessForegroundInformation,
4546 ProcessWow64Information,
4547 ProcessImageFileName,
4548 ProcessLUIDDeviceMapsEnabled,
4549 ProcessBreakOnTermination,
4550 ProcessDebugObjectHandle,
4551 ProcessDebugFlags,
4552 ProcessHandleTracing,
4553 ProcessIoPriority,
4554 ProcessExecuteFlags,
4555 ProcessTlsInformation,
4556 ProcessCookie,
4557 ProcessImageInformation,
4558 ProcessCycleTime,
4559 ProcessPagePriority,
4560 ProcessInstrumentationCallback,
4561 MaxProcessInfoClass
4562 } PROCESSINFOCLASS;
4563
4564 typedef enum _THREADINFOCLASS {
4565 ThreadBasicInformation,
4566 ThreadTimes,
4567 ThreadPriority,
4568 ThreadBasePriority,
4569 ThreadAffinityMask,
4570 ThreadImpersonationToken,
4571 ThreadDescriptorTableEntry,
4572 ThreadEnableAlignmentFaultFixup,
4573 ThreadEventPair_Reusable,
4574 ThreadQuerySetWin32StartAddress,
4575 ThreadZeroTlsCell,
4576 ThreadPerformanceCount,
4577 ThreadAmILastThread,
4578 ThreadIdealProcessor,
4579 ThreadPriorityBoost,
4580 ThreadSetTlsArrayAddress,
4581 ThreadIsIoPending,
4582 ThreadHideFromDebugger,
4583 ThreadBreakOnTermination,
4584 ThreadSwitchLegacyState,
4585 ThreadIsTerminated,
4586 ThreadLastSystemCall,
4587 ThreadIoPriority,
4588 ThreadCycleTime,
4589 ThreadPagePriority,