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