3dce7b8326a7049b7e6daa18dc14b2375dfdb920
[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 enum _KWAIT_REASON {
1319 Executive,
1320 FreePage,
1321 PageIn,
1322 PoolAllocation,
1323 DelayExecution,
1324 Suspended,
1325 UserRequest,
1326 WrExecutive,
1327 WrFreePage,
1328 WrPageIn,
1329 WrPoolAllocation,
1330 WrDelayExecution,
1331 WrSuspended,
1332 WrUserRequest,
1333 WrEventPair,
1334 WrQueue,
1335 WrLpcReceive,
1336 WrLpcReply,
1337 WrVirtualMemory,
1338 WrPageOut,
1339 WrRendezvous,
1340 Spare2,
1341 WrGuardedMutex,
1342 Spare4,
1343 Spare5,
1344 Spare6,
1345 WrKernel,
1346 WrResource,
1347 WrPushLock,
1348 WrMutex,
1349 WrQuantumEnd,
1350 WrDispatchInt,
1351 WrPreempted,
1352 WrYieldExecution,
1353 MaximumWaitReason
1354 } KWAIT_REASON;
1355
1356 typedef struct _KWAIT_BLOCK {
1357 LIST_ENTRY WaitListEntry;
1358 struct _KTHREAD * RESTRICTED_POINTER Thread;
1359 PVOID Object;
1360 struct _KWAIT_BLOCK * RESTRICTED_POINTER NextWaitBlock;
1361 USHORT WaitKey;
1362 UCHAR WaitType;
1363 UCHAR SpareByte;
1364 } KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
1365
1366 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
1367
1368 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
1369 BOOLEAN Removed;
1370 BOOLEAN Reserved[3];
1371 volatile LONG IoCount;
1372 KEVENT RemoveEvent;
1373 } IO_REMOVE_LOCK_COMMON_BLOCK;
1374
1375 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
1376 LONG Signature;
1377 LONG HighWatermark;
1378 LONGLONG MaxLockedTicks;
1379 LONG AllocateTag;
1380 LIST_ENTRY LockList;
1381 KSPIN_LOCK Spin;
1382 volatile LONG LowMemoryCount;
1383 ULONG Reserved1[4];
1384 PVOID Reserved2;
1385 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
1386 } IO_REMOVE_LOCK_DBG_BLOCK;
1387
1388 typedef struct _IO_REMOVE_LOCK {
1389 IO_REMOVE_LOCK_COMMON_BLOCK Common;
1390 #if DBG
1391 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
1392 #endif
1393 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
1394
1395 typedef struct _IO_WORKITEM *PIO_WORKITEM;
1396
1397 typedef VOID
1398 (DDKAPI IO_WORKITEM_ROUTINE)(
1399 IN PDEVICE_OBJECT DeviceObject,
1400 IN PVOID Context);
1401 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
1402
1403 typedef struct _SHARE_ACCESS {
1404 ULONG OpenCount;
1405 ULONG Readers;
1406 ULONG Writers;
1407 ULONG Deleters;
1408 ULONG SharedRead;
1409 ULONG SharedWrite;
1410 ULONG SharedDelete;
1411 } SHARE_ACCESS, *PSHARE_ACCESS;
1412
1413 typedef enum _KINTERRUPT_MODE {
1414 LevelSensitive,
1415 Latched
1416 } KINTERRUPT_MODE;
1417
1418 #define THREAD_WAIT_OBJECTS 3
1419
1420 typedef VOID
1421 (DDKAPI *PKINTERRUPT_ROUTINE)(
1422 VOID);
1423
1424 typedef enum _CREATE_FILE_TYPE {
1425 CreateFileTypeNone,
1426 CreateFileTypeNamedPipe,
1427 CreateFileTypeMailslot
1428 } CREATE_FILE_TYPE;
1429
1430 typedef struct _CONFIGURATION_INFORMATION {
1431 ULONG DiskCount;
1432 ULONG FloppyCount;
1433 ULONG CdRomCount;
1434 ULONG TapeCount;
1435 ULONG ScsiPortCount;
1436 ULONG SerialCount;
1437 ULONG ParallelCount;
1438 BOOLEAN AtDiskPrimaryAddressClaimed;
1439 BOOLEAN AtDiskSecondaryAddressClaimed;
1440 ULONG Version;
1441 ULONG MediumChangerCount;
1442 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
1443
1444 typedef enum _CONFIGURATION_TYPE {
1445 ArcSystem,
1446 CentralProcessor,
1447 FloatingPointProcessor,
1448 PrimaryIcache,
1449 PrimaryDcache,
1450 SecondaryIcache,
1451 SecondaryDcache,
1452 SecondaryCache,
1453 EisaAdapter,
1454 TcAdapter,
1455 ScsiAdapter,
1456 DtiAdapter,
1457 MultiFunctionAdapter,
1458 DiskController,
1459 TapeController,
1460 CdromController,
1461 WormController,
1462 SerialController,
1463 NetworkController,
1464 DisplayController,
1465 ParallelController,
1466 PointerController,
1467 KeyboardController,
1468 AudioController,
1469 OtherController,
1470 DiskPeripheral,
1471 FloppyDiskPeripheral,
1472 TapePeripheral,
1473 ModemPeripheral,
1474 MonitorPeripheral,
1475 PrinterPeripheral,
1476 PointerPeripheral,
1477 KeyboardPeripheral,
1478 TerminalPeripheral,
1479 OtherPeripheral,
1480 LinePeripheral,
1481 NetworkPeripheral,
1482 SystemMemory,
1483 DockingInformation,
1484 RealModeIrqRoutingTable,
1485 RealModePCIEnumeration,
1486 MaximumType
1487 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE;
1488
1489 #define IO_FORCE_ACCESS_CHECK 0x001
1490 #define IO_NO_PARAMETER_CHECKING 0x100
1491
1492 #define IO_REPARSE 0x0
1493 #define IO_REMOUNT 0x1
1494
1495 typedef NTSTATUS
1496 (DDKAPI *PIO_QUERY_DEVICE_ROUTINE)(
1497 IN PVOID Context,
1498 IN PUNICODE_STRING PathName,
1499 IN INTERFACE_TYPE BusType,
1500 IN ULONG BusNumber,
1501 IN PKEY_VALUE_FULL_INFORMATION *BusInformation,
1502 IN CONFIGURATION_TYPE ControllerType,
1503 IN ULONG ControllerNumber,
1504 IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation,
1505 IN CONFIGURATION_TYPE PeripheralType,
1506 IN ULONG PeripheralNumber,
1507 IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation);
1508
1509 typedef enum _IO_QUERY_DEVICE_DATA_FORMAT {
1510 IoQueryDeviceIdentifier = 0,
1511 IoQueryDeviceConfigurationData,
1512 IoQueryDeviceComponentInformation,
1513 IoQueryDeviceMaxData
1514 } IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT;
1515
1516 typedef enum _KBUGCHECK_CALLBACK_REASON {
1517 KbCallbackInvalid,
1518 KbCallbackReserved1,
1519 KbCallbackSecondaryDumpData,
1520 KbCallbackDumpIo,
1521 } KBUGCHECK_CALLBACK_REASON;
1522
1523 struct _KBUGCHECK_REASON_CALLBACK_RECORD;
1524
1525 typedef VOID
1526 (DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)(
1527 IN KBUGCHECK_CALLBACK_REASON Reason,
1528 IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record,
1529 IN OUT PVOID ReasonSpecificData,
1530 IN ULONG ReasonSpecificDataLength);
1531
1532 typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD {
1533 LIST_ENTRY Entry;
1534 PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine;
1535 PUCHAR Component;
1536 ULONG_PTR Checksum;
1537 KBUGCHECK_CALLBACK_REASON Reason;
1538 UCHAR State;
1539 } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD;
1540
1541 typedef enum _KBUGCHECK_BUFFER_DUMP_STATE {
1542 BufferEmpty,
1543 BufferInserted,
1544 BufferStarted,
1545 BufferFinished,
1546 BufferIncomplete
1547 } KBUGCHECK_BUFFER_DUMP_STATE;
1548
1549 typedef VOID
1550 (DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)(
1551 IN PVOID Buffer,
1552 IN ULONG Length);
1553
1554 typedef struct _KBUGCHECK_CALLBACK_RECORD {
1555 LIST_ENTRY Entry;
1556 PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine;
1557 PVOID Buffer;
1558 ULONG Length;
1559 PUCHAR Component;
1560 ULONG_PTR Checksum;
1561 UCHAR State;
1562 } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
1563
1564 typedef BOOLEAN
1565 (DDKAPI *PNMI_CALLBACK)(
1566 IN PVOID Context,
1567 IN BOOLEAN Handled);
1568
1569 /*
1570 * VOID
1571 * KeInitializeCallbackRecord(
1572 * IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
1573 */
1574 #define KeInitializeCallbackRecord(CallbackRecord) \
1575 CallbackRecord->State = BufferEmpty;
1576
1577 typedef enum _KDPC_IMPORTANCE {
1578 LowImportance,
1579 MediumImportance,
1580 HighImportance
1581 } KDPC_IMPORTANCE;
1582
1583 typedef enum _MEMORY_CACHING_TYPE_ORIG {
1584 MmFrameBufferCached = 2
1585 } MEMORY_CACHING_TYPE_ORIG;
1586
1587 typedef enum _MEMORY_CACHING_TYPE {
1588 MmNonCached = FALSE,
1589 MmCached = TRUE,
1590 MmWriteCombined = MmFrameBufferCached,
1591 MmHardwareCoherentCached,
1592 MmNonCachedUnordered,
1593 MmUSWCCached,
1594 MmMaximumCacheType
1595 } MEMORY_CACHING_TYPE;
1596
1597 typedef enum _MM_PAGE_PRIORITY {
1598 LowPagePriority,
1599 NormalPagePriority = 16,
1600 HighPagePriority = 32
1601 } MM_PAGE_PRIORITY;
1602
1603 typedef enum _LOCK_OPERATION {
1604 IoReadAccess,
1605 IoWriteAccess,
1606 IoModifyAccess
1607 } LOCK_OPERATION;
1608
1609 #define FLUSH_MULTIPLE_MAXIMUM 32
1610
1611 typedef enum _MM_SYSTEM_SIZE {
1612 MmSmallSystem,
1613 MmMediumSystem,
1614 MmLargeSystem
1615 } MM_SYSTEMSIZE;
1616
1617 typedef struct _OBJECT_HANDLE_INFORMATION {
1618 ULONG HandleAttributes;
1619 ACCESS_MASK GrantedAccess;
1620 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
1621
1622 typedef struct _CLIENT_ID {
1623 HANDLE UniqueProcess;
1624 HANDLE UniqueThread;
1625 } CLIENT_ID, *PCLIENT_ID;
1626
1627 typedef VOID
1628 (DDKAPI *PKSTART_ROUTINE)(
1629 IN PVOID StartContext);
1630
1631 typedef VOID
1632 (DDKAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)(
1633 IN HANDLE ParentId,
1634 IN HANDLE ProcessId,
1635 IN BOOLEAN Create);
1636
1637 typedef VOID
1638 (DDKAPI *PCREATE_THREAD_NOTIFY_ROUTINE)(
1639 IN HANDLE ProcessId,
1640 IN HANDLE ThreadId,
1641 IN BOOLEAN Create);
1642
1643 typedef struct _IMAGE_INFO {
1644 _ANONYMOUS_UNION union {
1645 ULONG Properties;
1646 _ANONYMOUS_STRUCT struct {
1647 ULONG ImageAddressingMode : 8;
1648 ULONG SystemModeImage : 1;
1649 ULONG ImageMappedToAllPids : 1;
1650 ULONG Reserved : 22;
1651 } DUMMYSTRUCTNAME;
1652 } DUMMYUNIONNAME;
1653 PVOID ImageBase;
1654 ULONG ImageSelector;
1655 SIZE_T ImageSize;
1656 ULONG ImageSectionNumber;
1657 } IMAGE_INFO, *PIMAGE_INFO;
1658
1659 #define IMAGE_ADDRESSING_MODE_32BIT 3
1660
1661 typedef VOID
1662 (DDKAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)(
1663 IN PUNICODE_STRING FullImageName,
1664 IN HANDLE ProcessId,
1665 IN PIMAGE_INFO ImageInfo);
1666
1667 #pragma pack(push,4)
1668 typedef enum _BUS_DATA_TYPE {
1669 ConfigurationSpaceUndefined = -1,
1670 Cmos,
1671 EisaConfiguration,
1672 Pos,
1673 CbusConfiguration,
1674 PCIConfiguration,
1675 VMEConfiguration,
1676 NuBusConfiguration,
1677 PCMCIAConfiguration,
1678 MPIConfiguration,
1679 MPSAConfiguration,
1680 PNPISAConfiguration,
1681 SgiInternalConfiguration,
1682 MaximumBusDataType
1683 } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
1684 #pragma pack(pop)
1685
1686 typedef struct _NT_TIB {
1687 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1688 PVOID StackBase;
1689 PVOID StackLimit;
1690 PVOID SubSystemTib;
1691 _ANONYMOUS_UNION union {
1692 PVOID FiberData;
1693 ULONG Version;
1694 } DUMMYUNIONNAME;
1695 PVOID ArbitraryUserPointer;
1696 struct _NT_TIB *Self;
1697 } NT_TIB, *PNT_TIB;
1698
1699 typedef struct _NT_TIB32 {
1700 ULONG ExceptionList;
1701 ULONG StackBase;
1702 ULONG StackLimit;
1703 ULONG SubSystemTib;
1704 __GNU_EXTENSION union {
1705 ULONG FiberData;
1706 ULONG Version;
1707 };
1708 ULONG ArbitraryUserPointer;
1709 ULONG Self;
1710 } NT_TIB32,*PNT_TIB32;
1711
1712 typedef struct _NT_TIB64 {
1713 ULONG64 ExceptionList;
1714 ULONG64 StackBase;
1715 ULONG64 StackLimit;
1716 ULONG64 SubSystemTib;
1717 __GNU_EXTENSION union {
1718 ULONG64 FiberData;
1719 ULONG Version;
1720 };
1721 ULONG64 ArbitraryUserPointer;
1722 ULONG64 Self;
1723 } NT_TIB64,*PNT_TIB64;
1724
1725 typedef enum _PROCESSINFOCLASS {
1726 ProcessBasicInformation,
1727 ProcessQuotaLimits,
1728 ProcessIoCounters,
1729 ProcessVmCounters,
1730 ProcessTimes,
1731 ProcessBasePriority,
1732 ProcessRaisePriority,
1733 ProcessDebugPort,
1734 ProcessExceptionPort,
1735 ProcessAccessToken,
1736 ProcessLdtInformation,
1737 ProcessLdtSize,
1738 ProcessDefaultHardErrorMode,
1739 ProcessIoPortHandlers,
1740 ProcessPooledUsageAndLimits,
1741 ProcessWorkingSetWatch,
1742 ProcessUserModeIOPL,
1743 ProcessEnableAlignmentFaultFixup,
1744 ProcessPriorityClass,
1745 ProcessWx86Information,
1746 ProcessHandleCount,
1747 ProcessAffinityMask,
1748 ProcessPriorityBoost,
1749 ProcessDeviceMap,
1750 ProcessSessionInformation,
1751 ProcessForegroundInformation,
1752 ProcessWow64Information,
1753 ProcessImageFileName,
1754 ProcessLUIDDeviceMapsEnabled,
1755 ProcessBreakOnTermination,
1756 ProcessDebugObjectHandle,
1757 ProcessDebugFlags,
1758 ProcessHandleTracing,
1759 ProcessIoPriority,
1760 ProcessExecuteFlags,
1761 ProcessTlsInformation,
1762 ProcessCookie,
1763 ProcessImageInformation,
1764 ProcessCycleTime,
1765 ProcessPagePriority,
1766 ProcessInstrumentationCallback,
1767 MaxProcessInfoClass
1768 } PROCESSINFOCLASS;
1769
1770 typedef enum _THREADINFOCLASS {
1771 ThreadBasicInformation,
1772 ThreadTimes,
1773 ThreadPriority,
1774 ThreadBasePriority,
1775 ThreadAffinityMask,
1776 ThreadImpersonationToken,
1777 ThreadDescriptorTableEntry,
1778 ThreadEnableAlignmentFaultFixup,
1779 ThreadEventPair_Reusable,
1780 ThreadQuerySetWin32StartAddress,
1781 ThreadZeroTlsCell,
1782 ThreadPerformanceCount,
1783 ThreadAmILastThread,
1784 ThreadIdealProcessor,
1785 ThreadPriorityBoost,
1786 ThreadSetTlsArrayAddress,
1787 ThreadIsIoPending,
1788 ThreadHideFromDebugger,
1789 ThreadBreakOnTermination,
1790 ThreadSwitchLegacyState,
1791 ThreadIsTerminated,
1792 ThreadLastSystemCall,
1793 ThreadIoPriority,
1794 ThreadCycleTime,
1795 ThreadPagePriority,
1796 ThreadActualBasePriority,
1797 MaxThreadInfoClass
1798 } THREADINFOCLASS;
1799
1800 typedef struct _PROCESS_BASIC_INFORMATION
1801 {
1802 NTSTATUS ExitStatus;
1803 struct _PEB *PebBaseAddress;
1804 ULONG_PTR AffinityMask;
1805 KPRIORITY BasePriority;
1806 ULONG_PTR UniqueProcessId;
1807 ULONG_PTR InheritedFromUniqueProcessId;
1808 } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION;
1809
1810 typedef struct _PROCESS_WS_WATCH_INFORMATION
1811 {
1812 PVOID FaultingPc;
1813 PVOID FaultingVa;
1814 } PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
1815
1816 typedef struct _PROCESS_DEVICEMAP_INFORMATION
1817 {
1818 __GNU_EXTENSION union
1819 {
1820 struct
1821 {
1822 HANDLE DirectoryHandle;
1823 } Set;
1824 struct
1825 {
1826 ULONG DriveMap;
1827 UCHAR DriveType[32];
1828 } Query;
1829 };
1830 } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION;
1831
1832 typedef struct _KERNEL_USER_TIMES
1833 {
1834 LARGE_INTEGER CreateTime;
1835 LARGE_INTEGER ExitTime;
1836 LARGE_INTEGER KernelTime;
1837 LARGE_INTEGER UserTime;
1838 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
1839
1840 typedef struct _PROCESS_ACCESS_TOKEN
1841 {
1842 HANDLE Token;
1843 HANDLE Thread;
1844 } PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
1845
1846 typedef struct _PROCESS_SESSION_INFORMATION
1847 {
1848 ULONG SessionId;
1849 } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION;
1850
1851 typedef VOID
1852 (DDKAPI *PREQUEST_POWER_COMPLETE)(
1853 IN PDEVICE_OBJECT DeviceObject,
1854 IN UCHAR MinorFunction,
1855 IN POWER_STATE PowerState,
1856 IN PVOID Context,
1857 IN PIO_STATUS_BLOCK IoStatus);
1858
1859 typedef enum _TRACE_INFORMATION_CLASS {
1860 TraceIdClass,
1861 TraceHandleClass,
1862 TraceEnableFlagsClass,
1863 TraceEnableLevelClass,
1864 GlobalLoggerHandleClass,
1865 EventLoggerHandleClass,
1866 AllLoggerHandlesClass,
1867 TraceHandleByNameClass
1868 } TRACE_INFORMATION_CLASS;
1869
1870 typedef enum _REG_NOTIFY_CLASS
1871 {
1872 RegNtDeleteKey,
1873 RegNtPreDeleteKey = RegNtDeleteKey,
1874 RegNtSetValueKey,
1875 RegNtPreSetValueKey = RegNtSetValueKey,
1876 RegNtDeleteValueKey,
1877 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
1878 RegNtSetInformationKey,
1879 RegNtPreSetInformationKey = RegNtSetInformationKey,
1880 RegNtRenameKey,
1881 RegNtPreRenameKey = RegNtRenameKey,
1882 RegNtEnumerateKey,
1883 RegNtPreEnumerateKey = RegNtEnumerateKey,
1884 RegNtEnumerateValueKey,
1885 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
1886 RegNtQueryKey,
1887 RegNtPreQueryKey = RegNtQueryKey,
1888 RegNtQueryValueKey,
1889 RegNtPreQueryValueKey = RegNtQueryValueKey,
1890 RegNtQueryMultipleValueKey,
1891 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
1892 RegNtPreCreateKey,
1893 RegNtPostCreateKey,
1894 RegNtPreOpenKey,
1895 RegNtPostOpenKey,
1896 RegNtKeyHandleClose,
1897 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
1898 RegNtPostDeleteKey,
1899 RegNtPostSetValueKey,
1900 RegNtPostDeleteValueKey,
1901 RegNtPostSetInformationKey,
1902 RegNtPostRenameKey,
1903 RegNtPostEnumerateKey,
1904 RegNtPostEnumerateValueKey,
1905 RegNtPostQueryKey,
1906 RegNtPostQueryValueKey,
1907 RegNtPostQueryMultipleValueKey,
1908 RegNtPostKeyHandleClose,
1909 RegNtPreCreateKeyEx,
1910 RegNtPostCreateKeyEx,
1911 RegNtPreOpenKeyEx,
1912 RegNtPostOpenKeyEx
1913 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
1914
1915 typedef NTSTATUS
1916 (NTAPI *PEX_CALLBACK_FUNCTION)(
1917 IN PVOID CallbackContext,
1918 IN PVOID Argument1,
1919 IN PVOID Argument2
1920 );
1921
1922 typedef struct _REG_DELETE_KEY_INFORMATION
1923 {
1924 PVOID Object;
1925 } REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION;
1926
1927 typedef struct _REG_SET_VALUE_KEY_INFORMATION
1928 {
1929 PVOID Object;
1930 PUNICODE_STRING ValueName;
1931 ULONG TitleIndex;
1932 ULONG Type;
1933 PVOID Data;
1934 ULONG DataSize;
1935 } REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION;
1936
1937 typedef struct _REG_DELETE_VALUE_KEY_INFORMATION
1938 {
1939 PVOID Object;
1940 PUNICODE_STRING ValueName;
1941 } REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION;
1942
1943 typedef struct _REG_SET_INFORMATION_KEY_INFORMATION
1944 {
1945 PVOID Object;
1946 KEY_SET_INFORMATION_CLASS KeySetInformationClass;
1947 PVOID KeySetInformation;
1948 ULONG KeySetInformationLength;
1949 } REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION;
1950
1951 typedef struct _REG_ENUMERATE_KEY_INFORMATION
1952 {
1953 PVOID Object;
1954 ULONG Index;
1955 KEY_INFORMATION_CLASS KeyInformationClass;
1956 PVOID KeyInformation;
1957 ULONG Length;
1958 PULONG ResultLength;
1959 } REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION;
1960
1961 typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION
1962 {
1963 PVOID Object;
1964 ULONG Index;
1965 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
1966 PVOID KeyValueInformation;
1967 ULONG Length;
1968 PULONG ResultLength;
1969 } REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION;
1970
1971 typedef struct _REG_QUERY_KEY_INFORMATION
1972 {
1973 PVOID Object;
1974 KEY_INFORMATION_CLASS KeyInformationClass;
1975 PVOID KeyInformation;
1976 ULONG Length;
1977 PULONG ResultLength;
1978 } REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION;
1979
1980 typedef struct _REG_QUERY_VALUE_KEY_INFORMATION
1981 {
1982 PVOID Object;
1983 PUNICODE_STRING ValueName;
1984 KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass;
1985 PVOID KeyValueInformation;
1986 ULONG Length;
1987 PULONG ResultLength;
1988 } REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION;
1989
1990 typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION
1991 {
1992 PVOID Object;
1993 PKEY_VALUE_ENTRY ValueEntries;
1994 ULONG EntryCount;
1995 PVOID ValueBuffer;
1996 PULONG BufferLength;
1997 PULONG RequiredBufferLength;
1998 } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION;
1999
2000 typedef struct _REG_PRE_CREATE_KEY_INFORMATION
2001 {
2002 PUNICODE_STRING CompleteName;
2003 } REG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_CREATE_KEY_INFORMATION;
2004
2005 typedef struct _REG_POST_CREATE_KEY_INFORMATION
2006 {
2007 PUNICODE_STRING CompleteName;
2008 PVOID Object;
2009 NTSTATUS Status;
2010 } REG_POST_CREATE_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION;
2011
2012 typedef struct _REG_PRE_OPEN_KEY_INFORMATION
2013 {
2014 PUNICODE_STRING CompleteName;
2015 } REG_PRE_OPEN_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;
2016
2017 typedef struct _REG_POST_OPEN_KEY_INFORMATION
2018 {
2019 PUNICODE_STRING CompleteName;
2020 PVOID Object;
2021 NTSTATUS Status;
2022 } REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION;
2023
2024 typedef struct _REG_POST_OPERATION_INFORMATION
2025 {
2026 PVOID Object;
2027 NTSTATUS Status;
2028 } REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION;
2029
2030 typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION
2031 {
2032 PVOID Object;
2033 } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION;
2034
2035 /*
2036 ** Storage structures
2037 */
2038 typedef enum _PARTITION_STYLE {
2039 PARTITION_STYLE_MBR,
2040 PARTITION_STYLE_GPT,
2041 PARTITION_STYLE_RAW
2042 } PARTITION_STYLE;
2043
2044 typedef struct _CREATE_DISK_MBR {
2045 ULONG Signature;
2046 } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
2047
2048 typedef struct _CREATE_DISK_GPT {
2049 GUID DiskId;
2050 ULONG MaxPartitionCount;
2051 } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
2052
2053 typedef struct _CREATE_DISK {
2054 PARTITION_STYLE PartitionStyle;
2055 _ANONYMOUS_UNION union {
2056 CREATE_DISK_MBR Mbr;
2057 CREATE_DISK_GPT Gpt;
2058 } DUMMYUNIONNAME;
2059 } CREATE_DISK, *PCREATE_DISK;
2060
2061 typedef struct _DISK_SIGNATURE {
2062 ULONG PartitionStyle;
2063 _ANONYMOUS_UNION union {
2064 struct {
2065 ULONG Signature;
2066 ULONG CheckSum;
2067 } Mbr;
2068 struct {
2069 GUID DiskId;
2070 } Gpt;
2071 } DUMMYUNIONNAME;
2072 } DISK_SIGNATURE, *PDISK_SIGNATURE;
2073
2074 typedef VOID
2075 (FASTCALL*PTIME_UPDATE_NOTIFY_ROUTINE)(
2076 IN HANDLE ThreadId,
2077 IN KPROCESSOR_MODE Mode);
2078
2079 #define DBG_STATUS_CONTROL_C 1
2080 #define DBG_STATUS_SYSRQ 2
2081 #define DBG_STATUS_BUGCHECK_FIRST 3
2082 #define DBG_STATUS_BUGCHECK_SECOND 4
2083 #define DBG_STATUS_FATAL 5
2084 #define DBG_STATUS_DEBUG_CONTROL 6
2085 #define DBG_STATUS_WORKER 7
2086
2087 typedef struct _PHYSICAL_MEMORY_RANGE {
2088 PHYSICAL_ADDRESS BaseAddress;
2089 LARGE_INTEGER NumberOfBytes;
2090 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
2091
2092 typedef ULONG_PTR
2093 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
2094 IN PVOID Context);
2095
2096 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
2097 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
2098 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
2099 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
2100
2101 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
2102 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
2103 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
2104 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
2105 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
2106
2107 #define HASH_STRING_ALGORITHM_DEFAULT 0
2108 #define HASH_STRING_ALGORITHM_X65599 1
2109 #define HASH_STRING_ALGORITHM_INVALID 0xffffffff
2110
2111 typedef VOID
2112 (DDKAPI *PTIMER_APC_ROUTINE)(
2113 IN PVOID TimerContext,
2114 IN ULONG TimerLowValue,
2115 IN LONG TimerHighValue);
2116
2117
2118
2119 /*
2120 ** WMI structures
2121 */
2122
2123 typedef VOID
2124 (DDKAPI *WMI_NOTIFICATION_CALLBACK)(
2125 PVOID Wnode,
2126 PVOID Context);
2127
2128
2129 /*
2130 ** Architecture specific structures
2131 */
2132 #define PCR_MINOR_VERSION 1
2133 #define PCR_MAJOR_VERSION 1
2134
2135 #ifdef _X86_
2136
2137 #define SIZE_OF_80387_REGISTERS 80
2138 #define CONTEXT_i386 0x10000
2139 #define CONTEXT_i486 0x10000
2140 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
2141 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
2142 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
2143 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
2144 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
2145 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
2146 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
2147 #define MAXIMUM_SUPPORTED_EXTENSION 512
2148
2149 typedef struct _FLOATING_SAVE_AREA {
2150 ULONG ControlWord;
2151 ULONG StatusWord;
2152 ULONG TagWord;
2153 ULONG ErrorOffset;
2154 ULONG ErrorSelector;
2155 ULONG DataOffset;
2156 ULONG DataSelector;
2157 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
2158 ULONG Cr0NpxState;
2159 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
2160
2161 typedef struct _CONTEXT {
2162 ULONG ContextFlags;
2163 ULONG Dr0;
2164 ULONG Dr1;
2165 ULONG Dr2;
2166 ULONG Dr3;
2167 ULONG Dr6;
2168 ULONG Dr7;
2169 FLOATING_SAVE_AREA FloatSave;
2170 ULONG SegGs;
2171 ULONG SegFs;
2172 ULONG SegEs;
2173 ULONG SegDs;
2174 ULONG Edi;
2175 ULONG Esi;
2176 ULONG Ebx;
2177 ULONG Edx;
2178 ULONG Ecx;
2179 ULONG Eax;
2180 ULONG Ebp;
2181 ULONG Eip;
2182 ULONG SegCs;
2183 ULONG EFlags;
2184 ULONG Esp;
2185 ULONG SegSs;
2186 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
2187 } CONTEXT;
2188
2189 //
2190 // Used to contain PFNs and PFN counts
2191 //
2192 typedef ULONG PFN_COUNT;
2193 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
2194 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
2195
2196 #define PASSIVE_LEVEL 0
2197 #define LOW_LEVEL 0
2198 #define APC_LEVEL 1
2199 #define DISPATCH_LEVEL 2
2200 #define PROFILE_LEVEL 27
2201 #define CLOCK1_LEVEL 28
2202 #define CLOCK2_LEVEL 28
2203 #define IPI_LEVEL 29
2204 #define POWER_LEVEL 30
2205 #define HIGH_LEVEL 31
2206
2207 typedef struct _KPCR_TIB {
2208 PVOID ExceptionList; /* 00 */
2209 PVOID StackBase; /* 04 */
2210 PVOID StackLimit; /* 08 */
2211 PVOID SubSystemTib; /* 0C */
2212 _ANONYMOUS_UNION union {
2213 PVOID FiberData; /* 10 */
2214 ULONG Version; /* 10 */
2215 } DUMMYUNIONNAME;
2216 PVOID ArbitraryUserPointer; /* 14 */
2217 struct _KPCR_TIB *Self; /* 18 */
2218 } KPCR_TIB, *PKPCR_TIB; /* 1C */
2219
2220 typedef struct _KPCR {
2221 KPCR_TIB Tib; /* 00 */
2222 struct _KPCR *Self; /* 1C */
2223 struct _KPRCB *Prcb; /* 20 */
2224 KIRQL Irql; /* 24 */
2225 ULONG IRR; /* 28 */
2226 ULONG IrrActive; /* 2C */
2227 ULONG IDR; /* 30 */
2228 PVOID KdVersionBlock; /* 34 */
2229 PUSHORT IDT; /* 38 */
2230 PUSHORT GDT; /* 3C */
2231 struct _KTSS *TSS; /* 40 */
2232 USHORT MajorVersion; /* 44 */
2233 USHORT MinorVersion; /* 46 */
2234 KAFFINITY SetMember; /* 48 */
2235 ULONG StallScaleFactor; /* 4C */
2236 UCHAR SpareUnused; /* 50 */
2237 UCHAR Number; /* 51 */
2238 UCHAR Spare0;
2239 UCHAR SecondLevelCacheAssociativity;
2240 ULONG VdmAlert;
2241 ULONG KernelReserved[14]; // For use by the kernel
2242 ULONG SecondLevelCacheSize;
2243 ULONG HalReserved[16]; // For use by Hal
2244 } KPCR, *PKPCR; /* 54 */
2245
2246 #define KeGetPcr() PCR
2247
2248 typedef struct _KFLOATING_SAVE {
2249 ULONG ControlWord;
2250 ULONG StatusWord;
2251 ULONG ErrorOffset;
2252 ULONG ErrorSelector;
2253 ULONG DataOffset;
2254 ULONG DataSelector;
2255 ULONG Cr0NpxState;
2256 ULONG Spare1;
2257 } KFLOATING_SAVE, *PKFLOATING_SAVE;
2258
2259 FORCEINLINE
2260 ULONG
2261 KeGetCurrentProcessorNumber(VOID)
2262 {
2263 return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
2264 }
2265
2266 NTHALAPI
2267 KIRQL
2268 DDKAPI
2269 KeGetCurrentIrql(
2270 VOID);
2271
2272 NTKERNELAPI
2273 PRKTHREAD
2274 NTAPI
2275 KeGetCurrentThread(
2276 VOID);
2277
2278 #define KI_USER_SHARED_DATA 0xffdf0000
2279
2280 #define PAGE_SIZE 0x1000
2281 #define PAGE_SHIFT 12L
2282
2283 #define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA)
2284
2285 extern NTKERNELAPI PVOID MmHighestUserAddress;
2286 extern NTKERNELAPI PVOID MmSystemRangeStart;
2287 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
2288
2289 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2290 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2291 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2292 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2293 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000
2294
2295 #define MM_KSEG0_BASE MM_SYSTEM_RANGE_START
2296 #define MM_SYSTEM_SPACE_END 0xFFFFFFFF
2297
2298 #elif defined(__x86_64__)
2299
2300 #define CONTEXT_AMD64 0x100000
2301 #if !defined(RC_INVOKED)
2302 #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
2303 #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
2304 #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
2305 #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
2306 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
2307
2308 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
2309 #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
2310
2311 #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
2312 #define CONTEXT_SERVICE_ACTIVE 0x10000000
2313 #define CONTEXT_EXCEPTION_REQUEST 0x40000000
2314 #define CONTEXT_EXCEPTION_REPORTING 0x80000000
2315 #endif
2316
2317 typedef struct DECLSPEC_ALIGN(16) _M128A {
2318 ULONGLONG Low;
2319 LONGLONG High;
2320 } M128A, *PM128A;
2321
2322 typedef struct _XMM_SAVE_AREA32 {
2323 USHORT ControlWord;
2324 USHORT StatusWord;
2325 UCHAR TagWord;
2326 UCHAR Reserved1;
2327 USHORT ErrorOpcode;
2328 ULONG ErrorOffset;
2329 USHORT ErrorSelector;
2330 USHORT Reserved2;
2331 ULONG DataOffset;
2332 USHORT DataSelector;
2333 USHORT Reserved3;
2334 ULONG MxCsr;
2335 ULONG MxCsr_Mask;
2336 M128A FloatRegisters[8];
2337 M128A XmmRegisters[16];
2338 UCHAR Reserved4[96];
2339 } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
2340
2341 typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
2342 ULONG64 P1Home;
2343 ULONG64 P2Home;
2344 ULONG64 P3Home;
2345 ULONG64 P4Home;
2346 ULONG64 P5Home;
2347 ULONG64 P6Home;
2348
2349 /* Control flags */
2350 ULONG ContextFlags;
2351 ULONG MxCsr;
2352
2353 /* Segment */
2354 USHORT SegCs;
2355 USHORT SegDs;
2356 USHORT SegEs;
2357 USHORT SegFs;
2358 USHORT SegGs;
2359 USHORT SegSs;
2360 ULONG EFlags;
2361
2362 /* Debug */
2363 ULONG64 Dr0;
2364 ULONG64 Dr1;
2365 ULONG64 Dr2;
2366 ULONG64 Dr3;
2367 ULONG64 Dr6;
2368 ULONG64 Dr7;
2369
2370 /* Integer */
2371 ULONG64 Rax;
2372 ULONG64 Rcx;
2373 ULONG64 Rdx;
2374 ULONG64 Rbx;
2375 ULONG64 Rsp;
2376 ULONG64 Rbp;
2377 ULONG64 Rsi;
2378 ULONG64 Rdi;
2379 ULONG64 R8;
2380 ULONG64 R9;
2381 ULONG64 R10;
2382 ULONG64 R11;
2383 ULONG64 R12;
2384 ULONG64 R13;
2385 ULONG64 R14;
2386 ULONG64 R15;
2387
2388 /* Counter */
2389 ULONG64 Rip;
2390
2391 /* Floating point */
2392 union {
2393 XMM_SAVE_AREA32 FltSave;
2394 struct {
2395 M128A Header[2];
2396 M128A Legacy[8];
2397 M128A Xmm0;
2398 M128A Xmm1;
2399 M128A Xmm2;
2400 M128A Xmm3;
2401 M128A Xmm4;
2402 M128A Xmm5;
2403 M128A Xmm6;
2404 M128A Xmm7;
2405 M128A Xmm8;
2406 M128A Xmm9;
2407 M128A Xmm10;
2408 M128A Xmm11;
2409 M128A Xmm12;
2410 M128A Xmm13;
2411 M128A Xmm14;
2412 M128A Xmm15;
2413 } DUMMYSTRUCTNAME;
2414 } DUMMYUNIONNAME;
2415
2416 /* Vector */
2417 M128A VectorRegister[26];
2418 ULONG64 VectorControl;
2419
2420 /* Debug control */
2421 ULONG64 DebugControl;
2422 ULONG64 LastBranchToRip;
2423 ULONG64 LastBranchFromRip;
2424 ULONG64 LastExceptionToRip;
2425 ULONG64 LastExceptionFromRip;
2426 } CONTEXT;
2427
2428 //
2429 // Used to contain PFNs and PFN counts
2430 //
2431 typedef ULONG PFN_COUNT;
2432 typedef ULONG64 PFN_NUMBER, *PPFN_NUMBER;
2433 typedef LONG64 SPFN_NUMBER, *PSPFN_NUMBER;
2434
2435 #define PASSIVE_LEVEL 0
2436 #define LOW_LEVEL 0
2437 #define APC_LEVEL 1
2438 #define DISPATCH_LEVEL 2
2439 #define CLOCK_LEVEL 13
2440 #define IPI_LEVEL 14
2441 #define POWER_LEVEL 14
2442 #define PROFILE_LEVEL 15
2443 #define HIGH_LEVEL 15
2444
2445 #define PAGE_SIZE 0x1000
2446 #define PAGE_SHIFT 12L
2447 #define PTI_SHIFT 12L
2448 #define PDI_SHIFT 21L
2449 #define PPI_SHIFT 30L
2450 #define PXI_SHIFT 39L
2451 #define PTE_PER_PAGE 512
2452 #define PDE_PER_PAGE 512
2453 #define PPE_PER_PAGE 512
2454 #define PXE_PER_PAGE 512
2455 #define PTI_MASK_AMD64 (PTE_PER_PAGE - 1)
2456 #define PDI_MASK_AMD64 (PDE_PER_PAGE - 1)
2457 #define PPI_MASK (PPE_PER_PAGE - 1)
2458 #define PXI_MASK (PXE_PER_PAGE - 1)
2459
2460 #define PXE_BASE 0xFFFFF6FB7DBED000ULL
2461 #define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL
2462 #define PPE_BASE 0xFFFFF6FB7DA00000ULL
2463 #define PDE_BASE 0xFFFFF6FB40000000ULL
2464 #define PTE_BASE 0xFFFFF68000000000ULL
2465 #define PXE_TOP 0xFFFFF6FB7DBEDFFFULL
2466 #define PPE_TOP 0xFFFFF6FB7DBFFFFFULL
2467 #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL
2468 #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL
2469
2470 extern NTKERNELAPI PVOID MmHighestUserAddress;
2471 extern NTKERNELAPI PVOID MmSystemRangeStart;
2472 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
2473
2474 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
2475 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
2476 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
2477 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
2478 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL
2479 #define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL
2480
2481 #define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA)
2482 #define SharedInterruptTime (&SharedUserData->InterruptTime)
2483 #define SharedSystemTime (&SharedUserData->SystemTime)
2484 #define SharedTickCount (&SharedUserData->TickCount)
2485
2486 #define KeQueryInterruptTime() \
2487 (*(volatile ULONG64*)SharedInterruptTime)
2488 #define KeQuerySystemTime(CurrentCount) \
2489 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime
2490 #define KeQueryTickCount(CurrentCount) \
2491 *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount
2492
2493 typedef struct _KPCR
2494 {
2495 __GNU_EXTENSION union
2496 {
2497 NT_TIB NtTib;
2498 __GNU_EXTENSION struct
2499 {
2500 union _KGDTENTRY64 *GdtBase;
2501 struct _KTSS64 *TssBase;
2502 ULONG64 UserRsp;
2503 struct _KPCR *Self;
2504 struct _KPRCB *CurrentPrcb;
2505 PKSPIN_LOCK_QUEUE LockArray;
2506 PVOID Used_Self;
2507 };
2508 };
2509 union _KIDTENTRY64 *IdtBase;
2510 ULONG64 Unused[2];
2511 KIRQL Irql;
2512 UCHAR SecondLevelCacheAssociativity;
2513 UCHAR ObsoleteNumber;
2514 UCHAR Fill0;
2515 ULONG Unused0[3];
2516 USHORT MajorVersion;
2517 USHORT MinorVersion;
2518 ULONG StallScaleFactor;
2519 PVOID Unused1[3];
2520 ULONG KernelReserved[15];
2521 ULONG SecondLevelCacheSize;
2522 ULONG HalReserved[16];
2523 ULONG Unused2;
2524 PVOID KdVersionBlock;
2525 PVOID Unused3;
2526 ULONG PcrAlign1[24];
2527 } KPCR, *PKPCR;
2528
2529 typedef struct _KFLOATING_SAVE {
2530 ULONG Dummy;
2531 } KFLOATING_SAVE, *PKFLOATING_SAVE;
2532
2533 NTKERNELAPI
2534 PRKTHREAD
2535 NTAPI
2536 KeGetCurrentThread(
2537 VOID);
2538
2539 FORCEINLINE
2540 PKPCR
2541 KeGetPcr(VOID)
2542 {
2543 return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self));
2544 }
2545
2546 FORCEINLINE
2547 ULONG
2548 KeGetCurrentProcessorNumber(VOID)
2549 {
2550 return (ULONG)__readgsword(0x184);
2551 }
2552
2553 #elif defined(__PowerPC__)
2554
2555 //
2556 // Used to contain PFNs and PFN counts
2557 //
2558 typedef ULONG PFN_COUNT;
2559 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
2560 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
2561
2562 #define PASSIVE_LEVEL 0
2563 #define LOW_LEVEL 0
2564 #define APC_LEVEL 1
2565 #define DISPATCH_LEVEL 2
2566 #define PROFILE_LEVEL 27
2567 #define CLOCK1_LEVEL 28
2568 #define CLOCK2_LEVEL 28
2569 #define IPI_LEVEL 29
2570 #define POWER_LEVEL 30
2571 #define HIGH_LEVEL 31
2572
2573 typedef struct _KFLOATING_SAVE {
2574 ULONG Dummy;
2575 } KFLOATING_SAVE, *PKFLOATING_SAVE;
2576
2577 typedef struct _KPCR_TIB {
2578 PVOID ExceptionList; /* 00 */
2579 PVOID StackBase; /* 04 */
2580 PVOID StackLimit; /* 08 */
2581 PVOID SubSystemTib; /* 0C */
2582 _ANONYMOUS_UNION union {
2583 PVOID FiberData; /* 10 */
2584 ULONG Version; /* 10 */
2585 } DUMMYUNIONNAME;
2586 PVOID ArbitraryUserPointer; /* 14 */
2587 struct _KPCR_TIB *Self; /* 18 */
2588 } KPCR_TIB, *PKPCR_TIB; /* 1C */
2589
2590 #define PCR_MINOR_VERSION 1
2591 #define PCR_MAJOR_VERSION 1
2592
2593 typedef struct _KPCR {
2594 KPCR_TIB Tib; /* 00 */
2595 struct _KPCR *Self; /* 1C */
2596 struct _KPRCB *Prcb; /* 20 */
2597 KIRQL Irql; /* 24 */
2598 ULONG IRR; /* 28 */
2599 ULONG IrrActive; /* 2C */
2600 ULONG IDR; /* 30 */
2601 PVOID KdVersionBlock; /* 34 */
2602 PUSHORT IDT; /* 38 */
2603 PUSHORT GDT; /* 3C */
2604 struct _KTSS *TSS; /* 40 */
2605 USHORT MajorVersion; /* 44 */
2606 USHORT MinorVersion; /* 46 */
2607 KAFFINITY SetMember; /* 48 */
2608 ULONG StallScaleFactor; /* 4C */
2609 UCHAR SpareUnused; /* 50 */
2610 UCHAR Number; /* 51 */
2611 } KPCR, *PKPCR; /* 54 */
2612
2613 #define KeGetPcr() PCR
2614
2615 static __inline
2616 ULONG
2617 DDKAPI
2618 KeGetCurrentProcessorNumber(VOID)
2619 {
2620 ULONG Number;
2621 __asm__ __volatile__ (
2622 "lwz %0, %c1(12)\n"
2623 : "=r" (Number)
2624 : "i" (FIELD_OFFSET(KPCR, Number))
2625 );
2626 return Number;
2627 }
2628
2629 #elif defined(_MIPS_)
2630
2631 #error MIPS Headers are totally incorrect
2632
2633 //
2634 // Used to contain PFNs and PFN counts
2635 //
2636 typedef ULONG PFN_COUNT;
2637 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
2638 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
2639
2640 #define PASSIVE_LEVEL 0
2641 #define APC_LEVEL 1
2642 #define DISPATCH_LEVEL 2
2643 #define PROFILE_LEVEL 27
2644 #define IPI_LEVEL 29
2645 #define HIGH_LEVEL 31
2646
2647 typedef struct _KPCR {
2648 struct _KPRCB *Prcb; /* 20 */
2649 KIRQL Irql; /* 24 */
2650 ULONG IRR; /* 28 */
2651 ULONG IDR; /* 30 */
2652 } KPCR, *PKPCR;
2653
2654 #define KeGetPcr() PCR
2655
2656 typedef struct _KFLOATING_SAVE {
2657 } KFLOATING_SAVE, *PKFLOATING_SAVE;
2658
2659 static __inline
2660 ULONG
2661 DDKAPI
2662 KeGetCurrentProcessorNumber(VOID)
2663 {
2664 return 0;
2665 }
2666
2667 #elif defined(_M_ARM)
2668
2669 //
2670 // NT-ARM is not documented, need DDK-ARM
2671 //
2672 #include <armddk.h>
2673
2674 #else
2675 #error Unknown architecture
2676 #endif
2677
2678 #define MM_DONT_ZERO_ALLOCATION 0x00000001
2679 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
2680
2681
2682 #define EFLAG_SIGN 0x8000
2683 #define EFLAG_ZERO 0x4000
2684 #define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO)
2685
2686 #define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
2687 #define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
2688 #define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
2689
2690 typedef enum _INTERLOCKED_RESULT {
2691 ResultNegative = RESULT_NEGATIVE,
2692 ResultZero = RESULT_ZERO,
2693 ResultPositive = RESULT_POSITIVE
2694 } INTERLOCKED_RESULT;
2695
2696 typedef VOID
2697 (NTAPI *PciPin2Line)(
2698 IN struct _BUS_HANDLER *BusHandler,
2699 IN struct _BUS_HANDLER *RootHandler,
2700 IN PCI_SLOT_NUMBER SlotNumber,
2701 IN PPCI_COMMON_CONFIG PciData
2702 );
2703
2704 typedef VOID
2705 (NTAPI *PciLine2Pin)(
2706 IN struct _BUS_HANDLER *BusHandler,
2707 IN struct _BUS_HANDLER *RootHandler,
2708 IN PCI_SLOT_NUMBER SlotNumber,
2709 IN PPCI_COMMON_CONFIG PciNewData,
2710 IN PPCI_COMMON_CONFIG PciOldData
2711 );
2712
2713 typedef VOID
2714 (NTAPI *PciReadWriteConfig)(
2715 IN struct _BUS_HANDLER *BusHandler,
2716 IN PCI_SLOT_NUMBER Slot,
2717 IN PVOID Buffer,
2718 IN ULONG Offset,
2719 IN ULONG Length
2720 );
2721
2722 #define PCI_DATA_TAG ' ICP'
2723 #define PCI_DATA_VERSION 1
2724
2725 typedef struct _PCIBUSDATA
2726 {
2727 ULONG Tag;
2728 ULONG Version;
2729 PciReadWriteConfig ReadConfig;
2730 PciReadWriteConfig WriteConfig;
2731 PciPin2Line Pin2Line;
2732 PciLine2Pin Line2Pin;
2733 PCI_SLOT_NUMBER ParentSlot;
2734 PVOID Reserved[4];
2735 } PCIBUSDATA, *PPCIBUSDATA;
2736
2737
2738 /** SPINLOCK FUNCTIONS ********************************************************/
2739
2740 NTKERNELAPI
2741 BOOLEAN
2742 FASTCALL
2743 KeTryToAcquireSpinLockAtDpcLevel(
2744 IN OUT PKSPIN_LOCK SpinLock
2745 );
2746
2747 NTKERNELAPI
2748 BOOLEAN
2749 FASTCALL
2750 KeTestSpinLock(
2751 IN PKSPIN_LOCK SpinLock
2752 );
2753
2754 #if defined (_X86_)
2755
2756 #if defined(WIN9X_COMPAT_SPINLOCK)
2757
2758 NTKERNELAPI
2759 VOID
2760 NTAPI
2761 KeInitializeSpinLock(
2762 IN PKSPIN_LOCK SpinLock
2763 );
2764
2765 #else
2766
2767 FORCEINLINE
2768 VOID
2769 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
2770 {
2771 /* Clear the lock */
2772 *SpinLock = 0;
2773 }
2774
2775 #endif
2776
2777 NTHALAPI
2778 KIRQL
2779 FASTCALL
2780 KfAcquireSpinLock(
2781 IN PKSPIN_LOCK SpinLock);
2782
2783 NTHALAPI
2784 VOID
2785 FASTCALL
2786 KfReleaseSpinLock(
2787 IN PKSPIN_LOCK SpinLock,
2788 IN KIRQL NewIrql);
2789
2790 NTKERNELAPI
2791 VOID
2792 FASTCALL
2793 KefAcquireSpinLockAtDpcLevel(
2794 IN PKSPIN_LOCK SpinLock);
2795
2796 NTKERNELAPI
2797 VOID
2798 FASTCALL
2799 KefReleaseSpinLockFromDpcLevel(
2800 IN PKSPIN_LOCK SpinLock);
2801
2802 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
2803 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
2804 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
2805 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
2806
2807 #define KeGetDcacheFillSize() 1L
2808
2809 #elif defined(_M_ARM) // !defined (_X86_)
2810
2811 FORCEINLINE
2812 VOID
2813 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
2814 {
2815 /* Clear the lock */
2816 *SpinLock = 0;
2817 }
2818
2819 NTHALAPI
2820 KIRQL
2821 FASTCALL
2822 KfAcquireSpinLock(
2823 IN PKSPIN_LOCK SpinLock);
2824
2825 NTHALAPI
2826 VOID
2827 FASTCALL
2828 KfReleaseSpinLock(
2829 IN PKSPIN_LOCK SpinLock,
2830 IN KIRQL NewIrql);
2831
2832
2833 NTKERNELAPI
2834 VOID
2835 FASTCALL
2836 KefAcquireSpinLockAtDpcLevel(
2837 IN PKSPIN_LOCK SpinLock);
2838
2839 NTKERNELAPI
2840 VOID
2841 FASTCALL
2842 KefReleaseSpinLockFromDpcLevel(
2843 IN PKSPIN_LOCK SpinLock);
2844
2845
2846 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
2847 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
2848 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
2849 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
2850
2851 NTKERNELAPI
2852 VOID
2853 NTAPI
2854 KeInitializeSpinLock(
2855 IN PKSPIN_LOCK SpinLock);
2856
2857 #else
2858
2859 FORCEINLINE
2860 VOID
2861 NTAPI
2862 KeInitializeSpinLock(
2863 PKSPIN_LOCK SpinLock)
2864 {
2865 *SpinLock = 0;
2866 }
2867
2868 NTKERNELAPI
2869 VOID
2870 KeReleaseSpinLock(
2871 IN PKSPIN_LOCK SpinLock,
2872 IN KIRQL NewIrql);
2873
2874 NTKERNELAPI
2875 VOID
2876 KeAcquireSpinLockAtDpcLevel(
2877 IN PKSPIN_LOCK SpinLock);
2878
2879 NTKERNELAPI
2880 VOID
2881 KeReleaseSpinLockFromDpcLevel(
2882 IN PKSPIN_LOCK SpinLock);
2883
2884 NTKERNELAPI
2885 KIRQL
2886 KeAcquireSpinLockRaiseToDpc(
2887 IN PKSPIN_LOCK SpinLock);
2888
2889 #define KeAcquireSpinLock(SpinLock, OldIrql) \
2890 *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
2891
2892 #endif // !defined (_X86_)
2893
2894 /*
2895 ** Utillity functions
2896 */
2897
2898 #define ARGUMENT_PRESENT(ArgumentPointer) \
2899 ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
2900
2901 /*
2902 * ULONG
2903 * BYTE_OFFSET(
2904 * IN PVOID Va)
2905 */
2906 #define BYTE_OFFSET(Va) \
2907 ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
2908
2909 /*
2910 * ULONG
2911 * BYTES_TO_PAGES(
2912 * IN ULONG Size)
2913 */
2914 #define BYTES_TO_PAGES(Size) \
2915 ((ULONG) ((ULONG_PTR) (Size) >> PAGE_SHIFT) + (((ULONG) (Size) & (PAGE_SIZE - 1)) != 0))
2916
2917 /*
2918 * PVOID
2919 * PAGE_ALIGN(
2920 * IN PVOID Va)
2921 */
2922 #define PAGE_ALIGN(Va) \
2923 ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
2924
2925 /*
2926 * ULONG_PTR
2927 * ROUND_TO_PAGES(
2928 * IN ULONG_PTR Size)
2929 */
2930 #define ROUND_TO_PAGES(Size) \
2931 ((ULONG_PTR) (((ULONG_PTR) Size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))
2932
2933
2934
2935 #if defined(_X86_) || defined(_AMD64_)
2936
2937 //
2938 // x86 and x64 performs a 0x2C interrupt
2939 //
2940 #define DbgRaiseAssertionFailure __int2c
2941
2942 #elif defined(_ARM_)
2943
2944 //
2945 // TODO
2946 //
2947
2948 #else
2949 #error Unsupported Architecture
2950 #endif
2951
2952 #if DBG
2953
2954 #define ASSERT(exp) \
2955 (VOID)((!(exp)) ? \
2956 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
2957
2958 #define ASSERTMSG(msg, exp) \
2959 (VOID)((!(exp)) ? \
2960 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE)
2961
2962 #define RTL_SOFT_ASSERT(exp) \
2963 (VOID)((!(exp)) ? \
2964 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
2965
2966 #define RTL_SOFT_ASSERTMSG(msg, exp) \
2967 (VOID)((!(exp)) ? \
2968 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
2969
2970 #define RTL_VERIFY(exp) ASSERT(exp)
2971 #define RTL_VERIFYMSG(msg, exp) ASSERT(msg, exp)
2972
2973 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
2974 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
2975
2976 #if defined(_MSC_VER)
2977
2978 #define NT_ASSERT(exp) \
2979 ((!(exp)) ? \
2980 (__annotation(L"Debug", L"AssertFail", L#exp), \
2981 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2982
2983 #define NT_ASSERTMSG(msg, exp) \
2984 ((!(exp)) ? \
2985 (__annotation(L"Debug", L"AssertFail", L##msg), \
2986 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2987
2988 #define NT_ASSERTMSGW(msg, exp) \
2989 ((!(exp)) ? \
2990 (__annotation(L"Debug", L"AssertFail", msg), \
2991 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2992
2993 #else
2994
2995 //
2996 // GCC doesn't support __annotation (nor PDB)
2997 //
2998 #define NT_ASSERT(exp) \
2999 (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
3000
3001 #define NT_ASSERTMSG NT_ASSERT
3002 #define NT_ASSERTMSGW NT_ASSERT
3003
3004 #endif
3005
3006 #else /* !DBG */
3007
3008 #define ASSERT(exp) ((VOID) 0)
3009 #define ASSERTMSG(msg, exp) ((VOID) 0)
3010
3011 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
3012 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
3013
3014 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
3015 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3016
3017 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
3018 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
3019
3020 #define NT_ASSERT(exp) ((VOID)0)
3021 #define NT_ASSERTMSG(exp) ((VOID)0)
3022 #define NT_ASSERTMSGW(exp) ((VOID)0)
3023
3024 #endif /* DBG */
3025
3026 /* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
3027 #if defined(_NTSYSTEM_) || defined(__GNUC__)
3028 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
3029 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
3030 #else
3031 #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
3032 #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
3033 #endif /* _NT_SYSTEM */
3034
3035 extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG;
3036 extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG;
3037
3038 /*
3039 ** Driver support routines
3040 */
3041
3042 /** Runtime library routines **/
3043
3044 static __inline VOID
3045 InitializeListHead(
3046 IN PLIST_ENTRY ListHead)
3047 {
3048 ListHead->Flink = ListHead->Blink = ListHead;
3049 }
3050
3051 static __inline VOID
3052 InsertHeadList(
3053 IN PLIST_ENTRY ListHead,
3054 IN PLIST_ENTRY Entry)
3055 {
3056 PLIST_ENTRY OldFlink;
3057 OldFlink = ListHead->Flink;
3058 Entry->Flink = OldFlink;
3059 Entry->Blink = ListHead;
3060 OldFlink->Blink = Entry;
3061 ListHead->Flink = Entry;
3062 }
3063
3064 static __inline VOID
3065 InsertTailList(
3066 IN PLIST_ENTRY ListHead,
3067 IN PLIST_ENTRY Entry)
3068 {
3069 PLIST_ENTRY OldBlink;
3070 OldBlink = ListHead->Blink;
3071 Entry->Flink = ListHead;
3072 Entry->Blink = OldBlink;
3073 OldBlink->Flink = Entry;
3074 ListHead->Blink = Entry;
3075 }
3076
3077 /*
3078 * BOOLEAN
3079 * IsListEmpty(
3080 * IN PLIST_ENTRY ListHead)
3081 */
3082 #define IsListEmpty(_ListHead) \
3083 ((_ListHead)->Flink == (_ListHead))
3084
3085 /*
3086 * PSINGLE_LIST_ENTRY
3087 * PopEntryList(
3088 * IN PSINGLE_LIST_ENTRY ListHead)
3089 */
3090 #define PopEntryList(ListHead) \
3091 (ListHead)->Next; \
3092 { \
3093 PSINGLE_LIST_ENTRY _FirstEntry; \
3094 _FirstEntry = (ListHead)->Next; \
3095 if (_FirstEntry != NULL) \
3096 (ListHead)->Next = _FirstEntry->Next; \
3097 }
3098
3099 /*
3100 * VOID
3101 * PushEntryList(
3102 * IN PSINGLE_LIST_ENTRY ListHead,
3103 * IN PSINGLE_LIST_ENTRY Entry)
3104 */
3105 #define PushEntryList(_ListHead, _Entry) \
3106 (_Entry)->Next = (_ListHead)->Next; \
3107 (_ListHead)->Next = (_Entry); \
3108
3109 static __inline BOOLEAN
3110 RemoveEntryList(
3111 IN PLIST_ENTRY Entry)
3112 {
3113 PLIST_ENTRY OldFlink;
3114 PLIST_ENTRY OldBlink;
3115
3116 OldFlink = Entry->Flink;
3117 OldBlink = Entry->Blink;
3118 OldFlink->Blink = OldBlink;
3119 OldBlink->Flink = OldFlink;
3120 return (BOOLEAN)(OldFlink == OldBlink);
3121 }
3122
3123 static __inline PLIST_ENTRY
3124 RemoveHeadList(
3125 IN PLIST_ENTRY ListHead)
3126 {
3127 PLIST_ENTRY Flink;
3128 PLIST_ENTRY Entry;
3129
3130 Entry = ListHead->Flink;
3131 Flink = Entry->Flink;
3132 ListHead->Flink = Flink;
3133 Flink->Blink = ListHead;
3134 return Entry;
3135 }
3136
3137 static __inline PLIST_ENTRY
3138 RemoveTailList(
3139 IN PLIST_ENTRY ListHead)
3140 {
3141 PLIST_ENTRY Blink;
3142 PLIST_ENTRY Entry;
3143
3144 Entry = ListHead->Blink;
3145 Blink = Entry->Blink;
3146 ListHead->Blink = Blink;
3147 Blink->Flink = ListHead;
3148 return Entry;
3149 }
3150
3151 NTSYSAPI
3152 NTSTATUS
3153 NTAPI
3154 RtlCharToInteger(
3155 IN PCSZ String,
3156 IN ULONG Base OPTIONAL,
3157 IN OUT PULONG Value);
3158
3159 NTSYSAPI
3160 LONG
3161 NTAPI
3162 RtlCompareString(
3163 IN PSTRING String1,
3164 IN PSTRING String2,
3165 BOOLEAN CaseInSensitive);
3166
3167 #if !defined(MIDL_PASS)
3168
3169 FORCEINLINE
3170 LUID
3171 NTAPI
3172 RtlConvertLongToLuid(
3173 IN LONG Val)
3174 {
3175 LUID Luid;
3176 LARGE_INTEGER Temp;
3177
3178 Temp.QuadPart = Val;
3179 Luid.LowPart = Temp.u.LowPart;
3180 Luid.HighPart = Temp.u.HighPart;
3181
3182 return Luid;
3183 }
3184
3185 FORCEINLINE
3186 LUID
3187 NTAPI
3188 RtlConvertUlongToLuid(
3189 IN ULONG Val)
3190 {
3191 LUID Luid;
3192
3193 Luid.LowPart = Val;
3194 Luid.HighPart = 0;
3195
3196 return Luid;
3197 }
3198 #endif
3199
3200
3201 NTSYSAPI
3202 VOID
3203 NTAPI
3204 RtlCopyMemory32(
3205 IN VOID UNALIGNED *Destination,
3206 IN CONST VOID UNALIGNED *Source,
3207 IN ULONG Length);
3208
3209 NTSYSAPI
3210 VOID
3211 NTAPI
3212 RtlCopyString(
3213 IN OUT PSTRING DestinationString,
3214 IN PSTRING SourceString OPTIONAL);
3215
3216 NTSYSAPI
3217 BOOLEAN
3218 NTAPI
3219 RtlEqualString(
3220 IN PSTRING String1,
3221 IN PSTRING String2,
3222 IN BOOLEAN CaseInSensitive);
3223
3224 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
3225 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
3226 *CallersAddress = (PVOID)_ReturnAddress(); \
3227 *CallersCaller = NULL;
3228 #else
3229 NTSYSAPI
3230 VOID
3231 NTAPI
3232 RtlGetCallersAddress(
3233 OUT PVOID *CallersAddress,
3234 OUT PVOID *CallersCaller);
3235 #endif
3236
3237 NTSYSAPI
3238 NTSTATUS
3239 NTAPI
3240 RtlGetVersion(
3241 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
3242
3243 NTSYSAPI
3244 VOID
3245 NTAPI
3246 RtlMapGenericMask(
3247 IN OUT PACCESS_MASK AccessMask,
3248 IN PGENERIC_MAPPING GenericMapping);
3249
3250 NTSYSAPI
3251 BOOLEAN
3252 NTAPI
3253 RtlPrefixUnicodeString(
3254 IN PCUNICODE_STRING String1,
3255 IN PCUNICODE_STRING String2,
3256 IN BOOLEAN CaseInSensitive);
3257
3258 NTSYSAPI
3259 NTSTATUS
3260 NTAPI
3261 RtlUpcaseUnicodeString(
3262 IN OUT PUNICODE_STRING DestinationString OPTIONAL,
3263 IN PCUNICODE_STRING SourceString,
3264 IN BOOLEAN AllocateDestinationString);
3265
3266 NTSYSAPI
3267 CHAR
3268 NTAPI
3269 RtlUpperChar(
3270 IN CHAR Character);
3271
3272 NTSYSAPI
3273 VOID
3274 NTAPI
3275 RtlUpperString(
3276 IN OUT PSTRING DestinationString,
3277 IN PSTRING SourceString);
3278
3279 NTSYSAPI
3280 NTSTATUS
3281 NTAPI
3282 RtlVerifyVersionInfo(
3283 IN PRTL_OSVERSIONINFOEXW VersionInfo,
3284 IN ULONG TypeMask,
3285 IN ULONGLONG ConditionMask);
3286
3287 NTSYSAPI
3288 NTSTATUS
3289 NTAPI
3290 RtlVolumeDeviceToDosName(
3291 IN PVOID VolumeDeviceObject,
3292 OUT PUNICODE_STRING DosName);
3293
3294 NTSYSAPI
3295 ULONG
3296 NTAPI
3297 RtlWalkFrameChain(
3298 OUT PVOID *Callers,
3299 IN ULONG Count,
3300 IN ULONG Flags);
3301
3302 NTKERNELAPI
3303 BOOLEAN
3304 NTAPI
3305 KeAreAllApcsDisabled(
3306 VOID
3307 );
3308
3309 /* Guarded Mutex routines */
3310
3311 NTKERNELAPI
3312 VOID
3313 FASTCALL
3314 KeAcquireGuardedMutex(
3315 IN OUT PKGUARDED_MUTEX GuardedMutex
3316 );
3317
3318 NTKERNELAPI
3319 VOID
3320 FASTCALL
3321 KeAcquireGuardedMutexUnsafe(
3322 IN OUT PKGUARDED_MUTEX GuardedMutex
3323 );
3324
3325 NTKERNELAPI
3326 VOID
3327 NTAPI
3328 KeEnterGuardedRegion(
3329 VOID
3330 );
3331
3332 NTKERNELAPI
3333 VOID
3334 NTAPI
3335 KeLeaveGuardedRegion(
3336 VOID
3337 );
3338
3339 NTKERNELAPI
3340 VOID
3341 FASTCALL
3342 KeInitializeGuardedMutex(
3343 OUT PKGUARDED_MUTEX GuardedMutex
3344 );
3345
3346 NTKERNELAPI
3347 VOID
3348 FASTCALL
3349 KeReleaseGuardedMutexUnsafe(
3350 IN OUT PKGUARDED_MUTEX GuardedMutex
3351 );
3352
3353 NTKERNELAPI
3354 VOID
3355 FASTCALL
3356 KeReleaseGuardedMutex(
3357 IN OUT PKGUARDED_MUTEX GuardedMutex
3358 );
3359
3360 NTKERNELAPI
3361 BOOLEAN
3362 FASTCALL
3363 KeTryToAcquireGuardedMutex(
3364 IN OUT PKGUARDED_MUTEX GuardedMutex
3365 );
3366
3367 /* Fast Mutex */
3368 #define ExInitializeFastMutex(_FastMutex) \
3369 { \
3370 (_FastMutex)->Count = FM_LOCK_BIT; \
3371 (_FastMutex)->Owner = NULL; \
3372 (_FastMutex)->Contention = 0; \
3373 KeInitializeEvent(&(_FastMutex)->Gate, SynchronizationEvent, FALSE); \
3374 }
3375
3376 NTKERNELAPI
3377 VOID
3378 NTAPI
3379 KeInitializeEvent(
3380 IN PRKEVENT Event,
3381 IN EVENT_TYPE Type,
3382 IN BOOLEAN State);
3383
3384 /******************************************************************************
3385 * Executive Types *
3386 ******************************************************************************/
3387
3388 typedef struct _ZONE_SEGMENT_HEADER {
3389 SINGLE_LIST_ENTRY SegmentList;
3390 PVOID Reserved;
3391 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
3392
3393 typedef struct _ZONE_HEADER {
3394 SINGLE_LIST_ENTRY FreeList;
3395 SINGLE_LIST_ENTRY SegmentList;
3396 ULONG BlockSize;
3397 ULONG TotalSegmentSize;
3398 } ZONE_HEADER, *PZONE_HEADER;
3399
3400 #define PROTECTED_POOL 0x80000000
3401
3402 /******************************************************************************
3403 * Executive Functions *
3404 ******************************************************************************/
3405
3406 NTKERNELAPI
3407 NTSTATUS
3408 NTAPI
3409 ExExtendZone(
3410 IN PZONE_HEADER Zone,
3411 IN PVOID Segment,
3412 IN ULONG SegmentSize);
3413
3414 static __inline PVOID
3415 ExAllocateFromZone(
3416 IN PZONE_HEADER Zone)
3417 {
3418 if (Zone->FreeList.Next)
3419 Zone->FreeList.Next = Zone->FreeList.Next->Next;
3420 return (PVOID) Zone->FreeList.Next;
3421 }
3422
3423 static __inline PVOID
3424 ExFreeToZone(
3425 IN PZONE_HEADER Zone,
3426 IN PVOID Block)
3427 {
3428 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
3429 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
3430 return ((PSINGLE_LIST_ENTRY) Block)->Next;
3431 }
3432
3433 NTKERNELAPI
3434 NTSTATUS
3435 NTAPI
3436 ExInitializeZone(
3437 IN PZONE_HEADER Zone,
3438 IN ULONG BlockSize,
3439 IN PVOID InitialSegment,
3440 IN ULONG InitialSegmentSize);
3441
3442 /*
3443 * PVOID
3444 * ExInterlockedAllocateFromZone(
3445 * IN PZONE_HEADER Zone,
3446 * IN PKSPIN_LOCK Lock)
3447 */
3448 #define ExInterlockedAllocateFromZone(Zone, Lock) \
3449 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
3450
3451 NTKERNELAPI
3452 NTSTATUS
3453 NTAPI
3454 ExInterlockedExtendZone(
3455 IN PZONE_HEADER Zone,
3456 IN PVOID Segment,
3457 IN ULONG SegmentSize,
3458 IN PKSPIN_LOCK Lock);
3459
3460 /* PVOID
3461 * ExInterlockedFreeToZone(
3462 * IN PZONE_HEADER Zone,
3463 * IN PVOID Block,
3464 * IN PKSPIN_LOCK Lock);
3465 */
3466 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
3467 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
3468
3469 /*
3470 * VOID
3471 * InitializeSListHead(
3472 * IN PSLIST_HEADER SListHead)
3473 */
3474 #define InitializeSListHead(_SListHead) \
3475 (_SListHead)->Alignment = 0
3476
3477 #define ExInitializeSListHead InitializeSListHead
3478
3479 /*
3480 * BOOLEAN
3481 * ExIsFullZone(
3482 * IN PZONE_HEADER Zone)
3483 */
3484 #define ExIsFullZone(Zone) \
3485 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
3486
3487 /* BOOLEAN
3488 * ExIsObjectInFirstZoneSegment(
3489 * IN PZONE_HEADER Zone,
3490 * IN PVOID Object);
3491 */
3492 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
3493 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
3494 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
3495 (Zone)->TotalSegmentSize)) )
3496
3497 NTKERNELAPI
3498 DECLSPEC_NORETURN
3499 VOID
3500 NTAPI
3501 ExRaiseAccessViolation(
3502 VOID);
3503
3504 NTKERNELAPI
3505 DECLSPEC_NORETURN
3506 VOID
3507 NTAPI
3508 ExRaiseDatatypeMisalignment(
3509 VOID);
3510
3511 NTKERNELAPI
3512 NTSTATUS
3513 NTAPI
3514 ExUuidCreate(
3515 OUT UUID *Uuid);
3516
3517 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
3518 #define ExAcquireResourceShared ExAcquireResourceSharedLite
3519 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
3520 #define ExDeleteResource ExDeleteResourceLite
3521 #define ExInitializeResource ExInitializeResourceLite
3522 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
3523 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
3524 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
3525 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
3526
3527
3528 #if DBG
3529
3530 #define PAGED_CODE() { \
3531 if (KeGetCurrentIrql() > APC_LEVEL) { \
3532 KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
3533 ASSERT(FALSE); \
3534 } \
3535 }
3536
3537 #else
3538
3539 #define PAGED_CODE()
3540
3541 #endif
3542
3543 NTKERNELAPI
3544 VOID
3545 NTAPI
3546 ProbeForRead(
3547 IN CONST VOID *Address,
3548 IN SIZE_T Length,
3549 IN ULONG Alignment);
3550
3551 NTKERNELAPI
3552 VOID
3553 NTAPI
3554 ProbeForWrite(
3555 IN PVOID Address,
3556 IN SIZE_T Length,
3557 IN ULONG Alignment);
3558
3559
3560
3561 /** Configuration manager routines **/
3562
3563 NTKERNELAPI
3564 NTSTATUS
3565 NTAPI
3566 CmRegisterCallback(
3567 IN PEX_CALLBACK_FUNCTION Function,
3568 IN PVOID Context,
3569 IN OUT PLARGE_INTEGER Cookie);
3570
3571 NTKERNELAPI
3572 NTSTATUS
3573 NTAPI
3574 CmUnRegisterCallback(
3575 IN LARGE_INTEGER Cookie);
3576
3577
3578
3579 /** Filesystem runtime library routines **/
3580
3581 NTKERNELAPI
3582 BOOLEAN
3583 NTAPI
3584 FsRtlIsTotalDeviceFailure(
3585 IN NTSTATUS Status);
3586
3587
3588
3589 /** Hardware abstraction layer routines **/
3590
3591 NTHALAPI
3592 BOOLEAN
3593 NTAPI
3594 HalMakeBeep(
3595 IN ULONG Frequency);
3596
3597 NTKERNELAPI
3598 VOID
3599 FASTCALL
3600 HalExamineMBR(
3601 IN PDEVICE_OBJECT DeviceObject,
3602 IN ULONG SectorSize,
3603 IN ULONG MBRTypeIdentifier,
3604 OUT PVOID *Buffer);
3605
3606 VOID
3607 NTAPI
3608 HalPutDmaAdapter(
3609 PADAPTER_OBJECT AdapterObject
3610 );
3611
3612
3613 /** Io access routines **/
3614
3615 #if !defined(_M_AMD64)
3616 NTHALAPI
3617 VOID
3618 NTAPI
3619 READ_PORT_BUFFER_UCHAR(
3620 IN PUCHAR Port,
3621 IN PUCHAR Buffer,
3622 IN ULONG Count);
3623
3624 NTHALAPI
3625 VOID
3626 NTAPI
3627 READ_PORT_BUFFER_ULONG(
3628 IN PULONG Port,
3629 IN PULONG Buffer,
3630 IN ULONG Count);
3631
3632 NTHALAPI
3633 VOID
3634 NTAPI
3635 READ_PORT_BUFFER_USHORT(
3636 IN PUSHORT Port,
3637 IN PUSHORT Buffer,
3638 IN ULONG Count);
3639
3640 NTHALAPI
3641 UCHAR
3642 NTAPI
3643 READ_PORT_UCHAR(
3644 IN PUCHAR Port);
3645
3646 NTHALAPI
3647 ULONG
3648 NTAPI
3649 READ_PORT_ULONG(
3650 IN PULONG Port);
3651
3652 NTHALAPI
3653 USHORT
3654 NTAPI
3655 READ_PORT_USHORT(
3656 IN PUSHORT Port);
3657
3658 NTKERNELAPI
3659 VOID
3660 NTAPI
3661 READ_REGISTER_BUFFER_UCHAR(
3662 IN PUCHAR Register,
3663 IN PUCHAR Buffer,
3664 IN ULONG Count);
3665
3666 NTKERNELAPI
3667 VOID
3668 NTAPI
3669 READ_REGISTER_BUFFER_ULONG(
3670 IN PULONG Register,
3671 IN PULONG Buffer,
3672 IN ULONG Count);
3673
3674 NTKERNELAPI
3675 VOID
3676 NTAPI
3677 READ_REGISTER_BUFFER_USHORT(
3678 IN PUSHORT Register,
3679 IN PUSHORT Buffer,
3680 IN ULONG Count);
3681
3682 NTKERNELAPI
3683 UCHAR
3684 NTAPI
3685 READ_REGISTER_UCHAR(
3686 IN PUCHAR Register);
3687
3688 NTKERNELAPI
3689 ULONG
3690 NTAPI
3691 READ_REGISTER_ULONG(
3692 IN PULONG Register);
3693
3694 NTKERNELAPI
3695 USHORT
3696 NTAPI
3697 READ_REGISTER_USHORT(
3698 IN PUSHORT Register);
3699
3700 NTHALAPI
3701 VOID
3702 NTAPI
3703 WRITE_PORT_BUFFER_UCHAR(
3704 IN PUCHAR Port,
3705 IN PUCHAR Buffer,
3706 IN ULONG Count);
3707
3708 NTHALAPI
3709 VOID
3710 NTAPI
3711 WRITE_PORT_BUFFER_ULONG(
3712 IN PULONG Port,
3713 IN PULONG Buffer,
3714 IN ULONG Count);
3715
3716 NTHALAPI
3717 VOID
3718 NTAPI
3719 WRITE_PORT_BUFFER_USHORT(
3720 IN PUSHORT Port,
3721 IN PUSHORT Buffer,
3722 IN ULONG Count);
3723
3724 NTHALAPI
3725 VOID
3726 NTAPI
3727 WRITE_PORT_UCHAR(
3728 IN PUCHAR Port,
3729 IN UCHAR Value);
3730
3731 NTHALAPI
3732 VOID
3733 NTAPI
3734 WRITE_PORT_ULONG(
3735 IN PULONG Port,
3736 IN ULONG Value);
3737
3738 NTHALAPI
3739 VOID
3740 NTAPI
3741 WRITE_PORT_USHORT(
3742 IN PUSHORT Port,
3743 IN USHORT Value);
3744
3745 NTKERNELAPI
3746 VOID
3747 NTAPI
3748 WRITE_REGISTER_BUFFER_UCHAR(
3749 IN PUCHAR Register,
3750 IN PUCHAR Buffer,
3751 IN ULONG Count);
3752
3753 NTKERNELAPI
3754 VOID
3755 NTAPI
3756 WRITE_REGISTER_BUFFER_ULONG(
3757 IN PULONG Register,
3758 IN PULONG Buffer,
3759 IN ULONG Count);
3760
3761 NTKERNELAPI
3762 VOID
3763 NTAPI
3764 WRITE_REGISTER_BUFFER_USHORT(
3765 IN PUSHORT Register,
3766 IN PUSHORT Buffer,
3767 IN ULONG Count);
3768
3769 NTKERNELAPI
3770 VOID
3771 NTAPI
3772 WRITE_REGISTER_UCHAR(
3773 IN PUCHAR Register,
3774 IN UCHAR Value);
3775
3776 NTKERNELAPI
3777 VOID
3778 NTAPI
3779 WRITE_REGISTER_ULONG(
3780 IN PULONG Register,
3781 IN ULONG Value);
3782
3783 NTKERNELAPI
3784 VOID
3785 NTAPI
3786 WRITE_REGISTER_USHORT(
3787 IN PUSHORT Register,
3788 IN USHORT Value);
3789
3790 #else
3791
3792 FORCEINLINE
3793 VOID
3794 READ_PORT_BUFFER_UCHAR(
3795 IN PUCHAR Port,
3796 IN PUCHAR Buffer,
3797 IN ULONG Count)
3798 {
3799 __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3800 }
3801
3802 FORCEINLINE
3803 VOID
3804 READ_PORT_BUFFER_ULONG(
3805 IN PULONG Port,
3806 IN PULONG Buffer,
3807 IN ULONG Count)
3808 {
3809 __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3810 }
3811
3812 FORCEINLINE
3813 VOID
3814 READ_PORT_BUFFER_USHORT(
3815 IN PUSHORT Port,
3816 IN PUSHORT Buffer,
3817 IN ULONG Count)
3818 {
3819 __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3820 }
3821
3822 FORCEINLINE
3823 UCHAR
3824 READ_PORT_UCHAR(
3825 IN PUCHAR Port)
3826 {
3827 return __inbyte((USHORT)(ULONG_PTR)Port);
3828 }
3829
3830 FORCEINLINE
3831 ULONG
3832 READ_PORT_ULONG(
3833 IN PULONG Port)
3834 {
3835 return __indword((USHORT)(ULONG_PTR)Port);
3836 }
3837
3838 FORCEINLINE
3839 USHORT
3840 READ_PORT_USHORT(
3841 IN PUSHORT Port)
3842 {
3843 return __inword((USHORT)(ULONG_PTR)Port);
3844 }
3845
3846 FORCEINLINE
3847 VOID
3848 READ_REGISTER_BUFFER_UCHAR(
3849 IN PUCHAR Register,
3850 IN PUCHAR Buffer,
3851 IN ULONG Count)
3852 {
3853 __movsb(Register, Buffer, Count);
3854 }
3855
3856 FORCEINLINE
3857 VOID
3858 READ_REGISTER_BUFFER_ULONG(
3859 IN PULONG Register,
3860 IN PULONG Buffer,
3861 IN ULONG Count)
3862 {
3863 __movsd(Register, Buffer, Count);
3864 }
3865
3866 FORCEINLINE
3867 VOID
3868 READ_REGISTER_BUFFER_USHORT(
3869 IN PUSHORT Register,
3870 IN PUSHORT Buffer,
3871 IN ULONG Count)
3872 {
3873 __movsw(Register, Buffer, Count);
3874 }
3875
3876 FORCEINLINE
3877 UCHAR
3878 READ_REGISTER_UCHAR(
3879 IN PUCHAR Register)
3880 {
3881 return *Register;
3882 }
3883
3884 FORCEINLINE
3885 ULONG
3886 READ_REGISTER_ULONG(
3887 IN PULONG Register)
3888 {
3889 return *Register;
3890 }
3891
3892 FORCEINLINE
3893 USHORT
3894 READ_REGISTER_USHORT(
3895 IN PUSHORT Register)
3896 {
3897 return *Register;
3898 }
3899
3900 FORCEINLINE
3901 VOID
3902 WRITE_PORT_BUFFER_UCHAR(
3903 IN PUCHAR Port,
3904 IN PUCHAR Buffer,
3905 IN ULONG Count)
3906 {
3907 __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3908 }
3909
3910 FORCEINLINE
3911 VOID
3912 WRITE_PORT_BUFFER_ULONG(
3913 IN PULONG Port,
3914 IN PULONG Buffer,
3915 IN ULONG Count)
3916 {
3917 __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3918 }
3919
3920 FORCEINLINE
3921 VOID
3922 WRITE_PORT_BUFFER_USHORT(
3923 IN PUSHORT Port,
3924 IN PUSHORT Buffer,
3925 IN ULONG Count)
3926 {
3927 __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3928 }
3929
3930 FORCEINLINE
3931 VOID
3932 WRITE_PORT_UCHAR(
3933 IN PUCHAR Port,
3934 IN UCHAR Value)
3935 {
3936 __outbyte((USHORT)(ULONG_PTR)Port, Value);
3937 }
3938
3939 FORCEINLINE
3940 VOID
3941 WRITE_PORT_ULONG(
3942 IN PULONG Port,
3943 IN ULONG Value)
3944 {
3945 __outdword((USHORT)(ULONG_PTR)Port, Value);
3946 }
3947
3948 FORCEINLINE
3949 VOID
3950 WRITE_PORT_USHORT(
3951 IN PUSHORT Port,
3952 IN USHORT Value)
3953 {
3954 __outword((USHORT)(ULONG_PTR)Port, Value);
3955 }
3956
3957 FORCEINLINE
3958 VOID
3959 WRITE_REGISTER_BUFFER_UCHAR(
3960 IN PUCHAR Register,
3961 IN PUCHAR Buffer,
3962 IN ULONG Count)
3963 {
3964 LONG Synch;
3965 __movsb(Register, Buffer, Count);
3966 InterlockedOr(&Synch, 1);
3967 }
3968
3969 FORCEINLINE
3970 VOID
3971 WRITE_REGISTER_BUFFER_ULONG(
3972 IN PULONG Register,
3973 IN PULONG Buffer,
3974 IN ULONG Count)
3975 {
3976 LONG Synch;
3977 __movsd(Register, Buffer, Count);
3978 InterlockedOr(&Synch, 1);
3979 }
3980
3981 FORCEINLINE
3982 VOID
3983 WRITE_REGISTER_BUFFER_USHORT(
3984 IN PUSHORT Register,
3985 IN PUSHORT Buffer,
3986 IN ULONG Count)
3987 {
3988 LONG Synch;
3989 __movsw(Register, Buffer, Count);
3990 InterlockedOr(&Synch, 1);
3991 }
3992
3993 FORCEINLINE
3994 VOID
3995 WRITE_REGISTER_UCHAR(
3996 IN PUCHAR Register,
3997 IN UCHAR Value)
3998 {
3999 LONG Synch;
4000 *Register = Value;
4001 InterlockedOr(&Synch, 1);
4002 }
4003
4004 FORCEINLINE
4005 VOID
4006 WRITE_REGISTER_ULONG(
4007 IN PULONG Register,
4008 IN ULONG Value)
4009 {
4010 LONG Synch;
4011 *Register = Value;
4012 InterlockedOr(&Synch, 1);
4013 }
4014
4015 FORCEINLINE
4016 VOID
4017 WRITE_REGISTER_USHORT(
4018 IN PUSHORT Register,
4019 IN USHORT Value)
4020 {
4021 LONG Sync;
4022 *Register = Value;
4023 InterlockedOr(&Sync, 1);
4024 }
4025
4026 #endif
4027
4028 /** I/O manager routines **/
4029
4030 NTKERNELAPI
4031 VOID
4032 NTAPI
4033 IoAcquireCancelSpinLock(
4034 OUT PKIRQL Irql);
4035
4036 NTKERNELAPI
4037 NTSTATUS
4038 NTAPI
4039 IoAcquireRemoveLockEx(
4040 IN PIO_REMOVE_LOCK RemoveLock,
4041 IN OPTIONAL PVOID Tag OPTIONAL,
4042 IN PCSTR File,
4043 IN ULONG Line,
4044 IN ULONG RemlockSize);
4045
4046 /*
4047 * NTSTATUS
4048 * IoAcquireRemoveLock(
4049 * IN PIO_REMOVE_LOCK RemoveLock,
4050 * IN OPTIONAL PVOID Tag)
4051 */
4052 #define IoAcquireRemoveLock(_RemoveLock, \
4053 _Tag) \
4054 IoAcquireRemoveLockEx(_RemoveLock, _Tag, __FILE__, __LINE__, sizeof(IO_REMOVE_LOCK))
4055
4056 /*
4057 * VOID
4058 * IoAdjustPagingPathCount(
4059 * IN PLONG Count,
4060 * IN BOOLEAN Increment)
4061 */
4062 #define IoAdjustPagingPathCount(_Count, \
4063 _Increment) \
4064 { \
4065 if (_Increment) \
4066 { \
4067 InterlockedIncrement(_Count); \
4068 } \
4069 else \
4070 { \
4071 InterlockedDecrement(_Count); \
4072 } \
4073 }
4074
4075 #ifndef DMA_MACROS_DEFINED
4076 NTKERNELAPI
4077 NTSTATUS
4078 NTAPI
4079 IoAllocateAdapterChannel(
4080 IN PADAPTER_OBJECT AdapterObject,
4081 IN PDEVICE_OBJECT DeviceObject,
4082 IN ULONG NumberOfMapRegisters,
4083 IN PDRIVER_CONTROL ExecutionRoutine,
4084 IN PVOID Context);
4085 #endif
4086
4087 NTKERNELAPI
4088 VOID
4089 NTAPI
4090 IoAllocateController(
4091 IN PCONTROLLER_OBJECT ControllerObject,
4092 IN PDEVICE_OBJECT DeviceObject,
4093 IN PDRIVER_CONTROL ExecutionRoutine,
4094 IN PVOID Context);
4095
4096 NTKERNELAPI
4097 NTSTATUS
4098 NTAPI
4099 IoAllocateDriverObjectExtension(
4100 IN PDRIVER_OBJECT DriverObject,
4101 IN PVOID ClientIdentificationAddress,
4102 IN ULONG DriverObjectExtensionSize,
4103 OUT PVOID *DriverObjectExtension);
4104
4105 NTKERNELAPI
4106 PVOID
4107 NTAPI
4108 IoAllocateErrorLogEntry(
4109 IN PVOID IoObject,
4110 IN UCHAR EntrySize);
4111
4112 NTKERNELAPI
4113 PIRP
4114 NTAPI
4115 IoAllocateIrp(
4116 IN CCHAR StackSize,
4117 IN BOOLEAN ChargeQuota);
4118
4119 NTKERNELAPI
4120 PMDL
4121 NTAPI
4122 IoAllocateMdl(
4123 IN PVOID VirtualAddress,
4124 IN ULONG Length,
4125 IN BOOLEAN SecondaryBuffer,
4126 IN BOOLEAN ChargeQuota,
4127 IN OUT PIRP Irp OPTIONAL);
4128
4129 NTKERNELAPI
4130 PIO_WORKITEM
4131 NTAPI
4132 IoAllocateWorkItem(
4133 IN PDEVICE_OBJECT DeviceObject);
4134
4135 /*
4136 * VOID IoAssignArcName(
4137 * IN PUNICODE_STRING ArcName,
4138 * IN PUNICODE_STRING DeviceName);
4139 */
4140 #define IoAssignArcName(_ArcName, _DeviceName) ( \
4141 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
4142
4143 NTKERNELAPI
4144 NTSTATUS
4145 NTAPI
4146 IoAttachDevice(
4147 IN PDEVICE_OBJECT SourceDevice,
4148 IN PUNICODE_STRING TargetDevice,
4149 OUT PDEVICE_OBJECT *AttachedDevice);
4150
4151 NTKERNELAPI
4152 PDEVICE_OBJECT
4153 NTAPI
4154 IoAttachDeviceToDeviceStack(
4155 IN PDEVICE_OBJECT SourceDevice,
4156 IN PDEVICE_OBJECT TargetDevice);
4157
4158 NTKERNELAPI
4159 PIRP
4160 NTAPI
4161 IoBuildAsynchronousFsdRequest(
4162 IN ULONG MajorFunction,
4163 IN PDEVICE_OBJECT DeviceObject,
4164 IN OUT PVOID Buffer OPTIONAL,
4165 IN ULONG Length OPTIONAL,
4166 IN PLARGE_INTEGER StartingOffset OPTIONAL,
4167 IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL);
4168
4169 NTKERNELAPI
4170 PIRP
4171 NTAPI
4172 IoBuildDeviceIoControlRequest(
4173 IN ULONG IoControlCode,
4174 IN PDEVICE_OBJECT DeviceObject,
4175 IN PVOID InputBuffer OPTIONAL,
4176 IN ULONG InputBufferLength,
4177 OUT PVOID OutputBuffer OPTIONAL,
4178 IN ULONG OutputBufferLength,
4179 IN BOOLEAN InternalDeviceIoControl,
4180 IN PKEVENT Event,
4181 OUT PIO_STATUS_BLOCK IoStatusBlock);
4182
4183 NTKERNELAPI
4184 VOID
4185 NTAPI
4186 IoBuildPartialMdl(
4187 IN PMDL SourceMdl,
4188 IN OUT PMDL TargetMdl,
4189 IN PVOID VirtualAddress,
4190 IN ULONG Length);
4191
4192 NTKERNELAPI
4193 PIRP
4194 NTAPI
4195 IoBuildSynchronousFsdRequest(
4196 IN ULONG MajorFunction,
4197 IN PDEVICE_OBJECT DeviceObject,
4198 IN OUT PVOID Buffer OPTIONAL,
4199 IN ULONG Length OPTIONAL,
4200 IN PLARGE_INTEGER StartingOffset OPTIONAL,
4201 IN PKEVENT Event,
4202 OUT PIO_STATUS_BLOCK IoStatusBlock);
4203
4204 NTKERNELAPI
4205 NTSTATUS
4206 FASTCALL
4207 IofCallDriver(
4208 IN PDEVICE_OBJECT DeviceObject,
4209 IN OUT PIRP Irp);
4210
4211 /*
4212 * NTSTATUS
4213 * IoCallDriver(
4214 * IN PDEVICE_OBJECT DeviceObject,
4215 * IN OUT PIRP Irp)
4216 */
4217 #define IoCallDriver IofCallDriver
4218
4219 NTKERNELAPI
4220 VOID
4221 NTAPI
4222 IoCancelFileOpen(
4223 IN PDEVICE_OBJECT DeviceObject,
4224 IN PFILE_OBJECT FileObject);
4225
4226 NTKERNELAPI
4227 BOOLEAN
4228 NTAPI
4229 IoCancelIrp(
4230 IN PIRP Irp);
4231
4232 NTKERNELAPI
4233 NTSTATUS
4234 NTAPI
4235 IoCheckShareAccess(
4236 IN ACCESS_MASK DesiredAccess,
4237 IN ULONG DesiredShareAccess,
4238 IN OUT PFILE_OBJECT FileObject,
4239 IN OUT PSHARE_ACCESS ShareAccess,
4240 IN BOOLEAN Update);
4241
4242 NTKERNELAPI
4243 VOID
4244 FASTCALL
4245 IofCompleteRequest(
4246 IN PIRP Irp,
4247 IN CCHAR PriorityBoost);
4248
4249 /*
4250 * VOID
4251 * IoCompleteRequest(
4252 * IN PIRP Irp,
4253 * IN CCHAR PriorityBoost)
4254 */
4255 #define IoCompleteRequest IofCompleteRequest
4256
4257 NTKERNELAPI
4258 NTSTATUS
4259 NTAPI
4260 IoConnectInterrupt(
4261 OUT PKINTERRUPT *InterruptObject,
4262 IN PKSERVICE_ROUTINE ServiceRoutine,
4263 IN PVOID ServiceContext,
4264 IN PKSPIN_LOCK SpinLock OPTIONAL,
4265 IN ULONG Vector,
4266 IN KIRQL Irql,
4267 IN KIRQL SynchronizeIrql,
4268 IN KINTERRUPT_MODE InterruptMode,
4269 IN BOOLEAN ShareVector,
4270 IN KAFFINITY ProcessorEnableMask,
4271 IN BOOLEAN FloatingSave);
4272
4273 /*
4274 * PIO_STACK_LOCATION
4275 * IoGetCurrentIrpStackLocation(
4276 * IN PIRP Irp)
4277 */
4278 #define IoGetCurrentIrpStackLocation(_Irp) \
4279 ((_Irp)->Tail.Overlay.CurrentStackLocation)
4280
4281 /*
4282 * PIO_STACK_LOCATION
4283 * IoGetNextIrpStackLocation(
4284 * IN PIRP Irp)
4285 */
4286 #define IoGetNextIrpStackLocation(_Irp) \
4287 ((_Irp)->Tail.Overlay.CurrentStackLocation - 1)
4288
4289 /*
4290 * VOID
4291 * IoCopyCurrentIrpStackLocationToNext(
4292 * IN PIRP Irp)
4293 */
4294 #define IoCopyCurrentIrpStackLocationToNext(_Irp) \
4295 { \
4296 PIO_STACK_LOCATION _IrpSp; \
4297 PIO_STACK_LOCATION _NextIrpSp; \
4298 _IrpSp = IoGetCurrentIrpStackLocation(_Irp); \
4299 _NextIrpSp = IoGetNextIrpStackLocation(_Irp); \
4300 RtlCopyMemory(_NextIrpSp, _IrpSp, \
4301 FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \
4302 _NextIrpSp->Control = 0; \
4303 }
4304
4305 NTKERNELAPI
4306 PCONTROLLER_OBJECT
4307 NTAPI
4308 IoCreateController(
4309 IN ULONG Size);
4310
4311 NTKERNELAPI
4312 NTSTATUS
4313 NTAPI
4314 IoCreateDevice(
4315 IN PDRIVER_OBJECT DriverObject,
4316 IN ULONG DeviceExtensionSize,
4317 IN PUNICODE_STRING DeviceName OPTIONAL,
4318 IN DEVICE_TYPE DeviceType,
4319 IN ULONG DeviceCharacteristics,
4320 IN BOOLEAN Exclusive,
4321 OUT PDEVICE_OBJECT *DeviceObject);
4322
4323 NTKERNELAPI
4324 NTSTATUS
4325 NTAPI
4326 IoCreateDisk(
4327 IN PDEVICE_OBJECT DeviceObject,
4328 IN PCREATE_DISK Disk);
4329
4330 NTKERNELAPI
4331 NTSTATUS
4332 NTAPI
4333 IoCreateFile(
4334 OUT PHANDLE FileHandle,
4335 IN ACCESS_MASK DesiredAccess,
4336 IN POBJECT_ATTRIBUTES ObjectAttributes,
4337 OUT PIO_STATUS_BLOCK IoStatusBlock,
4338 IN PLARGE_INTEGER AllocationSize OPTIONAL,
4339 IN ULONG FileAttributes,
4340 IN ULONG ShareAccess,
4341 IN ULONG Disposition,
4342 IN ULONG CreateOptions,
4343 IN PVOID EaBuffer OPTIONAL,
4344 IN ULONG EaLength,
4345 IN CREATE_FILE_TYPE CreateFileType,
4346 IN PVOID ExtraCreateParameters OPTIONAL,
4347 IN ULONG Options);
4348
4349 NTKERNELAPI
4350 PKEVENT
4351 NTAPI
4352 IoCreateNotificationEvent(
4353 IN PUNICODE_STRING EventName,
4354 OUT PHANDLE EventHandle);
4355
4356 NTKERNELAPI
4357 NTSTATUS
4358 NTAPI
4359 IoCreateSymbolicLink(
4360 IN PUNICODE_STRING SymbolicLinkName,
4361 IN PUNICODE_STRING DeviceName);
4362
4363 NTKERNELAPI
4364 PKEVENT
4365 NTAPI
4366 IoCreateSynchronizationEvent(
4367 IN PUNICODE_STRING EventName,
4368 OUT PHANDLE EventHandle);
4369
4370 NTKERNELAPI
4371 NTSTATUS
4372 NTAPI
4373 IoCreateUnprotectedSymbolicLink(
4374 IN PUNICODE_STRING SymbolicLinkName,
4375 IN PUNICODE_STRING DeviceName);
4376
4377 NTKERNELAPI
4378 NTSTATUS
4379 NTAPI
4380 IoCsqInitialize(
4381 PIO_CSQ Csq,
4382 IN PIO_CSQ_INSERT_IRP CsqInsertIrp,
4383 IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
4384 IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
4385 IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
4386 IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
4387 IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
4388
4389 NTKERNELAPI
4390 VOID
4391 NTAPI
4392 IoCsqInsertIrp(
4393 IN PIO_CSQ Csq,
4394 IN PIRP Irp,
4395 IN PIO_CSQ_IRP_CONTEXT Context);
4396
4397 NTKERNELAPI
4398 PIRP
4399 NTAPI
4400 IoCsqRemoveIrp(
4401 IN PIO_CSQ Csq,
4402 IN PIO_CSQ_IRP_CONTEXT Context);
4403
4404 NTKERNELAPI
4405 PIRP
4406 NTAPI
4407 IoCsqRemoveNextIrp(
4408 IN PIO_CSQ Csq,
4409 IN PVOID PeekContext);
4410
4411 NTKERNELAPI
4412 VOID
4413 NTAPI
4414 IoDeleteController(
4415 IN PCONTROLLER_OBJECT ControllerObject);
4416
4417 NTKERNELAPI
4418 VOID
4419 NTAPI
4420 IoDeleteDevice(
4421 IN PDEVICE_OBJECT DeviceObject);
4422
4423 NTKERNELAPI
4424 NTSTATUS
4425 NTAPI
4426 IoDeleteSymbolicLink(
4427 IN PUNICODE_STRING SymbolicLinkName);
4428
4429 /*
4430 * VOID
4431 * IoDeassignArcName(
4432 * IN PUNICODE_STRING ArcName)
4433 */
4434 #define IoDeassignArcName IoDeleteSymbolicLink
4435
4436 NTKERNELAPI
4437 VOID
4438 NTAPI
4439 IoDetachDevice(
4440 IN OUT PDEVICE_OBJECT TargetDevice);
4441
4442 NTKERNELAPI
4443 VOID
4444 NTAPI
4445 IoDisconnectInterrupt(
4446 IN PKINTERRUPT InterruptObject);
4447
4448 NTKERNELAPI
4449 BOOLEAN
4450 NTAPI
4451 IoForwardIrpSynchronously(
4452 IN PDEVICE_OBJECT DeviceObject,
4453 IN PIRP Irp);
4454
4455 #define IoForwardAndCatchIrp IoForwardIrpSynchronously
4456
4457 NTKERNELAPI
4458 VOID
4459 NTAPI
4460 IoFreeController(
4461 IN PCONTROLLER_OBJECT ControllerObject);
4462
4463 NTKERNELAPI
4464 VOID
4465 NTAPI
4466 IoFreeErrorLogEntry(
4467 PVOID ElEntry);
4468
4469 NTKERNELAPI
4470 VOID
4471 NTAPI
4472 IoFreeIrp(
4473 IN PIRP Irp);
4474
4475 NTKERNELAPI
4476 VOID
4477 NTAPI
4478 IoFreeMdl(
4479 IN PMDL Mdl);
4480
4481 NTKERNELAPI
4482 VOID
4483 NTAPI
4484 IoFreeWorkItem(
4485 IN PIO_WORKITEM pIOWorkItem);
4486
4487 NTKERNELAPI
4488 PDEVICE_OBJECT
4489 NTAPI
4490 IoGetAttachedDevice(
4491 IN PDEVICE_OBJECT DeviceObject);
4492
4493 NTKERNELAPI
4494 PDEVICE_OBJECT
4495 NTAPI
4496 IoGetAttachedDeviceReference(
4497 IN PDEVICE_OBJECT DeviceObject);
4498
4499 NTKERNELAPI
4500 NTSTATUS
4501 NTAPI
4502 IoGetBootDiskInformation(
4503 IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
4504 IN ULONG Size);
4505
4506 NTKERNELAPI
4507 PCONFIGURATION_INFORMATION
4508 NTAPI
4509 IoGetConfigurationInformation(
4510 VOID);
4511
4512 NTKERNELAPI
4513 PEPROCESS
4514 NTAPI
4515 IoGetCurrentProcess(
4516 VOID);
4517
4518 NTKERNELAPI
4519 NTSTATUS
4520 NTAPI
4521 IoGetDeviceInterfaceAlias(
4522 IN PUNICODE_STRING SymbolicLinkName,
4523 IN CONST GUID *AliasInterfaceClassGuid,
4524 OUT PUNICODE_STRING AliasSymbolicLinkName);
4525
4526 #define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
4527
4528 NTKERNELAPI
4529 NTSTATUS
4530 NTAPI
4531 IoGetDeviceInterfaces(
4532 IN CONST GUID *InterfaceClassGuid,
4533 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
4534 IN ULONG Flags,
4535 OUT PWSTR *SymbolicLinkList);
4536
4537 NTKERNELAPI
4538 NTSTATUS
4539 NTAPI
4540 IoGetDeviceObjectPointer(
4541 IN PUNICODE_STRING ObjectName,
4542 IN ACCESS_MASK DesiredAccess,
4543 OUT PFILE_OBJECT *FileObject,
4544 OUT PDEVICE_OBJECT *DeviceObject);
4545
4546 NTKERNELAPI
4547 NTSTATUS
4548 NTAPI
4549 IoGetDeviceProperty(
4550 IN PDEVICE_OBJECT DeviceObject,
4551 IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
4552 IN ULONG BufferLength,
4553 OUT PVOID PropertyBuffer,
4554 OUT PULONG ResultLength);
4555
4556 NTKERNELAPI
4557 PDEVICE_OBJECT
4558 NTAPI
4559 IoGetDeviceToVerify(
4560 IN PETHREAD Thread);
4561
4562 NTKERNELAPI
4563 PDMA_ADAPTER
4564 NTAPI
4565 IoGetDmaAdapter(
4566 IN PDEVICE_OBJECT PhysicalDeviceObject,
4567 IN PDEVICE_DESCRIPTION DeviceDescription,
4568 IN OUT PULONG NumberOfMapRegisters);
4569
4570 NTKERNELAPI
4571 PVOID
4572 NTAPI
4573 IoGetDriverObjectExtension(
4574 IN PDRIVER_OBJECT DriverObject,
4575 IN PVOID ClientIdentificationAddress);
4576
4577 NTKERNELAPI
4578 PGENERIC_MAPPING
4579 NTAPI
4580 IoGetFileObjectGenericMapping(
4581 VOID);
4582
4583 /*
4584 * ULONG
4585 * IoGetFunctionCodeFromCtlCode(
4586 * IN ULONG ControlCode)
4587 */
4588 #define IoGetFunctionCodeFromCtlCode(_ControlCode) \
4589 (((_ControlCode) >> 2) & 0x00000FFF)
4590
4591 NTKERNELAPI
4592 PVOID
4593 NTAPI
4594 IoGetInitialStack(
4595 VOID);
4596
4597 NTKERNELAPI
4598 PDEVICE_OBJECT
4599 NTAPI
4600 IoGetRelatedDeviceObject(
4601 IN PFILE_OBJECT FileObject);
4602
4603 NTKERNELAPI
4604 VOID
4605 NTAPI
4606 IoGetStackLimits(
4607 OUT PULONG_PTR LowLimit,
4608 OUT PULONG_PTR HighLimit);
4609
4610 FORCEINLINE
4611 ULONG_PTR
4612 IoGetRemainingStackSize(
4613 VOID
4614 )
4615 {
4616 ULONG_PTR End, Begin;
4617 ULONG_PTR Result;
4618
4619 IoGetStackLimits(&Begin, &End);
4620 Result = (ULONG_PTR)(&End) - Begin;
4621 return Result;
4622 }
4623
4624 NTKERNELAPI
4625 VOID
4626 NTAPI
4627 KeInitializeDpc(
4628 IN PRKDPC Dpc,
4629 IN PKDEFERRED_ROUTINE DeferredRoutine,
4630 IN PVOID DeferredContext);
4631
4632 /*
4633 * VOID
4634 * IoInitializeDpcRequest(
4635 * IN PDEVICE_OBJECT DeviceObject,
4636 * IN PIO_DPC_ROUTINE DpcRoutine)
4637 */
4638 #define IoInitializeDpcRequest(_DeviceObject, \
4639 _DpcRoutine) \
4640 KeInitializeDpc(&(_DeviceObject)->Dpc, \
4641 (PKDEFERRED_ROUTINE) (_DpcRoutine), \
4642 _DeviceObject)
4643
4644 NTKERNELAPI
4645 VOID
4646 NTAPI
4647 IoInitializeIrp(
4648 IN OUT PIRP Irp,
4649 IN USHORT PacketSize,
4650 IN CCHAR StackSize);
4651
4652 NTKERNELAPI
4653 VOID
4654 NTAPI
4655 IoInitializeRemoveLockEx(
4656 IN PIO_REMOVE_LOCK Lock,
4657 IN ULONG AllocateTag,
4658 IN ULONG MaxLockedMinutes,
4659 IN ULONG HighWatermark,
4660 IN ULONG RemlockSize);
4661
4662 /* VOID
4663 * IoInitializeRemoveLock(
4664 * IN PIO_REMOVE_LOCK Lock,
4665 * IN ULONG AllocateTag,
4666 * IN ULONG MaxLockedMinutes,
4667 * IN ULONG HighWatermark)
4668 */
4669 #define IoInitializeRemoveLock( \
4670 Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \
4671 IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \
4672 HighWatermark, sizeof(IO_REMOVE_LOCK))
4673
4674 NTKERNELAPI
4675 NTSTATUS
4676 NTAPI
4677 IoInitializeTimer(
4678 IN PDEVICE_OBJECT DeviceObject,
4679 IN PIO_TIMER_ROUTINE TimerRoutine,
4680 IN PVOID Context);
4681
4682 NTKERNELAPI
4683 VOID
4684 NTAPI
4685 IoInvalidateDeviceRelations(
4686 IN PDEVICE_OBJECT DeviceObject,
4687 IN DEVICE_RELATION_TYPE Type);
4688
4689 NTKERNELAPI
4690 VOID
4691 NTAPI
4692 IoInvalidateDeviceState(
4693 IN PDEVICE_OBJECT PhysicalDeviceObject);
4694
4695 NTKERNELAPI
4696 BOOLEAN
4697 NTAPI
4698 IoIs32bitProcess(
4699 IN PIRP Irp OPTIONAL);
4700
4701 /*
4702 * BOOLEAN
4703 * IoIsErrorUserInduced(
4704 * IN NTSTATUS Status);
4705 */
4706 #define IoIsErrorUserInduced(Status) \
4707 ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
4708 ((Status) == STATUS_IO_TIMEOUT) || \
4709 ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
4710 ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
4711 ((Status) == STATUS_VERIFY_REQUIRED) || \
4712 ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
4713 ((Status) == STATUS_WRONG_VOLUME)))
4714
4715 NTKERNELAPI
4716 BOOLEAN
4717 NTAPI
4718 IoIsWdmVersionAvailable(
4719 IN UCHAR MajorVersion,
4720 IN UCHAR MinorVersion);
4721
4722 NTKERNELAPI
4723 PIRP
4724 NTAPI
4725 IoMakeAssociatedIrp(
4726 IN PIRP Irp,
4727 IN CCHAR StackSize);
4728
4729 /*
4730 * VOID
4731 * IoMarkIrpPending(
4732 * IN OUT PIRP Irp)
4733 */
4734 #define IoMarkIrpPending(_Irp) \
4735 (IoGetCurrentIrpStackLocation(_Irp)->Control |= SL_PENDING_RETURNED)
4736
4737 NTKERNELAPI
4738 NTSTATUS
4739 NTAPI
4740 IoOpenDeviceInterfaceRegistryKey(
4741 IN PUNICODE_STRING SymbolicLinkName,
4742 IN ACCESS_MASK DesiredAccess,
4743 OUT PHANDLE DeviceInterfaceKey);
4744
4745 #define PLUGPLAY_REGKEY_DEVICE 1
4746 #define PLUGPLAY_REGKEY_DRIVER 2
4747 #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
4748
4749 NTKERNELAPI
4750 NTSTATUS
4751 NTAPI
4752 IoOpenDeviceRegistryKey(
4753 IN PDEVICE_OBJECT DeviceObject,
4754 IN ULONG DevInstKeyType,
4755 IN ACCESS_MASK DesiredAccess,
4756 OUT PHANDLE DevInstRegKey);
4757
4758 NTKERNELAPI
4759 NTSTATUS
4760 NTAPI
4761 IoQueryDeviceDescription(
4762 IN PINTERFACE_TYPE BusType OPTIONAL,
4763 IN PULONG BusNumber OPTIONAL,
4764 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
4765 IN PULONG ControllerNumber OPTIONAL,
4766 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
4767 IN PULONG PeripheralNumber OPTIONAL,
4768 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
4769 IN PVOID Context);
4770
4771 NTKERNELAPI
4772 VOID
4773 NTAPI
4774 IoQueueWorkItem(
4775 IN PIO_WORKITEM pIOWorkItem,
4776 IN PIO_WORKITEM_ROUTINE Routine,
4777 IN WORK_QUEUE_TYPE QueueType,
4778 IN PVOID Context);
4779
4780 NTKERNELAPI
4781 VOID
4782 NTAPI
4783 IoRaiseHardError(
4784 IN PIRP Irp,
4785 IN PVPB Vpb OPTIONAL,
4786 IN PDEVICE_OBJECT RealDeviceObject);
4787
4788 NTKERNELAPI
4789 BOOLEAN
4790 NTAPI
4791 IoRaiseInformationalHardError(
4792 IN NTSTATUS ErrorStatus,
4793 IN PUNICODE_STRING String OPTIONAL,
4794 IN PKTHREAD Thread OPTIONAL);
4795
4796 NTKERNELAPI
4797 NTSTATUS
4798 NTAPI
4799 IoReadDiskSignature(
4800 IN PDEVICE_OBJECT DeviceObject,
4801 IN ULONG BytesPerSector,
4802 OUT PDISK_SIGNATURE Signature);
4803
4804 NTKERNELAPI
4805 NTSTATUS
4806 FASTCALL
4807 IoReadPartitionTable(
4808 IN PDEVICE_OBJECT DeviceObject,
4809 IN ULONG SectorSize,
4810 IN BOOLEAN ReturnRecognizedPartitions,
4811 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
4812
4813 NTKERNELAPI
4814 NTSTATUS
4815 NTAPI
4816 IoReadPartitionTableEx(
4817 IN PDEVICE_OBJECT DeviceObject,
4818 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
4819
4820 NTKERNELAPI
4821 VOID
4822 NTAPI
4823 IoRegisterBootDriverReinitialization(
4824 IN PDRIVER_OBJECT DriverObject,
4825 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
4826 IN PVOID Context);
4827
4828 NTKERNELAPI
4829 VOID
4830 NTAPI
4831 IoRegisterBootDriverReinitialization(
4832 IN PDRIVER_OBJECT DriverObject,
4833 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
4834 IN PVOID Context);
4835
4836 NTKERNELAPI