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