- 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 #define ARGUMENT_PRESENT(ArgumentPointer) \
2246 ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
2247
2248 NTSYSAPI
2249 NTSTATUS
2250 NTAPI
2251 RtlCharToInteger(
2252 IN PCSZ String,
2253 IN ULONG Base OPTIONAL,
2254 IN OUT PULONG Value);
2255
2256 NTSYSAPI
2257 LONG
2258 NTAPI
2259 RtlCompareString(
2260 IN PSTRING String1,
2261 IN PSTRING String2,
2262 BOOLEAN CaseInSensitive);
2263
2264 #if !defined(MIDL_PASS)
2265
2266 FORCEINLINE
2267 LUID
2268 NTAPI
2269 RtlConvertLongToLuid(
2270 IN LONG Val)
2271 {
2272 LUID Luid;
2273 LARGE_INTEGER Temp;
2274
2275 Temp.QuadPart = Val;
2276 Luid.LowPart = Temp.u.LowPart;
2277 Luid.HighPart = Temp.u.HighPart;
2278
2279 return Luid;
2280 }
2281
2282 FORCEINLINE
2283 LUID
2284 NTAPI
2285 RtlConvertUlongToLuid(
2286 IN ULONG Val)
2287 {
2288 LUID Luid;
2289
2290 Luid.LowPart = Val;
2291 Luid.HighPart = 0;
2292
2293 return Luid;
2294 }
2295 #endif
2296
2297
2298 NTSYSAPI
2299 VOID
2300 NTAPI
2301 RtlCopyMemory32(
2302 IN VOID UNALIGNED *Destination,
2303 IN CONST VOID UNALIGNED *Source,
2304 IN ULONG Length);
2305
2306 NTSYSAPI
2307 VOID
2308 NTAPI
2309 RtlCopyString(
2310 IN OUT PSTRING DestinationString,
2311 IN PSTRING SourceString OPTIONAL);
2312
2313 NTSYSAPI
2314 BOOLEAN
2315 NTAPI
2316 RtlEqualString(
2317 IN PSTRING String1,
2318 IN PSTRING String2,
2319 IN BOOLEAN CaseInSensitive);
2320
2321 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
2322 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
2323 *CallersAddress = (PVOID)_ReturnAddress(); \
2324 *CallersCaller = NULL;
2325 #else
2326 NTSYSAPI
2327 VOID
2328 NTAPI
2329 RtlGetCallersAddress(
2330 OUT PVOID *CallersAddress,
2331 OUT PVOID *CallersCaller);
2332 #endif
2333
2334 NTSYSAPI
2335 NTSTATUS
2336 NTAPI
2337 RtlGetVersion(
2338 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
2339
2340 NTSYSAPI
2341 VOID
2342 NTAPI
2343 RtlMapGenericMask(
2344 IN OUT PACCESS_MASK AccessMask,
2345 IN PGENERIC_MAPPING GenericMapping);
2346
2347 NTSYSAPI
2348 BOOLEAN
2349 NTAPI
2350 RtlPrefixUnicodeString(
2351 IN PCUNICODE_STRING String1,
2352 IN PCUNICODE_STRING String2,
2353 IN BOOLEAN CaseInSensitive);
2354
2355 NTSYSAPI
2356 NTSTATUS
2357 NTAPI
2358 RtlUpcaseUnicodeString(
2359 IN OUT PUNICODE_STRING DestinationString OPTIONAL,
2360 IN PCUNICODE_STRING SourceString,
2361 IN BOOLEAN AllocateDestinationString);
2362
2363 NTSYSAPI
2364 CHAR
2365 NTAPI
2366 RtlUpperChar(
2367 IN CHAR Character);
2368
2369 NTSYSAPI
2370 VOID
2371 NTAPI
2372 RtlUpperString(
2373 IN OUT PSTRING DestinationString,
2374 IN PSTRING SourceString);
2375
2376 NTSYSAPI
2377 NTSTATUS
2378 NTAPI
2379 RtlVerifyVersionInfo(
2380 IN PRTL_OSVERSIONINFOEXW VersionInfo,
2381 IN ULONG TypeMask,
2382 IN ULONGLONG ConditionMask);
2383
2384 NTSYSAPI
2385 NTSTATUS
2386 NTAPI
2387 RtlVolumeDeviceToDosName(
2388 IN PVOID VolumeDeviceObject,
2389 OUT PUNICODE_STRING DosName);
2390
2391 NTSYSAPI
2392 ULONG
2393 NTAPI
2394 RtlWalkFrameChain(
2395 OUT PVOID *Callers,
2396 IN ULONG Count,
2397 IN ULONG Flags);
2398
2399 /******************************************************************************
2400 * Executive Types *
2401 ******************************************************************************/
2402
2403 typedef struct _ZONE_SEGMENT_HEADER {
2404 SINGLE_LIST_ENTRY SegmentList;
2405 PVOID Reserved;
2406 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
2407
2408 typedef struct _ZONE_HEADER {
2409 SINGLE_LIST_ENTRY FreeList;
2410 SINGLE_LIST_ENTRY SegmentList;
2411 ULONG BlockSize;
2412 ULONG TotalSegmentSize;
2413 } ZONE_HEADER, *PZONE_HEADER;
2414
2415 #define PROTECTED_POOL 0x80000000
2416
2417 /******************************************************************************
2418 * Executive Functions *
2419 ******************************************************************************/
2420
2421 NTKERNELAPI
2422 NTSTATUS
2423 NTAPI
2424 ExExtendZone(
2425 IN PZONE_HEADER Zone,
2426 IN PVOID Segment,
2427 IN ULONG SegmentSize);
2428
2429 static __inline PVOID
2430 ExAllocateFromZone(
2431 IN PZONE_HEADER Zone)
2432 {
2433 if (Zone->FreeList.Next)
2434 Zone->FreeList.Next = Zone->FreeList.Next->Next;
2435 return (PVOID) Zone->FreeList.Next;
2436 }
2437
2438 static __inline PVOID
2439 ExFreeToZone(
2440 IN PZONE_HEADER Zone,
2441 IN PVOID Block)
2442 {
2443 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
2444 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
2445 return ((PSINGLE_LIST_ENTRY) Block)->Next;
2446 }
2447
2448 NTKERNELAPI
2449 NTSTATUS
2450 NTAPI
2451 ExInitializeZone(
2452 IN PZONE_HEADER Zone,
2453 IN ULONG BlockSize,
2454 IN PVOID InitialSegment,
2455 IN ULONG InitialSegmentSize);
2456
2457 /*
2458 * PVOID
2459 * ExInterlockedAllocateFromZone(
2460 * IN PZONE_HEADER Zone,
2461 * IN PKSPIN_LOCK Lock)
2462 */
2463 #define ExInterlockedAllocateFromZone(Zone, Lock) \
2464 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
2465
2466 NTKERNELAPI
2467 NTSTATUS
2468 NTAPI
2469 ExInterlockedExtendZone(
2470 IN PZONE_HEADER Zone,
2471 IN PVOID Segment,
2472 IN ULONG SegmentSize,
2473 IN PKSPIN_LOCK Lock);
2474
2475 /* PVOID
2476 * ExInterlockedFreeToZone(
2477 * IN PZONE_HEADER Zone,
2478 * IN PVOID Block,
2479 * IN PKSPIN_LOCK Lock);
2480 */
2481 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
2482 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
2483
2484 /*
2485 * BOOLEAN
2486 * ExIsFullZone(
2487 * IN PZONE_HEADER Zone)
2488 */
2489 #define ExIsFullZone(Zone) \
2490 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
2491
2492 /* BOOLEAN
2493 * ExIsObjectInFirstZoneSegment(
2494 * IN PZONE_HEADER Zone,
2495 * IN PVOID Object);
2496 */
2497 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
2498 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
2499 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
2500 (Zone)->TotalSegmentSize)) )
2501
2502 NTKERNELAPI
2503 DECLSPEC_NORETURN
2504 VOID
2505 NTAPI
2506 ExRaiseAccessViolation(
2507 VOID);
2508
2509 NTKERNELAPI
2510 DECLSPEC_NORETURN
2511 VOID
2512 NTAPI
2513 ExRaiseDatatypeMisalignment(
2514 VOID);
2515
2516 NTKERNELAPI
2517 NTSTATUS
2518 NTAPI
2519 ExUuidCreate(
2520 OUT UUID *Uuid);
2521
2522 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
2523 #define ExAcquireResourceShared ExAcquireResourceSharedLite
2524 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
2525 #define ExDeleteResource ExDeleteResourceLite
2526 #define ExInitializeResource ExInitializeResourceLite
2527 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
2528 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
2529 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
2530 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
2531
2532
2533 #if DBG
2534
2535 #define PAGED_CODE() { \
2536 if (KeGetCurrentIrql() > APC_LEVEL) { \
2537 KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
2538 ASSERT(FALSE); \
2539 } \
2540 }
2541
2542 #else
2543
2544 #define PAGED_CODE()
2545
2546 #endif
2547
2548 NTKERNELAPI
2549 VOID
2550 NTAPI
2551 ProbeForRead(
2552 IN CONST VOID *Address,
2553 IN SIZE_T Length,
2554 IN ULONG Alignment);
2555
2556 NTKERNELAPI
2557 VOID
2558 NTAPI
2559 ProbeForWrite(
2560 IN PVOID Address,
2561 IN SIZE_T Length,
2562 IN ULONG Alignment);
2563
2564
2565
2566 /** Configuration manager routines **/
2567
2568 NTKERNELAPI
2569 NTSTATUS
2570 NTAPI
2571 CmRegisterCallback(
2572 IN PEX_CALLBACK_FUNCTION Function,
2573 IN PVOID Context,
2574 IN OUT PLARGE_INTEGER Cookie);
2575
2576 NTKERNELAPI
2577 NTSTATUS
2578 NTAPI
2579 CmUnRegisterCallback(
2580 IN LARGE_INTEGER Cookie);
2581
2582
2583
2584 /** Filesystem runtime library routines **/
2585
2586 NTKERNELAPI
2587 BOOLEAN
2588 NTAPI
2589 FsRtlIsTotalDeviceFailure(
2590 IN NTSTATUS Status);
2591
2592
2593
2594 /** Hardware abstraction layer routines **/
2595
2596 NTHALAPI
2597 BOOLEAN
2598 NTAPI
2599 HalMakeBeep(
2600 IN ULONG Frequency);
2601
2602 NTKERNELAPI
2603 VOID
2604 FASTCALL
2605 HalExamineMBR(
2606 IN PDEVICE_OBJECT DeviceObject,
2607 IN ULONG SectorSize,
2608 IN ULONG MBRTypeIdentifier,
2609 OUT PVOID *Buffer);
2610
2611 VOID
2612 NTAPI
2613 HalPutDmaAdapter(
2614 PADAPTER_OBJECT AdapterObject
2615 );
2616
2617
2618 /** Io access routines **/
2619
2620 #if !defined(_M_AMD64)
2621 NTHALAPI
2622 VOID
2623 NTAPI
2624 READ_PORT_BUFFER_UCHAR(
2625 IN PUCHAR Port,
2626 IN PUCHAR Buffer,
2627 IN ULONG Count);
2628
2629 NTHALAPI
2630 VOID
2631 NTAPI
2632 READ_PORT_BUFFER_ULONG(
2633 IN PULONG Port,
2634 IN PULONG Buffer,
2635 IN ULONG Count);
2636
2637 NTHALAPI
2638 VOID
2639 NTAPI
2640 READ_PORT_BUFFER_USHORT(
2641 IN PUSHORT Port,
2642 IN PUSHORT Buffer,
2643 IN ULONG Count);
2644
2645 NTHALAPI
2646 UCHAR
2647 NTAPI
2648 READ_PORT_UCHAR(
2649 IN PUCHAR Port);
2650
2651 NTHALAPI
2652 ULONG
2653 NTAPI
2654 READ_PORT_ULONG(
2655 IN PULONG Port);
2656
2657 NTHALAPI
2658 USHORT
2659 NTAPI
2660 READ_PORT_USHORT(
2661 IN PUSHORT Port);
2662
2663 NTKERNELAPI
2664 VOID
2665 NTAPI
2666 READ_REGISTER_BUFFER_UCHAR(
2667 IN PUCHAR Register,
2668 IN PUCHAR Buffer,
2669 IN ULONG Count);
2670
2671 NTKERNELAPI
2672 VOID
2673 NTAPI
2674 READ_REGISTER_BUFFER_ULONG(
2675 IN PULONG Register,
2676 IN PULONG Buffer,
2677 IN ULONG Count);
2678
2679 NTKERNELAPI
2680 VOID
2681 NTAPI
2682 READ_REGISTER_BUFFER_USHORT(
2683 IN PUSHORT Register,
2684 IN PUSHORT Buffer,
2685 IN ULONG Count);
2686
2687 NTKERNELAPI
2688 UCHAR
2689 NTAPI
2690 READ_REGISTER_UCHAR(
2691 IN PUCHAR Register);
2692
2693 NTKERNELAPI
2694 ULONG
2695 NTAPI
2696 READ_REGISTER_ULONG(
2697 IN PULONG Register);
2698
2699 NTKERNELAPI
2700 USHORT
2701 NTAPI
2702 READ_REGISTER_USHORT(
2703 IN PUSHORT Register);
2704
2705 NTHALAPI
2706 VOID
2707 NTAPI
2708 WRITE_PORT_BUFFER_UCHAR(
2709 IN PUCHAR Port,
2710 IN PUCHAR Buffer,
2711 IN ULONG Count);
2712
2713 NTHALAPI
2714 VOID
2715 NTAPI
2716 WRITE_PORT_BUFFER_ULONG(
2717 IN PULONG Port,
2718 IN PULONG Buffer,
2719 IN ULONG Count);
2720
2721 NTHALAPI
2722 VOID
2723 NTAPI
2724 WRITE_PORT_BUFFER_USHORT(
2725 IN PUSHORT Port,
2726 IN PUSHORT Buffer,
2727 IN ULONG Count);
2728
2729 NTHALAPI
2730 VOID
2731 NTAPI
2732 WRITE_PORT_UCHAR(
2733 IN PUCHAR Port,
2734 IN UCHAR Value);
2735
2736 NTHALAPI
2737 VOID
2738 NTAPI
2739 WRITE_PORT_ULONG(
2740 IN PULONG Port,
2741 IN ULONG Value);
2742
2743 NTHALAPI
2744 VOID
2745 NTAPI
2746 WRITE_PORT_USHORT(
2747 IN PUSHORT Port,
2748 IN USHORT Value);
2749
2750 NTKERNELAPI
2751 VOID
2752 NTAPI
2753 WRITE_REGISTER_BUFFER_UCHAR(
2754 IN PUCHAR Register,
2755 IN PUCHAR Buffer,
2756 IN ULONG Count);
2757
2758 NTKERNELAPI
2759 VOID
2760 NTAPI
2761 WRITE_REGISTER_BUFFER_ULONG(
2762 IN PULONG Register,
2763 IN PULONG Buffer,
2764 IN ULONG Count);
2765
2766 NTKERNELAPI
2767 VOID
2768 NTAPI
2769 WRITE_REGISTER_BUFFER_USHORT(
2770 IN PUSHORT Register,
2771 IN PUSHORT Buffer,
2772 IN ULONG Count);
2773
2774 NTKERNELAPI
2775 VOID
2776 NTAPI
2777 WRITE_REGISTER_UCHAR(
2778 IN PUCHAR Register,
2779 IN UCHAR Value);
2780
2781 NTKERNELAPI
2782 VOID
2783 NTAPI
2784 WRITE_REGISTER_ULONG(
2785 IN PULONG Register,
2786 IN ULONG Value);
2787
2788 NTKERNELAPI
2789 VOID
2790 NTAPI
2791 WRITE_REGISTER_USHORT(
2792 IN PUSHORT Register,
2793 IN USHORT Value);
2794
2795 #else
2796
2797 FORCEINLINE
2798 VOID
2799 READ_PORT_BUFFER_UCHAR(
2800 IN PUCHAR Port,
2801 IN PUCHAR Buffer,
2802 IN ULONG Count)
2803 {
2804 __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
2805 }
2806
2807 FORCEINLINE
2808 VOID
2809 READ_PORT_BUFFER_ULONG(
2810 IN PULONG Port,
2811 IN PULONG Buffer,
2812 IN ULONG Count)
2813 {
2814 __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
2815 }
2816
2817 FORCEINLINE
2818 VOID
2819 READ_PORT_BUFFER_USHORT(
2820 IN PUSHORT Port,
2821 IN PUSHORT Buffer,
2822 IN ULONG Count)
2823 {
2824 __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
2825 }
2826
2827 FORCEINLINE
2828 UCHAR
2829 READ_PORT_UCHAR(
2830 IN PUCHAR Port)
2831 {
2832 return __inbyte((USHORT)(ULONG_PTR)Port);
2833 }
2834
2835 FORCEINLINE
2836 ULONG
2837 READ_PORT_ULONG(
2838 IN PULONG Port)
2839 {
2840 return __indword((USHORT)(ULONG_PTR)Port);
2841 }
2842
2843 FORCEINLINE
2844 USHORT
2845 READ_PORT_USHORT(
2846 IN PUSHORT Port)
2847 {
2848 return __inword((USHORT)(ULONG_PTR)Port);
2849 }
2850
2851 FORCEINLINE
2852 VOID
2853 READ_REGISTER_BUFFER_UCHAR(
2854 IN PUCHAR Register,
2855 IN PUCHAR Buffer,
2856 IN ULONG Count)
2857 {
2858 __movsb(Register, Buffer, Count);
2859 }
2860
2861 FORCEINLINE
2862 VOID
2863 READ_REGISTER_BUFFER_ULONG(
2864 IN PULONG Register,
2865 IN PULONG Buffer,
2866 IN ULONG Count)
2867 {
2868 __movsd(Register, Buffer, Count);
2869 }
2870
2871 FORCEINLINE
2872 VOID
2873 READ_REGISTER_BUFFER_USHORT(
2874 IN PUSHORT Register,
2875 IN PUSHORT Buffer,
2876 IN ULONG Count)
2877 {
2878 __movsw(Register, Buffer, Count);
2879 }
2880
2881 FORCEINLINE
2882 UCHAR
2883 READ_REGISTER_UCHAR(
2884 IN PUCHAR Register)
2885 {
2886 return *Register;
2887 }
2888
2889 FORCEINLINE
2890 ULONG
2891 READ_REGISTER_ULONG(
2892 IN PULONG Register)
2893 {
2894 return *Register;
2895 }
2896
2897 FORCEINLINE
2898 USHORT
2899 READ_REGISTER_USHORT(
2900 IN PUSHORT Register)
2901 {
2902 return *Register;
2903 }
2904
2905 FORCEINLINE
2906 VOID
2907 WRITE_PORT_BUFFER_UCHAR(
2908 IN PUCHAR Port,
2909 IN PUCHAR Buffer,
2910 IN ULONG Count)
2911 {
2912 __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
2913 }
2914
2915 FORCEINLINE
2916 VOID
2917 WRITE_PORT_BUFFER_ULONG(
2918 IN PULONG Port,
2919 IN PULONG Buffer,
2920 IN ULONG Count)
2921 {
2922 __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
2923 }
2924
2925 FORCEINLINE
2926 VOID
2927 WRITE_PORT_BUFFER_USHORT(
2928 IN PUSHORT Port,
2929 IN PUSHORT Buffer,
2930 IN ULONG Count)
2931 {
2932 __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
2933 }
2934
2935 FORCEINLINE
2936 VOID
2937 WRITE_PORT_UCHAR(
2938 IN PUCHAR Port,
2939 IN UCHAR Value)
2940 {
2941 __outbyte((USHORT)(ULONG_PTR)Port, Value);
2942 }
2943
2944 FORCEINLINE
2945 VOID
2946 WRITE_PORT_ULONG(
2947 IN PULONG Port,
2948 IN ULONG Value)
2949 {
2950 __outdword((USHORT)(ULONG_PTR)Port, Value);
2951 }
2952
2953 FORCEINLINE
2954 VOID
2955 WRITE_PORT_USHORT(
2956 IN PUSHORT Port,
2957 IN USHORT Value)
2958 {
2959 __outword((USHORT)(ULONG_PTR)Port, Value);
2960 }
2961
2962 FORCEINLINE
2963 VOID
2964 WRITE_REGISTER_BUFFER_UCHAR(
2965 IN PUCHAR Register,
2966 IN PUCHAR Buffer,
2967 IN ULONG Count)
2968 {
2969 LONG Synch;
2970 __movsb(Register, Buffer, Count);
2971 InterlockedOr(&Synch, 1);
2972 }
2973
2974 FORCEINLINE
2975 VOID
2976 WRITE_REGISTER_BUFFER_ULONG(
2977 IN PULONG Register,
2978 IN PULONG Buffer,
2979 IN ULONG Count)
2980 {
2981 LONG Synch;
2982 __movsd(Register, Buffer, Count);
2983 InterlockedOr(&Synch, 1);
2984 }
2985
2986 FORCEINLINE
2987 VOID
2988 WRITE_REGISTER_BUFFER_USHORT(
2989 IN PUSHORT Register,
2990 IN PUSHORT Buffer,
2991 IN ULONG Count)
2992 {
2993 LONG Synch;
2994 __movsw(Register, Buffer, Count);
2995 InterlockedOr(&Synch, 1);
2996 }
2997
2998 FORCEINLINE
2999 VOID
3000 WRITE_REGISTER_UCHAR(
3001 IN PUCHAR Register,
3002 IN UCHAR Value)
3003 {
3004 LONG Synch;
3005 *Register = Value;
3006 InterlockedOr(&Synch, 1);
3007 }
3008
3009 FORCEINLINE
3010 VOID
3011 WRITE_REGISTER_ULONG(
3012 IN PULONG Register,
3013 IN ULONG Value)
3014 {
3015 LONG Synch;
3016 *Register = Value;
3017 InterlockedOr(&Synch, 1);
3018 }
3019
3020 FORCEINLINE
3021 VOID
3022 WRITE_REGISTER_USHORT(
3023 IN PUSHORT Register,
3024 IN USHORT Value)
3025 {
3026 LONG Sync;
3027 *Register = Value;
3028 InterlockedOr(&Sync, 1);
3029 }
3030
3031 #endif
3032
3033 /** I/O manager routines **/
3034
3035 NTKERNELAPI
3036 VOID
3037 NTAPI
3038 IoAcquireCancelSpinLock(
3039 OUT PKIRQL Irql);
3040
3041 NTKERNELAPI
3042 NTSTATUS
3043 NTAPI
3044 IoAcquireRemoveLockEx(
3045 IN PIO_REMOVE_LOCK RemoveLock,
3046 IN OPTIONAL PVOID Tag OPTIONAL,
3047 IN PCSTR File,
3048 IN ULONG Line,
3049 IN ULONG RemlockSize);
3050
3051 /*
3052 * NTSTATUS
3053 * IoAcquireRemoveLock(
3054 * IN PIO_REMOVE_LOCK RemoveLock,
3055 * IN OPTIONAL PVOID Tag)
3056 */
3057 #define IoAcquireRemoveLock(_RemoveLock, \
3058 _Tag) \
3059 IoAcquireRemoveLockEx(_RemoveLock, _Tag, __FILE__, __LINE__, sizeof(IO_REMOVE_LOCK))
3060
3061 /*
3062 * VOID
3063 * IoAdjustPagingPathCount(
3064 * IN PLONG Count,
3065 * IN BOOLEAN Increment)
3066 */
3067 #define IoAdjustPagingPathCount(_Count, \
3068 _Increment) \
3069 { \
3070 if (_Increment) \
3071 { \
3072 InterlockedIncrement(_Count); \
3073 } \
3074 else \
3075 { \
3076 InterlockedDecrement(_Count); \
3077 } \
3078 }
3079
3080 #ifndef DMA_MACROS_DEFINED
3081 NTKERNELAPI
3082 NTSTATUS
3083 NTAPI
3084 IoAllocateAdapterChannel(
3085 IN PADAPTER_OBJECT AdapterObject,
3086 IN PDEVICE_OBJECT DeviceObject,
3087 IN ULONG NumberOfMapRegisters,
3088 IN PDRIVER_CONTROL ExecutionRoutine,
3089 IN PVOID Context);
3090 #endif
3091
3092 NTKERNELAPI
3093 VOID
3094 NTAPI
3095 IoAllocateController(
3096 IN PCONTROLLER_OBJECT ControllerObject,
3097 IN PDEVICE_OBJECT DeviceObject,
3098 IN PDRIVER_CONTROL ExecutionRoutine,
3099 IN PVOID Context);
3100
3101 NTKERNELAPI
3102 NTSTATUS
3103 NTAPI
3104 IoAllocateDriverObjectExtension(
3105 IN PDRIVER_OBJECT DriverObject,
3106 IN PVOID ClientIdentificationAddress,
3107 IN ULONG DriverObjectExtensionSize,
3108 OUT PVOID *DriverObjectExtension);
3109
3110 NTKERNELAPI
3111 PVOID
3112 NTAPI
3113 IoAllocateErrorLogEntry(
3114 IN PVOID IoObject,
3115 IN UCHAR EntrySize);
3116
3117 NTKERNELAPI
3118 PIRP
3119 NTAPI
3120 IoAllocateIrp(
3121 IN CCHAR StackSize,
3122 IN BOOLEAN ChargeQuota);
3123
3124 NTKERNELAPI
3125 PMDL
3126 NTAPI
3127 IoAllocateMdl(
3128 IN PVOID VirtualAddress,
3129 IN ULONG Length,
3130 IN BOOLEAN SecondaryBuffer,
3131 IN BOOLEAN ChargeQuota,
3132 IN OUT PIRP Irp OPTIONAL);
3133
3134 NTKERNELAPI
3135 PIO_WORKITEM
3136 NTAPI
3137 IoAllocateWorkItem(
3138 IN PDEVICE_OBJECT DeviceObject);
3139
3140 /*
3141 * VOID IoAssignArcName(
3142 * IN PUNICODE_STRING ArcName,
3143 * IN PUNICODE_STRING DeviceName);
3144 */
3145 #define IoAssignArcName(_ArcName, _DeviceName) ( \
3146 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
3147
3148 NTKERNELAPI
3149 NTSTATUS
3150 NTAPI
3151 IoAttachDevice(
3152 IN PDEVICE_OBJECT SourceDevice,
3153 IN PUNICODE_STRING TargetDevice,
3154 OUT PDEVICE_OBJECT *AttachedDevice);
3155
3156 NTKERNELAPI
3157 PDEVICE_OBJECT
3158 NTAPI
3159 IoAttachDeviceToDeviceStack(
3160 IN PDEVICE_OBJECT SourceDevice,
3161 IN PDEVICE_OBJECT TargetDevice);
3162
3163 NTKERNELAPI
3164 PIRP
3165 NTAPI
3166 IoBuildAsynchronousFsdRequest(
3167 IN ULONG MajorFunction,
3168 IN PDEVICE_OBJECT DeviceObject,
3169 IN OUT PVOID Buffer OPTIONAL,
3170 IN ULONG Length OPTIONAL,
3171 IN PLARGE_INTEGER StartingOffset OPTIONAL,
3172 IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL);
3173
3174 NTKERNELAPI
3175 PIRP
3176 NTAPI
3177 IoBuildDeviceIoControlRequest(
3178 IN ULONG IoControlCode,
3179 IN PDEVICE_OBJECT DeviceObject,
3180 IN PVOID InputBuffer OPTIONAL,
3181 IN ULONG InputBufferLength,
3182 OUT PVOID OutputBuffer OPTIONAL,
3183 IN ULONG OutputBufferLength,
3184 IN BOOLEAN InternalDeviceIoControl,
3185 IN PKEVENT Event,
3186 OUT PIO_STATUS_BLOCK IoStatusBlock);
3187
3188 NTKERNELAPI
3189 VOID
3190 NTAPI
3191 IoBuildPartialMdl(
3192 IN PMDL SourceMdl,
3193 IN OUT PMDL TargetMdl,
3194 IN PVOID VirtualAddress,
3195 IN ULONG Length);
3196
3197 NTKERNELAPI
3198 PIRP
3199 NTAPI
3200 IoBuildSynchronousFsdRequest(
3201 IN ULONG MajorFunction,
3202 IN PDEVICE_OBJECT DeviceObject,
3203 IN OUT PVOID Buffer OPTIONAL,
3204 IN ULONG Length OPTIONAL,
3205 IN PLARGE_INTEGER StartingOffset OPTIONAL,
3206 IN PKEVENT Event,
3207 OUT PIO_STATUS_BLOCK IoStatusBlock);
3208
3209 NTKERNELAPI
3210 NTSTATUS
3211 FASTCALL
3212 IofCallDriver(
3213 IN PDEVICE_OBJECT DeviceObject,
3214 IN OUT PIRP Irp);
3215
3216 /*
3217 * NTSTATUS
3218 * IoCallDriver(
3219 * IN PDEVICE_OBJECT DeviceObject,
3220 * IN OUT PIRP Irp)
3221 */
3222 #define IoCallDriver IofCallDriver
3223
3224 NTKERNELAPI
3225 VOID
3226 NTAPI
3227 IoCancelFileOpen(
3228 IN PDEVICE_OBJECT DeviceObject,
3229 IN PFILE_OBJECT FileObject);
3230
3231 NTKERNELAPI
3232 BOOLEAN
3233 NTAPI
3234 IoCancelIrp(
3235 IN PIRP Irp);
3236
3237 NTKERNELAPI
3238 NTSTATUS
3239 NTAPI
3240 IoCheckShareAccess(
3241 IN ACCESS_MASK DesiredAccess,
3242 IN ULONG DesiredShareAccess,
3243 IN OUT PFILE_OBJECT FileObject,
3244 IN OUT PSHARE_ACCESS ShareAccess,
3245 IN BOOLEAN Update);
3246
3247 NTKERNELAPI
3248 VOID
3249 FASTCALL
3250 IofCompleteRequest(
3251 IN PIRP Irp,
3252 IN CCHAR PriorityBoost);
3253
3254 /*
3255 * VOID
3256 * IoCompleteRequest(
3257 * IN PIRP Irp,
3258 * IN CCHAR PriorityBoost)
3259 */
3260 #define IoCompleteRequest IofCompleteRequest
3261
3262 NTKERNELAPI
3263 NTSTATUS
3264 NTAPI
3265 IoConnectInterrupt(
3266 OUT PKINTERRUPT *InterruptObject,
3267 IN PKSERVICE_ROUTINE ServiceRoutine,
3268 IN PVOID ServiceContext,
3269 IN PKSPIN_LOCK SpinLock OPTIONAL,
3270 IN ULONG Vector,
3271 IN KIRQL Irql,
3272 IN KIRQL SynchronizeIrql,
3273 IN KINTERRUPT_MODE InterruptMode,
3274 IN BOOLEAN ShareVector,
3275 IN KAFFINITY ProcessorEnableMask,
3276 IN BOOLEAN FloatingSave);
3277
3278 /*
3279 * PIO_STACK_LOCATION
3280 * IoGetCurrentIrpStackLocation(
3281 * IN PIRP Irp)
3282 */
3283 #define IoGetCurrentIrpStackLocation(_Irp) \
3284 ((_Irp)->Tail.Overlay.CurrentStackLocation)
3285
3286 /*
3287 * PIO_STACK_LOCATION
3288 * IoGetNextIrpStackLocation(
3289 * IN PIRP Irp)
3290 */
3291 #define IoGetNextIrpStackLocation(_Irp) \
3292 ((_Irp)->Tail.Overlay.CurrentStackLocation - 1)
3293
3294 /*
3295 * VOID
3296 * IoCopyCurrentIrpStackLocationToNext(
3297 * IN PIRP Irp)
3298 */
3299 #define IoCopyCurrentIrpStackLocationToNext(_Irp) \
3300 { \
3301 PIO_STACK_LOCATION _IrpSp; \
3302 PIO_STACK_LOCATION _NextIrpSp; \
3303 _IrpSp = IoGetCurrentIrpStackLocation(_Irp); \
3304 _NextIrpSp = IoGetNextIrpStackLocation(_Irp); \
3305 RtlCopyMemory(_NextIrpSp, _IrpSp, \
3306 FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \
3307 _NextIrpSp->Control = 0; \
3308 }
3309
3310 NTKERNELAPI
3311 PCONTROLLER_OBJECT
3312 NTAPI
3313 IoCreateController(
3314 IN ULONG Size);
3315
3316 NTKERNELAPI
3317 NTSTATUS
3318 NTAPI
3319 IoCreateDevice(
3320 IN PDRIVER_OBJECT DriverObject,
3321 IN ULONG DeviceExtensionSize,
3322 IN PUNICODE_STRING DeviceName OPTIONAL,
3323 IN DEVICE_TYPE DeviceType,
3324 IN ULONG DeviceCharacteristics,
3325 IN BOOLEAN Exclusive,
3326 OUT PDEVICE_OBJECT *DeviceObject);
3327
3328 NTKERNELAPI
3329 NTSTATUS
3330 NTAPI
3331 IoCreateDisk(
3332 IN PDEVICE_OBJECT DeviceObject,
3333 IN PCREATE_DISK Disk);
3334
3335 NTKERNELAPI
3336 NTSTATUS
3337 NTAPI
3338 IoCreateFile(
3339 OUT PHANDLE FileHandle,
3340 IN ACCESS_MASK DesiredAccess,
3341 IN POBJECT_ATTRIBUTES ObjectAttributes,
3342 OUT PIO_STATUS_BLOCK IoStatusBlock,
3343 IN PLARGE_INTEGER AllocationSize OPTIONAL,
3344 IN ULONG FileAttributes,
3345 IN ULONG ShareAccess,
3346 IN ULONG Disposition,
3347 IN ULONG CreateOptions,
3348 IN PVOID EaBuffer OPTIONAL,
3349 IN ULONG EaLength,
3350 IN CREATE_FILE_TYPE CreateFileType,
3351 IN PVOID ExtraCreateParameters OPTIONAL,
3352 IN ULONG Options);
3353
3354 NTKERNELAPI
3355 PKEVENT
3356 NTAPI
3357 IoCreateNotificationEvent(
3358 IN PUNICODE_STRING EventName,
3359 OUT PHANDLE EventHandle);
3360
3361 NTKERNELAPI
3362 NTSTATUS
3363 NTAPI
3364 IoCreateSymbolicLink(
3365 IN PUNICODE_STRING SymbolicLinkName,
3366 IN PUNICODE_STRING DeviceName);
3367
3368 NTKERNELAPI
3369 PKEVENT
3370 NTAPI
3371 IoCreateSynchronizationEvent(
3372 IN PUNICODE_STRING EventName,
3373 OUT PHANDLE EventHandle);
3374
3375 NTKERNELAPI
3376 NTSTATUS
3377 NTAPI
3378 IoCreateUnprotectedSymbolicLink(
3379 IN PUNICODE_STRING SymbolicLinkName,
3380 IN PUNICODE_STRING DeviceName);
3381
3382 NTKERNELAPI
3383 NTSTATUS
3384 NTAPI
3385 IoCsqInitialize(
3386 PIO_CSQ Csq,
3387 IN PIO_CSQ_INSERT_IRP CsqInsertIrp,
3388 IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
3389 IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
3390 IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
3391 IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
3392 IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
3393
3394 NTKERNELAPI
3395 VOID
3396 NTAPI
3397 IoCsqInsertIrp(
3398 IN PIO_CSQ Csq,
3399 IN PIRP Irp,
3400 IN PIO_CSQ_IRP_CONTEXT Context);
3401
3402 NTKERNELAPI
3403 PIRP
3404 NTAPI
3405 IoCsqRemoveIrp(
3406 IN PIO_CSQ Csq,
3407 IN PIO_CSQ_IRP_CONTEXT Context);
3408
3409 NTKERNELAPI
3410 PIRP
3411 NTAPI
3412 IoCsqRemoveNextIrp(
3413 IN PIO_CSQ Csq,
3414 IN PVOID PeekContext);
3415
3416 NTKERNELAPI
3417 VOID
3418 NTAPI
3419 IoDeleteController(
3420 IN PCONTROLLER_OBJECT ControllerObject);
3421
3422 NTKERNELAPI
3423 VOID
3424 NTAPI
3425 IoDeleteDevice(
3426 IN PDEVICE_OBJECT DeviceObject);
3427
3428 NTKERNELAPI
3429 NTSTATUS
3430 NTAPI
3431 IoDeleteSymbolicLink(
3432 IN PUNICODE_STRING SymbolicLinkName);
3433
3434 /*
3435 * VOID
3436 * IoDeassignArcName(
3437 * IN PUNICODE_STRING ArcName)
3438 */
3439 #define IoDeassignArcName IoDeleteSymbolicLink
3440
3441 NTKERNELAPI
3442 VOID
3443 NTAPI
3444 IoDetachDevice(
3445 IN OUT PDEVICE_OBJECT TargetDevice);
3446
3447 NTKERNELAPI
3448 VOID
3449 NTAPI
3450 IoDisconnectInterrupt(
3451 IN PKINTERRUPT InterruptObject);
3452
3453 NTKERNELAPI
3454 BOOLEAN
3455 NTAPI
3456 IoForwardIrpSynchronously(
3457 IN PDEVICE_OBJECT DeviceObject,
3458 IN PIRP Irp);
3459
3460 #define IoForwardAndCatchIrp IoForwardIrpSynchronously
3461
3462 NTKERNELAPI
3463 VOID
3464 NTAPI
3465 IoFreeController(
3466 IN PCONTROLLER_OBJECT ControllerObject);
3467
3468 NTKERNELAPI
3469 VOID
3470 NTAPI
3471 IoFreeErrorLogEntry(
3472 PVOID ElEntry);
3473
3474 NTKERNELAPI
3475 VOID
3476 NTAPI
3477 IoFreeIrp(
3478 IN PIRP Irp);
3479
3480 NTKERNELAPI
3481 VOID
3482 NTAPI
3483 IoFreeMdl(
3484 IN PMDL Mdl);
3485
3486 NTKERNELAPI
3487 VOID
3488 NTAPI
3489 IoFreeWorkItem(
3490 IN PIO_WORKITEM pIOWorkItem);
3491
3492 NTKERNELAPI
3493 PDEVICE_OBJECT
3494 NTAPI
3495 IoGetAttachedDevice(
3496 IN PDEVICE_OBJECT DeviceObject);
3497
3498 NTKERNELAPI
3499 PDEVICE_OBJECT
3500 NTAPI
3501 IoGetAttachedDeviceReference(
3502 IN PDEVICE_OBJECT DeviceObject);
3503
3504 NTKERNELAPI
3505 NTSTATUS
3506 NTAPI
3507 IoGetBootDiskInformation(
3508 IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
3509 IN ULONG Size);
3510
3511 NTKERNELAPI
3512 PCONFIGURATION_INFORMATION
3513 NTAPI
3514 IoGetConfigurationInformation(
3515 VOID);
3516
3517 NTKERNELAPI
3518 PEPROCESS
3519 NTAPI
3520 IoGetCurrentProcess(
3521 VOID);
3522
3523 NTKERNELAPI
3524 NTSTATUS
3525 NTAPI
3526 IoGetDeviceInterfaceAlias(
3527 IN PUNICODE_STRING SymbolicLinkName,
3528 IN CONST GUID *AliasInterfaceClassGuid,
3529 OUT PUNICODE_STRING AliasSymbolicLinkName);
3530
3531 #define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
3532
3533 NTKERNELAPI
3534 NTSTATUS
3535 NTAPI
3536 IoGetDeviceInterfaces(
3537 IN CONST GUID *InterfaceClassGuid,
3538 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
3539 IN ULONG Flags,
3540 OUT PWSTR *SymbolicLinkList);
3541
3542 NTKERNELAPI
3543 NTSTATUS
3544 NTAPI
3545 IoGetDeviceObjectPointer(
3546 IN PUNICODE_STRING ObjectName,
3547 IN ACCESS_MASK DesiredAccess,
3548 OUT PFILE_OBJECT *FileObject,
3549 OUT PDEVICE_OBJECT *DeviceObject);
3550
3551 NTKERNELAPI
3552 NTSTATUS
3553 NTAPI
3554 IoGetDeviceProperty(
3555 IN PDEVICE_OBJECT DeviceObject,
3556 IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
3557 IN ULONG BufferLength,
3558 OUT PVOID PropertyBuffer,
3559 OUT PULONG ResultLength);
3560
3561 NTKERNELAPI
3562 PDEVICE_OBJECT
3563 NTAPI
3564 IoGetDeviceToVerify(
3565 IN PETHREAD Thread);
3566
3567 NTKERNELAPI
3568 PDMA_ADAPTER
3569 NTAPI
3570 IoGetDmaAdapter(
3571 IN PDEVICE_OBJECT PhysicalDeviceObject,
3572 IN PDEVICE_DESCRIPTION DeviceDescription,
3573 IN OUT PULONG NumberOfMapRegisters);
3574
3575 NTKERNELAPI
3576 PVOID
3577 NTAPI
3578 IoGetDriverObjectExtension(
3579 IN PDRIVER_OBJECT DriverObject,
3580 IN PVOID ClientIdentificationAddress);
3581
3582 NTKERNELAPI
3583 PGENERIC_MAPPING
3584 NTAPI
3585 IoGetFileObjectGenericMapping(
3586 VOID);
3587
3588 /*
3589 * ULONG
3590 * IoGetFunctionCodeFromCtlCode(
3591 * IN ULONG ControlCode)
3592 */
3593 #define IoGetFunctionCodeFromCtlCode(_ControlCode) \
3594 (((_ControlCode) >> 2) & 0x00000FFF)
3595
3596 NTKERNELAPI
3597 PVOID
3598 NTAPI
3599 IoGetInitialStack(
3600 VOID);
3601
3602 NTKERNELAPI
3603 PDEVICE_OBJECT
3604 NTAPI
3605 IoGetRelatedDeviceObject(
3606 IN PFILE_OBJECT FileObject);
3607
3608 NTKERNELAPI
3609 VOID
3610 NTAPI
3611 IoGetStackLimits(
3612 OUT PULONG_PTR LowLimit,
3613 OUT PULONG_PTR HighLimit);
3614
3615 FORCEINLINE
3616 ULONG_PTR
3617 IoGetRemainingStackSize(
3618 VOID
3619 )
3620 {
3621 ULONG_PTR End, Begin;
3622 ULONG_PTR Result;
3623
3624 IoGetStackLimits(&Begin, &End);
3625 Result = (ULONG_PTR)(&End) - Begin;
3626 return Result;
3627 }
3628
3629 NTKERNELAPI
3630 VOID
3631 NTAPI
3632 KeInitializeDpc(
3633 IN PRKDPC Dpc,
3634 IN PKDEFERRED_ROUTINE DeferredRoutine,
3635 IN PVOID DeferredContext);
3636
3637 /*
3638 * VOID
3639 * IoInitializeDpcRequest(
3640 * IN PDEVICE_OBJECT DeviceObject,
3641 * IN PIO_DPC_ROUTINE DpcRoutine)
3642 */
3643 #define IoInitializeDpcRequest(_DeviceObject, \
3644 _DpcRoutine) \
3645 KeInitializeDpc(&(_DeviceObject)->Dpc, \
3646 (PKDEFERRED_ROUTINE) (_DpcRoutine), \
3647 _DeviceObject)
3648
3649 NTKERNELAPI
3650 VOID
3651 NTAPI
3652 IoInitializeIrp(
3653 IN OUT PIRP Irp,
3654 IN USHORT PacketSize,
3655 IN CCHAR StackSize);
3656
3657 NTKERNELAPI
3658 VOID
3659 NTAPI
3660 IoInitializeRemoveLockEx(
3661 IN PIO_REMOVE_LOCK Lock,
3662 IN ULONG AllocateTag,
3663 IN ULONG MaxLockedMinutes,
3664 IN ULONG HighWatermark,
3665 IN ULONG RemlockSize);
3666
3667 /* VOID
3668 * IoInitializeRemoveLock(
3669 * IN PIO_REMOVE_LOCK Lock,
3670 * IN ULONG AllocateTag,
3671 * IN ULONG MaxLockedMinutes,
3672 * IN ULONG HighWatermark)
3673 */
3674 #define IoInitializeRemoveLock( \
3675 Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \
3676 IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \
3677 HighWatermark, sizeof(IO_REMOVE_LOCK))
3678
3679 NTKERNELAPI
3680 NTSTATUS
3681 NTAPI
3682 IoInitializeTimer(
3683 IN PDEVICE_OBJECT DeviceObject,
3684 IN PIO_TIMER_ROUTINE TimerRoutine,
3685 IN PVOID Context);
3686
3687 NTKERNELAPI
3688 VOID
3689 NTAPI
3690 IoInvalidateDeviceRelations(
3691 IN PDEVICE_OBJECT DeviceObject,
3692 IN DEVICE_RELATION_TYPE Type);
3693
3694 NTKERNELAPI
3695 VOID
3696 NTAPI
3697 IoInvalidateDeviceState(
3698 IN PDEVICE_OBJECT PhysicalDeviceObject);
3699
3700 NTKERNELAPI
3701 BOOLEAN
3702 NTAPI
3703 IoIs32bitProcess(
3704 IN PIRP Irp OPTIONAL);
3705
3706 /*
3707 * BOOLEAN
3708 * IoIsErrorUserInduced(
3709 * IN NTSTATUS Status);
3710 */
3711 #define IoIsErrorUserInduced(Status) \
3712 ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
3713 ((Status) == STATUS_IO_TIMEOUT) || \
3714 ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
3715 ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
3716 ((Status) == STATUS_VERIFY_REQUIRED) || \
3717 ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
3718 ((Status) == STATUS_WRONG_VOLUME)))
3719
3720 NTKERNELAPI
3721 BOOLEAN
3722 NTAPI
3723 IoIsWdmVersionAvailable(
3724 IN UCHAR MajorVersion,
3725 IN UCHAR MinorVersion);
3726
3727 NTKERNELAPI
3728 PIRP
3729 NTAPI
3730 IoMakeAssociatedIrp(
3731 IN PIRP Irp,
3732 IN CCHAR StackSize);
3733
3734 /*
3735 * VOID
3736 * IoMarkIrpPending(
3737 * IN OUT PIRP Irp)
3738 */
3739 #define IoMarkIrpPending(_Irp) \
3740 (IoGetCurrentIrpStackLocation(_Irp)->Control |= SL_PENDING_RETURNED)
3741
3742 NTKERNELAPI
3743 NTSTATUS
3744 NTAPI
3745 IoOpenDeviceInterfaceRegistryKey(
3746 IN PUNICODE_STRING SymbolicLinkName,
3747 IN ACCESS_MASK DesiredAccess,
3748 OUT PHANDLE DeviceInterfaceKey);
3749
3750 #define PLUGPLAY_REGKEY_DEVICE 1
3751 #define PLUGPLAY_REGKEY_DRIVER 2
3752 #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
3753
3754 NTKERNELAPI
3755 NTSTATUS
3756 NTAPI
3757 IoOpenDeviceRegistryKey(
3758 IN PDEVICE_OBJECT DeviceObject,
3759 IN ULONG DevInstKeyType,
3760 IN ACCESS_MASK DesiredAccess,
3761 OUT PHANDLE DevInstRegKey);
3762
3763 NTKERNELAPI
3764 NTSTATUS
3765 NTAPI
3766 IoQueryDeviceDescription(
3767 IN PINTERFACE_TYPE BusType OPTIONAL,
3768 IN PULONG BusNumber OPTIONAL,
3769 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
3770 IN PULONG ControllerNumber OPTIONAL,
3771 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
3772 IN PULONG PeripheralNumber OPTIONAL,
3773 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
3774 IN PVOID Context);
3775
3776 NTKERNELAPI
3777 VOID
3778 NTAPI
3779 IoQueueWorkItem(
3780 IN PIO_WORKITEM pIOWorkItem,
3781 IN PIO_WORKITEM_ROUTINE Routine,
3782 IN WORK_QUEUE_TYPE QueueType,
3783 IN PVOID Context);
3784
3785 NTKERNELAPI
3786 VOID
3787 NTAPI
3788 IoRaiseHardError(
3789 IN PIRP Irp,
3790 IN PVPB Vpb OPTIONAL,
3791 IN PDEVICE_OBJECT RealDeviceObject);
3792
3793 NTKERNELAPI
3794 BOOLEAN
3795 NTAPI
3796 IoRaiseInformationalHardError(
3797 IN NTSTATUS ErrorStatus,
3798 IN PUNICODE_STRING String OPTIONAL,
3799 IN PKTHREAD Thread OPTIONAL);
3800
3801 NTKERNELAPI
3802 NTSTATUS
3803 NTAPI
3804 IoReadDiskSignature(
3805 IN PDEVICE_OBJECT DeviceObject,
3806 IN ULONG BytesPerSector,
3807 OUT PDISK_SIGNATURE Signature);
3808
3809 NTKERNELAPI
3810 NTSTATUS
3811 FASTCALL
3812 IoReadPartitionTable(
3813 IN PDEVICE_OBJECT DeviceObject,
3814 IN ULONG SectorSize,
3815 IN BOOLEAN ReturnRecognizedPartitions,
3816 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
3817
3818 NTKERNELAPI
3819 NTSTATUS
3820 NTAPI
3821 IoReadPartitionTableEx(
3822 IN PDEVICE_OBJECT DeviceObject,
3823 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
3824
3825 NTKERNELAPI
3826 VOID
3827 NTAPI
3828 IoRegisterBootDriverReinitialization(
3829 IN PDRIVER_OBJECT DriverObject,
3830 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
3831 IN PVOID Context);
3832
3833 NTKERNELAPI
3834 VOID
3835 NTAPI
3836 IoRegisterBootDriverReinitialization(
3837 IN PDRIVER_OBJECT DriverObject,
3838 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
3839 IN PVOID Context);
3840
3841 NTKERNELAPI
3842 NTSTATUS
3843 NTAPI
3844 IoRegisterDeviceInterface(
3845 IN PDEVICE_OBJECT PhysicalDeviceObject,
3846 IN CONST GUID *InterfaceClassGuid,
3847 IN PUNICODE_STRING ReferenceString OPTIONAL,
3848 OUT PUNICODE_STRING SymbolicLinkName);
3849
3850 NTKERNELAPI
3851 VOID
3852 NTAPI
3853 IoRegisterDriverReinitialization(
3854 IN PDRIVER_OBJECT DriverObject,
3855 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
3856 IN PVOID Context);
3857
3858 NTKERNELAPI
3859 NTSTATUS
3860 NTAPI
3861 IoRegisterPlugPlayNotification(
3862 IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
3863 IN ULONG EventCategoryFlags,
3864 IN PVOID EventCategoryData OPTIONAL,
3865 IN PDRIVER_OBJECT DriverObject,
3866 IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine,
3867 IN PVOID Context,
3868 OUT PVOID *NotificationEntry);
3869
3870 NTKERNELAPI
3871 NTSTATUS
3872 NTAPI
3873 IoRegisterShutdownNotification(
3874 IN PDEVICE_OBJECT DeviceObject);
3875
3876 NTKERNELAPI
3877 VOID
3878 NTAPI
3879 IoReleaseCancelSpinLock(
3880 IN KIRQL Irql);
3881
3882 NTKERNELAPI
3883 VOID
3884 NTAPI
3885 IoReleaseRemoveLockAndWaitEx(
3886 IN PIO_REMOVE_LOCK RemoveLock,
3887 IN PVOID Tag,
3888 IN ULONG RemlockSize);
3889
3890 NTKERNELAPI
3891 VOID
3892 NTAPI
3893 IoReleaseRemoveLockEx(
3894 IN PIO_REMOVE_LOCK RemoveLock,
3895 IN PVOID Tag,
3896 IN ULONG RemlockSize);
3897
3898 /*
3899 * VOID
3900 * IoReleaseRemoveLock(
3901 * IN PIO_REMOVE_LOCK RemoveLock,
3902 * IN PVOID Tag)
3903 */
3904 #define IoReleaseRemoveLock(_RemoveLock, \
3905 _Tag) \
3906 IoReleaseRemoveLockEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
3907
3908 /*
3909 * VOID
3910 * IoReleaseRemoveLockAndWait(
3911 * IN PIO_REMOVE_LOCK RemoveLock,
3912 * IN PVOID Tag)
3913 */
3914 #define IoReleaseRemoveLockAndWait(_RemoveLock, \
3915 _Tag) \
3916 IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
3917
3918 NTKERNELAPI
3919 VOID
3920 NTAPI
3921 IoRemoveShareAccess(
3922 IN PFILE_OBJECT FileObject,
3923 IN OUT PSHARE_ACCESS ShareAccess);
3924
3925 NTKERNELAPI
3926 NTSTATUS
3927 NTAPI
3928 IoReportDetectedDevice(
3929 IN PDRIVER_OBJECT DriverObject,
3930 IN INTERFACE_TYPE LegacyBusType,
3931 IN ULONG BusNumber,
3932 IN ULONG SlotNumber,
3933 IN PCM_RESOURCE_LIST ResourceList,
3934 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
3935 IN BOOLEAN ResourceAssigned,
3936 IN OUT PDEVICE_OBJECT *DeviceObject);
3937
3938 NTKERNELAPI
3939 NTSTATUS
3940 NTAPI
3941 IoReportResourceForDetection(
3942 IN PDRIVER_OBJECT DriverObject,
3943 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
3944 IN ULONG DriverListSize OPTIONAL,
3945 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
3946 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
3947 IN ULONG DeviceListSize OPTIONAL,
3948 OUT PBOOLEAN ConflictDetected);
3949
3950 NTKERNELAPI
3951 NTSTATUS
3952 NTAPI
3953 IoReportResourceUsage(
3954 IN PUNICODE_STRING DriverClassName OPTIONAL,
3955 IN PDRIVER_OBJECT DriverObject,
3956 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
3957 IN ULONG DriverListSize OPTIONAL,
3958 IN PDEVICE_OBJECT DeviceObject,
3959 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
3960 IN ULONG DeviceListSize OPTIONAL,
3961 IN BOOLEAN OverrideConflict,
3962 OUT PBOOLEAN ConflictDetected);
3963
3964 NTKERNELAPI
3965 NTSTATUS
3966 NTAPI
3967 IoReportTargetDeviceChange(
3968 IN PDEVICE_OBJECT PhysicalDeviceObject,
3969 IN PVOID NotificationStructure);
3970
3971 NTKERNELAPI
3972 NTSTATUS
3973 NTAPI
3974 IoReportTargetDeviceChangeAsynchronous(
3975 IN PDEVICE_OBJECT PhysicalDeviceObject,
3976 IN PVOID NotificationStructure,
3977 IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL,
3978 IN PVOID Context OPTIONAL);
3979
3980 NTKERNELAPI
3981 VOID
3982 NTAPI
3983 IoRequestDeviceEject(
3984 IN PDEVICE_OBJECT PhysicalDeviceObject);
3985
3986 /*
3987 * VOID
3988 * IoRequestDpc(
3989 * IN PDEVICE_OBJECT DeviceObject,
3990 * IN PIRP Irp,
3991 * IN PVOID Context);
3992 */
3993 #define IoRequestDpc(DeviceObject, Irp, Context)( \
3994 KeInsertQueueDpc(&(DeviceObject)->Dpc, (Irp), (Context)))
3995
3996 NTKERNELAPI
3997 VOID
3998 NTAPI
3999 IoReuseIrp(
4000 IN OUT PIRP Irp,
4001 IN NTSTATUS Status);
4002
4003 /*
4004 * PDRIVER_CANCEL
4005 * IoSetCancelRoutine(
4006 * IN PIRP Irp,
4007 * IN PDRIVER_CANCEL CancelRoutine)
4008 */
4009 #define IoSetCancelRoutine(_Irp, \
4010 _CancelRoutine) \
4011 ((PDRIVER_CANCEL) InterlockedExchangePointer( \
4012 (PVOID *) &(_Irp)->CancelRoutine, (PVOID) (_CancelRoutine)))
4013
4014 /*
4015 * VOID
4016 * IoSetCompletionRoutine(
4017 * IN PIRP Irp,
4018 * IN PIO_COMPLETION_ROUTINE CompletionRoutine,
4019 * IN PVOID Context,
4020 * IN BOOLEAN InvokeOnSuccess,
4021 * IN BOOLEAN InvokeOnError,
4022 * IN BOOLEAN InvokeOnCancel)
4023 */
4024 #define IoSetCompletionRoutine(_Irp, \
4025 _CompletionRoutine, \
4026 _Context, \