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