- 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 typedef struct _PCI_COMMON_CONFIG {
1128 USHORT VendorID;
1129 USHORT DeviceID;
1130 USHORT Command;
1131 USHORT Status;
1132 UCHAR RevisionID;
1133 UCHAR ProgIf;
1134 UCHAR SubClass;
1135 UCHAR BaseClass;
1136 UCHAR CacheLineSize;
1137 UCHAR LatencyTimer;
1138 UCHAR HeaderType;
1139 UCHAR BIST;
1140 union {
1141 struct _PCI_HEADER_TYPE_0 {
1142 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
1143 ULONG CIS;
1144 USHORT SubVendorID;
1145 USHORT SubSystemID;
1146 ULONG ROMBaseAddress;
1147 UCHAR CapabilitiesPtr;
1148 UCHAR Reserved1[3];
1149 ULONG Reserved2;
1150 UCHAR InterruptLine;
1151 UCHAR InterruptPin;
1152 UCHAR MinimumGrant;
1153 UCHAR MaximumLatency;
1154 } type0;
1155 struct _PCI_HEADER_TYPE_1 {
1156 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
1157 UCHAR PrimaryBus;
1158 UCHAR SecondaryBus;
1159 UCHAR SubordinateBus;
1160 UCHAR SecondaryLatency;
1161 UCHAR IOBase;
1162 UCHAR IOLimit;
1163 USHORT SecondaryStatus;
1164 USHORT MemoryBase;
1165 USHORT MemoryLimit;
1166 USHORT PrefetchBase;
1167 USHORT PrefetchLimit;
1168 ULONG PrefetchBaseUpper32;
1169 ULONG PrefetchLimitUpper32;
1170 USHORT IOBaseUpper16;
1171 USHORT IOLimitUpper16;
1172 UCHAR CapabilitiesPtr;
1173 UCHAR Reserved1[3];
1174 ULONG ROMBaseAddress;
1175 UCHAR InterruptLine;
1176 UCHAR InterruptPin;
1177 USHORT BridgeControl;
1178 } type1;
1179 struct _PCI_HEADER_TYPE_2 {
1180 ULONG SocketRegistersBaseAddress;
1181 UCHAR CapabilitiesPtr;
1182 UCHAR Reserved;
1183 USHORT SecondaryStatus;
1184 UCHAR PrimaryBus;
1185 UCHAR SecondaryBus;
1186 UCHAR SubordinateBus;
1187 UCHAR SecondaryLatency;
1188 struct {
1189 ULONG Base;
1190 ULONG Limit;
1191 } Range[PCI_TYPE2_ADDRESSES - 1];
1192 UCHAR InterruptLine;
1193 UCHAR InterruptPin;
1194 USHORT BridgeControl;
1195 } type2;
1196 } u;
1197 UCHAR DeviceSpecific[192];
1198 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
1199
1200
1201 #define PCI_ADDRESS_MEMORY_SPACE 0x00000000
1202
1203 typedef struct _OSVERSIONINFOA {
1204 ULONG dwOSVersionInfoSize;
1205 ULONG dwMajorVersion;
1206 ULONG dwMinorVersion;
1207 ULONG dwBuildNumber;
1208 ULONG dwPlatformId;
1209 CHAR szCSDVersion[128];
1210 } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
1211
1212 typedef struct _OSVERSIONINFOW {
1213 ULONG dwOSVersionInfoSize;
1214 ULONG dwMajorVersion;
1215 ULONG dwMinorVersion;
1216 ULONG dwBuildNumber;
1217 ULONG dwPlatformId;
1218 WCHAR szCSDVersion[128];
1219 } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW;
1220
1221 #ifdef UNICODE
1222 typedef OSVERSIONINFOW OSVERSIONINFO;
1223 typedef POSVERSIONINFOW POSVERSIONINFO;
1224 typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
1225 #else
1226 typedef OSVERSIONINFOA OSVERSIONINFO;
1227 typedef POSVERSIONINFOA POSVERSIONINFO;
1228 typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
1229 #endif // UNICODE
1230
1231 typedef struct _OSVERSIONINFOEXA {
1232 ULONG dwOSVersionInfoSize;
1233 ULONG dwMajorVersion;
1234 ULONG dwMinorVersion;
1235 ULONG dwBuildNumber;
1236 ULONG dwPlatformId;
1237 CHAR szCSDVersion[128];
1238 USHORT wServicePackMajor;
1239 USHORT wServicePackMinor;
1240 USHORT wSuiteMask;
1241 UCHAR wProductType;
1242 UCHAR wReserved;
1243 } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
1244
1245 typedef struct _OSVERSIONINFOEXW {
1246 ULONG dwOSVersionInfoSize;
1247 ULONG dwMajorVersion;
1248 ULONG dwMinorVersion;
1249 ULONG dwBuildNumber;
1250 ULONG dwPlatformId;
1251 WCHAR szCSDVersion[128];
1252 USHORT wServicePackMajor;
1253 USHORT wServicePackMinor;
1254 USHORT wSuiteMask;
1255 UCHAR wProductType;
1256 UCHAR wReserved;
1257 } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW;
1258
1259 #ifdef UNICODE
1260 typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
1261 typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
1262 typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
1263 #else
1264 typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
1265 typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
1266 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
1267 #endif // UNICODE
1268
1269 NTSYSAPI
1270 ULONGLONG
1271 DDKAPI
1272 VerSetConditionMask(
1273 IN ULONGLONG ConditionMask,
1274 IN ULONG TypeMask,
1275 IN UCHAR Condition);
1276
1277 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
1278 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
1279 (TypeBitMask), (ComparisonType)))
1280
1281 /* RtlVerifyVersionInfo() TypeMask */
1282
1283 #define VER_MINORVERSION 0x0000001
1284 #define VER_MAJORVERSION 0x0000002
1285 #define VER_BUILDNUMBER 0x0000004
1286 #define VER_PLATFORMID 0x0000008
1287 #define VER_SERVICEPACKMINOR 0x0000010
1288 #define VER_SERVICEPACKMAJOR 0x0000020
1289 #define VER_SUITENAME 0x0000040
1290 #define VER_PRODUCT_TYPE 0x0000080
1291
1292 /* RtlVerifyVersionInfo() ComparisonType */
1293
1294 #define VER_EQUAL 1
1295 #define VER_GREATER 2
1296 #define VER_GREATER_EQUAL 3
1297 #define VER_LESS 4
1298 #define VER_LESS_EQUAL 5
1299 #define VER_AND 6
1300 #define VER_OR 7
1301
1302 #define VER_CONDITION_MASK 7
1303 #define VER_NUM_BITS_PER_CONDITION_MASK 3
1304
1305 struct _RTL_RANGE;
1306
1307 typedef BOOLEAN
1308 (NTAPI *PRTL_CONFLICT_RANGE_CALLBACK) (
1309 PVOID Context,
1310 struct _RTL_RANGE *Range
1311 );
1312
1313 typedef enum _EVENT_TYPE {
1314 NotificationEvent,
1315 SynchronizationEvent
1316 } EVENT_TYPE;
1317
1318 typedef struct _KWAIT_BLOCK {
1319 LIST_ENTRY WaitListEntry;
1320 struct _KTHREAD * RESTRICTED_POINTER Thread;
1321 PVOID Object;
1322 struct _KWAIT_BLOCK * RESTRICTED_POINTER NextWaitBlock;
1323 USHORT WaitKey;
1324 UCHAR WaitType;
1325 UCHAR SpareByte;
1326 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
1327
1328 typedef enum _KINTERRUPT_MODE {
1329 LevelSensitive,
1330 Latched
1331 } KINTERRUPT_MODE;
1332
1333 #define THREAD_WAIT_OBJECTS 3
1334
1335 typedef VOID
1336 (DDKAPI *PKINTERRUPT_ROUTINE)(
1337 VOID);
1338
1339 typedef enum _CREATE_FILE_TYPE {
1340 CreateFileTypeNone,
1341 CreateFileTypeNamedPipe,
1342 CreateFileTypeMailslot
1343 } CREATE_FILE_TYPE;
1344
1345 typedef struct _CONFIGURATION_INFORMATION {
1346 ULONG DiskCount;
1347 ULONG FloppyCount;
1348 ULONG CdRomCount;
1349 ULONG TapeCount;
1350 ULONG ScsiPortCount;
1351 ULONG SerialCount;
1352 ULONG ParallelCount;
1353 BOOLEAN AtDiskPrimaryAddressClaimed;
1354 BOOLEAN AtDiskSecondaryAddressClaimed;
1355 ULONG Version;
1356 ULONG MediumChangerCount;
1357 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
1358
1359 typedef enum _CONFIGURATION_TYPE {
1360 ArcSystem,
1361 CentralProcessor,
1362 FloatingPointProcessor,
1363 PrimaryIcache,
1364 PrimaryDcache,
1365 SecondaryIcache,
1366 SecondaryDcache,
1367 SecondaryCache,
1368 EisaAdapter,
1369 TcAdapter,
1370 ScsiAdapter,
1371 DtiAdapter,
1372 MultiFunctionAdapter,
1373 DiskController,
1374 TapeController,
1375 CdromController,
1376 WormController,
1377 SerialController,
1378 NetworkController,
1379 DisplayController,
1380 ParallelController,
1381 PointerController,
1382 KeyboardController,
1383 AudioController,
1384 OtherController,
1385 DiskPeripheral,
1386 FloppyDiskPeripheral,
1387 TapePeripheral,
1388 ModemPeripheral,
1389 MonitorPeripheral,
1390 PrinterPeripheral,
1391 PointerPeripheral,
1392 KeyboardPeripheral,
1393 TerminalPeripheral,
1394 OtherPeripheral,
1395 LinePeripheral,
1396 NetworkPeripheral,
1397 SystemMemory,
1398 DockingInformation,
1399 RealModeIrqRoutingTable,
1400 RealModePCIEnumeration,
1401 MaximumType
1402 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
1403
1404 #define IO_FORCE_ACCESS_CHECK 0x001
1405 #define IO_NO_PARAMETER_CHECKING 0x100
1406
1407 #define IO_REPARSE 0x0
1408 #define IO_REMOUNT 0x1
1409
1410 typedef NTSTATUS
1411 (DDKAPI *PIO_QUERY_DEVICE_ROUTINE)(
1412 IN PVOID Context,
1413 IN PUNICODE_STRING PathName,
1414 IN INTERFACE_TYPE BusType,
1415 IN ULONG BusNumber,
1416 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
1417 IN CONFIGURATION_TYPE ControllerType,
1418 IN ULONG ControllerNumber,
1419 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
1420 IN CONFIGURATION_TYPE PeripheralType,
1421 IN ULONG PeripheralNumber,
1422 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
1423
1424 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
1425 IoQueryDeviceIdentifier = 0,
1426 IoQueryDeviceConfigurationData,
1427 IoQueryDeviceComponentInformation,
1428 IoQueryDeviceMaxData
1429 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
1430
1431 typedef enum _KBUGCHECK_CALLBACK_REASON {
1432 KbCallbackInvalid,
1433 KbCallbackReserved1,
1434 KbCallbackSecondaryDumpData,
1435 KbCallbackDumpIo,
1436 } KBUGCHECK_CALLBACK_REASON;
1437
1438 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
1439
1440 typedef VOID
1441 (DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)(
1442 IN KBUGCHECK_CALLBACK_REASON Reason,
1443 IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
1444 IN OUT PVOID ReasonSpecificData,
1445 IN ULONG ReasonSpecificDataLength);
1446
1447 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
1448 LIST_ENTRY Entry;
1449 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
1450 PUCHAR Component;
1451 ULONG_PTR Checksum;
1452 KBUGCHECK_CALLBACK_REASON Reason;
1453 UCHAR State;
1454 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
1455
1456 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
1457 BufferEmpty,
1458 BufferInserted,
1459 BufferStarted,
1460 BufferFinished,
1461 BufferIncomplete
1462 } KBUGCHECK_BUFFER_DUMP_STATE;
1463
1464 typedef VOID
1465 (DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)(
1466 IN PVOID Buffer,
1467 IN ULONG Length);
1468
1469 typedef struct _KBUGCHECK_CALLBACK_RECORD {
1470 LIST_ENTRY Entry;
1471 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
1472 PVOID Buffer;
1473 ULONG Length;
1474 PUCHAR Component;
1475 ULONG_PTR Checksum;
1476 UCHAR State;
1477 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
1478
1479 typedef BOOLEAN
1480 (DDKAPI *PNMI_CALLBACK)(
1481 IN PVOID Context,
1482 IN BOOLEAN Handled);
1483
1484 /*
1485 * VOID
1486 * KeInitializeCallbackRecord(
1487 * IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
1488 */
1489 #define KeInitializeCallbackRecord(CallbackRecord) \
1490 CallbackRecord->State = BufferEmpty;
1491
1492 typedef enum _KDPC_IMPORTANCE {
1493 LowImportance,
1494 MediumImportance,
1495 HighImportance
1496 } KDPC_IMPORTANCE;
1497
1498 typedef enum _MEMORY_CACHING_TYPE_ORIG {
1499 MmFrameBufferCached = 2
1500 } MEMORY_CACHING_TYPE_ORIG;
1501
1502 typedef enum _MEMORY_CACHING_TYPE {
1503 MmNonCached = FALSE,
1504 MmCached = TRUE,
1505 MmWriteCombined = MmFrameBufferCached,
1506 MmHardwareCoherentCached,
1507 MmNonCachedUnordered,
1508 MmUSWCCached,
1509 MmMaximumCacheType
1510 } MEMORY_CACHING_TYPE;
1511
1512 typedef enum _MM_PAGE_PRIORITY {
1513 LowPagePriority,
1514 NormalPagePriority = 16,
1515 HighPagePriority = 32
1516 } MM_PAGE_PRIORITY;
1517
1518 typedef enum _LOCK_OPERATION {
1519 IoReadAccess,
1520 IoWriteAccess,
1521 IoModifyAccess
1522 } LOCK_OPERATION;
1523
1524 #define FLUSH_MULTIPLE_MAXIMUM 32
1525
1526 typedef enum _MM_SYSTEM_SIZE {
1527 MmSmallSystem,
1528 MmMediumSystem,
1529 MmLargeSystem
1530 } MM_SYSTEMSIZE;
1531
1532 typedef struct _OBJECT_HANDLE_INFORMATION {
1533 ULONG HandleAttributes;
1534 ACCESS_MASK GrantedAccess;
1535 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
1536
1537 typedef struct _CLIENT_ID {
1538 HANDLE UniqueProcess;
1539 HANDLE UniqueThread;
1540 } CLIENT_ID, *PCLIENT_ID;
1541
1542 typedef VOID
1543 (DDKAPI *PKSTART_ROUTINE)(
1544 IN PVOID StartContext);
1545
1546 typedef VOID
1547 (DDKAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
1548 IN HANDLE ParentId,
1549 IN HANDLE ProcessId,
1550 IN BOOLEAN Create);
1551
1552 typedef VOID
1553 (DDKAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
1554 IN HANDLE ProcessId,
1555 IN HANDLE ThreadId,
1556 IN BOOLEAN Create);
1557
1558 typedef struct _IMAGE_INFO {
1559 _ANONYMOUS_UNION union {
1560 ULONG Properties;
1561 _ANONYMOUS_STRUCT struct {
1562 ULONG ImageAddressingMode : 8;
1563 ULONG SystemModeImage : 1;
1564 ULONG ImageMappedToAllPids : 1;
1565 ULONG Reserved : 22;
1566 } DUMMYSTRUCTNAME;
1567 } DUMMYUNIONNAME;
1568 PVOID ImageBase;
1569 ULONG ImageSelector;
1570 SIZE_T ImageSize;
1571 ULONG ImageSectionNumber;
1572 } IMAGE_INFO, *PIMAGE_INFO;
1573
1574 #define IMAGE_ADDRESSING_MODE_32BIT 3
1575
1576 typedef VOID
1577 (DDKAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
1578 IN PUNICODE_STRING FullImageName,
1579 IN HANDLE ProcessId,
1580 IN PIMAGE_INFO ImageInfo);
1581
1582 #pragma pack(push,4)
1583 typedef enum _BUS_DATA_TYPE {
1584 ConfigurationSpaceUndefined = -1,
1585 Cmos,
1586 EisaConfiguration,
1587 Pos,
1588 CbusConfiguration,
1589 PCIConfiguration,
1590 VMEConfiguration,
1591 NuBusConfiguration,
1592 PCMCIAConfiguration,
1593 MPIConfiguration,
1594 MPSAConfiguration,
1595 PNPISAConfiguration,
1596 SgiInternalConfiguration,
1597 MaximumBusDataType
1598 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
1599 #pragma pack(pop)
1600
1601 typedef struct _NT_TIB {
1602 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1603 PVOID StackBase;
1604 PVOID StackLimit;
1605 PVOID SubSystemTib;
1606 _ANONYMOUS_UNION union {
1607 PVOID FiberData;
1608 ULONG Version;
1609 } DUMMYUNIONNAME;
1610 PVOID ArbitraryUserPointer;
1611 struct _NT_TIB *Self;
1612 } NT_TIB, *PNT_TIB;
1613
1614 typedef struct _NT_TIB32 {
1615 ULONG ExceptionList;
1616 ULONG StackBase;
1617 ULONG StackLimit;
1618 ULONG SubSystemTib;
1619 __GNU_EXTENSION union {
1620 ULONG FiberData;
1621 ULONG Version;
1622 };
1623 ULONG ArbitraryUserPointer;
1624 ULONG Self;
1625 } NT_TIB32,*PNT_TIB32;
1626
1627 typedef struct _NT_TIB64 {
1628 ULONG64 ExceptionList;
1629 ULONG64 StackBase;
1630 ULONG64 StackLimit;
1631 ULONG64 SubSystemTib;
1632 __GNU_EXTENSION union {
1633 ULONG64 FiberData;
1634 ULONG Version;
1635 };
1636 ULONG64 ArbitraryUserPointer;
1637 ULONG64 Self;
1638 } NT_TIB64,*PNT_TIB64;
1639
1640 typedef enum _PROCESSINFOCLASS {
1641 ProcessBasicInformation,
1642 ProcessQuotaLimits,
1643 ProcessIoCounters,
1644 ProcessVmCounters,
1645 ProcessTimes,
1646 ProcessBasePriority,
1647 ProcessRaisePriority,
1648 ProcessDebugPort,
1649 ProcessExceptionPort,
1650 ProcessAccessToken,
1651 ProcessLdtInformation,
1652 ProcessLdtSize,
1653 ProcessDefaultHardErrorMode,
1654 ProcessIoPortHandlers,
1655 ProcessPooledUsageAndLimits,
1656 ProcessWorkingSetWatch,
1657 ProcessUserModeIOPL,
1658 ProcessEnableAlignmentFaultFixup,
1659 ProcessPriorityClass,
1660 ProcessWx86Information,
1661 ProcessHandleCount,
1662 ProcessAffinityMask,
1663 ProcessPriorityBoost,
1664 ProcessDeviceMap,
1665 ProcessSessionInformation,
1666 ProcessForegroundInformation,
1667 ProcessWow64Information,
1668 ProcessImageFileName,
1669 ProcessLUIDDeviceMapsEnabled,
1670 ProcessBreakOnTermination,
1671 ProcessDebugObjectHandle,
1672 ProcessDebugFlags,
1673 ProcessHandleTracing,
1674 ProcessIoPriority,
1675 ProcessExecuteFlags,
1676 ProcessTlsInformation,
1677 ProcessCookie,
1678 ProcessImageInformation,
1679 ProcessCycleTime,
1680 ProcessPagePriority,
1681 ProcessInstrumentationCallback,
1682 MaxProcessInfoClass
1683 } PROCESSINFOCLASS;
1684
1685 typedef enum _THREADINFOCLASS {
1686 ThreadBasicInformation,
1687 ThreadTimes,
1688 ThreadPriority,
1689 ThreadBasePriority,
1690 ThreadAffinityMask,
1691 ThreadImpersonationToken,
1692 ThreadDescriptorTableEntry,
1693 ThreadEnableAlignmentFaultFixup,
1694 ThreadEventPair_Reusable,
1695 ThreadQuerySetWin32StartAddress,
1696 ThreadZeroTlsCell,
1697 ThreadPerformanceCount,
1698 ThreadAmILastThread,
1699 ThreadIdealProcessor,
1700 ThreadPriorityBoost,
1701 ThreadSetTlsArrayAddress,
1702 ThreadIsIoPending,
1703 ThreadHideFromDebugger,
1704 ThreadBreakOnTermination,
1705 ThreadSwitchLegacyState,
1706 ThreadIsTerminated,
1707 ThreadLastSystemCall,
1708 ThreadIoPriority,
1709 ThreadCycleTime,
1710 ThreadPagePriority,
1711 ThreadActualBasePriority,
1712 MaxThreadInfoClass
1713 } THREADINFOCLASS;
1714
1715 typedef struct _PROCESS_BASIC_INFORMATION
1716 {
1717 NTSTATUS ExitStatus;
1718 struct _PEB *PebBaseAddress;
1719 ULONG_PTR AffinityMask;
1720 KPRIORITY BasePriority;
1721 ULONG_PTR UniqueProcessId;
1722 ULONG_PTR InheritedFromUniqueProcessId;
1723 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
1724
1725 typedef struct _PROCESS_WS_WATCH_INFORMATION
1726 {
1727 PVOID FaultingPc;
1728 PVOID FaultingVa;
1729 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
1730
1731 typedef struct _PROCESS_DEVICEMAP_INFORMATION
1732 {
1733 __GNU_EXTENSION union
1734 {
1735 struct
1736 {
1737 HANDLE DirectoryHandle;
1738 } Set;
1739 struct
1740 {
1741 ULONG DriveMap;
1742 UCHAR DriveType[32];
1743 } Query;
1744 };
1745 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
1746
1747 typedef struct _KERNEL_USER_TIMES
1748 {
1749 LARGE_INTEGER CreateTime;
1750 LARGE_INTEGER ExitTime;
1751 LARGE_INTEGER KernelTime;
1752 LARGE_INTEGER UserTime;
1753 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
1754
1755 typedef struct _PROCESS_ACCESS_TOKEN
1756 {
1757 HANDLE Token;
1758 HANDLE Thread;
1759 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
1760
1761 typedef struct _PROCESS_SESSION_INFORMATION
1762 {
1763 ULONG SessionId;
1764 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
1765
1766 typedef VOID
1767 (DDKAPI *PREQUEST_POWER_COMPLETE)(
1768 IN PDEVICE_OBJECT DeviceObject,
1769 IN UCHAR MinorFunction,
1770 IN POWER_STATE PowerState,
1771 IN PVOID Context,
1772 IN PIO_STATUS_BLOCK IoStatus);
1773
1774 typedef enum _TRACE_INFORMATION_CLASS {
1775 TraceIdClass,
1776 TraceHandleClass,
1777 TraceEnableFlagsClass,
1778 TraceEnableLevelClass,
1779 GlobalLoggerHandleClass,
1780 EventLoggerHandleClass,
1781 AllLoggerHandlesClass,
1782 TraceHandleByNameClass
1783 } TRACE_INFORMATION_CLASS;
1784
1785 typedef enum _REG_NOTIFY_CLASS
1786 {
1787 RegNtDeleteKey,
1788 RegNtPreDeleteKey = RegNtDeleteKey,
1789 RegNtSetValueKey,
1790 RegNtPreSetValueKey = RegNtSetValueKey,
1791 RegNtDeleteValueKey,
1792 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
1793 RegNtSetInformationKey,
1794 RegNtPreSetInformationKey = RegNtSetInformationKey,
1795 RegNtRenameKey,
1796 RegNtPreRenameKey = RegNtRenameKey,
1797 RegNtEnumerateKey,
1798 RegNtPreEnumerateKey = RegNtEnumerateKey,
1799 RegNtEnumerateValueKey,
1800 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
1801 RegNtQueryKey,
1802 RegNtPreQueryKey = RegNtQueryKey,
1803 RegNtQueryValueKey,
1804 RegNtPreQueryValueKey = RegNtQueryValueKey,
1805 RegNtQueryMultipleValueKey,
1806 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
1807 RegNtPreCreateKey,
1808 RegNtPostCreateKey,
1809 RegNtPreOpenKey,
1810 RegNtPostOpenKey,
1811 RegNtKeyHandleClose,
1812 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
1813 RegNtPostDeleteKey,
1814 RegNtPostSetValueKey,
1815 RegNtPostDeleteValueKey,
1816 RegNtPostSetInformationKey,
1817 RegNtPostRenameKey,
1818 RegNtPostEnumerateKey,
1819 RegNtPostEnumerateValueKey,
1820 RegNtPostQueryKey,
1821 RegNtPostQueryValueKey,
1822 RegNtPostQueryMultipleValueKey,
1823 RegNtPostKeyHandleClose,
1824 RegNtPreCreateKeyEx,
1825 RegNtPostCreateKeyEx,
1826 RegNtPreOpenKeyEx,
1827 RegNtPostOpenKeyEx
1828 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
1829
1830 typedef NTSTATUS
1831 (NTAPI *PEX_CALLBACK_FUNCTION)(
1832 IN PVOID CallbackContext,
1833 IN PVOID Argument1,
1834 IN PVOID Argument2
1835 );
1836
1837 typedef struct _REG_DELETE_KEY_INFORMATION
1838 {
1839 PVOID Object;
1840 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION;
1841
1842 typedef struct _REG_SET_VALUE_KEY_INFORMATION
1843 {
1844 PVOID Object;
1845 PUNICODE_STRING ValueName;
1846 ULONG TitleIndex;
1847 ULONG Type;
1848 PVOID Data;
1849 ULONG DataSize;
1850 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
1851
1852 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION
1853 {
1854 PVOID Object;
1855 PUNICODE_STRING ValueName;
1856 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
1857
1858 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION
1859 {
1860 PVOID Object;
1861 KEY_SET_INFORMATION_CLASS KeySetInformationClass;
1862 PVOID KeySetInformation;
1863 ULONG KeySetInformationLength;
1864 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
1865
1866 typedef struct _REG_ENUMERATE_KEY_INFORMATION
1867 {
1868 PVOID Object;
1869 ULONG Index;
1870 KEY_INFORMATION_CLASS KeyInformationClass;
1871 PVOID KeyInformation;
1872 ULONG Length;
1873 PULONG ResultLength;
1874 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
1875
1876 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION
1877 {
1878 PVOID Object;
1879 ULONG Index;
1880 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
1881 PVOID KeyValueInformation;
1882 ULONG Length;
1883 PULONG ResultLength;
1884 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
1885
1886 typedef struct _REG_QUERY_KEY_INFORMATION
1887 {
1888 PVOID Object;
1889 KEY_INFORMATION_CLASS KeyInformationClass;
1890 PVOID KeyInformation;
1891 ULONG Length;
1892 PULONG ResultLength;
1893 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
1894
1895 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION
1896 {
1897 PVOID Object;
1898 PUNICODE_STRING ValueName;
1899 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
1900 PVOID KeyValueInformation;
1901 ULONG Length;
1902 PULONG ResultLength;
1903 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
1904
1905 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION
1906 {
1907 PVOID Object;
1908 PKEY_VALUE_ENTRY ValueEntries;
1909 ULONG EntryCount;
1910 PVOID ValueBuffer;
1911 PULONG BufferLength;
1912 PULONG RequiredBufferLength;
1913 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
1914
1915 typedef struct _REG_PRE_CREATE_KEY_INFORMATION
1916 {
1917 PUNICODE_STRING CompleteName;
1918 } REG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_CREATE_KEY_INFORMATION;
1919
1920 typedef struct _REG_POST_CREATE_KEY_INFORMATION
1921 {
1922 PUNICODE_STRING CompleteName;
1923 PVOID Object;
1924 NTSTATUS Status;
1925 } REG_POST_CREATE_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION;
1926
1927 typedef struct _REG_PRE_OPEN_KEY_INFORMATION
1928 {
1929 PUNICODE_STRING CompleteName;
1930 } REG_PRE_OPEN_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;
1931
1932 typedef struct _REG_POST_OPEN_KEY_INFORMATION
1933 {
1934 PUNICODE_STRING CompleteName;
1935 PVOID Object;
1936 NTSTATUS Status;
1937 } REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
1938
1939 typedef struct _REG_POST_OPERATION_INFORMATION
1940 {
1941 PVOID Object;
1942 NTSTATUS Status;
1943 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
1944
1945 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION
1946 {
1947 PVOID Object;
1948 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
1949
1950 /*
1951 ** Storage structures
1952 */
1953 typedef enum _PARTITION_STYLE {
1954 PARTITION_STYLE_MBR,
1955 PARTITION_STYLE_GPT,
1956 PARTITION_STYLE_RAW
1957 } PARTITION_STYLE;
1958
1959 typedef struct _CREATE_DISK_MBR {
1960 ULONG Signature;
1961 } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
1962
1963 typedef struct _CREATE_DISK_GPT {
1964 GUID DiskId;
1965 ULONG MaxPartitionCount;
1966 } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
1967
1968 typedef struct _CREATE_DISK {
1969 PARTITION_STYLE PartitionStyle;
1970 _ANONYMOUS_UNION union {
1971 CREATE_DISK_MBR Mbr;
1972 CREATE_DISK_GPT Gpt;
1973 } DUMMYUNIONNAME;
1974 } CREATE_DISK, *PCREATE_DISK;
1975
1976 typedef struct _DISK_SIGNATURE {
1977 ULONG PartitionStyle;
1978 _ANONYMOUS_UNION union {
1979 struct {
1980 ULONG Signature;
1981 ULONG CheckSum;
1982 } Mbr;
1983 struct {
1984 GUID DiskId;
1985 } Gpt;
1986 } DUMMYUNIONNAME;
1987 } DISK_SIGNATURE, *PDISK_SIGNATURE;
1988
1989 typedef VOID
1990 (FASTCALL*PTIME_UPDATE_NOTIFY_ROUTINE)(
1991 IN HANDLE ThreadId,
1992 IN KPROCESSOR_MODE Mode);
1993
1994 #define DBG_STATUS_CONTROL_C 1
1995 #define DBG_STATUS_SYSRQ 2
1996 #define DBG_STATUS_BUGCHECK_FIRST 3
1997 #define DBG_STATUS_BUGCHECK_SECOND 4
1998 #define DBG_STATUS_FATAL 5
1999 #define DBG_STATUS_DEBUG_CONTROL 6
2000 #define DBG_STATUS_WORKER 7
2001
2002 typedef struct _PHYSICAL_MEMORY_RANGE {
2003 PHYSICAL_ADDRESS BaseAddress;
2004 LARGE_INTEGER NumberOfBytes;
2005 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
2006
2007 typedef ULONG_PTR
2008 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
2009 IN PVOID Context);
2010
2011 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
2012 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
2013 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
2014 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
2015
2016 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
2017 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
2018 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
2019 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
2020 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
2021
2022 #define HASH_STRING_ALGORITHM_DEFAULT 0
2023 #define HASH_STRING_ALGORITHM_X65599 1
2024 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
2025
2026 typedef VOID
2027 (DDKAPI *PTIMER_APC_ROUTINE)(
2028 IN PVOID TimerContext,
2029 IN ULONG TimerLowValue,
2030 IN LONG TimerHighValue);
2031
2032
2033
2034 /*
2035 ** WMI structures
2036 */
2037
2038 typedef VOID
2039 (DDKAPI *WMI_NOTIFICATION_CALLBACK)(
2040 PVOID Wnode,
2041 PVOID Context);
2042
2043
2044 /*
2045 ** Architecture specific structures
2046 */
2047 #define PCR_MINOR_VERSION 1
2048 #define PCR_MAJOR_VERSION 1
2049
2050 #ifdef _X86_
2051
2052 #define SIZE_OF_80387_REGISTERS 80
2053 #define CONTEXT_i386 0x10000
2054 #define CONTEXT_i486 0x10000
2055 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
2056 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
2057 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
2058 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
2059 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
2060 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
2061 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
2062 #define MAXIMUM_SUPPORTED_EXTENSION 512
2063
2064 typedef struct _FLOATING_SAVE_AREA {
2065 ULONG ControlWord;
2066 ULONG StatusWord;
2067 ULONG TagWord;
2068 ULONG ErrorOffset;
2069 ULONG ErrorSelector;
2070 ULONG DataOffset;
2071 ULONG DataSelector;
2072 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
2073 ULONG Cr0NpxState;
2074 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
2075
2076 typedef struct _CONTEXT {
2077 ULONG ContextFlags;
2078 ULONG Dr0;
2079 ULONG Dr1;
2080 ULONG Dr2;
2081 ULONG Dr3;
2082 ULONG Dr6;
2083 ULONG Dr7;
2084 FLOATING_SAVE_AREA FloatSave;
2085 ULONG SegGs;
2086 ULONG SegFs;
2087 ULONG SegEs;
2088 ULONG SegDs;
2089 ULONG Edi;
2090 ULONG Esi;
2091 ULONG Ebx;
2092 ULONG Edx;
2093 ULONG Ecx;
2094 ULONG Eax;
2095 ULONG Ebp;
2096 ULONG Eip;
2097 ULONG SegCs;
2098 ULONG EFlags;
2099 ULONG Esp;
2100 ULONG SegSs;
2101 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
2102 } CONTEXT;
2103
2104 //
2105 // Used to contain PFNs and PFN counts
2106 //
2107 typedef ULONG PFN_COUNT;
2108 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
2109 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
2110
2111 #define PASSIVE_LEVEL 0
2112 #define LOW_LEVEL 0
2113 #define APC_LEVEL 1
2114 #define DISPATCH_LEVEL 2
2115 #define PROFILE_LEVEL 27
2116 #define CLOCK1_LEVEL 28
2117 #define CLOCK2_LEVEL 28
2118 #define IPI_LEVEL 29
2119 #define POWER_LEVEL 30
2120 #define HIGH_LEVEL 31
2121
2122 typedef struct _KPCR_TIB {
2123 PVOID ExceptionList; /* 00 */
2124 PVOID StackBase; /* 04 */
2125 PVOID StackLimit; /* 08 */
2126 PVOID SubSystemTib; /* 0C */
2127 _ANONYMOUS_UNION union {
2128 PVOID FiberData; /* 10 */
2129 ULONG Version; /* 10 */
2130 } DUMMYUNIONNAME;
2131 PVOID ArbitraryUserPointer; /* 14 */
2132 struct _KPCR_TIB *Self; /* 18 */
2133 } KPCR_TIB, *PKPCR_TIB; /* 1C */
2134
2135 typedef struct _KPCR {
2136 KPCR_TIB Tib; /* 00 */
2137 struct _KPCR *Self; /* 1C */
2138 struct _KPRCB *Prcb; /* 20 */
2139 KIRQL Irql; /* 24 */
2140 ULONG IRR; /* 28 */
2141 ULONG IrrActive; /* 2C */
2142 ULONG IDR; /* 30 */
2143 PVOID KdVersionBlock; /* 34 */
2144 PUSHORT IDT; /* 38 */
2145 PUSHORT GDT; /* 3C */
2146 struct _KTSS *TSS; /* 40 */
2147 USHORT MajorVersion; /* 44 */
2148 USHORT MinorVersion; /* 46 */
2149 KAFFINITY SetMember; /* 48 */
2150 ULONG StallScaleFactor; /* 4C */
2151 UCHAR SpareUnused; /* 50 */
2152 UCHAR Number; /* 51 */
2153 UCHAR Spare0;
2154 UCHAR SecondLevelCacheAssociativity;
2155 ULONG VdmAlert;
2156 ULONG KernelReserved[14]; // For use by the kernel
2157 ULONG SecondLevelCacheSize;
2158 ULONG HalReserved[16]; // For use by Hal
2159 } KPCR, *PKPCR; /* 54 */
2160
2161 #define KeGetPcr() PCR
2162
2163 typedef struct _KFLOATING_SAVE {
2164 ULONG ControlWord;
2165 ULONG StatusWord;
2166 ULONG ErrorOffset;
2167 ULONG ErrorSelector;
2168 ULONG DataOffset;
2169 ULONG DataSelector;
2170 ULONG Cr0NpxState;
2171 ULONG Spare1;
2172 } KFLOATING_SAVE, *PKFLOATING_SAVE;
2173
2174 FORCEINLINE
2175 ULONG
2176 KeGetCurrentProcessorNumber(VOID)
2177 {
2178 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
2179 }
2180
2181 NTHALAPI
2182 KIRQL
2183 DDKAPI
2184 KeGetCurrentIrql(
2185 VOID);
2186
2187 NTKERNELAPI
2188 PRKTHREAD
2189 NTAPI
2190 KeGetCurrentThread(
2191 VOID);
2192
2193 #define KI_USER_SHARED_DATA 0xffdf0000
2194
2195 #define PAGE_SIZE 0x1000
2196 #define PAGE_SHIFT 12L
2197
2198 #define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA)
2199
2200 extern NTKERNELAPI PVOID MmHighestUserAddress;
2201 extern NTKERNELAPI PVOID MmSystemRangeStart;
2202 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
2203
2204 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2205 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2206 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2207 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2208 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
2209
2210 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
2211 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
2212
2213 #elif defined(__x86_64__)
2214
2215 #define CONTEXT_AMD64 0x100000
2216 #if !defined(RC_INVOKED)
2217 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
2218 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
2219 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
2220 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
2221 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
2222
2223 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2224 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
2225
2226 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
2227 #define CONTEXT_SERVICE_ACTIVE 0x10000000
2228 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
2229 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
2230 #endif
2231
2232 typedef struct DECLSPEC_ALIGN(16) _M128A {
2233 ULONGLONG Low;
2234 LONGLONG High;
2235 } M128A, *PM128A;
2236
2237 typedef struct _XMM_SAVE_AREA32 {
2238 USHORT ControlWord;
2239 USHORT StatusWord;
2240 UCHAR TagWord;
2241 UCHAR Reserved1;
2242 USHORT ErrorOpcode;
2243 ULONG ErrorOffset;
2244 USHORT ErrorSelector;
2245 USHORT Reserved2;
2246 ULONG DataOffset;
2247 USHORT DataSelector;
2248 USHORT Reserved3;
2249 ULONG MxCsr;
2250 ULONG MxCsr_Mask;
2251 M128A FloatRegisters[8];
2252 M128A XmmRegisters[16];
2253 UCHAR Reserved4[96];
2254 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
2255
2256 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
2257 ULONG64 P1Home;
2258 ULONG64 P2Home;
2259 ULONG64 P3Home;
2260 ULONG64 P4Home;
2261 ULONG64 P5Home;
2262 ULONG64 P6Home;
2263
2264 /* Control flags */
2265 ULONG ContextFlags;
2266 ULONG MxCsr;
2267
2268 /* Segment */
2269 USHORT SegCs;
2270 USHORT SegDs;
2271 USHORT SegEs;
2272 USHORT SegFs;
2273 USHORT SegGs;
2274 USHORT SegSs;
2275 ULONG EFlags;
2276
2277 /* Debug */
2278 ULONG64 Dr0;
2279 ULONG64 Dr1;
2280 ULONG64 Dr2;
2281 ULONG64 Dr3;
2282 ULONG64 Dr6;
2283 ULONG64 Dr7;
2284
2285 /* Integer */
2286 ULONG64 Rax;
2287 ULONG64 Rcx;
2288 ULONG64 Rdx;
2289 ULONG64 Rbx;
2290 ULONG64 Rsp;
2291 ULONG64 Rbp;
2292 ULONG64 Rsi;
2293 ULONG64 Rdi;
2294 ULONG64 R8;
2295 ULONG64 R9;
2296 ULONG64 R10;
2297 ULONG64 R11;
2298 ULONG64 R12;
2299 ULONG64 R13;
2300 ULONG64 R14;
2301 ULONG64 R15;
2302
2303 /* Counter */
2304 ULONG64 Rip;
2305
2306 /* Floating point */
2307 union {
2308 XMM_SAVE_AREA32 FltSave;
2309 struct {
2310 M128A Header[2];
2311 M128A Legacy[8];
2312 M128A Xmm0;
2313 M128A Xmm1;
2314 M128A Xmm2;
2315 M128A Xmm3;
2316 M128A Xmm4;
2317 M128A Xmm5;
2318 M128A Xmm6;
2319 M128A Xmm7;
2320 M128A Xmm8;
2321 M128A Xmm9;
2322 M128A Xmm10;
2323 M128A Xmm11;
2324 M128A Xmm12;
2325 M128A Xmm13;
2326 M128A Xmm14;
2327 M128A Xmm15;
2328 } DUMMYSTRUCTNAME;
2329 } DUMMYUNIONNAME;
2330
2331 /* Vector */
2332 M128A VectorRegister[26];
2333 ULONG64 VectorControl;
2334
2335 /* Debug control */
2336 ULONG64 DebugControl;
2337 ULONG64 LastBranchToRip;
2338 ULONG64 LastBranchFromRip;
2339 ULONG64 LastExceptionToRip;
2340 ULONG64 LastExceptionFromRip;
2341 } CONTEXT;
2342
2343 //
2344 // Used to contain PFNs and PFN counts
2345 //
2346 typedef ULONG PFN_COUNT;
2347 typedef ULONG64 PFN_NUMBER, *PPFN_NUMBER;
2348 typedef LONG64 SPFN_NUMBER, *PSPFN_NUMBER;
2349
2350 #define PASSIVE_LEVEL 0
2351 #define LOW_LEVEL 0
2352 #define APC_LEVEL 1
2353 #define DISPATCH_LEVEL 2
2354 #define CLOCK_LEVEL 13
2355 #define IPI_LEVEL 14
2356 #define POWER_LEVEL 14
2357 #define PROFILE_LEVEL 15
2358 #define HIGH_LEVEL 15
2359
2360 #define PAGE_SIZE 0x1000
2361 #define PAGE_SHIFT 12L
2362 #define PTI_SHIFT 12L
2363 #define PDI_SHIFT 21L
2364 #define PPI_SHIFT 30L
2365 #define PXI_SHIFT 39L
2366 #define PTE_PER_PAGE 512
2367 #define PDE_PER_PAGE 512
2368 #define PPE_PER_PAGE 512
2369 #define PXE_PER_PAGE 512
2370 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
2371 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
2372 #define PPI_MASK (PPE_PER_PAGE - 1)
2373 #define PXI_MASK (PXE_PER_PAGE - 1)
2374
2375 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
2376 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
2377 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
2378 #define PDE_BASE 0xFFFFF6FB40000000ULL
2379 #define PTE_BASE 0xFFFFF68000000000ULL
2380 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
2381 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
2382 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
2383 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
2384
2385 extern NTKERNELAPI PVOID MmHighestUserAddress;
2386 extern NTKERNELAPI PVOID MmSystemRangeStart;
2387 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
2388
2389 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2390 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2391 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2392 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2393 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
2394 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
2395
2396 #define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA)
2397 #define SharedInterruptTime (&SharedUserData->InterruptTime)
2398 #define SharedSystemTime (&SharedUserData->SystemTime)
2399 #define SharedTickCount (&SharedUserData->TickCount)
2400
2401 #define KeQueryInterruptTime() \
2402 (*(volatile ULONG64*)SharedInterruptTime)
2403 #define KeQuerySystemTime(CurrentCount) \
2404 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
2405 #define KeQueryTickCount(CurrentCount) \
2406 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
2407
2408 typedef struct _KPCR
2409 {
2410 __GNU_EXTENSION union
2411 {
2412 NT_TIB NtTib;
2413 __GNU_EXTENSION struct
2414 {
2415 union _KGDTENTRY64 *GdtBase;
2416 struct _KTSS64 *TssBase;
2417 ULONG64 UserRsp;
2418 struct _KPCR *Self;
2419 struct _KPRCB *CurrentPrcb;
2420 PKSPIN_LOCK_QUEUE LockArray;
2421 PVOID Used_Self;
2422 };
2423 };
2424 union _KIDTENTRY64 *IdtBase;
2425 ULONG64 Unused[2];
2426 KIRQL Irql;
2427 UCHAR SecondLevelCacheAssociativity;
2428 UCHAR ObsoleteNumber;
2429 UCHAR Fill0;
2430 ULONG Unused0[3];
2431 USHORT MajorVersion;
2432 USHORT MinorVersion;
2433 ULONG StallScaleFactor;
2434 PVOID Unused1[3];
2435 ULONG KernelReserved[15];
2436 ULONG SecondLevelCacheSize;
2437 ULONG HalReserved[16];
2438 ULONG Unused2;
2439 PVOID KdVersionBlock;
2440 PVOID Unused3;
2441 ULONG PcrAlign1[24];
2442 } KPCR, *PKPCR;
2443
2444 typedef struct _KFLOATING_SAVE {
2445 ULONG Dummy;
2446 } KFLOATING_SAVE, *PKFLOATING_SAVE;
2447
2448 NTKERNELAPI
2449 PRKTHREAD
2450 NTAPI
2451 KeGetCurrentThread(
2452 VOID);
2453
2454 FORCEINLINE
2455 PKPCR
2456 KeGetPcr(VOID)
2457 {
2458 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
2459 }
2460
2461 FORCEINLINE
2462 ULONG
2463 KeGetCurrentProcessorNumber(VOID)
2464 {
2465 return (ULONG)__readgsword(0x184);
2466 }
2467
2468 #elif defined(__PowerPC__)
2469
2470 //
2471 // Used to contain PFNs and PFN counts
2472 //
2473 typedef ULONG PFN_COUNT;
2474 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
2475 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
2476
2477 #define PASSIVE_LEVEL 0
2478 #define LOW_LEVEL 0
2479 #define APC_LEVEL 1
2480 #define DISPATCH_LEVEL 2
2481 #define PROFILE_LEVEL 27
2482 #define CLOCK1_LEVEL 28
2483 #define CLOCK2_LEVEL 28
2484 #define IPI_LEVEL 29
2485 #define POWER_LEVEL 30
2486 #define HIGH_LEVEL 31
2487
2488 typedef struct _KFLOATING_SAVE {
2489 ULONG Dummy;
2490 } KFLOATING_SAVE, *PKFLOATING_SAVE;
2491
2492 typedef struct _KPCR_TIB {
2493 PVOID ExceptionList; /* 00 */
2494 PVOID StackBase; /* 04 */
2495 PVOID StackLimit; /* 08 */
2496 PVOID SubSystemTib; /* 0C */
2497 _ANONYMOUS_UNION union {
2498 PVOID FiberData; /* 10 */
2499 ULONG Version; /* 10 */
2500 } DUMMYUNIONNAME;
2501 PVOID ArbitraryUserPointer; /* 14 */
2502 struct _KPCR_TIB *Self; /* 18 */
2503 } KPCR_TIB, *PKPCR_TIB; /* 1C */
2504
2505 #define PCR_MINOR_VERSION 1
2506 #define PCR_MAJOR_VERSION 1
2507
2508 typedef struct _KPCR {
2509 KPCR_TIB Tib; /* 00 */
2510 struct _KPCR *Self; /* 1C */
2511 struct _KPRCB *Prcb; /* 20 */
2512 KIRQL Irql; /* 24 */
2513 ULONG IRR; /* 28 */
2514 ULONG IrrActive; /* 2C */
2515 ULONG IDR; /* 30 */
2516 PVOID KdVersionBlock; /* 34 */
2517 PUSHORT IDT; /* 38 */
2518 PUSHORT GDT; /* 3C */
2519 struct _KTSS *TSS; /* 40 */
2520 USHORT MajorVersion; /* 44 */
2521 USHORT MinorVersion; /* 46 */
2522 KAFFINITY SetMember; /* 48 */
2523 ULONG StallScaleFactor; /* 4C */
2524 UCHAR SpareUnused; /* 50 */
2525 UCHAR Number; /* 51 */
2526 } KPCR, *PKPCR; /* 54 */
2527
2528 #define KeGetPcr() PCR
2529
2530 static __inline
2531 ULONG
2532 DDKAPI
2533 KeGetCurrentProcessorNumber(VOID)
2534 {
2535 ULONG Number;
2536 __asm__ __volatile__ (
2537 "lwz %0, %c1(12)\n"
2538 : "=r" (Number)
2539 : "i" (FIELD_OFFSET(KPCR, Number))
2540 );
2541 return Number;
2542 }
2543
2544 #elif defined(_MIPS_)
2545
2546 #error MIPS Headers are totally incorrect
2547
2548 //
2549 // Used to contain PFNs and PFN counts
2550 //
2551 typedef ULONG PFN_COUNT;
2552 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
2553 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
2554
2555 #define PASSIVE_LEVEL 0
2556 #define APC_LEVEL 1
2557 #define DISPATCH_LEVEL 2
2558 #define PROFILE_LEVEL 27
2559 #define IPI_LEVEL 29
2560 #define HIGH_LEVEL 31
2561
2562 typedef struct _KPCR {
2563 struct _KPRCB *Prcb; /* 20 */
2564 KIRQL Irql; /* 24 */
2565 ULONG IRR; /* 28 */
2566 ULONG IDR; /* 30 */
2567 } KPCR, *PKPCR;
2568
2569 #define KeGetPcr() PCR
2570
2571 typedef struct _KFLOATING_SAVE {
2572 } KFLOATING_SAVE, *PKFLOATING_SAVE;
2573
2574 static __inline
2575 ULONG
2576 DDKAPI
2577 KeGetCurrentProcessorNumber(VOID)
2578 {
2579 return 0;
2580 }
2581
2582 #elif defined(_M_ARM)
2583
2584 //
2585 // NT-ARM is not documented, need DDK-ARM
2586 //
2587 #include <armddk.h>
2588
2589 #else
2590 #error Unknown architecture
2591 #endif
2592
2593 #define MM_DONT_ZERO_ALLOCATION 0x00000001
2594 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
2595
2596
2597 #define EFLAG_SIGN 0x8000
2598 #define EFLAG_ZERO 0x4000
2599 #define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO)
2600
2601 #define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
2602 #define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
2603 #define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
2604
2605 typedef enum _INTERLOCKED_RESULT {
2606 ResultNegative = RESULT_NEGATIVE,
2607 ResultZero = RESULT_ZERO,
2608 ResultPositive = RESULT_POSITIVE
2609 } INTERLOCKED_RESULT;
2610
2611 typedef VOID
2612 (NTAPI *PciPin2Line)(
2613 IN struct _BUS_HANDLER *BusHandler,
2614 IN struct _BUS_HANDLER *RootHandler,
2615 IN PCI_SLOT_NUMBER SlotNumber,
2616 IN PPCI_COMMON_CONFIG PciData
2617 );
2618
2619 typedef VOID
2620 (NTAPI *PciLine2Pin)(
2621 IN struct _BUS_HANDLER *BusHandler,
2622 IN struct _BUS_HANDLER *RootHandler,
2623 IN PCI_SLOT_NUMBER SlotNumber,
2624 IN PPCI_COMMON_CONFIG PciNewData,
2625 IN PPCI_COMMON_CONFIG PciOldData
2626 );
2627
2628 typedef VOID
2629 (NTAPI *PciReadWriteConfig)(
2630 IN struct _BUS_HANDLER *BusHandler,
2631 IN PCI_SLOT_NUMBER Slot,
2632 IN PVOID Buffer,
2633 IN ULONG Offset,
2634 IN ULONG Length
2635 );
2636
2637 #define PCI_DATA_TAG ' ICP'
2638 #define PCI_DATA_VERSION 1
2639
2640 typedef struct _PCIBUSDATA
2641 {
2642 ULONG Tag;
2643 ULONG Version;
2644 PciReadWriteConfig ReadConfig;
2645 PciReadWriteConfig WriteConfig;
2646 PciPin2Line Pin2Line;
2647 PciLine2Pin Line2Pin;
2648 PCI_SLOT_NUMBER ParentSlot;
2649 PVOID Reserved[4];
2650 } PCIBUSDATA, *PPCIBUSDATA;
2651
2652
2653 /** SPINLOCK FUNCTIONS ********************************************************/
2654
2655 NTKERNELAPI
2656 BOOLEAN
2657 FASTCALL
2658 KeTryToAcquireSpinLockAtDpcLevel(
2659 IN OUT PKSPIN_LOCK SpinLock
2660 );
2661
2662 NTKERNELAPI
2663 BOOLEAN
2664 FASTCALL
2665 KeTestSpinLock(
2666 IN PKSPIN_LOCK SpinLock
2667 );
2668
2669 #if defined (_X86_)
2670
2671 #if defined(WIN9X_COMPAT_SPINLOCK)
2672
2673 NTKERNELAPI
2674 VOID
2675 NTAPI
2676 KeInitializeSpinLock(
2677 IN PKSPIN_LOCK SpinLock
2678 );
2679
2680 #else
2681
2682 FORCEINLINE
2683 VOID
2684 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
2685 {
2686 /* Clear the lock */
2687 *SpinLock = 0;
2688 }
2689
2690 #endif
2691
2692 NTHALAPI
2693 KIRQL
2694 FASTCALL
2695 KfAcquireSpinLock(
2696 IN PKSPIN_LOCK SpinLock);
2697
2698 NTHALAPI
2699 VOID
2700 FASTCALL
2701 KfReleaseSpinLock(
2702 IN PKSPIN_LOCK SpinLock,
2703 IN KIRQL NewIrql);
2704
2705 NTKERNELAPI
2706 VOID
2707 FASTCALL
2708 KefAcquireSpinLockAtDpcLevel(
2709 IN PKSPIN_LOCK SpinLock);
2710
2711 NTKERNELAPI
2712 VOID
2713 FASTCALL
2714 KefReleaseSpinLockFromDpcLevel(
2715 IN PKSPIN_LOCK SpinLock);
2716
2717 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
2718 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
2719 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
2720 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
2721
2722 #define KeGetDcacheFillSize() 1L
2723
2724 #elif defined(_M_ARM) // !defined (_X86_)
2725
2726 FORCEINLINE
2727 VOID
2728 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
2729 {
2730 /* Clear the lock */
2731 *SpinLock = 0;
2732 }
2733
2734 NTHALAPI
2735 KIRQL
2736 FASTCALL
2737 KfAcquireSpinLock(
2738 IN PKSPIN_LOCK SpinLock);
2739
2740 NTHALAPI
2741 VOID
2742 FASTCALL
2743 KfReleaseSpinLock(
2744 IN PKSPIN_LOCK SpinLock,
2745 IN KIRQL NewIrql);
2746
2747
2748 NTKERNELAPI
2749 VOID
2750 FASTCALL
2751 KefAcquireSpinLockAtDpcLevel(
2752 IN PKSPIN_LOCK SpinLock);
2753
2754 NTKERNELAPI
2755 VOID
2756 FASTCALL
2757 KefReleaseSpinLockFromDpcLevel(
2758 IN PKSPIN_LOCK SpinLock);
2759
2760
2761 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
2762 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
2763 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
2764 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
2765
2766 NTKERNELAPI
2767 VOID
2768 NTAPI
2769 KeInitializeSpinLock(
2770 IN PKSPIN_LOCK SpinLock);
2771
2772 #else
2773
2774 FORCEINLINE
2775 VOID
2776 NTAPI
2777 KeInitializeSpinLock(
2778 PKSPIN_LOCK SpinLock)
2779 {
2780 *SpinLock = 0;
2781 }
2782
2783 NTKERNELAPI
2784 VOID
2785 KeReleaseSpinLock(
2786 IN PKSPIN_LOCK SpinLock,
2787 IN KIRQL NewIrql);
2788
2789 NTKERNELAPI
2790 VOID
2791 KeAcquireSpinLockAtDpcLevel(
2792 IN PKSPIN_LOCK SpinLock);
2793
2794 NTKERNELAPI
2795 VOID
2796 KeReleaseSpinLockFromDpcLevel(
2797 IN PKSPIN_LOCK SpinLock);
2798
2799 NTKERNELAPI
2800 KIRQL
2801 KeAcquireSpinLockRaiseToDpc(
2802 IN PKSPIN_LOCK SpinLock);
2803
2804 #define KeAcquireSpinLock(SpinLock, OldIrql) \
2805 *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
2806
2807 #endif // !defined (_X86_)
2808
2809 /*
2810 ** Utillity functions
2811 */
2812
2813 #define ARGUMENT_PRESENT(ArgumentPointer) \
2814 ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
2815
2816 /*
2817 * ULONG
2818 * BYTE_OFFSET(
2819 * IN PVOID Va)
2820 */
2821 #define BYTE_OFFSET(Va) \
2822 ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
2823
2824 /*
2825 * ULONG
2826 * BYTES_TO_PAGES(
2827 * IN ULONG Size)
2828 */
2829 #define BYTES_TO_PAGES(Size) \
2830 ((ULONG) ((ULONG_PTR) (Size) >> PAGE_SHIFT) + (((ULONG) (Size) & (PAGE_SIZE - 1)) != 0))
2831
2832 /*
2833 * PVOID
2834 * PAGE_ALIGN(
2835 * IN PVOID Va)
2836 */
2837 #define PAGE_ALIGN(Va) \
2838 ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
2839
2840 /*
2841 * ULONG_PTR
2842 * ROUND_TO_PAGES(
2843 * IN ULONG_PTR Size)
2844 */
2845 #define ROUND_TO_PAGES(Size) \
2846 ((ULONG_PTR) (((ULONG_PTR) Size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))
2847
2848
2849
2850 #if defined(_X86_) || defined(_AMD64_)
2851
2852 //
2853 // x86 and x64 performs a 0x2C interrupt
2854 //
2855 #define DbgRaiseAssertionFailure __int2c
2856
2857 #elif defined(_ARM_)
2858
2859 //
2860 // TODO
2861 //
2862
2863 #else
2864 #error Unsupported Architecture
2865 #endif
2866
2867 #if DBG
2868
2869 #define ASSERT(exp) \
2870 (VOID)((!(exp)) ? \
2871 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
2872
2873 #define ASSERTMSG(msg, exp) \
2874 (VOID)((!(exp)) ? \
2875 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE)
2876
2877 #define RTL_SOFT_ASSERT(exp) \
2878 (VOID)((!(exp)) ? \
2879 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
2880
2881 #define RTL_SOFT_ASSERTMSG(msg, exp) \
2882 (VOID)((!(exp)) ? \
2883 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
2884
2885 #define RTL_VERIFY(exp) ASSERT(exp)
2886 #define RTL_VERIFYMSG(msg, exp) ASSERT(msg, exp)
2887
2888 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
2889 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
2890
2891 #if defined(_MSC_VER)
2892
2893 #define NT_ASSERT(exp) \
2894 ((!(exp)) ? \
2895 (__annotation(L"Debug", L"AssertFail", L#exp), \
2896 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2897
2898 #define NT_ASSERTMSG(msg, exp) \
2899 ((!(exp)) ? \
2900 (__annotation(L"Debug", L"AssertFail", L##msg), \
2901 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2902
2903 #define NT_ASSERTMSGW(msg, exp) \
2904 ((!(exp)) ? \
2905 (__annotation(L"Debug", L"AssertFail", msg), \
2906 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2907
2908 #else
2909
2910 //
2911 // GCC doesn't support __annotation (nor PDB)
2912 //
2913 #define NT_ASSERT(exp) \
2914 (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
2915
2916 #define NT_ASSERTMSG NT_ASSERT
2917 #define NT_ASSERTMSGW NT_ASSERT
2918
2919 #endif
2920
2921 #else /* !DBG */
2922
2923 #define ASSERT(exp) ((VOID) 0)
2924 #define ASSERTMSG(msg, exp) ((VOID) 0)
2925
2926 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
2927 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
2928
2929 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
2930 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
2931
2932 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
2933 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
2934
2935 #define NT_ASSERT(exp) ((VOID)0)
2936 #define NT_ASSERTMSG(exp) ((VOID)0)
2937 #define NT_ASSERTMSGW(exp) ((VOID)0)
2938
2939 #endif /* DBG */
2940
2941 /* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
2942 #if defined(_NTSYSTEM_) || defined(__GNUC__)
2943 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
2944 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
2945 #else
2946 #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
2947 #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
2948 #endif /* _NT_SYSTEM */
2949
2950 extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG;
2951 extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG;
2952
2953 /*
2954 ** Driver support routines
2955 */
2956
2957 /** Runtime library routines **/
2958
2959 static __inline VOID
2960 InitializeListHead(
2961 IN PLIST_ENTRY ListHead)
2962 {
2963 ListHead->Flink = ListHead->Blink = ListHead;
2964 }
2965
2966 static __inline VOID
2967 InsertHeadList(
2968 IN PLIST_ENTRY ListHead,
2969 IN PLIST_ENTRY Entry)
2970 {
2971 PLIST_ENTRY OldFlink;
2972 OldFlink = ListHead->Flink;
2973 Entry->Flink = OldFlink;
2974 Entry->Blink = ListHead;
2975 OldFlink->Blink = Entry;
2976 ListHead->Flink = Entry;
2977 }
2978
2979 static __inline VOID
2980 InsertTailList(
2981 IN PLIST_ENTRY ListHead,
2982 IN PLIST_ENTRY Entry)
2983 {
2984 PLIST_ENTRY OldBlink;
2985 OldBlink = ListHead->Blink;
2986 Entry->Flink = ListHead;
2987 Entry->Blink = OldBlink;
2988 OldBlink->Flink = Entry;
2989 ListHead->Blink = Entry;
2990 }
2991
2992 /*
2993 * BOOLEAN
2994 * IsListEmpty(
2995 * IN PLIST_ENTRY ListHead)
2996 */
2997 #define IsListEmpty(_ListHead) \
2998 ((_ListHead)->Flink == (_ListHead))
2999
3000 /*
3001 * PSINGLE_LIST_ENTRY
3002 * PopEntryList(
3003 * IN PSINGLE_LIST_ENTRY ListHead)
3004 */
3005 #define PopEntryList(ListHead) \
3006 (ListHead)->Next; \
3007 { \
3008 PSINGLE_LIST_ENTRY _FirstEntry; \
3009 _FirstEntry = (ListHead)->Next; \
3010 if (_FirstEntry != NULL) \
3011 (ListHead)->Next = _FirstEntry->Next; \
3012 }
3013
3014 /*
3015 * VOID
3016 * PushEntryList(
3017 * IN PSINGLE_LIST_ENTRY ListHead,
3018 * IN PSINGLE_LIST_ENTRY Entry)
3019 */
3020 #define PushEntryList(_ListHead, _Entry) \
3021 (_Entry)->Next = (_ListHead)->Next; \
3022 (_ListHead)->Next = (_Entry); \
3023
3024 static __inline BOOLEAN
3025 RemoveEntryList(
3026 IN PLIST_ENTRY Entry)
3027 {
3028 PLIST_ENTRY OldFlink;
3029 PLIST_ENTRY OldBlink;
3030
3031 OldFlink = Entry->Flink;
3032 OldBlink = Entry->Blink;
3033 OldFlink->Blink = OldBlink;
3034 OldBlink->Flink = OldFlink;
3035 return (BOOLEAN)(OldFlink == OldBlink);
3036 }
3037
3038 static __inline PLIST_ENTRY
3039 RemoveHeadList(
3040 IN PLIST_ENTRY ListHead)
3041 {
3042 PLIST_ENTRY Flink;
3043 PLIST_ENTRY Entry;
3044
3045 Entry = ListHead->Flink;
3046 Flink = Entry->Flink;
3047 ListHead->Flink = Flink;
3048 Flink->Blink = ListHead;
3049 return Entry;
3050 }
3051
3052 static __inline PLIST_ENTRY
3053 RemoveTailList(
3054 IN PLIST_ENTRY ListHead)
3055 {
3056 PLIST_ENTRY Blink;
3057 PLIST_ENTRY Entry;
3058
3059 Entry = ListHead->Blink;
3060 Blink = Entry->Blink;
3061 ListHead->Blink = Blink;
3062 Blink->Flink = ListHead;
3063 return Entry;
3064 }
3065
3066 NTSYSAPI
3067 NTSTATUS
3068 NTAPI
3069 RtlCharToInteger(
3070 IN PCSZ String,
3071 IN ULONG Base OPTIONAL,
3072 IN OUT PULONG Value);
3073
3074 NTSYSAPI
3075 LONG
3076 NTAPI
3077 RtlCompareString(
3078 IN PSTRING String1,
3079 IN PSTRING String2,
3080 BOOLEAN CaseInSensitive);
3081
3082 #if !defined(MIDL_PASS)
3083
3084 FORCEINLINE
3085 LUID
3086 NTAPI
3087 RtlConvertLongToLuid(
3088 IN LONG Val)
3089 {
3090 LUID Luid;
3091 LARGE_INTEGER Temp;
3092
3093 Temp.QuadPart = Val;
3094 Luid.LowPart = Temp.u.LowPart;
3095 Luid.HighPart = Temp.u.HighPart;
3096
3097 return Luid;
3098 }
3099
3100 FORCEINLINE
3101 LUID
3102 NTAPI
3103 RtlConvertUlongToLuid(
3104 IN ULONG Val)
3105 {
3106 LUID Luid;
3107
3108 Luid.LowPart = Val;
3109 Luid.HighPart = 0;
3110
3111 return Luid;
3112 }
3113 #endif
3114
3115
3116 NTSYSAPI
3117 VOID
3118 NTAPI
3119 RtlCopyMemory32(
3120 IN VOID UNALIGNED *Destination,
3121 IN CONST VOID UNALIGNED *Source,
3122 IN ULONG Length);
3123
3124 NTSYSAPI
3125 VOID
3126 NTAPI
3127 RtlCopyString(
3128 IN OUT PSTRING DestinationString,
3129 IN PSTRING SourceString OPTIONAL);
3130
3131 NTSYSAPI
3132 BOOLEAN
3133 NTAPI
3134 RtlEqualString(
3135 IN PSTRING String1,
3136 IN PSTRING String2,
3137 IN BOOLEAN CaseInSensitive);
3138
3139 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3140 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3141 *CallersAddress = (PVOID)_ReturnAddress(); \
3142 *CallersCaller = NULL;
3143 #else
3144 NTSYSAPI
3145 VOID
3146 NTAPI
3147 RtlGetCallersAddress(
3148 OUT PVOID *CallersAddress,
3149 OUT PVOID *CallersCaller);
3150 #endif
3151
3152 NTSYSAPI
3153 NTSTATUS
3154 NTAPI
3155 RtlGetVersion(
3156 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
3157
3158 NTSYSAPI
3159 VOID
3160 NTAPI
3161 RtlMapGenericMask(
3162 IN OUT PACCESS_MASK AccessMask,
3163 IN PGENERIC_MAPPING GenericMapping);
3164
3165 NTSYSAPI
3166 BOOLEAN
3167 NTAPI
3168 RtlPrefixUnicodeString(
3169 IN PCUNICODE_STRING String1,
3170 IN PCUNICODE_STRING String2,
3171 IN BOOLEAN CaseInSensitive);
3172
3173 NTSYSAPI
3174 NTSTATUS
3175 NTAPI
3176 RtlUpcaseUnicodeString(
3177 IN OUT PUNICODE_STRING DestinationString OPTIONAL,
3178 IN PCUNICODE_STRING SourceString,
3179 IN BOOLEAN AllocateDestinationString);
3180
3181 NTSYSAPI
3182 CHAR
3183 NTAPI
3184 RtlUpperChar(
3185 IN CHAR Character);
3186
3187 NTSYSAPI
3188 VOID
3189 NTAPI
3190 RtlUpperString(
3191 IN OUT PSTRING DestinationString,
3192 IN PSTRING SourceString);
3193
3194 NTSYSAPI
3195 NTSTATUS
3196 NTAPI
3197 RtlVerifyVersionInfo(
3198 IN PRTL_OSVERSIONINFOEXW VersionInfo,
3199 IN ULONG TypeMask,
3200 IN ULONGLONG ConditionMask);
3201
3202 NTSYSAPI
3203 NTSTATUS
3204 NTAPI
3205 RtlVolumeDeviceToDosName(
3206 IN PVOID VolumeDeviceObject,
3207 OUT PUNICODE_STRING DosName);
3208
3209 NTSYSAPI
3210 ULONG
3211 NTAPI
3212 RtlWalkFrameChain(
3213 OUT PVOID *Callers,
3214 IN ULONG Count,
3215 IN ULONG Flags);
3216
3217 NTKERNELAPI
3218 BOOLEAN
3219 NTAPI
3220 KeAreAllApcsDisabled(
3221 VOID
3222 );
3223
3224 /* Guarded Mutex routines */
3225
3226 NTKERNELAPI
3227 VOID
3228 FASTCALL
3229 KeAcquireGuardedMutex(
3230 IN OUT PKGUARDED_MUTEX GuardedMutex
3231 );
3232
3233 NTKERNELAPI
3234 VOID
3235 FASTCALL
3236 KeAcquireGuardedMutexUnsafe(
3237 IN OUT PKGUARDED_MUTEX GuardedMutex
3238 );
3239
3240 NTKERNELAPI
3241 VOID
3242 NTAPI
3243 KeEnterGuardedRegion(
3244 VOID
3245 );
3246
3247 NTKERNELAPI
3248 VOID
3249 NTAPI
3250 KeLeaveGuardedRegion(
3251 VOID
3252 );
3253
3254 NTKERNELAPI
3255 VOID
3256 FASTCALL
3257 KeInitializeGuardedMutex(
3258 OUT PKGUARDED_MUTEX GuardedMutex
3259 );
3260
3261 NTKERNELAPI
3262 VOID
3263 FASTCALL
3264 KeReleaseGuardedMutexUnsafe(
3265 IN OUT PKGUARDED_MUTEX GuardedMutex
3266 );
3267
3268 NTKERNELAPI
3269 VOID
3270 FASTCALL
3271 KeReleaseGuardedMutex(
3272 IN OUT PKGUARDED_MUTEX GuardedMutex
3273 );
3274
3275 NTKERNELAPI
3276 BOOLEAN
3277 FASTCALL
3278 KeTryToAcquireGuardedMutex(
3279 IN OUT PKGUARDED_MUTEX GuardedMutex
3280 );
3281
3282 /* Fast Mutex */
3283 #define ExInitializeFastMutex(_FastMutex) \
3284 { \
3285 (_FastMutex)->Count = FM_LOCK_BIT; \
3286 (_FastMutex)->Owner = NULL; \
3287 (_FastMutex)->Contention = 0; \
3288 KeInitializeEvent(&(_FastMutex)->Gate, SynchronizationEvent, FALSE); \
3289 }
3290
3291 NTKERNELAPI
3292 VOID
3293 NTAPI
3294 KeInitializeEvent(
3295 IN PRKEVENT Event,
3296 IN EVENT_TYPE Type,
3297 IN BOOLEAN State);
3298
3299 /******************************************************************************
3300 * Executive Types *
3301 ******************************************************************************/
3302
3303 typedef struct _ZONE_SEGMENT_HEADER {
3304 SINGLE_LIST_ENTRY SegmentList;
3305 PVOID Reserved;
3306 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
3307
3308 typedef struct _ZONE_HEADER {
3309 SINGLE_LIST_ENTRY FreeList;
3310 SINGLE_LIST_ENTRY SegmentList;
3311 ULONG BlockSize;
3312 ULONG TotalSegmentSize;
3313 } ZONE_HEADER, *PZONE_HEADER;
3314
3315 #define PROTECTED_POOL 0x80000000
3316
3317 /******************************************************************************
3318 * Executive Functions *
3319 ******************************************************************************/
3320
3321 NTKERNELAPI
3322 NTSTATUS
3323 NTAPI
3324 ExExtendZone(
3325 IN PZONE_HEADER Zone,
3326 IN PVOID Segment,
3327 IN ULONG SegmentSize);
3328
3329 static __inline PVOID
3330 ExAllocateFromZone(
3331 IN PZONE_HEADER Zone)
3332 {
3333 if (Zone->FreeList.Next)
3334 Zone->FreeList.Next = Zone->FreeList.Next->Next;
3335 return (PVOID) Zone->FreeList.Next;
3336 }
3337
3338 static __inline PVOID
3339 ExFreeToZone(
3340 IN PZONE_HEADER Zone,
3341 IN PVOID Block)
3342 {
3343 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
3344 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
3345 return ((PSINGLE_LIST_ENTRY) Block)->Next;
3346 }
3347
3348 NTKERNELAPI
3349 NTSTATUS
3350 NTAPI
3351 ExInitializeZone(
3352 IN PZONE_HEADER Zone,
3353 IN ULONG BlockSize,
3354 IN PVOID InitialSegment,
3355 IN ULONG InitialSegmentSize);
3356
3357 /*
3358 * PVOID
3359 * ExInterlockedAllocateFromZone(
3360 * IN PZONE_HEADER Zone,
3361 * IN PKSPIN_LOCK Lock)
3362 */
3363 #define ExInterlockedAllocateFromZone(Zone, Lock) \
3364 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
3365
3366 NTKERNELAPI
3367 NTSTATUS
3368 NTAPI
3369 ExInterlockedExtendZone(
3370 IN PZONE_HEADER Zone,
3371 IN PVOID Segment,
3372 IN ULONG SegmentSize,
3373 IN PKSPIN_LOCK Lock);
3374
3375 /* PVOID
3376 * ExInterlockedFreeToZone(
3377 * IN PZONE_HEADER Zone,
3378 * IN PVOID Block,
3379 * IN PKSPIN_LOCK Lock);
3380 */
3381 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
3382 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
3383
3384 /*
3385 * VOID
3386 * InitializeSListHead(
3387 * IN PSLIST_HEADER SListHead)
3388 */
3389 #define InitializeSListHead(_SListHead) \
3390 (_SListHead)->Alignment = 0
3391
3392 #define ExInitializeSListHead InitializeSListHead
3393
3394 /*
3395 * BOOLEAN
3396 * ExIsFullZone(
3397 * IN PZONE_HEADER Zone)
3398 */
3399 #define ExIsFullZone(Zone) \
3400 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
3401
3402 /* BOOLEAN
3403 * ExIsObjectInFirstZoneSegment(
3404 * IN PZONE_HEADER Zone,
3405 * IN PVOID Object);
3406 */
3407 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
3408 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
3409 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
3410 (Zone)->TotalSegmentSize)) )
3411
3412 NTKERNELAPI
3413 DECLSPEC_NORETURN
3414 VOID
3415 NTAPI
3416 ExRaiseAccessViolation(
3417 VOID);
3418
3419 NTKERNELAPI
3420 DECLSPEC_NORETURN
3421 VOID
3422 NTAPI
3423 ExRaiseDatatypeMisalignment(
3424 VOID);
3425
3426 NTKERNELAPI
3427 NTSTATUS
3428 NTAPI
3429 ExUuidCreate(
3430 OUT UUID *Uuid);
3431
3432 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
3433 #define ExAcquireResourceShared ExAcquireResourceSharedLite
3434 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
3435 #define ExDeleteResource ExDeleteResourceLite
3436 #define ExInitializeResource ExInitializeResourceLite
3437 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
3438 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
3439 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
3440 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
3441
3442
3443 #if DBG
3444
3445 #define PAGED_CODE() { \
3446 if (KeGetCurrentIrql() > APC_LEVEL) { \
3447 KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
3448 ASSERT(FALSE); \
3449 } \
3450 }
3451
3452 #else
3453
3454 #define PAGED_CODE()
3455
3456 #endif
3457
3458 NTKERNELAPI
3459 VOID
3460 NTAPI
3461 ProbeForRead(
3462 IN CONST VOID *Address,
3463 IN SIZE_T Length,
3464 IN ULONG Alignment);
3465
3466 NTKERNELAPI
3467 VOID
3468 NTAPI
3469 ProbeForWrite(
3470 IN PVOID Address,
3471 IN SIZE_T Length,
3472 IN ULONG Alignment);
3473
3474
3475
3476 /** Configuration manager routines **/
3477
3478 NTKERNELAPI
3479 NTSTATUS
3480 NTAPI
3481 CmRegisterCallback(
3482 IN PEX_CALLBACK_FUNCTION Function,
3483 IN PVOID Context,
3484 IN OUT PLARGE_INTEGER Cookie);
3485
3486 NTKERNELAPI
3487 NTSTATUS
3488 NTAPI
3489 CmUnRegisterCallback(
3490 IN LARGE_INTEGER Cookie);
3491
3492
3493
3494 /** Filesystem runtime library routines **/
3495
3496 NTKERNELAPI
3497 BOOLEAN
3498 NTAPI
3499 FsRtlIsTotalDeviceFailure(
3500 IN NTSTATUS Status);
3501
3502
3503
3504 /** Hardware abstraction layer routines **/
3505
3506 NTHALAPI
3507 BOOLEAN
3508 NTAPI
3509 HalMakeBeep(
3510 IN ULONG Frequency);
3511
3512 NTKERNELAPI
3513 VOID
3514 FASTCALL
3515 HalExamineMBR(
3516 IN PDEVICE_OBJECT DeviceObject,
3517 IN ULONG SectorSize,
3518 IN ULONG MBRTypeIdentifier,
3519 OUT PVOID *Buffer);
3520
3521 VOID
3522 NTAPI
3523 HalPutDmaAdapter(
3524 PADAPTER_OBJECT AdapterObject
3525 );
3526
3527
3528 /** Io access routines **/
3529
3530 #if !defined(_M_AMD64)
3531 NTHALAPI
3532 VOID
3533 NTAPI
3534 READ_PORT_BUFFER_UCHAR(
3535 IN PUCHAR Port,
3536 IN PUCHAR Buffer,
3537 IN ULONG Count);
3538
3539 NTHALAPI
3540 VOID
3541 NTAPI
3542 READ_PORT_BUFFER_ULONG(
3543 IN PULONG Port,
3544 IN PULONG Buffer,
3545 IN ULONG Count);
3546
3547 NTHALAPI
3548 VOID
3549 NTAPI
3550 READ_PORT_BUFFER_USHORT(
3551 IN PUSHORT Port,
3552 IN PUSHORT Buffer,
3553 IN ULONG Count);
3554
3555 NTHALAPI
3556 UCHAR
3557 NTAPI
3558 READ_PORT_UCHAR(
3559 IN PUCHAR Port);
3560
3561 NTHALAPI
3562 ULONG
3563 NTAPI
3564 READ_PORT_ULONG(
3565 IN PULONG Port);
3566
3567 NTHALAPI
3568 USHORT
3569 NTAPI
3570 READ_PORT_USHORT(
3571 IN PUSHORT Port);
3572
3573 NTKERNELAPI
3574 VOID
3575 NTAPI
3576 READ_REGISTER_BUFFER_UCHAR(
3577 IN PUCHAR Register,
3578 IN PUCHAR Buffer,
3579 IN ULONG Count);
3580
3581 NTKERNELAPI
3582 VOID
3583 NTAPI
3584 READ_REGISTER_BUFFER_ULONG(
3585 IN PULONG Register,
3586 IN PULONG Buffer,
3587 IN ULONG Count);
3588
3589 NTKERNELAPI
3590 VOID
3591 NTAPI
3592 READ_REGISTER_BUFFER_USHORT(
3593 IN PUSHORT Register,
3594 IN PUSHORT Buffer,
3595 IN ULONG Count);
3596
3597 NTKERNELAPI
3598 UCHAR
3599 NTAPI
3600 READ_REGISTER_UCHAR(
3601 IN PUCHAR Register);
3602
3603 NTKERNELAPI
3604 ULONG
3605 NTAPI
3606 READ_REGISTER_ULONG(
3607 IN PULONG Register);
3608
3609 NTKERNELAPI
3610 USHORT
3611 NTAPI
3612 READ_REGISTER_USHORT(
3613 IN PUSHORT Register);
3614
3615 NTHALAPI
3616 VOID
3617 NTAPI
3618 WRITE_PORT_BUFFER_UCHAR(
3619 IN PUCHAR Port,
3620 IN PUCHAR Buffer,
3621 IN ULONG Count);
3622
3623 NTHALAPI
3624 VOID
3625 NTAPI
3626 WRITE_PORT_BUFFER_ULONG(
3627 IN PULONG Port,
3628 IN PULONG Buffer,
3629 IN ULONG Count);
3630
3631 NTHALAPI
3632 VOID
3633 NTAPI
3634 WRITE_PORT_BUFFER_USHORT(
3635 IN PUSHORT Port,
3636 IN PUSHORT Buffer,
3637 IN ULONG Count);
3638
3639 NTHALAPI
3640 VOID
3641 NTAPI
3642 WRITE_PORT_UCHAR(
3643 IN PUCHAR Port,
3644 IN UCHAR Value);
3645
3646 NTHALAPI
3647 VOID
3648 NTAPI
3649 WRITE_PORT_ULONG(
3650 IN PULONG Port,
3651 IN ULONG Value);
3652
3653 NTHALAPI
3654 VOID
3655 NTAPI
3656 WRITE_PORT_USHORT(
3657 IN PUSHORT Port,
3658 IN USHORT Value);
3659
3660 NTKERNELAPI
3661 VOID
3662 NTAPI
3663 WRITE_REGISTER_BUFFER_UCHAR(
3664 IN PUCHAR Register,
3665 IN PUCHAR Buffer,
3666 IN ULONG Count);
3667
3668 NTKERNELAPI
3669 VOID
3670 NTAPI
3671 WRITE_REGISTER_BUFFER_ULONG(
3672 IN PULONG Register,
3673 IN PULONG Buffer,
3674 IN ULONG Count);
3675
3676 NTKERNELAPI
3677 VOID
3678 NTAPI
3679 WRITE_REGISTER_BUFFER_USHORT(
3680 IN PUSHORT Register,
3681 IN PUSHORT Buffer,
3682 IN ULONG Count);
3683
3684 NTKERNELAPI
3685 VOID
3686 NTAPI
3687 WRITE_REGISTER_UCHAR(
3688 IN PUCHAR Register,
3689 IN UCHAR Value);
3690
3691 NTKERNELAPI
3692 VOID
3693 NTAPI
3694 WRITE_REGISTER_ULONG(
3695 IN PULONG Register,
3696 IN ULONG Value);
3697
3698 NTKERNELAPI
3699 VOID
3700 NTAPI
3701 WRITE_REGISTER_USHORT(
3702 IN PUSHORT Register,
3703 IN USHORT Value);
3704
3705 #else
3706
3707 FORCEINLINE
3708 VOID
3709 READ_PORT_BUFFER_UCHAR(
3710 IN PUCHAR Port,
3711 IN PUCHAR Buffer,
3712 IN ULONG Count)
3713 {
3714 __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3715 }
3716
3717 FORCEINLINE
3718 VOID
3719 READ_PORT_BUFFER_ULONG(
3720 IN PULONG Port,
3721 IN PULONG Buffer,
3722 IN ULONG Count)
3723 {
3724 __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3725 }
3726
3727 FORCEINLINE
3728 VOID
3729 READ_PORT_BUFFER_USHORT(
3730 IN PUSHORT Port,
3731 IN PUSHORT Buffer,
3732 IN ULONG Count)
3733 {
3734 __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3735 }
3736
3737 FORCEINLINE
3738 UCHAR
3739 READ_PORT_UCHAR(
3740 IN PUCHAR Port)
3741 {
3742 return __inbyte((USHORT)(ULONG_PTR)Port);
3743 }
3744
3745 FORCEINLINE
3746 ULONG
3747 READ_PORT_ULONG(
3748 IN PULONG Port)
3749 {
3750 return __indword((USHORT)(ULONG_PTR)Port);
3751 }
3752
3753 FORCEINLINE
3754 USHORT
3755 READ_PORT_USHORT(
3756 IN PUSHORT Port)
3757 {
3758 return __inword((USHORT)(ULONG_PTR)Port);
3759 }
3760
3761 FORCEINLINE
3762 VOID
3763 READ_REGISTER_BUFFER_UCHAR(
3764 IN PUCHAR Register,
3765 IN PUCHAR Buffer,
3766 IN ULONG Count)
3767 {
3768 __movsb(Register, Buffer, Count);
3769 }
3770
3771 FORCEINLINE
3772 VOID
3773 READ_REGISTER_BUFFER_ULONG(
3774 IN PULONG Register,
3775 IN PULONG Buffer,
3776 IN ULONG Count)
3777 {
3778 __movsd(Register, Buffer, Count);
3779 }
3780
3781 FORCEINLINE
3782 VOID
3783 READ_REGISTER_BUFFER_USHORT(
3784 IN PUSHORT Register,
3785 IN PUSHORT Buffer,
3786 IN ULONG Count)
3787 {
3788 __movsw(Register, Buffer, Count);
3789 }
3790
3791 FORCEINLINE
3792 UCHAR
3793 READ_REGISTER_UCHAR(
3794 IN PUCHAR Register)
3795 {
3796 return *Register;
3797 }
3798
3799 FORCEINLINE
3800 ULONG
3801 READ_REGISTER_ULONG(
3802 IN PULONG Register)
3803 {
3804 return *Register;
3805 }
3806
3807 FORCEINLINE
3808 USHORT
3809 READ_REGISTER_USHORT(
3810 IN PUSHORT Register)
3811 {
3812 return *Register;
3813 }
3814
3815 FORCEINLINE
3816 VOID
3817 WRITE_PORT_BUFFER_UCHAR(
3818 IN PUCHAR Port,
3819 IN PUCHAR Buffer,
3820 IN ULONG Count)
3821 {
3822 __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3823 }
3824
3825 FORCEINLINE
3826 VOID
3827 WRITE_PORT_BUFFER_ULONG(
3828 IN PULONG Port,
3829 IN PULONG Buffer,
3830 IN ULONG Count)
3831 {
3832 __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3833 }
3834
3835 FORCEINLINE
3836 VOID
3837 WRITE_PORT_BUFFER_USHORT(
3838 IN PUSHORT Port,
3839 IN PUSHORT Buffer,
3840 IN ULONG Count)
3841 {
3842 __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3843 }
3844
3845 FORCEINLINE
3846 VOID
3847 WRITE_PORT_UCHAR(
3848 IN PUCHAR Port,
3849 IN UCHAR Value)
3850 {
3851 __outbyte((USHORT)(ULONG_PTR)Port, Value);
3852 }
3853
3854 FORCEINLINE
3855 VOID
3856 WRITE_PORT_ULONG(
3857 IN PULONG Port,
3858 IN ULONG Value)
3859 {
3860 __outdword((USHORT)(ULONG_PTR)Port, Value);
3861 }
3862
3863 FORCEINLINE
3864 VOID
3865 WRITE_PORT_USHORT(
3866 IN PUSHORT Port,
3867 IN USHORT Value)
3868 {
3869 __outword((USHORT)(ULONG_PTR)Port, Value);
3870 }
3871
3872 FORCEINLINE
3873 VOID
3874 WRITE_REGISTER_BUFFER_UCHAR(
3875 IN PUCHAR Register,
3876 IN PUCHAR Buffer,
3877 IN ULONG Count)
3878 {
3879 LONG Synch;
3880 __movsb(Register, Buffer, Count);
3881 InterlockedOr(&Synch, 1);
3882 }
3883
3884 FORCEINLINE
3885 VOID
3886 WRITE_REGISTER_BUFFER_ULONG(
3887 IN PULONG Register,
3888 IN PULONG Buffer,
3889 IN ULONG Count)
3890 {
3891 LONG Synch;
3892 __movsd(Register, Buffer, Count);
3893 InterlockedOr(&Synch, 1);
3894 }
3895
3896 FORCEINLINE
3897 VOID
3898 WRITE_REGISTER_BUFFER_USHORT(
3899 IN PUSHORT Register,
3900 IN PUSHORT Buffer,
3901 IN ULONG Count)
3902 {
3903 LONG Synch;
3904 __movsw(Register, Buffer, Count);
3905 InterlockedOr(&Synch, 1);
3906 }
3907
3908 FORCEINLINE
3909 VOID
3910 WRITE_REGISTER_UCHAR(
3911 IN PUCHAR Register,
3912 IN UCHAR Value)
3913 {
3914 LONG Synch;
3915 *Register = Value;
3916 InterlockedOr(&Synch, 1);
3917 }
3918
3919 FORCEINLINE
3920 VOID
3921 WRITE_REGISTER_ULONG(
3922 IN PULONG Register,
3923 IN ULONG Value)
3924 {
3925 LONG Synch;
3926 *Register = Value;
3927 InterlockedOr(&Synch, 1);
3928 }
3929
3930 FORCEINLINE
3931 VOID
3932 WRITE_REGISTER_USHORT(
3933 IN PUSHORT Register,
3934 IN USHORT Value)
3935 {
3936 LONG Sync;
3937 *Register = Value;
3938 InterlockedOr(&Sync, 1);
3939 }
3940
3941 #endif
3942
3943 /** I/O manager routines **/
3944
3945 NTKERNELAPI
3946 VOID
3947 NTAPI
3948 IoAcquireCancelSpinLock(
3949 OUT PKIRQL Irql);
3950
3951 NTKERNELAPI
3952 NTSTATUS
3953 NTAPI
3954 IoAcquireRemoveLockEx(
3955 IN PIO_REMOVE_LOCK RemoveLock,
3956 IN OPTIONAL PVOID Tag OPTIONAL,
3957 IN PCSTR File,
3958 IN ULONG Line,
3959 IN ULONG RemlockSize);
3960
3961 /*
3962 * NTSTATUS
3963 * IoAcquireRemoveLock(
3964 * IN PIO_REMOVE_LOCK RemoveLock,
3965 * IN OPTIONAL PVOID Tag)
3966 */
3967 #define IoAcquireRemoveLock(_RemoveLock, \
3968 _Tag) \
3969 IoAcquireRemoveLockEx(_RemoveLock, _Tag, __FILE__, __LINE__, sizeof(IO_REMOVE_LOCK))
3970
3971 /*
3972 * VOID