969dc8abbd3d2a29a62204611da1723cf74e9404
[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 #define MM_DONT_ZERO_ALLOCATION 0x00000001
2056 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002
2057
2058
2059 #define EFLAG_SIGN 0x8000
2060 #define EFLAG_ZERO 0x4000
2061 #define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO)
2062
2063 #define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
2064 #define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT)
2065 #define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT)
2066
2067 typedef enum _INTERLOCKED_RESULT {
2068 ResultNegative = RESULT_NEGATIVE,
2069 ResultZero = RESULT_ZERO,
2070 ResultPositive = RESULT_POSITIVE
2071 } INTERLOCKED_RESULT;
2072
2073 typedef VOID
2074 (NTAPI *PciPin2Line)(
2075 IN struct _BUS_HANDLER *BusHandler,
2076 IN struct _BUS_HANDLER *RootHandler,
2077 IN PCI_SLOT_NUMBER SlotNumber,
2078 IN PPCI_COMMON_CONFIG PciData
2079 );
2080
2081 typedef VOID
2082 (NTAPI *PciLine2Pin)(
2083 IN struct _BUS_HANDLER *BusHandler,
2084 IN struct _BUS_HANDLER *RootHandler,
2085 IN PCI_SLOT_NUMBER SlotNumber,
2086 IN PPCI_COMMON_CONFIG PciNewData,
2087 IN PPCI_COMMON_CONFIG PciOldData
2088 );
2089
2090 typedef VOID
2091 (NTAPI *PciReadWriteConfig)(
2092 IN struct _BUS_HANDLER *BusHandler,
2093 IN PCI_SLOT_NUMBER Slot,
2094 IN PVOID Buffer,
2095 IN ULONG Offset,
2096 IN ULONG Length
2097 );
2098
2099 #define PCI_DATA_TAG ' ICP'
2100 #define PCI_DATA_VERSION 1
2101
2102 typedef struct _PCIBUSDATA
2103 {
2104 ULONG Tag;
2105 ULONG Version;
2106 PciReadWriteConfig ReadConfig;
2107 PciReadWriteConfig WriteConfig;
2108 PciPin2Line Pin2Line;
2109 PciLine2Pin Line2Pin;
2110 PCI_SLOT_NUMBER ParentSlot;
2111 PVOID Reserved[4];
2112 } PCIBUSDATA, *PPCIBUSDATA;
2113
2114
2115 /** SPINLOCK FUNCTIONS ********************************************************/
2116
2117 NTKERNELAPI
2118 BOOLEAN
2119 FASTCALL
2120 KeTryToAcquireSpinLockAtDpcLevel(
2121 IN OUT PKSPIN_LOCK SpinLock
2122 );
2123
2124 NTKERNELAPI
2125 BOOLEAN
2126 FASTCALL
2127 KeTestSpinLock(
2128 IN PKSPIN_LOCK SpinLock
2129 );
2130
2131 #if defined (_X86_)
2132
2133 #if defined(WIN9X_COMPAT_SPINLOCK)
2134
2135 NTKERNELAPI
2136 VOID
2137 NTAPI
2138 KeInitializeSpinLock(
2139 IN PKSPIN_LOCK SpinLock
2140 );
2141
2142 #else
2143
2144 FORCEINLINE
2145 VOID
2146 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
2147 {
2148 /* Clear the lock */
2149 *SpinLock = 0;
2150 }
2151
2152 #endif
2153
2154 NTHALAPI
2155 KIRQL
2156 FASTCALL
2157 KfAcquireSpinLock(
2158 IN PKSPIN_LOCK SpinLock);
2159
2160 NTHALAPI
2161 VOID
2162 FASTCALL
2163 KfReleaseSpinLock(
2164 IN PKSPIN_LOCK SpinLock,
2165 IN KIRQL NewIrql);
2166
2167 NTKERNELAPI
2168 VOID
2169 FASTCALL
2170 KefAcquireSpinLockAtDpcLevel(
2171 IN PKSPIN_LOCK SpinLock);
2172
2173 NTKERNELAPI
2174 VOID
2175 FASTCALL
2176 KefReleaseSpinLockFromDpcLevel(
2177 IN PKSPIN_LOCK SpinLock);
2178
2179 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
2180 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
2181 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
2182 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
2183
2184 #define KeGetDcacheFillSize() 1L
2185
2186 #elif defined(_M_ARM) // !defined (_X86_)
2187
2188 FORCEINLINE
2189 VOID
2190 KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
2191 {
2192 /* Clear the lock */
2193 *SpinLock = 0;
2194 }
2195
2196 NTHALAPI
2197 KIRQL
2198 FASTCALL
2199 KfAcquireSpinLock(
2200 IN PKSPIN_LOCK SpinLock);
2201
2202 NTHALAPI
2203 VOID
2204 FASTCALL
2205 KfReleaseSpinLock(
2206 IN PKSPIN_LOCK SpinLock,
2207 IN KIRQL NewIrql);
2208
2209
2210 NTKERNELAPI
2211 VOID
2212 FASTCALL
2213 KefAcquireSpinLockAtDpcLevel(
2214 IN PKSPIN_LOCK SpinLock);
2215
2216 NTKERNELAPI
2217 VOID
2218 FASTCALL
2219 KefReleaseSpinLockFromDpcLevel(
2220 IN PKSPIN_LOCK SpinLock);
2221
2222
2223 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
2224 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
2225 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
2226 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
2227
2228 NTKERNELAPI
2229 VOID
2230 NTAPI
2231 KeInitializeSpinLock(
2232 IN PKSPIN_LOCK SpinLock);
2233
2234 #else
2235
2236 FORCEINLINE
2237 VOID
2238 NTAPI
2239 KeInitializeSpinLock(
2240 PKSPIN_LOCK SpinLock)
2241 {
2242 *SpinLock = 0;
2243 }
2244
2245 NTKERNELAPI
2246 VOID
2247 KeReleaseSpinLock(
2248 IN PKSPIN_LOCK SpinLock,
2249 IN KIRQL NewIrql);
2250
2251 NTKERNELAPI
2252 VOID
2253 KeAcquireSpinLockAtDpcLevel(
2254 IN PKSPIN_LOCK SpinLock);
2255
2256 NTKERNELAPI
2257 VOID
2258 KeReleaseSpinLockFromDpcLevel(
2259 IN PKSPIN_LOCK SpinLock);
2260
2261 NTKERNELAPI
2262 KIRQL
2263 KeAcquireSpinLockRaiseToDpc(
2264 IN PKSPIN_LOCK SpinLock);
2265
2266 #define KeAcquireSpinLock(SpinLock, OldIrql) \
2267 *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
2268
2269 #endif // !defined (_X86_)
2270
2271 /*
2272 ** Utillity functions
2273 */
2274
2275 #define ARGUMENT_PRESENT(ArgumentPointer) \
2276 ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL)
2277
2278 /*
2279 * ULONG
2280 * BYTE_OFFSET(
2281 * IN PVOID Va)
2282 */
2283 #define BYTE_OFFSET(Va) \
2284 ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
2285
2286 /*
2287 * ULONG
2288 * BYTES_TO_PAGES(
2289 * IN ULONG Size)
2290 */
2291 #define BYTES_TO_PAGES(Size) \
2292 ((ULONG) ((ULONG_PTR) (Size) >> PAGE_SHIFT) + (((ULONG) (Size) & (PAGE_SIZE - 1)) != 0))
2293
2294 /*
2295 * PVOID
2296 * PAGE_ALIGN(
2297 * IN PVOID Va)
2298 */
2299 #define PAGE_ALIGN(Va) \
2300 ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
2301
2302 /*
2303 * ULONG_PTR
2304 * ROUND_TO_PAGES(
2305 * IN ULONG_PTR Size)
2306 */
2307 #define ROUND_TO_PAGES(Size) \
2308 ((ULONG_PTR) (((ULONG_PTR) Size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))
2309
2310
2311
2312 #if defined(_X86_) || defined(_AMD64_)
2313
2314 //
2315 // x86 and x64 performs a 0x2C interrupt
2316 //
2317 #define DbgRaiseAssertionFailure __int2c
2318
2319 #elif defined(_ARM_)
2320
2321 //
2322 // TODO
2323 //
2324
2325 #else
2326 #error Unsupported Architecture
2327 #endif
2328
2329 #if DBG
2330
2331 #define ASSERT(exp) \
2332 (VOID)((!(exp)) ? \
2333 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
2334
2335 #define ASSERTMSG(msg, exp) \
2336 (VOID)((!(exp)) ? \
2337 RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE)
2338
2339 #define RTL_SOFT_ASSERT(exp) \
2340 (VOID)((!(exp)) ? \
2341 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
2342
2343 #define RTL_SOFT_ASSERTMSG(msg, exp) \
2344 (VOID)((!(exp)) ? \
2345 DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE)
2346
2347 #define RTL_VERIFY(exp) ASSERT(exp)
2348 #define RTL_VERIFYMSG(msg, exp) ASSERT(msg, exp)
2349
2350 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
2351 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
2352
2353 #if defined(_MSC_VER)
2354
2355 #define NT_ASSERT(exp) \
2356 ((!(exp)) ? \
2357 (__annotation(L"Debug", L"AssertFail", L#exp), \
2358 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2359
2360 #define NT_ASSERTMSG(msg, exp) \
2361 ((!(exp)) ? \
2362 (__annotation(L"Debug", L"AssertFail", L##msg), \
2363 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2364
2365 #define NT_ASSERTMSGW(msg, exp) \
2366 ((!(exp)) ? \
2367 (__annotation(L"Debug", L"AssertFail", msg), \
2368 DbgRaiseAssertionFailure(), FALSE) : TRUE)
2369
2370 #else
2371
2372 //
2373 // GCC doesn't support __annotation (nor PDB)
2374 //
2375 #define NT_ASSERT(exp) \
2376 (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
2377
2378 #define NT_ASSERTMSG NT_ASSERT
2379 #define NT_ASSERTMSGW NT_ASSERT
2380
2381 #endif
2382
2383 #else /* !DBG */
2384
2385 #define ASSERT(exp) ((VOID) 0)
2386 #define ASSERTMSG(msg, exp) ((VOID) 0)
2387
2388 #define RTL_SOFT_ASSERT(exp) ((VOID) 0)
2389 #define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0)
2390
2391 #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
2392 #define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
2393
2394 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
2395 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
2396
2397 #define NT_ASSERT(exp) ((VOID)0)
2398 #define NT_ASSERTMSG(exp) ((VOID)0)
2399 #define NT_ASSERTMSGW(exp) ((VOID)0)
2400
2401 #endif /* DBG */
2402
2403 /* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
2404 #if defined(_NTSYSTEM_) || defined(__GNUC__)
2405 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
2406 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
2407 #else
2408 #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
2409 #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
2410 #endif /* _NT_SYSTEM */
2411
2412 extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG;
2413 extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG;
2414
2415 /*
2416 ** Driver support routines
2417 */
2418
2419 /** Runtime library routines **/
2420
2421 static __inline VOID
2422 InitializeListHead(
2423 IN PLIST_ENTRY ListHead)
2424 {
2425 ListHead->Flink = ListHead->Blink = ListHead;
2426 }
2427
2428 static __inline VOID
2429 InsertHeadList(
2430 IN PLIST_ENTRY ListHead,
2431 IN PLIST_ENTRY Entry)
2432 {
2433 PLIST_ENTRY OldFlink;
2434 OldFlink = ListHead->Flink;
2435 Entry->Flink = OldFlink;
2436 Entry->Blink = ListHead;
2437 OldFlink->Blink = Entry;
2438 ListHead->Flink = Entry;
2439 }
2440
2441 static __inline VOID
2442 InsertTailList(
2443 IN PLIST_ENTRY ListHead,
2444 IN PLIST_ENTRY Entry)
2445 {
2446 PLIST_ENTRY OldBlink;
2447 OldBlink = ListHead->Blink;
2448 Entry->Flink = ListHead;
2449 Entry->Blink = OldBlink;
2450 OldBlink->Flink = Entry;
2451 ListHead->Blink = Entry;
2452 }
2453
2454 /*
2455 * BOOLEAN
2456 * IsListEmpty(
2457 * IN PLIST_ENTRY ListHead)
2458 */
2459 #define IsListEmpty(_ListHead) \
2460 ((_ListHead)->Flink == (_ListHead))
2461
2462 /*
2463 * PSINGLE_LIST_ENTRY
2464 * PopEntryList(
2465 * IN PSINGLE_LIST_ENTRY ListHead)
2466 */
2467 #define PopEntryList(ListHead) \
2468 (ListHead)->Next; \
2469 { \
2470 PSINGLE_LIST_ENTRY _FirstEntry; \
2471 _FirstEntry = (ListHead)->Next; \
2472 if (_FirstEntry != NULL) \
2473 (ListHead)->Next = _FirstEntry->Next; \
2474 }
2475
2476 /*
2477 * VOID
2478 * PushEntryList(
2479 * IN PSINGLE_LIST_ENTRY ListHead,
2480 * IN PSINGLE_LIST_ENTRY Entry)
2481 */
2482 #define PushEntryList(_ListHead, _Entry) \
2483 (_Entry)->Next = (_ListHead)->Next; \
2484 (_ListHead)->Next = (_Entry); \
2485
2486 static __inline BOOLEAN
2487 RemoveEntryList(
2488 IN PLIST_ENTRY Entry)
2489 {
2490 PLIST_ENTRY OldFlink;
2491 PLIST_ENTRY OldBlink;
2492
2493 OldFlink = Entry->Flink;
2494 OldBlink = Entry->Blink;
2495 OldFlink->Blink = OldBlink;
2496 OldBlink->Flink = OldFlink;
2497 return (BOOLEAN)(OldFlink == OldBlink);
2498 }
2499
2500 static __inline PLIST_ENTRY
2501 RemoveHeadList(
2502 IN PLIST_ENTRY ListHead)
2503 {
2504 PLIST_ENTRY Flink;
2505 PLIST_ENTRY Entry;
2506
2507 Entry = ListHead->Flink;
2508 Flink = Entry->Flink;
2509 ListHead->Flink = Flink;
2510 Flink->Blink = ListHead;
2511 return Entry;
2512 }
2513
2514 static __inline PLIST_ENTRY
2515 RemoveTailList(
2516 IN PLIST_ENTRY ListHead)
2517 {
2518 PLIST_ENTRY Blink;
2519 PLIST_ENTRY Entry;
2520
2521 Entry = ListHead->Blink;
2522 Blink = Entry->Blink;
2523 ListHead->Blink = Blink;
2524 Blink->Flink = ListHead;
2525 return Entry;
2526 }
2527
2528 NTSYSAPI
2529 NTSTATUS
2530 NTAPI
2531 RtlCharToInteger(
2532 IN PCSZ String,
2533 IN ULONG Base OPTIONAL,
2534 IN OUT PULONG Value);
2535
2536 NTSYSAPI
2537 LONG
2538 NTAPI
2539 RtlCompareString(
2540 IN PSTRING String1,
2541 IN PSTRING String2,
2542 BOOLEAN CaseInSensitive);
2543
2544 #if !defined(MIDL_PASS)
2545
2546 FORCEINLINE
2547 LUID
2548 NTAPI
2549 RtlConvertLongToLuid(
2550 IN LONG Val)
2551 {
2552 LUID Luid;
2553 LARGE_INTEGER Temp;
2554
2555 Temp.QuadPart = Val;
2556 Luid.LowPart = Temp.u.LowPart;
2557 Luid.HighPart = Temp.u.HighPart;
2558
2559 return Luid;
2560 }
2561
2562 FORCEINLINE
2563 LUID
2564 NTAPI
2565 RtlConvertUlongToLuid(
2566 IN ULONG Val)
2567 {
2568 LUID Luid;
2569
2570 Luid.LowPart = Val;
2571 Luid.HighPart = 0;
2572
2573 return Luid;
2574 }
2575 #endif
2576
2577
2578 NTSYSAPI
2579 VOID
2580 NTAPI
2581 RtlCopyMemory32(
2582 IN VOID UNALIGNED *Destination,
2583 IN CONST VOID UNALIGNED *Source,
2584 IN ULONG Length);
2585
2586 NTSYSAPI
2587 VOID
2588 NTAPI
2589 RtlCopyString(
2590 IN OUT PSTRING DestinationString,
2591 IN PSTRING SourceString OPTIONAL);
2592
2593 NTSYSAPI
2594 BOOLEAN
2595 NTAPI
2596 RtlEqualString(
2597 IN PSTRING String1,
2598 IN PSTRING String2,
2599 IN BOOLEAN CaseInSensitive);
2600
2601 #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
2602 #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
2603 *CallersAddress = (PVOID)_ReturnAddress(); \
2604 *CallersCaller = NULL;
2605 #else
2606 NTSYSAPI
2607 VOID
2608 NTAPI
2609 RtlGetCallersAddress(
2610 OUT PVOID *CallersAddress,
2611 OUT PVOID *CallersCaller);
2612 #endif
2613
2614 NTSYSAPI
2615 NTSTATUS
2616 NTAPI
2617 RtlGetVersion(
2618 IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
2619
2620 NTSYSAPI
2621 VOID
2622 NTAPI
2623 RtlMapGenericMask(
2624 IN OUT PACCESS_MASK AccessMask,
2625 IN PGENERIC_MAPPING GenericMapping);
2626
2627 NTSYSAPI
2628 BOOLEAN
2629 NTAPI
2630 RtlPrefixUnicodeString(
2631 IN PCUNICODE_STRING String1,
2632 IN PCUNICODE_STRING String2,
2633 IN BOOLEAN CaseInSensitive);
2634
2635 NTSYSAPI
2636 NTSTATUS
2637 NTAPI
2638 RtlUpcaseUnicodeString(
2639 IN OUT PUNICODE_STRING DestinationString OPTIONAL,
2640 IN PCUNICODE_STRING SourceString,
2641 IN BOOLEAN AllocateDestinationString);
2642
2643 NTSYSAPI
2644 CHAR
2645 NTAPI
2646 RtlUpperChar(
2647 IN CHAR Character);
2648
2649 NTSYSAPI
2650 VOID
2651 NTAPI
2652 RtlUpperString(
2653 IN OUT PSTRING DestinationString,
2654 IN PSTRING SourceString);
2655
2656 NTSYSAPI
2657 NTSTATUS
2658 NTAPI
2659 RtlVerifyVersionInfo(
2660 IN PRTL_OSVERSIONINFOEXW VersionInfo,
2661 IN ULONG TypeMask,
2662 IN ULONGLONG ConditionMask);
2663
2664 NTSYSAPI
2665 NTSTATUS
2666 NTAPI
2667 RtlVolumeDeviceToDosName(
2668 IN PVOID VolumeDeviceObject,
2669 OUT PUNICODE_STRING DosName);
2670
2671 NTSYSAPI
2672 ULONG
2673 NTAPI
2674 RtlWalkFrameChain(
2675 OUT PVOID *Callers,
2676 IN ULONG Count,
2677 IN ULONG Flags);
2678
2679 NTKERNELAPI
2680 BOOLEAN
2681 NTAPI
2682 KeAreAllApcsDisabled(
2683 VOID
2684 );
2685
2686 /* Guarded Mutex routines */
2687
2688 NTKERNELAPI
2689 VOID
2690 FASTCALL
2691 KeAcquireGuardedMutex(
2692 IN OUT PKGUARDED_MUTEX GuardedMutex
2693 );
2694
2695 NTKERNELAPI
2696 VOID
2697 FASTCALL
2698 KeAcquireGuardedMutexUnsafe(
2699 IN OUT PKGUARDED_MUTEX GuardedMutex
2700 );
2701
2702 NTKERNELAPI
2703 VOID
2704 NTAPI
2705 KeEnterGuardedRegion(
2706 VOID
2707 );
2708
2709 NTKERNELAPI
2710 VOID
2711 NTAPI
2712 KeLeaveGuardedRegion(
2713 VOID
2714 );
2715
2716 NTKERNELAPI
2717 VOID
2718 FASTCALL
2719 KeInitializeGuardedMutex(
2720 OUT PKGUARDED_MUTEX GuardedMutex
2721 );
2722
2723 NTKERNELAPI
2724 VOID
2725 FASTCALL
2726 KeReleaseGuardedMutexUnsafe(
2727 IN OUT PKGUARDED_MUTEX GuardedMutex
2728 );
2729
2730 NTKERNELAPI
2731 VOID
2732 FASTCALL
2733 KeReleaseGuardedMutex(
2734 IN OUT PKGUARDED_MUTEX GuardedMutex
2735 );
2736
2737 NTKERNELAPI
2738 BOOLEAN
2739 FASTCALL
2740 KeTryToAcquireGuardedMutex(
2741 IN OUT PKGUARDED_MUTEX GuardedMutex
2742 );
2743
2744 /* Fast Mutex */
2745 #define ExInitializeFastMutex(_FastMutex) \
2746 { \
2747 (_FastMutex)->Count = FM_LOCK_BIT; \
2748 (_FastMutex)->Owner = NULL; \
2749 (_FastMutex)->Contention = 0; \
2750 KeInitializeEvent(&(_FastMutex)->Gate, SynchronizationEvent, FALSE); \
2751 }
2752
2753 NTKERNELAPI
2754 VOID
2755 NTAPI
2756 KeInitializeEvent(
2757 IN PRKEVENT Event,
2758 IN EVENT_TYPE Type,
2759 IN BOOLEAN State);
2760
2761 /******************************************************************************
2762 * Executive Types *
2763 ******************************************************************************/
2764
2765 typedef struct _ZONE_SEGMENT_HEADER {
2766 SINGLE_LIST_ENTRY SegmentList;
2767 PVOID Reserved;
2768 } ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER;
2769
2770 typedef struct _ZONE_HEADER {
2771 SINGLE_LIST_ENTRY FreeList;
2772 SINGLE_LIST_ENTRY SegmentList;
2773 ULONG BlockSize;
2774 ULONG TotalSegmentSize;
2775 } ZONE_HEADER, *PZONE_HEADER;
2776
2777 #define PROTECTED_POOL 0x80000000
2778
2779 /******************************************************************************
2780 * Executive Functions *
2781 ******************************************************************************/
2782
2783 NTKERNELAPI
2784 NTSTATUS
2785 NTAPI
2786 ExExtendZone(
2787 IN PZONE_HEADER Zone,
2788 IN PVOID Segment,
2789 IN ULONG SegmentSize);
2790
2791 static __inline PVOID
2792 ExAllocateFromZone(
2793 IN PZONE_HEADER Zone)
2794 {
2795 if (Zone->FreeList.Next)
2796 Zone->FreeList.Next = Zone->FreeList.Next->Next;
2797 return (PVOID) Zone->FreeList.Next;
2798 }
2799
2800 static __inline PVOID
2801 ExFreeToZone(
2802 IN PZONE_HEADER Zone,
2803 IN PVOID Block)
2804 {
2805 ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next;
2806 Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block);
2807 return ((PSINGLE_LIST_ENTRY) Block)->Next;
2808 }
2809
2810 NTKERNELAPI
2811 NTSTATUS
2812 NTAPI
2813 ExInitializeZone(
2814 IN PZONE_HEADER Zone,
2815 IN ULONG BlockSize,
2816 IN PVOID InitialSegment,
2817 IN ULONG InitialSegmentSize);
2818
2819 /*
2820 * PVOID
2821 * ExInterlockedAllocateFromZone(
2822 * IN PZONE_HEADER Zone,
2823 * IN PKSPIN_LOCK Lock)
2824 */
2825 #define ExInterlockedAllocateFromZone(Zone, Lock) \
2826 ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock))
2827
2828 NTKERNELAPI
2829 NTSTATUS
2830 NTAPI
2831 ExInterlockedExtendZone(
2832 IN PZONE_HEADER Zone,
2833 IN PVOID Segment,
2834 IN ULONG SegmentSize,
2835 IN PKSPIN_LOCK Lock);
2836
2837 /* PVOID
2838 * ExInterlockedFreeToZone(
2839 * IN PZONE_HEADER Zone,
2840 * IN PVOID Block,
2841 * IN PKSPIN_LOCK Lock);
2842 */
2843 #define ExInterlockedFreeToZone(Zone, Block, Lock) \
2844 ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock)
2845
2846 /*
2847 * VOID
2848 * InitializeSListHead(
2849 * IN PSLIST_HEADER SListHead)
2850 */
2851 #define InitializeSListHead(_SListHead) \
2852 (_SListHead)->Alignment = 0
2853
2854 #define ExInitializeSListHead InitializeSListHead
2855
2856 /*
2857 * BOOLEAN
2858 * ExIsFullZone(
2859 * IN PZONE_HEADER Zone)
2860 */
2861 #define ExIsFullZone(Zone) \
2862 ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL)
2863
2864 /* BOOLEAN
2865 * ExIsObjectInFirstZoneSegment(
2866 * IN PZONE_HEADER Zone,
2867 * IN PVOID Object);
2868 */
2869 #define ExIsObjectInFirstZoneSegment(Zone,Object) \
2870 ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \
2871 ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \
2872 (Zone)->TotalSegmentSize)) )
2873
2874 NTKERNELAPI
2875 DECLSPEC_NORETURN
2876 VOID
2877 NTAPI
2878 ExRaiseAccessViolation(
2879 VOID);
2880
2881 NTKERNELAPI
2882 DECLSPEC_NORETURN
2883 VOID
2884 NTAPI
2885 ExRaiseDatatypeMisalignment(
2886 VOID);
2887
2888 NTKERNELAPI
2889 NTSTATUS
2890 NTAPI
2891 ExUuidCreate(
2892 OUT UUID *Uuid);
2893
2894 #define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite
2895 #define ExAcquireResourceShared ExAcquireResourceSharedLite
2896 #define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite
2897 #define ExDeleteResource ExDeleteResourceLite
2898 #define ExInitializeResource ExInitializeResourceLite
2899 #define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite
2900 #define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite
2901 #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite
2902 #define ExReleaseResourceForThread ExReleaseResourceForThreadLite
2903
2904
2905 #if DBG
2906
2907 #define PAGED_CODE() { \
2908 if (KeGetCurrentIrql() > APC_LEVEL) { \
2909 KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \
2910 ASSERT(FALSE); \
2911 } \
2912 }
2913
2914 #else
2915
2916 #define PAGED_CODE()
2917
2918 #endif
2919
2920 NTKERNELAPI
2921 VOID
2922 NTAPI
2923 ProbeForRead(
2924 IN CONST VOID *Address,
2925 IN SIZE_T Length,
2926 IN ULONG Alignment);
2927
2928 NTKERNELAPI
2929 VOID
2930 NTAPI
2931 ProbeForWrite(
2932 IN PVOID Address,
2933 IN SIZE_T Length,
2934 IN ULONG Alignment);
2935
2936
2937
2938 /** Configuration manager routines **/
2939
2940 NTKERNELAPI
2941 NTSTATUS
2942 NTAPI
2943 CmRegisterCallback(
2944 IN PEX_CALLBACK_FUNCTION Function,
2945 IN PVOID Context,
2946 IN OUT PLARGE_INTEGER Cookie);
2947
2948 NTKERNELAPI
2949 NTSTATUS
2950 NTAPI
2951 CmUnRegisterCallback(
2952 IN LARGE_INTEGER Cookie);
2953
2954
2955
2956 /** Filesystem runtime library routines **/
2957
2958 NTKERNELAPI
2959 BOOLEAN
2960 NTAPI
2961 FsRtlIsTotalDeviceFailure(
2962 IN NTSTATUS Status);
2963
2964
2965
2966 /** Hardware abstraction layer routines **/
2967
2968 NTHALAPI
2969 BOOLEAN
2970 NTAPI
2971 HalMakeBeep(
2972 IN ULONG Frequency);
2973
2974 NTKERNELAPI
2975 VOID
2976 FASTCALL
2977 HalExamineMBR(
2978 IN PDEVICE_OBJECT DeviceObject,
2979 IN ULONG SectorSize,
2980 IN ULONG MBRTypeIdentifier,
2981 OUT PVOID *Buffer);
2982
2983 VOID
2984 NTAPI
2985 HalPutDmaAdapter(
2986 PADAPTER_OBJECT AdapterObject
2987 );
2988
2989
2990 /** Io access routines **/
2991
2992 #if !defined(_M_AMD64)
2993 NTHALAPI
2994 VOID
2995 NTAPI
2996 READ_PORT_BUFFER_UCHAR(
2997 IN PUCHAR Port,
2998 IN PUCHAR Buffer,
2999 IN ULONG Count);
3000
3001 NTHALAPI
3002 VOID
3003 NTAPI
3004 READ_PORT_BUFFER_ULONG(
3005 IN PULONG Port,
3006 IN PULONG Buffer,
3007 IN ULONG Count);
3008
3009 NTHALAPI
3010 VOID
3011 NTAPI
3012 READ_PORT_BUFFER_USHORT(
3013 IN PUSHORT Port,
3014 IN PUSHORT Buffer,
3015 IN ULONG Count);
3016
3017 NTHALAPI
3018 UCHAR
3019 NTAPI
3020 READ_PORT_UCHAR(
3021 IN PUCHAR Port);
3022
3023 NTHALAPI
3024 ULONG
3025 NTAPI
3026 READ_PORT_ULONG(
3027 IN PULONG Port);
3028
3029 NTHALAPI
3030 USHORT
3031 NTAPI
3032 READ_PORT_USHORT(
3033 IN PUSHORT Port);
3034
3035 NTKERNELAPI
3036 VOID
3037 NTAPI
3038 READ_REGISTER_BUFFER_UCHAR(
3039 IN PUCHAR Register,
3040 IN PUCHAR Buffer,
3041 IN ULONG Count);
3042
3043 NTKERNELAPI
3044 VOID
3045 NTAPI
3046 READ_REGISTER_BUFFER_ULONG(
3047 IN PULONG Register,
3048 IN PULONG Buffer,
3049 IN ULONG Count);
3050
3051 NTKERNELAPI
3052 VOID
3053 NTAPI
3054 READ_REGISTER_BUFFER_USHORT(
3055 IN PUSHORT Register,
3056 IN PUSHORT Buffer,
3057 IN ULONG Count);
3058
3059 NTKERNELAPI
3060 UCHAR
3061 NTAPI
3062 READ_REGISTER_UCHAR(
3063 IN PUCHAR Register);
3064
3065 NTKERNELAPI
3066 ULONG
3067 NTAPI
3068 READ_REGISTER_ULONG(
3069 IN PULONG Register);
3070
3071 NTKERNELAPI
3072 USHORT
3073 NTAPI
3074 READ_REGISTER_USHORT(
3075 IN PUSHORT Register);
3076
3077 NTHALAPI
3078 VOID
3079 NTAPI
3080 WRITE_PORT_BUFFER_UCHAR(
3081 IN PUCHAR Port,
3082 IN PUCHAR Buffer,
3083 IN ULONG Count);
3084
3085 NTHALAPI
3086 VOID
3087 NTAPI
3088 WRITE_PORT_BUFFER_ULONG(
3089 IN PULONG Port,
3090 IN PULONG Buffer,
3091 IN ULONG Count);
3092
3093 NTHALAPI
3094 VOID
3095 NTAPI
3096 WRITE_PORT_BUFFER_USHORT(
3097 IN PUSHORT Port,
3098 IN PUSHORT Buffer,
3099 IN ULONG Count);
3100
3101 NTHALAPI
3102 VOID
3103 NTAPI
3104 WRITE_PORT_UCHAR(
3105 IN PUCHAR Port,
3106 IN UCHAR Value);
3107
3108 NTHALAPI
3109 VOID
3110 NTAPI
3111 WRITE_PORT_ULONG(
3112 IN PULONG Port,
3113 IN ULONG Value);
3114
3115 NTHALAPI
3116 VOID
3117 NTAPI
3118 WRITE_PORT_USHORT(
3119 IN PUSHORT Port,
3120 IN USHORT Value);
3121
3122 NTKERNELAPI
3123 VOID
3124 NTAPI
3125 WRITE_REGISTER_BUFFER_UCHAR(
3126 IN PUCHAR Register,
3127 IN PUCHAR Buffer,
3128 IN ULONG Count);
3129
3130 NTKERNELAPI
3131 VOID
3132 NTAPI
3133 WRITE_REGISTER_BUFFER_ULONG(
3134 IN PULONG Register,
3135 IN PULONG Buffer,
3136 IN ULONG Count);
3137
3138 NTKERNELAPI
3139 VOID
3140 NTAPI
3141 WRITE_REGISTER_BUFFER_USHORT(
3142 IN PUSHORT Register,
3143 IN PUSHORT Buffer,
3144 IN ULONG Count);
3145
3146 NTKERNELAPI
3147 VOID
3148 NTAPI
3149 WRITE_REGISTER_UCHAR(
3150 IN PUCHAR Register,
3151 IN UCHAR Value);
3152
3153 NTKERNELAPI
3154 VOID
3155 NTAPI
3156 WRITE_REGISTER_ULONG(
3157 IN PULONG Register,
3158 IN ULONG Value);
3159
3160 NTKERNELAPI
3161 VOID
3162 NTAPI
3163 WRITE_REGISTER_USHORT(
3164 IN PUSHORT Register,
3165 IN USHORT Value);
3166
3167 #else
3168
3169 FORCEINLINE
3170 VOID
3171 READ_PORT_BUFFER_UCHAR(
3172 IN PUCHAR Port,
3173 IN PUCHAR Buffer,
3174 IN ULONG Count)
3175 {
3176 __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3177 }
3178
3179 FORCEINLINE
3180 VOID
3181 READ_PORT_BUFFER_ULONG(
3182 IN PULONG Port,
3183 IN PULONG Buffer,
3184 IN ULONG Count)
3185 {
3186 __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3187 }
3188
3189 FORCEINLINE
3190 VOID
3191 READ_PORT_BUFFER_USHORT(
3192 IN PUSHORT Port,
3193 IN PUSHORT Buffer,
3194 IN ULONG Count)
3195 {
3196 __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3197 }
3198
3199 FORCEINLINE
3200 UCHAR
3201 READ_PORT_UCHAR(
3202 IN PUCHAR Port)
3203 {
3204 return __inbyte((USHORT)(ULONG_PTR)Port);
3205 }
3206
3207 FORCEINLINE
3208 ULONG
3209 READ_PORT_ULONG(
3210 IN PULONG Port)
3211 {
3212 return __indword((USHORT)(ULONG_PTR)Port);
3213 }
3214
3215 FORCEINLINE
3216 USHORT
3217 READ_PORT_USHORT(
3218 IN PUSHORT Port)
3219 {
3220 return __inword((USHORT)(ULONG_PTR)Port);
3221 }
3222
3223 FORCEINLINE
3224 VOID
3225 READ_REGISTER_BUFFER_UCHAR(
3226 IN PUCHAR Register,
3227 IN PUCHAR Buffer,
3228 IN ULONG Count)
3229 {
3230 __movsb(Register, Buffer, Count);
3231 }
3232
3233 FORCEINLINE
3234 VOID
3235 READ_REGISTER_BUFFER_ULONG(
3236 IN PULONG Register,
3237 IN PULONG Buffer,
3238 IN ULONG Count)
3239 {
3240 __movsd(Register, Buffer, Count);
3241 }
3242
3243 FORCEINLINE
3244 VOID
3245 READ_REGISTER_BUFFER_USHORT(
3246 IN PUSHORT Register,
3247 IN PUSHORT Buffer,
3248 IN ULONG Count)
3249 {
3250 __movsw(Register, Buffer, Count);
3251 }
3252
3253 FORCEINLINE
3254 UCHAR
3255 READ_REGISTER_UCHAR(
3256 IN PUCHAR Register)
3257 {
3258 return *Register;
3259 }
3260
3261 FORCEINLINE
3262 ULONG
3263 READ_REGISTER_ULONG(
3264 IN PULONG Register)
3265 {
3266 return *Register;
3267 }
3268
3269 FORCEINLINE
3270 USHORT
3271 READ_REGISTER_USHORT(
3272 IN PUSHORT Register)
3273 {
3274 return *Register;
3275 }
3276
3277 FORCEINLINE
3278 VOID
3279 WRITE_PORT_BUFFER_UCHAR(
3280 IN PUCHAR Port,
3281 IN PUCHAR Buffer,
3282 IN ULONG Count)
3283 {
3284 __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3285 }
3286
3287 FORCEINLINE
3288 VOID
3289 WRITE_PORT_BUFFER_ULONG(
3290 IN PULONG Port,
3291 IN PULONG Buffer,
3292 IN ULONG Count)
3293 {
3294 __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3295 }
3296
3297 FORCEINLINE
3298 VOID
3299 WRITE_PORT_BUFFER_USHORT(
3300 IN PUSHORT Port,
3301 IN PUSHORT Buffer,
3302 IN ULONG Count)
3303 {
3304 __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
3305 }
3306
3307 FORCEINLINE
3308 VOID
3309 WRITE_PORT_UCHAR(
3310 IN PUCHAR Port,
3311 IN UCHAR Value)
3312 {
3313 __outbyte((USHORT)(ULONG_PTR)Port, Value);
3314 }
3315
3316 FORCEINLINE
3317 VOID
3318 WRITE_PORT_ULONG(
3319 IN PULONG Port,
3320 IN ULONG Value)
3321 {
3322 __outdword((USHORT)(ULONG_PTR)Port, Value);
3323 }
3324
3325 FORCEINLINE
3326 VOID
3327 WRITE_PORT_USHORT(
3328 IN PUSHORT Port,
3329 IN USHORT Value)
3330 {
3331 __outword((USHORT)(ULONG_PTR)Port, Value);
3332 }
3333
3334 FORCEINLINE
3335 VOID
3336 WRITE_REGISTER_BUFFER_UCHAR(
3337 IN PUCHAR Register,
3338 IN PUCHAR Buffer,
3339 IN ULONG Count)
3340 {
3341 LONG Synch;
3342 __movsb(Register, Buffer, Count);
3343 InterlockedOr(&Synch, 1);
3344 }
3345
3346 FORCEINLINE
3347 VOID
3348 WRITE_REGISTER_BUFFER_ULONG(
3349 IN PULONG Register,
3350 IN PULONG Buffer,
3351 IN ULONG Count)
3352 {
3353 LONG Synch;
3354 __movsd(Register, Buffer, Count);
3355 InterlockedOr(&Synch, 1);
3356 }
3357
3358 FORCEINLINE
3359 VOID
3360 WRITE_REGISTER_BUFFER_USHORT(
3361 IN PUSHORT Register,
3362 IN PUSHORT Buffer,
3363 IN ULONG Count)
3364 {
3365 LONG Synch;
3366 __movsw(Register, Buffer, Count);
3367 InterlockedOr(&Synch, 1);
3368 }
3369
3370 FORCEINLINE
3371 VOID
3372 WRITE_REGISTER_UCHAR(
3373 IN PUCHAR Register,
3374 IN UCHAR Value)
3375 {
3376 LONG Synch;
3377 *Register = Value;
3378 InterlockedOr(&Synch, 1);
3379 }
3380
3381 FORCEINLINE
3382 VOID
3383 WRITE_REGISTER_ULONG(
3384 IN PULONG Register,
3385 IN ULONG Value)
3386 {
3387 LONG Synch;
3388 *Register = Value;
3389 InterlockedOr(&Synch, 1);
3390 }
3391
3392 FORCEINLINE
3393 VOID
3394 WRITE_REGISTER_USHORT(
3395 IN PUSHORT Register,
3396 IN USHORT Value)
3397 {
3398 LONG Sync;
3399 *Register = Value;
3400 InterlockedOr(&Sync, 1);
3401 }
3402
3403 #endif
3404
3405 /** I/O manager routines **/
3406
3407 NTKERNELAPI
3408 VOID
3409 NTAPI
3410 IoAcquireCancelSpinLock(
3411 OUT PKIRQL Irql);
3412
3413 NTKERNELAPI
3414 NTSTATUS
3415 NTAPI
3416 IoAcquireRemoveLockEx(
3417 IN PIO_REMOVE_LOCK RemoveLock,
3418 IN OPTIONAL PVOID Tag OPTIONAL,
3419 IN PCSTR File,
3420 IN ULONG Line,
3421 IN ULONG RemlockSize);
3422
3423 /*
3424 * NTSTATUS
3425 * IoAcquireRemoveLock(
3426 * IN PIO_REMOVE_LOCK RemoveLock,
3427 * IN OPTIONAL PVOID Tag)
3428 */
3429 #define IoAcquireRemoveLock(_RemoveLock, \
3430 _Tag) \
3431 IoAcquireRemoveLockEx(_RemoveLock, _Tag, __FILE__, __LINE__, sizeof(IO_REMOVE_LOCK))
3432
3433 /*
3434 * VOID
3435 * IoAdjustPagingPathCount(
3436 * IN PLONG Count,
3437 * IN BOOLEAN Increment)
3438 */
3439 #define IoAdjustPagingPathCount(_Count, \
3440 _Increment) \
3441 { \
3442 if (_Increment) \
3443 { \
3444 InterlockedIncrement(_Count); \
3445 } \
3446 else \
3447 { \
3448 InterlockedDecrement(_Count); \
3449 } \
3450 }
3451
3452 #ifndef DMA_MACROS_DEFINED
3453 NTKERNELAPI
3454 NTSTATUS
3455 NTAPI
3456 IoAllocateAdapterChannel(
3457 IN PADAPTER_OBJECT AdapterObject,
3458 IN PDEVICE_OBJECT DeviceObject,
3459 IN ULONG NumberOfMapRegisters,
3460 IN PDRIVER_CONTROL ExecutionRoutine,
3461 IN PVOID Context);
3462 #endif
3463
3464 NTKERNELAPI
3465 VOID
3466 NTAPI
3467 IoAllocateController(
3468 IN PCONTROLLER_OBJECT ControllerObject,
3469 IN PDEVICE_OBJECT DeviceObject,
3470 IN PDRIVER_CONTROL ExecutionRoutine,
3471 IN PVOID Context);
3472
3473 NTKERNELAPI
3474 NTSTATUS
3475 NTAPI
3476 IoAllocateDriverObjectExtension(
3477 IN PDRIVER_OBJECT DriverObject,
3478 IN PVOID ClientIdentificationAddress,
3479 IN ULONG DriverObjectExtensionSize,
3480 OUT PVOID *DriverObjectExtension);
3481
3482 NTKERNELAPI
3483 PVOID
3484 NTAPI
3485 IoAllocateErrorLogEntry(
3486 IN PVOID IoObject,
3487 IN UCHAR EntrySize);
3488
3489 NTKERNELAPI
3490 PIRP
3491 NTAPI
3492 IoAllocateIrp(
3493 IN CCHAR StackSize,
3494 IN BOOLEAN ChargeQuota);
3495
3496 NTKERNELAPI
3497 PMDL
3498 NTAPI
3499 IoAllocateMdl(
3500 IN PVOID VirtualAddress,
3501 IN ULONG Length,
3502 IN BOOLEAN SecondaryBuffer,
3503 IN BOOLEAN ChargeQuota,
3504 IN OUT PIRP Irp OPTIONAL);
3505
3506 NTKERNELAPI
3507 PIO_WORKITEM
3508 NTAPI
3509 IoAllocateWorkItem(
3510 IN PDEVICE_OBJECT DeviceObject);
3511
3512 /*
3513 * VOID IoAssignArcName(
3514 * IN PUNICODE_STRING ArcName,
3515 * IN PUNICODE_STRING DeviceName);
3516 */
3517 #define IoAssignArcName(_ArcName, _DeviceName) ( \
3518 IoCreateSymbolicLink((_ArcName), (_DeviceName)))
3519
3520 NTKERNELAPI
3521 NTSTATUS
3522 NTAPI
3523 IoAttachDevice(
3524 IN PDEVICE_OBJECT SourceDevice,
3525 IN PUNICODE_STRING TargetDevice,
3526 OUT PDEVICE_OBJECT *AttachedDevice);
3527
3528 NTKERNELAPI
3529 PDEVICE_OBJECT
3530 NTAPI
3531 IoAttachDeviceToDeviceStack(
3532 IN PDEVICE_OBJECT SourceDevice,
3533 IN PDEVICE_OBJECT TargetDevice);
3534
3535 NTKERNELAPI
3536 PIRP
3537 NTAPI
3538 IoBuildAsynchronousFsdRequest(
3539 IN ULONG MajorFunction,
3540 IN PDEVICE_OBJECT DeviceObject,
3541 IN OUT PVOID Buffer OPTIONAL,
3542 IN ULONG Length OPTIONAL,
3543 IN PLARGE_INTEGER StartingOffset OPTIONAL,
3544 IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL);
3545
3546 NTKERNELAPI
3547 PIRP
3548 NTAPI
3549 IoBuildDeviceIoControlRequest(
3550 IN ULONG IoControlCode,
3551 IN PDEVICE_OBJECT DeviceObject,
3552 IN PVOID InputBuffer OPTIONAL,
3553 IN ULONG InputBufferLength,
3554 OUT PVOID OutputBuffer OPTIONAL,
3555 IN ULONG OutputBufferLength,
3556 IN BOOLEAN InternalDeviceIoControl,
3557 IN PKEVENT Event,
3558 OUT PIO_STATUS_BLOCK IoStatusBlock);
3559
3560 NTKERNELAPI
3561 VOID
3562 NTAPI
3563 IoBuildPartialMdl(
3564 IN PMDL SourceMdl,
3565 IN OUT PMDL TargetMdl,
3566 IN PVOID VirtualAddress,
3567 IN ULONG Length);
3568
3569 NTKERNELAPI
3570 PIRP
3571 NTAPI
3572 IoBuildSynchronousFsdRequest(
3573 IN ULONG MajorFunction,
3574 IN PDEVICE_OBJECT DeviceObject,
3575 IN OUT PVOID Buffer OPTIONAL,
3576 IN ULONG Length OPTIONAL,
3577 IN PLARGE_INTEGER StartingOffset OPTIONAL,
3578 IN PKEVENT Event,
3579 OUT PIO_STATUS_BLOCK IoStatusBlock);
3580
3581 NTKERNELAPI
3582 NTSTATUS
3583 FASTCALL
3584 IofCallDriver(
3585 IN PDEVICE_OBJECT DeviceObject,
3586 IN OUT PIRP Irp);
3587
3588 /*
3589 * NTSTATUS
3590 * IoCallDriver(
3591 * IN PDEVICE_OBJECT DeviceObject,
3592 * IN OUT PIRP Irp)
3593 */
3594 #define IoCallDriver IofCallDriver
3595
3596 NTKERNELAPI
3597 VOID
3598 NTAPI
3599 IoCancelFileOpen(
3600 IN PDEVICE_OBJECT DeviceObject,
3601 IN PFILE_OBJECT FileObject);
3602
3603 NTKERNELAPI
3604 BOOLEAN
3605 NTAPI
3606 IoCancelIrp(
3607 IN PIRP Irp);
3608
3609 NTKERNELAPI
3610 NTSTATUS
3611 NTAPI
3612 IoCheckShareAccess(
3613 IN ACCESS_MASK DesiredAccess,
3614 IN ULONG DesiredShareAccess,
3615 IN OUT PFILE_OBJECT FileObject,
3616 IN OUT PSHARE_ACCESS ShareAccess,
3617 IN BOOLEAN Update);
3618
3619 NTKERNELAPI
3620 VOID
3621 FASTCALL
3622 IofCompleteRequest(
3623 IN PIRP Irp,
3624 IN CCHAR PriorityBoost);
3625
3626 /*
3627 * VOID
3628 * IoCompleteRequest(
3629 * IN PIRP Irp,
3630 * IN CCHAR PriorityBoost)
3631 */
3632 #define IoCompleteRequest IofCompleteRequest
3633
3634 NTKERNELAPI
3635 NTSTATUS
3636 NTAPI
3637 IoConnectInterrupt(
3638 OUT PKINTERRUPT *InterruptObject,
3639 IN PKSERVICE_ROUTINE ServiceRoutine,
3640 IN PVOID ServiceContext,
3641 IN PKSPIN_LOCK SpinLock OPTIONAL,
3642 IN ULONG Vector,
3643 IN KIRQL Irql,
3644 IN KIRQL SynchronizeIrql,
3645 IN KINTERRUPT_MODE InterruptMode,
3646 IN BOOLEAN ShareVector,
3647 IN KAFFINITY ProcessorEnableMask,
3648 IN BOOLEAN FloatingSave);
3649
3650 /*
3651 * PIO_STACK_LOCATION
3652 * IoGetCurrentIrpStackLocation(
3653 * IN PIRP Irp)
3654 */
3655 #define IoGetCurrentIrpStackLocation(_Irp) \
3656 ((_Irp)->Tail.Overlay.CurrentStackLocation)
3657
3658 /*
3659 * PIO_STACK_LOCATION
3660 * IoGetNextIrpStackLocation(
3661 * IN PIRP Irp)
3662 */
3663 #define IoGetNextIrpStackLocation(_Irp) \
3664 ((_Irp)->Tail.Overlay.CurrentStackLocation - 1)
3665
3666 /*
3667 * VOID
3668 * IoCopyCurrentIrpStackLocationToNext(
3669 * IN PIRP Irp)
3670 */
3671 #define IoCopyCurrentIrpStackLocationToNext(_Irp) \
3672 { \
3673 PIO_STACK_LOCATION _IrpSp; \
3674 PIO_STACK_LOCATION _NextIrpSp; \
3675 _IrpSp = IoGetCurrentIrpStackLocation(_Irp); \
3676 _NextIrpSp = IoGetNextIrpStackLocation(_Irp); \
3677 RtlCopyMemory(_NextIrpSp, _IrpSp, \
3678 FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \
3679 _NextIrpSp->Control = 0; \
3680 }
3681
3682 NTKERNELAPI
3683 PCONTROLLER_OBJECT
3684 NTAPI
3685 IoCreateController(
3686 IN ULONG Size);
3687
3688 NTKERNELAPI
3689 NTSTATUS
3690 NTAPI
3691 IoCreateDevice(
3692 IN PDRIVER_OBJECT DriverObject,
3693 IN ULONG DeviceExtensionSize,
3694 IN PUNICODE_STRING DeviceName OPTIONAL,
3695 IN DEVICE_TYPE DeviceType,
3696 IN ULONG DeviceCharacteristics,
3697 IN BOOLEAN Exclusive,
3698 OUT PDEVICE_OBJECT *DeviceObject);
3699
3700 NTKERNELAPI
3701 NTSTATUS
3702 NTAPI
3703 IoCreateDisk(
3704 IN PDEVICE_OBJECT DeviceObject,
3705 IN PCREATE_DISK Disk);
3706
3707 NTKERNELAPI
3708 NTSTATUS
3709 NTAPI
3710 IoCreateFile(
3711 OUT PHANDLE FileHandle,
3712 IN ACCESS_MASK DesiredAccess,
3713 IN POBJECT_ATTRIBUTES ObjectAttributes,
3714 OUT PIO_STATUS_BLOCK IoStatusBlock,
3715 IN PLARGE_INTEGER AllocationSize OPTIONAL,
3716 IN ULONG FileAttributes,
3717 IN ULONG ShareAccess,
3718 IN ULONG Disposition,
3719 IN ULONG CreateOptions,
3720 IN PVOID EaBuffer OPTIONAL,
3721 IN ULONG EaLength,
3722 IN CREATE_FILE_TYPE CreateFileType,
3723 IN PVOID ExtraCreateParameters OPTIONAL,
3724 IN ULONG Options);
3725
3726 NTKERNELAPI
3727 PKEVENT
3728 NTAPI
3729 IoCreateNotificationEvent(
3730 IN PUNICODE_STRING EventName,
3731 OUT PHANDLE EventHandle);
3732
3733 NTKERNELAPI
3734 NTSTATUS
3735 NTAPI
3736 IoCreateSymbolicLink(
3737 IN PUNICODE_STRING SymbolicLinkName,
3738 IN PUNICODE_STRING DeviceName);
3739
3740 NTKERNELAPI
3741 PKEVENT
3742 NTAPI
3743 IoCreateSynchronizationEvent(
3744 IN PUNICODE_STRING EventName,
3745 OUT PHANDLE EventHandle);
3746
3747 NTKERNELAPI
3748 NTSTATUS
3749 NTAPI
3750 IoCreateUnprotectedSymbolicLink(
3751 IN PUNICODE_STRING SymbolicLinkName,
3752 IN PUNICODE_STRING DeviceName);
3753
3754 NTKERNELAPI
3755 NTSTATUS
3756 NTAPI
3757 IoCsqInitialize(
3758 PIO_CSQ Csq,
3759 IN PIO_CSQ_INSERT_IRP CsqInsertIrp,
3760 IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
3761 IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
3762 IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
3763 IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
3764 IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
3765
3766 NTKERNELAPI
3767 VOID
3768 NTAPI
3769 IoCsqInsertIrp(
3770 IN PIO_CSQ Csq,
3771 IN PIRP Irp,
3772 IN PIO_CSQ_IRP_CONTEXT Context);
3773
3774 NTKERNELAPI
3775 PIRP
3776 NTAPI
3777 IoCsqRemoveIrp(
3778 IN PIO_CSQ Csq,
3779 IN PIO_CSQ_IRP_CONTEXT Context);
3780
3781 NTKERNELAPI
3782 PIRP
3783 NTAPI
3784 IoCsqRemoveNextIrp(
3785 IN PIO_CSQ Csq,
3786 IN PVOID PeekContext);
3787
3788 NTKERNELAPI
3789 VOID
3790 NTAPI
3791 IoDeleteController(
3792 IN PCONTROLLER_OBJECT ControllerObject);
3793
3794 NTKERNELAPI
3795 VOID
3796 NTAPI
3797 IoDeleteDevice(
3798 IN PDEVICE_OBJECT DeviceObject);
3799
3800 NTKERNELAPI
3801 NTSTATUS
3802 NTAPI
3803 IoDeleteSymbolicLink(
3804 IN PUNICODE_STRING SymbolicLinkName);
3805
3806 /*
3807 * VOID
3808 * IoDeassignArcName(
3809 * IN PUNICODE_STRING ArcName)
3810 */
3811 #define IoDeassignArcName IoDeleteSymbolicLink
3812
3813 NTKERNELAPI
3814 VOID
3815 NTAPI
3816 IoDetachDevice(
3817 IN OUT PDEVICE_OBJECT TargetDevice);
3818
3819 NTKERNELAPI
3820 VOID
3821 NTAPI
3822 IoDisconnectInterrupt(
3823 IN PKINTERRUPT InterruptObject);
3824
3825 NTKERNELAPI
3826 BOOLEAN
3827 NTAPI
3828 IoForwardIrpSynchronously(
3829 IN PDEVICE_OBJECT DeviceObject,
3830 IN PIRP Irp);
3831
3832 #define IoForwardAndCatchIrp IoForwardIrpSynchronously
3833
3834 NTKERNELAPI
3835 VOID
3836 NTAPI
3837 IoFreeController(
3838 IN PCONTROLLER_OBJECT ControllerObject);
3839
3840 NTKERNELAPI
3841 VOID
3842 NTAPI
3843 IoFreeErrorLogEntry(
3844 PVOID ElEntry);
3845
3846 NTKERNELAPI
3847 VOID
3848 NTAPI
3849 IoFreeIrp(
3850 IN PIRP Irp);
3851
3852 NTKERNELAPI
3853 VOID
3854 NTAPI
3855 IoFreeMdl(
3856 IN PMDL Mdl);
3857
3858 NTKERNELAPI
3859 VOID
3860 NTAPI
3861 IoFreeWorkItem(
3862 IN PIO_WORKITEM pIOWorkItem);
3863
3864 NTKERNELAPI
3865 PDEVICE_OBJECT
3866 NTAPI
3867 IoGetAttachedDevice(
3868 IN PDEVICE_OBJECT DeviceObject);
3869
3870 NTKERNELAPI
3871 PDEVICE_OBJECT
3872 NTAPI
3873 IoGetAttachedDeviceReference(
3874 IN PDEVICE_OBJECT DeviceObject);
3875
3876 NTKERNELAPI
3877 NTSTATUS
3878 NTAPI
3879 IoGetBootDiskInformation(
3880 IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
3881 IN ULONG Size);
3882
3883 NTKERNELAPI
3884 PCONFIGURATION_INFORMATION
3885 NTAPI
3886 IoGetConfigurationInformation(
3887 VOID);
3888
3889 NTKERNELAPI
3890 PEPROCESS
3891 NTAPI
3892 IoGetCurrentProcess(
3893 VOID);
3894
3895 NTKERNELAPI
3896 NTSTATUS
3897 NTAPI
3898 IoGetDeviceInterfaceAlias(
3899 IN PUNICODE_STRING SymbolicLinkName,
3900 IN CONST GUID *AliasInterfaceClassGuid,
3901 OUT PUNICODE_STRING AliasSymbolicLinkName);
3902
3903 #define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
3904
3905 NTKERNELAPI
3906 NTSTATUS
3907 NTAPI
3908 IoGetDeviceInterfaces(
3909 IN CONST GUID *InterfaceClassGuid,
3910 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
3911 IN ULONG Flags,
3912 OUT PWSTR *SymbolicLinkList);
3913
3914 NTKERNELAPI
3915 NTSTATUS
3916 NTAPI
3917 IoGetDeviceObjectPointer(
3918 IN PUNICODE_STRING ObjectName,
3919 IN ACCESS_MASK DesiredAccess,
3920 OUT PFILE_OBJECT *FileObject,
3921 OUT PDEVICE_OBJECT *DeviceObject);
3922
3923 NTKERNELAPI
3924 NTSTATUS
3925 NTAPI
3926 IoGetDeviceProperty(
3927 IN PDEVICE_OBJECT DeviceObject,
3928 IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
3929 IN ULONG BufferLength,
3930 OUT PVOID PropertyBuffer,
3931 OUT PULONG ResultLength);
3932
3933 NTKERNELAPI
3934 PDEVICE_OBJECT
3935 NTAPI
3936 IoGetDeviceToVerify(
3937 IN PETHREAD Thread);
3938
3939 NTKERNELAPI
3940 PDMA_ADAPTER
3941 NTAPI
3942 IoGetDmaAdapter(
3943 IN PDEVICE_OBJECT PhysicalDeviceObject,
3944 IN PDEVICE_DESCRIPTION DeviceDescription,
3945 IN OUT PULONG NumberOfMapRegisters);
3946
3947 NTKERNELAPI
3948 PVOID
3949 NTAPI
3950 IoGetDriverObjectExtension(
3951 IN PDRIVER_OBJECT DriverObject,
3952 IN PVOID ClientIdentificationAddress);
3953
3954 NTKERNELAPI
3955 PGENERIC_MAPPING
3956 NTAPI
3957 IoGetFileObjectGenericMapping(
3958 VOID);
3959
3960 /*
3961 * ULONG
3962 * IoGetFunctionCodeFromCtlCode(
3963 * IN ULONG ControlCode)
3964 */
3965 #define IoGetFunctionCodeFromCtlCode(_ControlCode) \
3966 (((_ControlCode) >> 2) & 0x00000FFF)
3967
3968 NTKERNELAPI
3969 PVOID
3970 NTAPI
3971 IoGetInitialStack(
3972 VOID);
3973
3974 NTKERNELAPI
3975 PDEVICE_OBJECT
3976 NTAPI
3977 IoGetRelatedDeviceObject(
3978 IN PFILE_OBJECT FileObject);
3979
3980 NTKERNELAPI
3981 VOID
3982 NTAPI
3983 IoGetStackLimits(
3984 OUT PULONG_PTR LowLimit,
3985 OUT PULONG_PTR HighLimit);
3986
3987 FORCEINLINE
3988 ULONG_PTR
3989 IoGetRemainingStackSize(
3990 VOID
3991 )
3992 {
3993 ULONG_PTR End, Begin;
3994 ULONG_PTR Result;
3995
3996 IoGetStackLimits(&Begin, &End);
3997 Result = (ULONG_PTR)(&End) - Begin;
3998 return Result;
3999 }
4000
4001 NTKERNELAPI
4002 VOID
4003 NTAPI
4004 KeInitializeDpc(
4005 IN PRKDPC Dpc,
4006 IN PKDEFERRED_ROUTINE DeferredRoutine,
4007 IN PVOID DeferredContext);
4008
4009 /*
4010 * VOID
4011 * IoInitializeDpcRequest(
4012 * IN PDEVICE_OBJECT DeviceObject,
4013 * IN PIO_DPC_ROUTINE DpcRoutine)
4014 */
4015 #define IoInitializeDpcRequest(_DeviceObject, \
4016 _DpcRoutine) \
4017 KeInitializeDpc(&(_DeviceObject)->Dpc, \
4018 (PKDEFERRED_ROUTINE) (_DpcRoutine), \
4019 _DeviceObject)
4020
4021 NTKERNELAPI
4022 VOID
4023 NTAPI
4024 IoInitializeIrp(
4025 IN OUT PIRP Irp,
4026 IN USHORT PacketSize,
4027 IN CCHAR StackSize);
4028
4029 NTKERNELAPI
4030 VOID
4031 NTAPI
4032 IoInitializeRemoveLockEx(
4033 IN PIO_REMOVE_LOCK Lock,
4034 IN ULONG AllocateTag,
4035 IN ULONG MaxLockedMinutes,
4036 IN ULONG HighWatermark,
4037 IN ULONG RemlockSize);
4038
4039 /* VOID
4040 * IoInitializeRemoveLock(
4041 * IN PIO_REMOVE_LOCK Lock,
4042 * IN ULONG AllocateTag,
4043 * IN ULONG MaxLockedMinutes,
4044 * IN ULONG HighWatermark)
4045 */
4046 #define IoInitializeRemoveLock( \
4047 Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \
4048 IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \
4049 HighWatermark, sizeof(IO_REMOVE_LOCK))
4050
4051 NTKERNELAPI
4052 NTSTATUS
4053 NTAPI
4054 IoInitializeTimer(
4055 IN PDEVICE_OBJECT DeviceObject,
4056 IN PIO_TIMER_ROUTINE TimerRoutine,
4057 IN PVOID Context);
4058
4059 NTKERNELAPI
4060 VOID
4061 NTAPI
4062 IoInvalidateDeviceRelations(
4063 IN PDEVICE_OBJECT DeviceObject,
4064 IN DEVICE_RELATION_TYPE Type);
4065
4066 NTKERNELAPI
4067 VOID
4068 NTAPI
4069 IoInvalidateDeviceState(
4070 IN PDEVICE_OBJECT PhysicalDeviceObject);
4071
4072 NTKERNELAPI
4073 BOOLEAN
4074 NTAPI
4075 IoIs32bitProcess(
4076 IN PIRP Irp OPTIONAL);
4077
4078 /*
4079 * BOOLEAN
4080 * IoIsErrorUserInduced(
4081 * IN NTSTATUS Status);
4082 */
4083 #define IoIsErrorUserInduced(Status) \
4084 ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
4085 ((Status) == STATUS_IO_TIMEOUT) || \
4086 ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
4087 ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
4088 ((Status) == STATUS_VERIFY_REQUIRED) || \
4089 ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
4090 ((Status) == STATUS_WRONG_VOLUME)))
4091
4092 NTKERNELAPI
4093 BOOLEAN
4094 NTAPI
4095 IoIsWdmVersionAvailable(
4096 IN UCHAR MajorVersion,
4097 IN UCHAR MinorVersion);
4098
4099 NTKERNELAPI
4100 PIRP
4101 NTAPI
4102 IoMakeAssociatedIrp(
4103 IN PIRP Irp,
4104 IN CCHAR StackSize);
4105
4106 /*
4107 * VOID
4108 * IoMarkIrpPending(
4109 * IN OUT PIRP Irp)
4110 */
4111 #define IoMarkIrpPending(_Irp) \
4112 (IoGetCurrentIrpStackLocation(_Irp)->Control |= SL_PENDING_RETURNED)
4113
4114 NTKERNELAPI
4115 NTSTATUS
4116 NTAPI
4117 IoOpenDeviceInterfaceRegistryKey(
4118 IN PUNICODE_STRING SymbolicLinkName,
4119 IN ACCESS_MASK DesiredAccess,
4120 OUT PHANDLE DeviceInterfaceKey);
4121
4122 #define PLUGPLAY_REGKEY_DEVICE 1
4123 #define PLUGPLAY_REGKEY_DRIVER 2
4124 #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4
4125
4126 NTKERNELAPI
4127 NTSTATUS
4128 NTAPI
4129 IoOpenDeviceRegistryKey(
4130 IN PDEVICE_OBJECT DeviceObject,
4131 IN ULONG DevInstKeyType,
4132 IN ACCESS_MASK DesiredAccess,
4133 OUT PHANDLE DevInstRegKey);
4134
4135 NTKERNELAPI
4136 NTSTATUS
4137 NTAPI
4138 IoQueryDeviceDescription(
4139 IN PINTERFACE_TYPE BusType OPTIONAL,
4140 IN PULONG BusNumber OPTIONAL,
4141 IN PCONFIGURATION_TYPE ControllerType OPTIONAL,
4142 IN PULONG ControllerNumber OPTIONAL,
4143 IN PCONFIGURATION_TYPE PeripheralType OPTIONAL,
4144 IN PULONG PeripheralNumber OPTIONAL,
4145 IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
4146 IN PVOID Context);
4147
4148 NTKERNELAPI
4149 VOID
4150 NTAPI
4151 IoQueueWorkItem(
4152 IN PIO_WORKITEM pIOWorkItem,
4153 IN PIO_WORKITEM_ROUTINE Routine,
4154 IN WORK_QUEUE_TYPE QueueType,
4155 IN PVOID Context);
4156
4157 NTKERNELAPI
4158 VOID
4159 NTAPI
4160 IoRaiseHardError(
4161 IN PIRP Irp,
4162 IN PVPB Vpb OPTIONAL,
4163 IN PDEVICE_OBJECT RealDeviceObject);
4164
4165 NTKERNELAPI
4166 BOOLEAN
4167 NTAPI
4168 IoRaiseInformationalHardError(
4169 IN NTSTATUS ErrorStatus,
4170 IN PUNICODE_STRING String OPTIONAL,
4171 IN PKTHREAD Thread OPTIONAL);
4172
4173 NTKERNELAPI
4174 NTSTATUS
4175 NTAPI
4176 IoReadDiskSignature(
4177 IN PDEVICE_OBJECT DeviceObject,
4178 IN ULONG BytesPerSector,
4179 OUT PDISK_SIGNATURE Signature);
4180
4181 NTKERNELAPI
4182 NTSTATUS
4183 FASTCALL
4184 IoReadPartitionTable(
4185 IN PDEVICE_OBJECT DeviceObject,
4186 IN ULONG SectorSize,
4187 IN BOOLEAN ReturnRecognizedPartitions,
4188 OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
4189
4190 NTKERNELAPI
4191 NTSTATUS
4192 NTAPI
4193 IoReadPartitionTableEx(
4194 IN PDEVICE_OBJECT DeviceObject,
4195 IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
4196
4197 NTKERNELAPI
4198 VOID
4199 NTAPI
4200 IoRegisterBootDriverReinitialization(
4201 IN PDRIVER_OBJECT DriverObject,
4202 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
4203 IN PVOID Context);
4204
4205 NTKERNELAPI
4206 VOID
4207 NTAPI
4208 IoRegisterBootDriverReinitialization(
4209 IN PDRIVER_OBJECT DriverObject,
4210 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
4211 IN PVOID Context);
4212
4213 NTKERNELAPI
4214 NTSTATUS
4215 NTAPI
4216 IoRegisterDeviceInterface(
4217 IN PDEVICE_OBJECT PhysicalDeviceObject,
4218 IN CONST GUID *InterfaceClassGuid,
4219 IN PUNICODE_STRING ReferenceString OPTIONAL,
4220 OUT PUNICODE_STRING SymbolicLinkName);
4221
4222 NTKERNELAPI
4223 VOID
4224 NTAPI
4225 IoRegisterDriverReinitialization(
4226 IN PDRIVER_OBJECT DriverObject,
4227 IN PDRIVER_REINITIALIZE DriverReinitializationRoutine,
4228 IN PVOID Context);
4229
4230 NTKERNELAPI
4231 NTSTATUS
4232 NTAPI
4233 IoRegisterPlugPlayNotification(
4234 IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
4235 IN ULONG EventCategoryFlags,
4236 IN PVOID EventCategoryData OPTIONAL,
4237 IN PDRIVER_OBJECT DriverObject,
4238 IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine,
4239 IN PVOID Context,
4240 OUT PVOID *NotificationEntry);
4241
4242 NTKERNELAPI
4243 NTSTATUS
4244 NTAPI
4245 IoRegisterShutdownNotification(
4246 IN PDEVICE_OBJECT DeviceObject);
4247
4248 NTKERNELAPI
4249 VOID
4250 NTAPI
4251 IoReleaseCancelSpinLock(
4252 IN KIRQL Irql);
4253
4254 NTKERNELAPI
4255 VOID
4256 NTAPI
4257 IoReleaseRemoveLockAndWaitEx(
4258 IN PIO_REMOVE_LOCK RemoveLock,
4259 IN PVOID Tag,
4260 IN ULONG RemlockSize);
4261
4262 NTKERNELAPI
4263 VOID
4264 NTAPI
4265 IoReleaseRemoveLockEx(
4266 IN PIO_REMOVE_LOCK RemoveLock,
4267 IN PVOID Tag,
4268 IN ULONG RemlockSize);
4269
4270 /*
4271 * VOID
4272 * IoReleaseRemoveLock(
4273 * IN PIO_REMOVE_LOCK RemoveLock,
4274 * IN PVOID Tag)
4275 */
4276 #define IoReleaseRemoveLock(_RemoveLock, \
4277 _Tag) \
4278 IoReleaseRemoveLockEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
4279
4280 /*
4281 * VOID
4282 * IoReleaseRemoveLockAndWait(
4283 * IN PIO_REMOVE_LOCK RemoveLock,
4284 * IN PVOID Tag)
4285 */
4286 #define IoReleaseRemoveLockAndWait(_RemoveLock, \
4287 _Tag) \
4288 IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
4289
4290 NTKERNELAPI
4291 VOID
4292 NTAPI
4293 IoRemoveShareAccess(
4294 IN PFILE_OBJECT FileObject,
4295 IN OUT PSHARE_ACCESS ShareAccess);
4296
4297 NTKERNELAPI
4298 NTSTATUS
4299 NTAPI
4300 IoReportDetectedDevice(
4301 IN PDRIVER_OBJECT DriverObject,
4302 IN INTERFACE_TYPE LegacyBusType,
4303 IN ULONG BusNumber,
4304 IN ULONG SlotNumber,
4305 IN PCM_RESOURCE_LIST ResourceList,
4306 IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL,
4307 IN BOOLEAN ResourceAssigned,
4308 IN OUT PDEVICE_OBJECT *DeviceObject);
4309
4310 NTKERNELAPI
4311 NTSTATUS
4312 NTAPI
4313 IoReportResourceForDetection(
4314 IN PDRIVER_OBJECT DriverObject,
4315 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
4316 IN ULONG DriverListSize OPTIONAL,
4317 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
4318 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
4319 IN ULONG DeviceListSize OPTIONAL,
4320 OUT PBOOLEAN ConflictDetected);
4321
4322 NTKERNELAPI
4323 NTSTATUS
4324 NTAPI
4325 IoReportResourceUsage(
4326 IN PUNICODE_STRING DriverClassName OPTIONAL,
4327 IN PDRIVER_OBJECT DriverObject,
4328 IN PCM_RESOURCE_LIST DriverList OPTIONAL,
4329 IN ULONG DriverListSize OPTIONAL,
4330 IN PDEVICE_OBJECT DeviceObject,
4331 IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
4332 IN ULONG DeviceListSize OPTIONAL,
4333 IN BOOLEAN OverrideConflict,
4334 OUT PBOOLEAN ConflictDetected);
4335
4336 NTKERNELAPI
4337 NTSTATUS
4338 NTAPI
4339 IoReportTargetDeviceChange(
4340 IN PDEVICE_OBJECT PhysicalDeviceObject,
4341 IN PVOID NotificationStructure);
4342
4343 NTKERNELAPI
4344 NTSTATUS
4345 NTAPI
4346 IoReportTargetDeviceChangeAsynchronous(
4347 IN PDEVICE_OBJECT PhysicalDeviceObject,
4348 IN PVOID NotificationStructure,
4349 IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL,
4350 IN PVOID Context OPTIONAL);
4351
4352 NTKERNELAPI
4353 VOID
4354 NTAPI
4355 IoRequestDeviceEject(
4356 IN PDEVICE_OBJECT PhysicalDeviceObject);
4357
4358 /*
4359 * VOID
4360 * IoRequestDpc(
4361 * IN PDEVICE_OBJECT DeviceObject,
4362 * IN PIRP Irp,
4363 * IN PVOID Context);
4364 */
4365 #define IoRequestDpc(DeviceObject, Irp, Context)( \
4366 KeInsertQueueDpc(&(DeviceObject)->Dpc, (Irp), (Context)))
4367
4368 NTKERNELAPI
4369 VOID
4370 NTAPI
4371 IoReuseIrp(
4372 IN OUT PIRP Irp,
4373 IN NTSTATUS Status);
4374
4375 /*
4376 * PDRIVER_CANCEL
4377 * IoSetCancelRoutine(
4378 * IN PIRP Irp,
4379 * IN PDRIVER_CANCEL CancelRoutine)
4380 */
4381 #define IoSetCancelRoutine(_Irp, \
4382 _CancelRoutine) \
4383 ((PDRIVER_CANCEL) InterlockedExchangePointer( \
4384 (PVOID *) &(_Irp)->CancelRoutine, (PVOID) (_CancelRoutine)))
4385
4386 /*
4387 * VOID
4388 * IoSetCompletionRoutine(
4389 * IN PIRP Irp,
4390 * IN PIO_COMPLETION_ROUTINE CompletionRoutine,
4391 * IN PVOID Context,
4392 * IN BOOLEAN InvokeOnSuccess,
4393 * IN BOOLEAN InvokeOnError,
4394 * IN BOOLEAN InvokeOnCancel)
4395 */
4396 #define IoSetCompletionRoutine(_Irp, \
4397 _CompletionRoutine, \
4398 _Context, \
4399 _InvokeOnSuccess, \
4400 _InvokeOnError, \
4401 _InvokeOnCancel) \
4402 { \
4403 PIO_STACK_LOCATION _IrpSp; \
4404 ASSERT((_InvokeOnSuccess) || (_InvokeOnError) || (_InvokeOnCancel) ? \
4405 (_CompletionRoutine) != NULL : TRUE); \
4406 _IrpSp = IoGetNextIrpStackLocation(_Irp); \
4407 _IrpSp->CompletionRoutine = (PIO_COMPLETION_ROUTINE)(_CompletionRoutine); \
4408 _IrpSp->Context = (_Context); \
4409 _IrpSp->Control = 0; \
4410 if (_InvokeOnSuccess) _IrpSp->Control = SL_INVOKE_ON_SUCCESS; \
4411 if (_InvokeOnError) _IrpSp->Control |= SL_INVOKE_ON_ERROR; \
4412 if (_InvokeOnCancel) _IrpSp->Control |= SL_INVOKE_ON_CANCEL; \
4413 }
4414
4415 NTKERNELAPI
4416 NTSTATUS
4417 NTAPI
4418 IoSetCompletionRoutineEx(
4419 IN PDEVICE_OBJECT DeviceObject,
4420 IN PIRP Irp,
4421 IN PIO_COMPLETION_ROUTINE CompletionRoutine,
4422 IN PVOID Context,
4423 IN BOOLEAN InvokeOnSuccess,
4424 IN BOOLEAN InvokeOnError,
4425 IN BOOLEAN InvokeOnCancel);
4426
4427 NTKERNELAPI
4428 NTSTATUS
4429 NTAPI
4430 IoSetDeviceInterfaceState(
4431 IN PUNICODE_STRING SymbolicLinkName,
4432 IN BOOLEAN Enable);
4433
4434 NTKERNELAPI
4435 VOID
4436 NTAPI
4437 IoSetHardErrorOrVerifyDevice(
4438 IN PIRP Irp,
4439 IN PDEVICE_OBJECT DeviceObject);
4440
4441 /*
4442 * VOID
4443 * IoSetNextIrpStackLocation(
4444 * IN OUT PIRP Irp)
4445 */
4446 #define IoSetNextIrpStackLocation(_Irp) \
4447 { \
4448 (_Irp)->CurrentLocation--; \
4449 (_Irp)->Tail.Overlay.CurrentStackLocation--; \
4450 }
4451
4452 NTKERNELAPI
4453 NTSTATUS
4454 FASTCALL
4455 IoSetPartitionInformation(
4456 IN PDEVICE_OBJECT DeviceObject,
4457 IN ULONG SectorSize,
4458 IN ULONG PartitionNumber,
4459 IN ULONG PartitionType);
4460
4461 NTKERNELAPI
4462 NTSTATUS
4463 NTAPI
4464 IoSetPartitionInformationEx(
4465 IN PDEVICE_OBJECT DeviceObject,
4466 IN ULONG PartitionNumber,
4467 IN struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
4468
4469 NTKERNELAPI
4470 VOID
4471 NTAPI
4472 IoSetShareAccess(
4473 IN ACCESS_MASK DesiredAccess,
4474 IN ULONG DesiredShareAccess,
4475 IN OUT PFILE_OBJECT FileObject,
4476 OUT PSHARE_ACCESS ShareAccess);
4477
4478 NTKERNELAPI
4479 VOID
4480 NTAPI
4481 IoSetStartIoAttributes(
4482 IN PDEVICE_OBJECT DeviceObject,
4483 IN BOOLEAN DeferredStartIo,
4484 IN BOOLEAN NonCancelable);
4485
4486 NTKERNELAPI
4487 NTSTATUS
4488 NTAPI
4489 IoSetSystemPartition(
4490 IN PUNICODE_STRING VolumeNameString);
4491
4492 NTKERNELAPI
4493 BOOLEAN
4494 NTAPI
4495 IoSetThreadHardErrorMode(
4496 IN BOOLEAN EnableHardErrors);
4497
4498 /*
4499 * USHORT
4500 * IoSizeOfIrp(
4501 * IN CCHAR StackSize)
4502 */
4503 #define IoSizeOfIrp(_StackSize) \
4504 ((USHORT) (sizeof(IRP) + ((_StackSize) * (sizeof(IO_STACK_LOCATION)))))
4505
4506 /*
4507 * VOID
4508 * IoSkipCurrentIrpStackLocation(
4509 * IN PIRP Irp)
4510 */
4511 #define IoSkipCurrentIrpStackLocation(_Irp) \
4512 { \
4513 (_Irp)->CurrentLocation++; \
4514 (_Irp)->Tail.Overlay.CurrentStackLocation++; \
4515 }
4516
4517 NTKERNELAPI
4518 VOID
4519 NTAPI
4520 IoStartNextPacket(
4521 IN PDEVICE_OBJECT DeviceObject,
4522 IN BOOLEAN Cancelable);
4523
4524 NTKERNELAPI
4525 VOID
4526 NTAPI
4527 IoStartNextPacketByKey(
4528 IN PDEVICE_OBJECT DeviceObject,
4529 IN BOOLEAN Cancelable,
4530 IN ULONG Key);
4531
4532 NTKERNELAPI
4533 VOID
4534 NTAPI
4535 IoStartPacket(
4536 IN PDEVICE_OBJECT DeviceObject,
4537 IN PIRP Irp,
4538 IN PULONG Key OPTIONAL,
4539 IN PDRIVER_CANCEL CancelFunction OPTIONAL);
4540
4541 NTKERNELAPI
4542 VOID
4543 NTAPI
4544 IoStartTimer(
4545 IN PDEVICE_OBJECT DeviceObject);
4546
4547 NTKERNELAPI
4548 VOID
4549 NTAPI
4550 IoStopTimer(
4551 IN PDEVICE_OBJECT DeviceObject);
4552
4553 NTKERNELAPI
4554 NTSTATUS
4555 NTAPI
4556 IoUnregisterPlugPlayNotification(
4557 IN PVOID NotificationEntry);
4558
4559 NTKERNELAPI
4560 VOID
4561 NTAPI
4562 IoUnregisterShutdownNotification(
4563 IN PDEVICE_OBJECT DeviceObject);
4564
4565 NTKERNELAPI
4566 VOID
4567 NTAPI
4568 IoUpdateShareAccess(
4569 IN PFILE_OBJECT FileObject,
4570 IN OUT PSHARE_ACCESS ShareAccess);
4571
4572 NTKERNELAPI
4573 NTSTATUS
4574 NTAPI
4575 IoVerifyPartitionTable(
4576 IN PDEVICE_OBJECT DeviceObject,
4577 IN BOOLEAN FixErrors);
4578
4579 NTKERNELAPI
4580 NTSTATUS
4581 NTAPI
4582 IoVolumeDeviceToDosName(
4583 IN PVOID VolumeDeviceObject,
4584 OUT PUNICODE_STRING DosName);
4585
4586 NTKERNELAPI
4587 NTSTATUS
4588 NTAPI
4589 IoWMIAllocateInstanceIds(
4590 IN GUID *Guid,
4591 IN ULONG InstanceCount,
4592 OUT ULONG *FirstInstanceId);
4593
4594 NTKERNELAPI
4595 ULONG
4596 NTAPI
4597 IoWMIDeviceObjectToProviderId(
4598 IN PDEVICE_OBJECT DeviceObject);
4599
4600 NTKERNELAPI
4601 NTSTATUS
4602 NTAPI
4603 IoWMIDeviceObjectToInstanceName(
4604 IN PVOID DataBlockObject,
4605 IN PDEVICE_OBJECT DeviceObject,
4606 OUT PUNICODE_STRING InstanceName);
4607
4608 NTKERNELAPI
4609 NTSTATUS
4610 NTAPI
4611 IoWMIExecuteMethod(
4612 IN PVOID DataBlockObject,
4613 IN PUNICODE_STRING InstanceName,
4614 IN ULONG MethodId,
4615 IN ULONG InBufferSize,
4616 IN OUT PULONG OutBufferSize,
4617 IN OUT PUCHAR InOutBuffer);
4618
4619 NTKERNELAPI
4620 NTSTATUS
4621 NTAPI
4622 IoWMIHandleToInstanceName(
4623 IN PVOID DataBlockObject,
4624 IN HANDLE FileHandle,
4625 OUT PUNICODE_STRING InstanceName);
4626
4627 NTKERNELAPI
4628 NTSTATUS
4629 NTAPI
4630 IoWMIOpenBlock(
4631 IN GUID *DataBlockGuid,
4632 IN ULONG DesiredAccess,
4633 OUT PVOID *DataBlockObject);
4634
4635 NTKERNELAPI
4636 NTSTATUS
4637 NTAPI
4638 IoWMIQueryAllData(
4639 IN PVOID DataBlockObject,
4640 IN OUT ULONG *InOutBufferSize,
4641 OUT PVOID OutBuffer);
4642
4643 NTKERNELAPI
4644 NTSTATUS
4645 NTAPI
4646 IoWMIQueryAllDataMultiple(
4647 IN PVOID *DataBlockObjectList,
4648 IN ULONG ObjectCount,
4649 IN OUT ULONG *InOutBufferSize,
4650 OUT PVOID OutBuffer);
4651
4652 NTKERNELAPI
4653 NTSTATUS
4654 NTAPI
4655 IoWMIQuerySingleInstance(
4656 IN PVOID DataBlockObject,
4657 IN PUNICODE_STRING InstanceName,
4658 IN OUT ULONG *InOutBufferSize,
4659 OUT PVOID OutBuffer);
4660
4661 NTKERNELAPI
4662 NTSTATUS
4663 NTAPI
4664 IoWMIQuerySingleInstanceMultiple(
4665 IN PVOID *DataBlockObjectList,
4666 IN PUNICODE_STRING InstanceNames,
4667 IN ULONG ObjectCount,
4668 IN OUT ULONG *InOutBufferSize,
4669 OUT PVOID OutBuffer);
4670
4671 NTKERNELAPI
4672 NTSTATUS
4673 NTAPI
4674 IoWMIRegistrationControl(
4675 IN PDEVICE_OBJECT DeviceObject,
4676 IN ULONG Action);
4677
4678 NTKERNELAPI
4679 NTSTATUS
4680 NTAPI
4681 IoWMISetNotificationCallback(
4682 IN PVOID Object,
4683 IN WMI_NOTIFICATION_CALLBACK Callback,
4684 IN PVOID Context);
4685
4686 NTKERNELAPI
4687 NTSTATUS
4688 NTAPI
4689 IoWMISetSingleInstance(
4690 IN PVOID DataBlockObject,
4691 IN PUNICODE_STRING InstanceName,
4692 IN ULONG Version,
4693 IN ULONG ValueBufferSize,
4694 IN PVOID ValueBuffer);
4695
4696 NTKERNELAPI
4697 NTSTATUS
4698 NTAPI
4699 IoWMISetSingleItem(
4700 IN PVOID DataBlockObject,
4701 IN PUNICODE_STRING InstanceName,
4702 IN ULONG DataItemId,
4703 IN ULONG Version,
4704 IN ULONG ValueBufferSize,
4705 IN PVOID ValueBuffer);
4706
4707 NTKERNELAPI
4708 NTSTATUS
4709 NTAPI
4710 IoWMISuggestInstanceName(
4711 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
4712 IN PUNICODE_STRING SymbolicLinkName OPTIONAL,
4713 IN BOOLEAN CombineNames,
4714 OUT PUNICODE_STRING SuggestedInstanceName);
4715
4716 NTKERNELAPI
4717 NTSTATUS
4718 NTAPI
4719 IoWMIWriteEvent(
4720 IN PVOID WnodeEventItem);
4721
4722 NTKERNELAPI
4723 VOID
4724 NTAPI
4725 IoWriteErrorLogEntry(
4726 IN PVOID ElEntry);
4727
4728 NTKERNELAPI
4729 NTSTATUS
4730 FASTCALL
4731 IoWritePartitionTable(
4732 IN PDEVICE_OBJECT DeviceObject,
4733 IN ULONG SectorSize,
4734 IN ULONG SectorsPerTrack,
4735 IN ULONG NumberOfHeads,
4736 IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
4737
4738 NTKERNELAPI
4739 NTSTATUS
4740 NTAPI
4741 IoWritePartitionTableEx(
4742 IN PDEVICE_OBJECT DeviceObject,
4743 IN struct _DRIVE_LAYOUT_INFORMATION_EX *PartitionBuffer);
4744
4745
4746
4747 /** Kernel routines **/
4748
4749 #if defined (_M_AMD64)
4750 NTKERNELAPI
4751 VOID
4752 FASTCALL
4753 KeAcquireInStackQueuedSpinLock(
4754 IN PKSPIN_LOCK SpinLock,
4755 IN PKLOCK_QUEUE_HANDLE LockHandle);
4756
4757 NTKERNELAPI
4758 VOID
4759 FASTCALL
4760 KeReleaseInStackQueuedSpinLock(
4761 IN PKLOCK_QUEUE_HANDLE LockHandle);
4762 #else
4763 NTHALAPI
4764 VOID
4765 FASTCALL
4766 KeAcquireInStackQueuedSpinLock(
4767 IN PKSPIN_LOCK SpinLock,
4768 IN PKLOCK_QUEUE_HANDLE LockHandle);
4769
4770 NTHALAPI
4771 VOID
4772 FASTCALL
4773 KeReleaseInStackQueuedSpinLock(
4774 IN PKLOCK_QUEUE_HANDLE LockHandle);
4775 #endif
4776
4777 NTKERNELAPI
4778 VOID
4779 FASTCALL
4780 KeAcquireInStackQueuedSpinLockAtDpcLevel(
4781 IN PKSPIN_LOCK SpinLock,
4782 IN PKLOCK_QUEUE_HANDLE LockHandle);
4783
4784 NTKERNELAPI
4785 KIRQL
4786 NTAPI
4787 KeAcquireInterruptSpinLock(
4788 IN PKINTERRUPT Interrupt);
4789
4790 NTKERNELAPI
4791 BOOLEAN
4792 NTAPI
4793 KeAreApcsDisabled(
4794 VOID);
4795
4796 NTKERNELAPI
4797 DECLSPEC_NORETURN
4798 VOID
4799 NTAPI
4800 KeBugCheck(
4801 IN ULONG BugCheckCode);
4802
4803 NTKERNELAPI
4804 DECLSPEC_NORETURN
4805 VOID
4806 NTAPI
4807 KeBugCheckEx(
4808 IN ULONG BugCheckCode,
4809 IN ULONG_PTR BugCheckParameter1,
4810 IN ULONG_PTR BugCheckParameter2,
4811 IN ULONG_PTR BugCheckParameter3,
4812 IN ULONG_PTR BugCheckParameter4);
4813
4814 NTKERNELAPI
4815 BOOLEAN
4816 NTAPI
4817 KeCancelTimer(
4818 IN PKTIMER Timer);
4819
4820 NTKERNELAPI
4821 VOID
4822 NTAPI
4823 KeClearEvent(
4824 IN PRKEVENT Event);
4825
4826 NTKERNELAPI
4827 NTSTATUS
4828 NTAPI
4829 KeDelayExecutionThread(
4830 IN KPROCESSOR_MODE WaitMode,
4831 IN BOOLEAN Alertable,
4832 IN PLARGE_INTEGER Interval);
4833
4834 NTKERNELAPI
4835 BOOLEAN
4836 NTAPI
4837 KeDeregisterBugCheckCallback(
4838 IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord);
4839
4840 NTKERNELAPI
4841 VOID
4842 NTAPI
4843 KeEnterCriticalRegion(
4844 VOID);
4845
4846 /*
4847 * VOID
4848 * KeFlushIoBuffers(
4849 * IN PMDL Mdl,
4850 * IN BOOLEAN ReadOperation,
4851 * IN BOOLEAN DmaOperation)
4852 */
4853 #define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
4854
4855 #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
4856 #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
4857 #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
4858 #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
4859
4860 NTKERNELAPI
4861 VOID
4862 NTAPI
4863 KeFlushQueuedDpcs(
4864 VOID
4865 );
4866
4867 NTHALAPI
4868 VOID
4869 NTAPI
4870 KeFlushWriteBuffer(VOID);
4871
4872 NTKERNELAPI
4873 ULONG
4874 NTAPI
4875 KeGetRecommendedSharedDataAlignment(
4876 VOID);
4877
4878 NTKERNELAPI
4879 VOID
4880 NTAPI
4881 KeInitializeDeviceQueue(
4882 IN PKDEVICE_QUEUE DeviceQueue);
4883
4884 NTKERNELAPI
4885 VOID
4886 NTAPI
4887 KeInitializeMutex(
4888 IN PRKMUTEX Mutex,
4889 IN ULONG Level);
4890
4891 NTKERNELAPI
4892 VOID
4893 NTAPI
4894 KeInitializeSemaphore(
4895 IN PRKSEMAPHORE Semaphore,
4896 IN LONG Count,
4897 IN LONG Limit