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