- Move MMFLUSH_TYPE enum from winddk.h to ntifs.h
[reactos.git] / include / ddk / winddk.h
1 /*
2 * winddk.h
3 *
4 * Windows Device Driver Kit
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23 #ifndef __WINDDK_H
24 #define __WINDDK_H
25
26 /* Helper macro to enable gcc's extension. */
27 #ifndef __GNU_EXTENSION
28 #ifdef __GNUC__
29 #define __GNU_EXTENSION __extension__
30 #else
31 #define __GNU_EXTENSION
32 #endif
33 #endif
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #include <excpt.h>
40 #include <ntdef.h>
41 #include <ntstatus.h>
42
43 #include "intrin.h"
44
45 /* Pseudo modifiers for parameters */
46 #ifndef IN
47 #define IN
48 #endif
49 #ifndef OUT
50 #define OUT
51 #endif
52 #ifndef OPTIONAL
53 #define OPTIONAL
54 #endif
55 #ifndef UNALLIGNED
56 #define UNALLIGNED
57 #endif
58
59 #define CONST const
60
61 #define RESTRICTED_POINTER
62
63 #define DECLSPEC_ADDRSAFE
64
65 #ifdef NONAMELESSUNION
66 # define _DDK_DUMMYUNION_MEMBER(name) DUMMYUNIONNAME.name
67 # define _DDK_DUMMYUNION_N_MEMBER(n, name) DUMMYUNIONNAME##n.name
68 #else
69 # define _DDK_DUMMYUNION_MEMBER(name) name
70 # define _DDK_DUMMYUNION_N_MEMBER(n, name) name
71 #endif
72
73 /*
74 ** Forward declarations
75 */
76
77 struct _KPCR;
78 struct _KPRCB;
79 struct _KTSS;
80 struct _DRIVE_LAYOUT_INFORMATION_EX;
81 struct _LOADER_PARAMETER_BLOCK;
82
83
84 #if 1
85 /* FIXME: Unknown definitions */
86 struct _SET_PARTITION_INFORMATION_EX;
87 typedef ULONG WAIT_TYPE;
88 #define WaitAll 0
89 #define WaitAny 1
90 typedef HANDLE TRACEHANDLE;
91 typedef PVOID PWMILIB_CONTEXT;
92 typedef ULONG LOGICAL;
93 #endif
94
95 /*
96 ** WmiLib specific structure
97 */
98 typedef enum
99 {
100 IrpProcessed, // Irp was processed and possibly completed
101 IrpNotCompleted, // Irp was process and NOT completed
102 IrpNotWmi, // Irp is not a WMI irp
103 IrpForward // Irp is wmi irp, but targeted at another device object
104 } SYSCTL_IRP_DISPOSITION, *PSYSCTL_IRP_DISPOSITION;
105
106 #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 BOOLEAN
3046 NTAPI
3047 MmFlushImageSection(
3048 IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
3049 IN MMFLUSH_TYPE FlushType);
3050
3051 NTKERNELAPI
3052 VOID
3053 NTAPI
3054 MmFreeNonCachedMemory(
3055 IN PVOID BaseAddress,
3056 IN SIZE_T NumberOfBytes);
3057
3058 NTKERNELAPI
3059 PHYSICAL_ADDRESS
3060 NTAPI
3061 MmGetPhysicalAddress(
3062 IN PVOID BaseAddress);
3063
3064 NTKERNELAPI
3065 PPHYSICAL_MEMORY_RANGE
3066 NTAPI
3067 MmGetPhysicalMemoryRanges(
3068 VOID);
3069
3070 NTKERNELAPI
3071 PVOID
3072 NTAPI
3073 MmGetVirtualForPhysical(
3074 IN PHYSICAL_ADDRESS PhysicalAddress);
3075
3076 NTKERNELAPI
3077 NTSTATUS
3078 NTAPI
3079 MmMapUserAddressesToPage(
3080 IN PVOID BaseAddress,
3081 IN SIZE_T NumberOfBytes,
3082 IN PVOID PageAddress);
3083
3084 NTKERNELAPI
3085 PVOID
3086 NTAPI
3087 MmMapVideoDisplay(
3088 IN PHYSICAL_ADDRESS PhysicalAddress,
3089 IN SIZE_T NumberOfBytes,
3090 IN MEMORY_CACHING_TYPE CacheType);
3091
3092 NTKERNELAPI
3093 NTSTATUS
3094 NTAPI
3095 MmMapViewInSessionSpace(
3096 IN PVOID Section,
3097 OUT PVOID *MappedBase,
3098 IN OUT PSIZE_T ViewSize);
3099
3100 NTKERNELAPI
3101 NTSTATUS
3102 NTAPI
3103 MmMapViewInSystemSpace(
3104 IN PVOID Section,
3105 OUT PVOID *MappedBase,
3106 IN PSIZE_T ViewSize);
3107
3108 NTKERNELAPI
3109 NTSTATUS
3110 NTAPI
3111 MmMarkPhysicalMemoryAsBad(
3112 IN PPHYSICAL_ADDRESS StartAddress,
3113 IN OUT PLARGE_INTEGER NumberOfBytes);
3114
3115 NTKERNELAPI
3116 NTSTATUS
3117 NTAPI
3118 MmMarkPhysicalMemoryAsGood(
3119 IN PPHYSICAL_ADDRESS StartAddress,
3120 IN OUT PLARGE_INTEGER NumberOfBytes);
3121
3122 /*
3123 * ULONG
3124 * ADDRESS_AND_SIZE_TO_SPAN_PAGES(
3125 * IN PVOID Va,
3126 * IN ULONG Size)
3127 */
3128 #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, \
3129 _Size) \
3130 ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
3131 + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
3132
3133 NTKERNELAPI
3134 BOOLEAN
3135 NTAPI
3136 MmIsAddressValid(
3137 IN PVOID VirtualAddress);
3138
3139 NTKERNELAPI
3140 BOOLEAN
3141 NTAPI
3142 MmIsThisAnNtAsSystem(
3143 VOID);
3144
3145 NTKERNELAPI
3146 PVOID
3147 NTAPI
3148 MmLockPagableImageSection(
3149 IN PVOID AddressWithinSection);
3150
3151 /*
3152 * PVOID
3153 * MmLockPagableCodeSection(
3154 * IN PVOID AddressWithinSection)
3155 */
3156 #define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
3157
3158 NTKERNELAPI
3159 VOID
3160 NTAPI
3161 MmLockPagableSectionByHandle(
3162 IN PVOID ImageSectionHandle);
3163
3164 NTKERNELAPI
3165 PVOID
3166 NTAPI
3167 MmLockPageableDataSection (
3168 IN PVOID AddressWithinSection
3169 );
3170
3171 NTKERNELAPI
3172 VOID
3173 NTAPI
3174 MmUnlockPageableImageSection(
3175 IN PVOID ImageSectionHandle
3176 );
3177
3178 NTKERNELAPI
3179 NTSTATUS
3180 NTAPI
3181 MmUnmapViewInSessionSpace(
3182 IN PVOID MappedBase);
3183
3184 NTKERNELAPI
3185 NTSTATUS
3186 NTAPI
3187 MmUnmapViewInSystemSpace(
3188 IN PVOID MappedBase);
3189
3190 NTKERNELAPI
3191 VOID
3192 NTAPI
3193 MmUnsecureVirtualMemory(
3194 IN HANDLE SecureHandle);
3195
3196 NTKERNELAPI
3197 NTSTATUS
3198 NTAPI
3199 MmRemovePhysicalMemory(
3200 IN PPHYSICAL_ADDRESS StartAddress,
3201 IN OUT PLARGE_INTEGER NumberOfBytes);
3202
3203 NTKERNELAPI
3204 HANDLE
3205 NTAPI
3206 MmSecureVirtualMemory(
3207 IN PVOID Address,
3208 IN SIZE_T Size,
3209 IN ULONG ProbeMode);
3210
3211 NTKERNELAPI
3212 VOID
3213 NTAPI
3214 MmUnmapVideoDisplay(
3215 IN PVOID BaseAddress,
3216 IN SIZE_T NumberOfBytes);
3217
3218 /** Object manager routines **/
3219
3220 NTKERNELAPI
3221 NTSTATUS
3222 NTAPI
3223 ObAssignSecurity(
3224 IN PACCESS_STATE AccessState,
3225 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
3226 IN PVOID Object,
3227 IN POBJECT_TYPE Type);
3228
3229 NTKERNELAPI
3230 VOID
3231 NTAPI
3232 ObDereferenceSecurityDescriptor(
3233 PSECURITY_DESCRIPTOR SecurityDescriptor,
3234 ULONG Count);
3235
3236 NTKERNELAPI
3237 NTSTATUS
3238 NTAPI
3239 ObLogSecurityDescriptor(
3240 IN PSECURITY_DESCRIPTOR InputSecurityDescriptor,
3241 OUT PSECURITY_DESCRIPTOR *OutputSecurityDescriptor,
3242 IN ULONG RefBias);
3243
3244 NTKERNELAPI
3245 NTSTATUS
3246 NTAPI
3247 ObOpenObjectByName(
3248 IN POBJECT_ATTRIBUTES ObjectAttributes,
3249 IN POBJECT_TYPE ObjectType,
3250 IN KPROCESSOR_MODE AccessMode,
3251 IN PACCESS_STATE PassedAccessState,
3252 IN ACCESS_MASK DesiredAccess,
3253 IN OUT PVOID ParseContext OPTIONAL,
3254 OUT PHANDLE Handle);
3255
3256 NTKERNELAPI
3257 NTSTATUS
3258 NTAPI
3259 ObReferenceObjectByName(
3260 IN PUNICODE_STRING ObjectPath,
3261 IN ULONG Attributes,
3262 IN PACCESS_STATE PassedAccessState OPTIONAL,
3263 IN ACCESS_MASK DesiredAccess OPTIONAL,
3264 IN POBJECT_TYPE ObjectType,
3265 IN KPROCESSOR_MODE AccessMode,
3266 IN OUT PVOID ParseContext OPTIONAL,
3267 OUT PVOID *Object);
3268
3269 NTKERNELAPI
3270 VOID
3271 NTAPI
3272 ObReferenceSecurityDescriptor(
3273 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
3274 IN ULONG Count);
3275
3276 /** Process manager routines **/
3277
3278 NTKERNELAPI
3279 NTSTATUS
3280 NTAPI
3281 PsCreateSystemProcess(
3282 IN PHANDLE ProcessHandle,
3283 IN ACCESS_MASK DesiredAccess,
3284 IN POBJECT_ATTRIBUTES ObjectAttributes);
3285
3286 NTKERNELAPI
3287 HANDLE
3288 NTAPI
3289 PsGetCurrentProcessId(
3290 VOID);
3291
3292 NTKERNELAPI
3293 HANDLE
3294 NTAPI
3295 PsGetCurrentThreadId(
3296 VOID);
3297
3298 NTKERNELAPI
3299 HANDLE
3300 NTAPI
3301 PsGetProcessId(PEPROCESS Process);
3302
3303 NTKERNELAPI
3304 BOOLEAN
3305 NTAPI
3306 PsGetVersion(
3307 PULONG MajorVersion OPTIONAL,
3308 PULONG MinorVersion OPTIONAL,
3309 PULONG BuildNumber OPTIONAL,
3310 PUNICODE_STRING CSDVersion OPTIONAL);
3311
3312 NTKERNELAPI
3313 NTSTATUS
3314 NTAPI
3315 PsRemoveCreateThreadNotifyRoutine(
3316 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3317
3318 NTKERNELAPI
3319 NTSTATUS
3320 NTAPI
3321 PsRemoveLoadImageNotifyRoutine(
3322 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3323
3324 NTKERNELAPI
3325 NTSTATUS
3326 NTAPI
3327 PsSetCreateProcessNotifyRoutine(
3328 IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
3329 IN BOOLEAN Remove);
3330
3331 NTKERNELAPI
3332 NTSTATUS
3333 NTAPI
3334 PsSetCreateThreadNotifyRoutine(
3335 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3336
3337 NTKERNELAPI
3338 NTSTATUS
3339 NTAPI
3340 PsSetLoadImageNotifyRoutine(
3341 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3342
3343 extern NTSYSAPI PEPROCESS PsInitialSystemProcess;
3344
3345 /** Security reference monitor routines **/
3346
3347 NTKERNELAPI
3348 BOOLEAN
3349 NTAPI
3350 SeSinglePrivilegeCheck(
3351 LUID PrivilegeValue,
3352 KPROCESSOR_MODE PreviousMode);
3353
3354 /** NtXxx and ZwXxx routines **/
3355
3356 NTSYSCALLAPI
3357 NTSTATUS
3358 NTAPI
3359 NtOpenProcess(
3360 OUT PHANDLE ProcessHandle,
3361 IN ACCESS_MASK DesiredAccess,
3362 IN POBJECT_ATTRIBUTES ObjectAttributes,
3363 IN PCLIENT_ID ClientId OPTIONAL);
3364
3365 NTSYSCALLAPI
3366 NTSTATUS
3367 NTAPI
3368 NtQueryInformationProcess(
3369 IN HANDLE ProcessHandle,
3370 IN PROCESSINFOCLASS ProcessInformationClass,
3371 OUT PVOID ProcessInformation,
3372 IN ULONG ProcessInformationLength,
3373 OUT PULONG ReturnLength OPTIONAL);
3374
3375 NTSYSAPI
3376 NTSTATUS
3377 NTAPI
3378 ZwCancelTimer(
3379 IN HANDLE TimerHandle,
3380 OUT PBOOLEAN CurrentState OPTIONAL);
3381
3382 NTSYSCALLAPI
3383 NTSTATUS
3384 NTAPI
3385 NtClose(
3386 IN HANDLE Handle);
3387
3388 NTSYSCALLAPI
3389 NTSTATUS
3390 NTAPI
3391 NtCreateEvent(
3392 OUT PHANDLE EventHandle,
3393 IN ACCESS_MASK DesiredAccess,
3394 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3395 IN EVENT_TYPE EventType,
3396 IN BOOLEAN InitialState);
3397
3398 NTSYSAPI
3399 NTSTATUS
3400 NTAPI
3401 ZwCreateEvent(
3402 OUT PHANDLE EventHandle,
3403 IN ACCESS_MASK DesiredAccess,
3404 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3405 IN EVENT_TYPE EventType,
3406 IN BOOLEAN InitialState);
3407
3408 NTSYSAPI
3409 NTSTATUS
3410 NTAPI
3411 ZwCreateTimer(
3412 OUT PHANDLE TimerHandle,
3413 IN ACCESS_MASK DesiredAccess,
3414 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3415 IN TIMER_TYPE TimerType);
3416
3417 NTSYSCALLAPI
3418 NTSTATUS
3419 NTAPI
3420 NtDeviceIoControlFile(
3421 IN HANDLE DeviceHandle,
3422 IN HANDLE Event OPTIONAL,
3423 IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
3424 IN PVOID UserApcContext OPTIONAL,
3425 OUT PIO_STATUS_BLOCK IoStatusBlock,
3426 IN ULONG IoControlCode,
3427 IN PVOID InputBuffer,
3428 IN ULONG InputBufferSize,
3429 OUT PVOID OutputBuffer,
3430 IN ULONG OutputBufferSize);
3431
3432 NTSYSCALLAPI
3433 NTSTATUS
3434 NTAPI
3435 NtMapViewOfSection(
3436 IN HANDLE SectionHandle,
3437 IN HANDLE ProcessHandle,
3438 IN OUT PVOID *BaseAddress,
3439 IN ULONG_PTR ZeroBits,
3440 IN SIZE_T CommitSize,
3441 IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
3442 IN OUT PSIZE_T ViewSize,
3443 IN SECTION_INHERIT InheritDisposition,
3444 IN ULONG AllocationType,
3445 IN ULONG Protect);
3446
3447 NTSYSCALLAPI
3448 NTSTATUS
3449 NTAPI
3450 NtOpenFile(
3451 OUT PHANDLE FileHandle,
3452 IN ACCESS_MASK DesiredAccess,
3453 IN POBJECT_ATTRIBUTES ObjectAttributes,
3454 OUT PIO_STATUS_BLOCK IoStatusBlock,
3455 IN ULONG ShareAccess,
3456 IN ULONG OpenOptions);
3457
3458
3459
3460 NTSYSAPI
3461 NTSTATUS
3462 NTAPI
3463 ZwOpenFile(
3464 OUT PHANDLE FileHandle,
3465 IN ACCESS_MASK DesiredAccess,
3466 IN POBJECT_ATTRIBUTES ObjectAttributes,
3467 OUT PIO_STATUS_BLOCK IoStatusBlock,
3468 IN ULONG ShareAccess,
3469 IN ULONG OpenOptions);
3470
3471 NTSYSAPI
3472 NTSTATUS
3473 NTAPI
3474 ZwOpenTimer(
3475 OUT PHANDLE TimerHandle,
3476 IN ACCESS_MASK DesiredAccess,
3477 IN POBJECT_ATTRIBUTES ObjectAttributes);
3478
3479 NTSYSCALLAPI
3480 NTSTATUS
3481 NTAPI
3482 NtReadFile(
3483 IN HANDLE FileHandle,
3484 IN HANDLE Event OPTIONAL,
3485 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
3486 IN PVOID ApcContext OPTIONAL,
3487 OUT PIO_STATUS_BLOCK IoStatusBlock,
3488 OUT PVOID Buffer,
3489 IN ULONG Length,
3490 IN PLARGE_INTEGER ByteOffset OPTIONAL,
3491 IN PULONG Key OPTIONAL);
3492
3493 NTSYSCALLAPI
3494 NTSTATUS
3495 NTAPI
3496 NtSetEvent(
3497 IN HANDLE EventHandle,
3498 OUT PLONG PreviousState OPTIONAL);
3499
3500 NTSYSAPI
3501 NTSTATUS
3502 NTAPI
3503 ZwSetEvent(
3504 IN HANDLE EventHandle,
3505 OUT PLONG PreviousState OPTIONAL);
3506
3507 NTSYSAPI
3508 NTSTATUS
3509 NTAPI
3510 ZwSetInformationThread(
3511 IN HANDLE ThreadHandle,
3512 IN THREADINFOCLASS ThreadInformationClass,
3513 IN PVOID ThreadInformation,
3514 IN ULONG ThreadInformationLength);
3515
3516 NTSYSAPI
3517 NTSTATUS
3518 NTAPI
3519 ZwSetTimer(
3520 IN HANDLE TimerHandle,
3521 IN PLARGE_INTEGER DueTime,
3522 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
3523 IN PVOID TimerContext OPTIONAL,
3524 IN BOOLEAN WakeTimer,
3525 IN LONG Period OPTIONAL,
3526 OUT PBOOLEAN PreviousState OPTIONAL);
3527
3528 /* [Nt|Zw]MapViewOfSection.InheritDisposition constants */
3529 #define AT_EXTENDABLE_FILE 0x00002000
3530 #define AT_RESERVED 0x20000000
3531 #define AT_ROUND_TO_PAGE 0x40000000
3532
3533 NTSYSCALLAPI
3534 NTSTATUS
3535 NTAPI
3536 NtUnmapViewOfSection(
3537 IN HANDLE ProcessHandle,
3538 IN PVOID BaseAddress);
3539
3540 NTSYSCALLAPI
3541 NTSTATUS
3542 NTAPI
3543 NtWaitForSingleObject(
3544 IN HANDLE ObjectHandle,
3545 IN BOOLEAN Alertable,
3546 IN PLARGE_INTEGER TimeOut OPTIONAL);
3547
3548 NTSYSCALLAPI
3549 NTSTATUS
3550 NTAPI
3551 NtWriteFile(
3552 IN HANDLE FileHandle,
3553 IN HANDLE Event OPTIONAL,
3554 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
3555 IN PVOID ApcContext OPTIONAL,
3556 OUT PIO_STATUS_BLOCK IoStatusBlock,
3557 IN PVOID Buffer,
3558 IN ULONG Length,
3559 IN PLARGE_INTEGER ByteOffset OPTIONAL,
3560 IN PULONG Key OPTIONAL);
3561
3562 /** Power management support routines **/
3563
3564 NTKERNELAPI
3565 NTSTATUS
3566 NTAPI
3567 PoRequestShutdownEvent(
3568 OUT PVOID *Event);
3569
3570 /** WMI library support routines **/
3571
3572 NTSTATUS
3573 NTAPI
3574 WmiCompleteRequest(
3575 IN PDEVICE_OBJECT DeviceObject,
3576 IN PIRP Irp,
3577 IN NTSTATUS Status,
3578 IN ULONG BufferUsed,
3579 IN CCHAR PriorityBoost);
3580
3581 NTSTATUS
3582 NTAPI
3583 WmiFireEvent(
3584 IN PDEVICE_OBJECT DeviceObject,
3585 IN LPGUID Guid,
3586 IN ULONG InstanceIndex,
3587 IN ULONG EventDataSize,
3588 IN PVOID EventData);
3589
3590 NTSTATUS
3591 NTAPI
3592 WmiSystemControl(
3593 IN PWMILIB_CONTEXT WmiLibInfo,
3594 IN PDEVICE_OBJECT DeviceObject,
3595 IN PIRP Irp,
3596 OUT PSYSCTL_IRP_DISPOSITION IrpDisposition);
3597
3598 /** Kernel debugger routines **/
3599
3600 ULONG
3601 NTAPI
3602 DbgPrompt(
3603 IN PCCH Prompt,
3604 OUT PCH Response,
3605 IN ULONG MaximumResponseLength
3606 );
3607
3608 /** Stuff from winnt4.h */
3609
3610 NTKERNELAPI
3611 NTSTATUS
3612 NTAPI
3613 IoAssignResources(
3614 IN PUNICODE_STRING RegistryPath,
3615 IN PUNICODE_STRING DriverClassName OPTIONAL,
3616 IN PDRIVER_OBJECT DriverObject,
3617 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
3618 IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
3619 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3620
3621 NTKERNELAPI
3622 NTSTATUS
3623 NTAPI
3624 IoAttachDeviceByPointer(
3625 IN PDEVICE_OBJECT SourceDevice,
3626 IN PDEVICE_OBJECT TargetDevice);
3627
3628 NTKERNELAPI
3629 BOOLEAN
3630 NTAPI
3631 MmIsNonPagedSystemAddressValid(
3632 IN PVOID VirtualAddress);
3633
3634 #if defined(_AMD64_) || defined(_IA64_)
3635 //DECLSPEC_DEPRECATED_DDK_WINXP
3636 static __inline
3637 LARGE_INTEGER
3638 NTAPI_INLINE
3639 RtlLargeIntegerDivide(
3640 IN LARGE_INTEGER Dividend,
3641 IN LARGE_INTEGER Divisor,
3642 IN OUT PLARGE_INTEGER Remainder)
3643 {
3644 LARGE_INTEGER ret;
3645 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
3646 if (Remainder)
3647 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
3648 return ret;
3649 }
3650 #else
3651 NTSYSAPI
3652 LARGE_INTEGER
3653 NTAPI
3654 RtlLargeIntegerDivide(
3655 IN LARGE_INTEGER Dividend,
3656 IN LARGE_INTEGER Divisor,
3657 IN OUT PLARGE_INTEGER Remainder);
3658 #endif
3659
3660 NTKERNELAPI
3661 INTERLOCKED_RESULT
3662 NTAPI
3663 ExInterlockedDecrementLong(
3664 IN PLONG Addend,
3665 IN PKSPIN_LOCK Lock);
3666
3667 NTKERNELAPI
3668 ULONG
3669 NTAPI
3670 ExInterlockedExchangeUlong(
3671 IN PULONG Target,
3672 IN ULONG Value,
3673 IN PKSPIN_LOCK Lock);
3674
3675 NTKERNELAPI
3676 INTERLOCKED_RESULT
3677 NTAPI
3678 ExInterlockedIncrementLong(
3679 IN PLONG Addend,
3680 IN PKSPIN_LOCK Lock);
3681
3682 NTHALAPI
3683 VOID
3684 NTAPI
3685 HalAcquireDisplayOwnership(
3686 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
3687
3688 NTHALAPI
3689 NTSTATUS
3690 NTAPI
3691 HalAllocateAdapterChannel(
3692 IN PADAPTER_OBJECT AdapterObject,
3693 IN PWAIT_CONTEXT_BLOCK Wcb,
3694 IN ULONG NumberOfMapRegisters,
3695 IN PDRIVER_CONTROL ExecutionRoutine);
3696
3697 NTHALAPI
3698 NTSTATUS
3699 NTAPI
3700 HalAssignSlotResources(
3701 IN PUNICODE_STRING RegistryPath,
3702 IN PUNICODE_STRING DriverClassName,
3703 IN PDRIVER_OBJECT DriverObject,
3704 IN PDEVICE_OBJECT DeviceObject,
3705 IN INTERFACE_TYPE BusType,
3706 IN ULONG BusNumber,
3707 IN ULONG SlotNumber,
3708 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3709
3710 NTHALAPI
3711 PADAPTER_OBJECT
3712 NTAPI
3713 HalGetAdapter(
3714 IN PDEVICE_DESCRIPTION DeviceDescription,
3715 IN OUT PULONG NumberOfMapRegisters);
3716
3717 NTHALAPI
3718 ULONG
3719 NTAPI
3720 HalGetBusData(
3721 IN BUS_DATA_TYPE BusDataType,
3722 IN ULONG BusNumber,
3723 IN ULONG SlotNumber,
3724 IN PVOID Buffer,
3725 IN ULONG Length);
3726
3727 NTHALAPI
3728 ULONG
3729 NTAPI
3730 HalGetBusDataByOffset(
3731 IN BUS_DATA_TYPE BusDataType,
3732 IN ULONG BusNumber,
3733 IN ULONG SlotNumber,
3734 IN PVOID Buffer,
3735 IN ULONG Offset,
3736 IN ULONG Length);
3737
3738 NTHALAPI
3739 ULONG
3740 NTAPI
3741 HalGetDmaAlignmentRequirement(
3742 VOID);
3743
3744 NTHALAPI
3745 ULONG
3746 NTAPI
3747 HalGetInterruptVector(
3748 IN INTERFACE_TYPE InterfaceType,
3749 IN ULONG BusNumber,
3750 IN ULONG BusInterruptLevel,
3751 IN ULONG BusInterruptVector,
3752 OUT PKIRQL Irql,
3753 OUT PKAFFINITY Affinity);
3754
3755 NTHALAPI
3756 ULONG
3757 NTAPI
3758 HalSetBusData(
3759 IN BUS_DATA_TYPE BusDataType,
3760 IN ULONG BusNumber,
3761 IN ULONG SlotNumber,
3762 IN PVOID Buffer,
3763 IN ULONG Length);
3764
3765 NTHALAPI
3766 ULONG
3767 NTAPI
3768 HalSetBusDataByOffset(
3769 IN BUS_DATA_TYPE BusDataType,
3770 IN ULONG BusNumber,
3771 IN ULONG SlotNumber,
3772 IN PVOID Buffer,
3773 IN ULONG Offset,
3774 IN ULONG Length);
3775
3776 NTHALAPI
3777 BOOLEAN
3778 NTAPI
3779 HalTranslateBusAddress(
3780 IN INTERFACE_TYPE InterfaceType,
3781 IN ULONG BusNumber,
3782 IN PHYSICAL_ADDRESS BusAddress,
3783 IN OUT PULONG AddressSpace,
3784 OUT PPHYSICAL_ADDRESS TranslatedAddress);
3785
3786 NTSYSAPI
3787 BOOLEAN
3788 NTAPI
3789 RtlLargeIntegerEqualToZero(
3790 IN LARGE_INTEGER Operand);
3791
3792 NTSYSAPI
3793 BOOLEAN
3794 NTAPI
3795 RtlLargeIntegerGreaterOrEqualToZero(
3796 IN LARGE_INTEGER Operand);
3797
3798 NTSYSAPI
3799 BOOLEAN
3800 NTAPI
3801 RtlLargeIntegerGreaterThan(
3802 IN LARGE_INTEGER Operand1,
3803 IN LARGE_INTEGER Operand2);
3804
3805 NTSYSAPI
3806 BOOLEAN
3807 NTAPI
3808 RtlLargeIntegerGreaterThanOrEqualTo(
3809 IN LARGE_INTEGER Operand1,
3810 IN LARGE_INTEGER Operand2);
3811
3812 NTSYSAPI
3813 BOOLEAN
3814 NTAPI
3815 RtlLargeIntegerGreaterThanZero(
3816 IN LARGE_INTEGER Operand);
3817
3818 NTSYSAPI
3819 BOOLEAN
3820 NTAPI
3821 RtlLargeIntegerLessOrEqualToZero(
3822 IN LARGE_INTEGER Operand);
3823
3824 NTSYSAPI
3825 BOOLEAN
3826 NTAPI
3827 RtlLargeIntegerLessThan(
3828 IN LARGE_INTEGER Operand1,
3829 IN LARGE_INTEGER Operand2);
3830
3831 NTSYSAPI
3832 BOOLEAN
3833 NTAPI
3834 RtlLargeIntegerLessThanOrEqualTo(
3835 IN LARGE_INTEGER Operand1,
3836 IN LARGE_INTEGER Operand2);
3837
3838 NTSYSAPI
3839 BOOLEAN
3840 NTAPI
3841 RtlLargeIntegerLessThanZero(
3842 IN LARGE_INTEGER Operand);
3843
3844 NTSYSAPI
3845 LARGE_INTEGER
3846 NTAPI
3847 RtlLargeIntegerNegate(
3848 IN LARGE_INTEGER Subtrahend);
3849
3850 NTSYSAPI
3851 BOOLEAN
3852 NTAPI
3853 RtlLargeIntegerNotEqualTo(
3854 IN LARGE_INTEGER Operand1,
3855 IN LARGE_INTEGER Operand2);
3856
3857 NTSYSAPI
3858 BOOLEAN
3859 NTAPI
3860 RtlLargeIntegerNotEqualToZero(
3861 IN LARGE_INTEGER Operand);
3862
3863 NTSYSAPI
3864 LARGE_INTEGER
3865 NTAPI
3866 RtlLargeIntegerShiftLeft(
3867 IN LARGE_INTEGER LargeInteger,
3868 IN CCHAR ShiftCount);
3869
3870 NTSYSAPI
3871 LARGE_INTEGER
3872 NTAPI
3873 RtlLargeIntegerShiftRight(
3874 IN LARGE_INTEGER LargeInteger,
3875 IN CCHAR ShiftCount);
3876
3877 NTSYSAPI
3878 LARGE_INTEGER
3879 NTAPI
3880 RtlLargeIntegerSubtract(
3881 IN LARGE_INTEGER Minuend,
3882 IN LARGE_INTEGER Subtrahend);
3883
3884
3885 /*
3886 * ULONG
3887 * COMPUTE_PAGES_SPANNED(
3888 * IN PVOID Va,
3889 * IN ULONG Size)
3890 */
3891 #define COMPUTE_PAGES_SPANNED(Va, \
3892 Size) \
3893 (ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va, Size))
3894
3895
3896 /*
3897 ** Architecture specific structures
3898 */
3899
3900 #ifdef _X86_
3901
3902 NTKERNELAPI
3903 INTERLOCKED_RESULT
3904 FASTCALL
3905 Exfi386InterlockedIncrementLong(
3906 IN PLONG Addend);
3907
3908 NTKERNELAPI
3909 INTERLOCKED_RESULT
3910 FASTCALL
3911 Exfi386InterlockedDecrementLong(
3912 IN PLONG Addend);
3913
3914 NTKERNELAPI
3915 ULONG
3916 FASTCALL
3917 Exfi386InterlockedExchangeUlong(
3918 IN PULONG Target,
3919 IN ULONG Value);
3920
3921 #endif /* _X86_ */
3922
3923 #ifdef _M_ARM
3924 //
3925 // NT-ARM is not documented
3926 //
3927 #include <armddk.h>
3928 #endif
3929
3930 #ifdef __cplusplus
3931 }
3932 #endif
3933
3934 #endif /* __WINDDK_H */