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