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