ffe2c0877e21efd9b77855ef3e7b511ea4ae94f2
[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 typedef enum _MMFLUSH_TYPE {
3045 MmFlushForDelete,
3046 MmFlushForWrite
3047 } MMFLUSH_TYPE;
3048
3049 NTKERNELAPI
3050 BOOLEAN
3051 NTAPI
3052 MmFlushImageSection(
3053 IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
3054 IN MMFLUSH_TYPE FlushType);
3055
3056 NTKERNELAPI
3057 VOID
3058 NTAPI
3059 MmFreeNonCachedMemory(
3060 IN PVOID BaseAddress,
3061 IN SIZE_T NumberOfBytes);
3062
3063 NTKERNELAPI
3064 PHYSICAL_ADDRESS
3065 NTAPI
3066 MmGetPhysicalAddress(
3067 IN PVOID BaseAddress);
3068
3069 NTKERNELAPI
3070 PPHYSICAL_MEMORY_RANGE
3071 NTAPI
3072 MmGetPhysicalMemoryRanges(
3073 VOID);
3074
3075 NTKERNELAPI
3076 PVOID
3077 NTAPI
3078 MmGetVirtualForPhysical(
3079 IN PHYSICAL_ADDRESS PhysicalAddress);
3080
3081 NTKERNELAPI
3082 NTSTATUS
3083 NTAPI
3084 MmMapUserAddressesToPage(
3085 IN PVOID BaseAddress,
3086 IN SIZE_T NumberOfBytes,
3087 IN PVOID PageAddress);
3088
3089 NTKERNELAPI
3090 PVOID
3091 NTAPI
3092 MmMapVideoDisplay(
3093 IN PHYSICAL_ADDRESS PhysicalAddress,
3094 IN SIZE_T NumberOfBytes,
3095 IN MEMORY_CACHING_TYPE CacheType);
3096
3097 NTKERNELAPI
3098 NTSTATUS
3099 NTAPI
3100 MmMapViewInSessionSpace(
3101 IN PVOID Section,
3102 OUT PVOID *MappedBase,
3103 IN OUT PSIZE_T ViewSize);
3104
3105 NTKERNELAPI
3106 NTSTATUS
3107 NTAPI
3108 MmMapViewInSystemSpace(
3109 IN PVOID Section,
3110 OUT PVOID *MappedBase,
3111 IN PSIZE_T ViewSize);
3112
3113 NTKERNELAPI
3114 NTSTATUS
3115 NTAPI
3116 MmMarkPhysicalMemoryAsBad(
3117 IN PPHYSICAL_ADDRESS StartAddress,
3118 IN OUT PLARGE_INTEGER NumberOfBytes);
3119
3120 NTKERNELAPI
3121 NTSTATUS
3122 NTAPI
3123 MmMarkPhysicalMemoryAsGood(
3124 IN PPHYSICAL_ADDRESS StartAddress,
3125 IN OUT PLARGE_INTEGER NumberOfBytes);
3126
3127 /*
3128 * ULONG
3129 * ADDRESS_AND_SIZE_TO_SPAN_PAGES(
3130 * IN PVOID Va,
3131 * IN ULONG Size)
3132 */
3133 #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, \
3134 _Size) \
3135 ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
3136 + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
3137
3138 NTKERNELAPI
3139 BOOLEAN
3140 NTAPI
3141 MmIsAddressValid(
3142 IN PVOID VirtualAddress);
3143
3144 NTKERNELAPI
3145 BOOLEAN
3146 NTAPI
3147 MmIsThisAnNtAsSystem(
3148 VOID);
3149
3150 NTKERNELAPI
3151 PVOID
3152 NTAPI
3153 MmLockPagableImageSection(
3154 IN PVOID AddressWithinSection);
3155
3156 /*
3157 * PVOID
3158 * MmLockPagableCodeSection(
3159 * IN PVOID AddressWithinSection)
3160 */
3161 #define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
3162
3163 NTKERNELAPI
3164 VOID
3165 NTAPI
3166 MmLockPagableSectionByHandle(
3167 IN PVOID ImageSectionHandle);
3168
3169 NTKERNELAPI
3170 PVOID
3171 NTAPI
3172 MmLockPageableDataSection (
3173 IN PVOID AddressWithinSection
3174 );
3175
3176 NTKERNELAPI
3177 VOID
3178 NTAPI
3179 MmUnlockPageableImageSection(
3180 IN PVOID ImageSectionHandle
3181 );
3182
3183 NTKERNELAPI
3184 NTSTATUS
3185 NTAPI
3186 MmUnmapViewInSessionSpace(
3187 IN PVOID MappedBase);
3188
3189 NTKERNELAPI
3190 NTSTATUS
3191 NTAPI
3192 MmUnmapViewInSystemSpace(
3193 IN PVOID MappedBase);
3194
3195 NTKERNELAPI
3196 VOID
3197 NTAPI
3198 MmUnsecureVirtualMemory(
3199 IN HANDLE SecureHandle);
3200
3201 NTKERNELAPI
3202 NTSTATUS
3203 NTAPI
3204 MmRemovePhysicalMemory(
3205 IN PPHYSICAL_ADDRESS StartAddress,
3206 IN OUT PLARGE_INTEGER NumberOfBytes);
3207
3208 NTKERNELAPI
3209 HANDLE
3210 NTAPI
3211 MmSecureVirtualMemory(
3212 IN PVOID Address,
3213 IN SIZE_T Size,
3214 IN ULONG ProbeMode);
3215
3216 NTKERNELAPI
3217 VOID
3218 NTAPI
3219 MmUnmapVideoDisplay(
3220 IN PVOID BaseAddress,
3221 IN SIZE_T NumberOfBytes);
3222
3223 /** Object manager routines **/
3224
3225 NTKERNELAPI
3226 NTSTATUS
3227 NTAPI
3228 ObAssignSecurity(
3229 IN PACCESS_STATE AccessState,
3230 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
3231 IN PVOID Object,
3232 IN POBJECT_TYPE Type);
3233
3234 NTKERNELAPI
3235 VOID
3236 NTAPI
3237 ObDereferenceSecurityDescriptor(
3238 PSECURITY_DESCRIPTOR SecurityDescriptor,
3239 ULONG Count);
3240
3241 NTKERNELAPI
3242 NTSTATUS
3243 NTAPI
3244 ObInsertObject(
3245 IN PVOID Object,
3246 IN PACCESS_STATE PassedAccessState OPTIONAL,
3247 IN ACCESS_MASK DesiredAccess,
3248 IN ULONG AdditionalReferences,
3249 OUT PVOID* ReferencedObject OPTIONAL,
3250 OUT PHANDLE Handle);
3251
3252 NTKERNELAPI
3253 NTSTATUS
3254 NTAPI
3255 ObLogSecurityDescriptor(
3256 IN PSECURITY_DESCRIPTOR InputSecurityDescriptor,
3257 OUT PSECURITY_DESCRIPTOR *OutputSecurityDescriptor,
3258 IN ULONG RefBias);
3259
3260 NTKERNELAPI
3261 VOID
3262 NTAPI
3263 ObMakeTemporaryObject(
3264 IN PVOID Object);
3265
3266 NTKERNELAPI
3267 NTSTATUS
3268 NTAPI
3269 ObOpenObjectByName(
3270 IN POBJECT_ATTRIBUTES ObjectAttributes,
3271 IN POBJECT_TYPE ObjectType,
3272 IN KPROCESSOR_MODE AccessMode,
3273 IN PACCESS_STATE PassedAccessState,
3274 IN ACCESS_MASK DesiredAccess,
3275 IN OUT PVOID ParseContext OPTIONAL,
3276 OUT PHANDLE Handle);
3277
3278 NTKERNELAPI
3279 NTSTATUS
3280 NTAPI
3281 ObOpenObjectByPointer(
3282 IN PVOID Object,
3283 IN ULONG HandleAttributes,
3284 IN PACCESS_STATE PassedAccessState OPTIONAL,
3285 IN ACCESS_MASK DesiredAccess OPTIONAL,
3286 IN POBJECT_TYPE ObjectType OPTIONAL,
3287 IN KPROCESSOR_MODE AccessMode,
3288 OUT PHANDLE Handle);
3289
3290 NTKERNELAPI
3291 NTSTATUS
3292 NTAPI
3293 ObQueryObjectAuditingByHandle(
3294 IN HANDLE Handle,
3295 OUT PBOOLEAN GenerateOnClose);
3296
3297 NTKERNELAPI
3298 NTSTATUS
3299 NTAPI
3300 ObReferenceObjectByName(
3301 IN PUNICODE_STRING ObjectPath,
3302 IN ULONG Attributes,
3303 IN PACCESS_STATE PassedAccessState OPTIONAL,
3304 IN ACCESS_MASK DesiredAccess OPTIONAL,
3305 IN POBJECT_TYPE ObjectType,
3306 IN KPROCESSOR_MODE AccessMode,
3307 IN OUT PVOID ParseContext OPTIONAL,
3308 OUT PVOID *Object);
3309
3310 NTKERNELAPI
3311 VOID
3312 NTAPI
3313 ObReferenceSecurityDescriptor(
3314 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
3315 IN ULONG Count);
3316
3317 /** Process manager routines **/
3318
3319 NTKERNELAPI
3320 NTSTATUS
3321 NTAPI
3322 PsCreateSystemProcess(
3323 IN PHANDLE ProcessHandle,
3324 IN ACCESS_MASK DesiredAccess,
3325 IN POBJECT_ATTRIBUTES ObjectAttributes);
3326
3327 NTKERNELAPI
3328 HANDLE
3329 NTAPI
3330 PsGetCurrentProcessId(
3331 VOID);
3332
3333 NTKERNELAPI
3334 HANDLE
3335 NTAPI
3336 PsGetCurrentThreadId(
3337 VOID);
3338
3339 NTKERNELAPI
3340 HANDLE
3341 NTAPI
3342 PsGetProcessId(PEPROCESS Process);
3343
3344 NTKERNELAPI
3345 BOOLEAN
3346 NTAPI
3347 PsGetVersion(
3348 PULONG MajorVersion OPTIONAL,
3349 PULONG MinorVersion OPTIONAL,
3350 PULONG BuildNumber OPTIONAL,
3351 PUNICODE_STRING CSDVersion OPTIONAL);
3352
3353 NTKERNELAPI
3354 NTSTATUS
3355 NTAPI
3356 PsRemoveCreateThreadNotifyRoutine(
3357 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3358
3359 NTKERNELAPI
3360 NTSTATUS
3361 NTAPI
3362 PsRemoveLoadImageNotifyRoutine(
3363 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3364
3365 NTKERNELAPI
3366 NTSTATUS
3367 NTAPI
3368 PsSetCreateProcessNotifyRoutine(
3369 IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine,
3370 IN BOOLEAN Remove);
3371
3372 NTKERNELAPI
3373 NTSTATUS
3374 NTAPI
3375 PsSetCreateThreadNotifyRoutine(
3376 IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine);
3377
3378 NTKERNELAPI
3379 NTSTATUS
3380 NTAPI
3381 PsSetLoadImageNotifyRoutine(
3382 IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine);
3383
3384 extern NTSYSAPI PEPROCESS PsInitialSystemProcess;
3385
3386 /** Security reference monitor routines **/
3387
3388 NTKERNELAPI
3389 BOOLEAN
3390 NTAPI
3391 SeSinglePrivilegeCheck(
3392 LUID PrivilegeValue,
3393 KPROCESSOR_MODE PreviousMode);
3394
3395 /** NtXxx and ZwXxx routines **/
3396
3397 NTSYSCALLAPI
3398 NTSTATUS
3399 NTAPI
3400 NtOpenProcess(
3401 OUT PHANDLE ProcessHandle,
3402 IN ACCESS_MASK DesiredAccess,
3403 IN POBJECT_ATTRIBUTES ObjectAttributes,
3404 IN PCLIENT_ID ClientId OPTIONAL);
3405
3406 NTSYSCALLAPI
3407 NTSTATUS
3408 NTAPI
3409 NtQueryInformationProcess(
3410 IN HANDLE ProcessHandle,
3411 IN PROCESSINFOCLASS ProcessInformationClass,
3412 OUT PVOID ProcessInformation,
3413 IN ULONG ProcessInformationLength,
3414 OUT PULONG ReturnLength OPTIONAL);
3415
3416 NTSYSAPI
3417 NTSTATUS
3418 NTAPI
3419 ZwCancelTimer(
3420 IN HANDLE TimerHandle,
3421 OUT PBOOLEAN CurrentState OPTIONAL);
3422
3423 NTSYSCALLAPI
3424 NTSTATUS
3425 NTAPI
3426 NtClose(
3427 IN HANDLE Handle);
3428
3429 NTSYSCALLAPI
3430 NTSTATUS
3431 NTAPI
3432 NtCreateEvent(
3433 OUT PHANDLE EventHandle,
3434 IN ACCESS_MASK DesiredAccess,
3435 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3436 IN EVENT_TYPE EventType,
3437 IN BOOLEAN InitialState);
3438
3439 NTSYSAPI
3440 NTSTATUS
3441 NTAPI
3442 ZwCreateEvent(
3443 OUT PHANDLE EventHandle,
3444 IN ACCESS_MASK DesiredAccess,
3445 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3446 IN EVENT_TYPE EventType,
3447 IN BOOLEAN InitialState);
3448
3449 NTSYSAPI
3450 NTSTATUS
3451 NTAPI
3452 ZwCreateTimer(
3453 OUT PHANDLE TimerHandle,
3454 IN ACCESS_MASK DesiredAccess,
3455 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
3456 IN TIMER_TYPE TimerType);
3457
3458 NTSYSCALLAPI
3459 NTSTATUS
3460 NTAPI
3461 NtDeviceIoControlFile(
3462 IN HANDLE DeviceHandle,
3463 IN HANDLE Event OPTIONAL,
3464 IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
3465 IN PVOID UserApcContext OPTIONAL,
3466 OUT PIO_STATUS_BLOCK IoStatusBlock,
3467 IN ULONG IoControlCode,
3468 IN PVOID InputBuffer,
3469 IN ULONG InputBufferSize,
3470 OUT PVOID OutputBuffer,
3471 IN ULONG OutputBufferSize);
3472
3473 NTSYSAPI
3474 NTSTATUS
3475 NTAPI
3476 ZwDeviceIoControlFile(
3477 IN HANDLE DeviceHandle,
3478 IN HANDLE Event OPTIONAL,
3479 IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
3480 IN PVOID UserApcContext OPTIONAL,
3481 OUT PIO_STATUS_BLOCK IoStatusBlock,
3482 IN ULONG IoControlCode,
3483 IN PVOID InputBuffer,
3484 IN ULONG InputBufferSize,
3485 OUT PVOID OutputBuffer,
3486 IN ULONG OutputBufferSize);
3487
3488 NTSYSCALLAPI
3489 NTSTATUS
3490 NTAPI
3491 NtMapViewOfSection(
3492 IN HANDLE SectionHandle,
3493 IN HANDLE ProcessHandle,
3494 IN OUT PVOID *BaseAddress,
3495 IN ULONG_PTR ZeroBits,
3496 IN SIZE_T CommitSize,
3497 IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
3498 IN OUT PSIZE_T ViewSize,
3499 IN SECTION_INHERIT InheritDisposition,
3500 IN ULONG AllocationType,
3501 IN ULONG Protect);
3502
3503 NTSYSCALLAPI
3504 NTSTATUS
3505 NTAPI
3506 NtOpenFile(
3507 OUT PHANDLE FileHandle,
3508 IN ACCESS_MASK DesiredAccess,
3509 IN POBJECT_ATTRIBUTES ObjectAttributes,
3510 OUT PIO_STATUS_BLOCK IoStatusBlock,
3511 IN ULONG ShareAccess,
3512 IN ULONG OpenOptions);
3513
3514
3515
3516 NTSYSAPI
3517 NTSTATUS
3518 NTAPI
3519 ZwOpenFile(
3520 OUT PHANDLE FileHandle,
3521 IN ACCESS_MASK DesiredAccess,
3522 IN POBJECT_ATTRIBUTES ObjectAttributes,
3523 OUT PIO_STATUS_BLOCK IoStatusBlock,
3524 IN ULONG ShareAccess,
3525 IN ULONG OpenOptions);
3526
3527 NTSYSAPI
3528 NTSTATUS
3529 NTAPI
3530 ZwOpenTimer(
3531 OUT PHANDLE TimerHandle,
3532 IN ACCESS_MASK DesiredAccess,
3533 IN POBJECT_ATTRIBUTES ObjectAttributes);
3534
3535 NTSYSCALLAPI
3536 NTSTATUS
3537 NTAPI
3538 NtReadFile(
3539 IN HANDLE FileHandle,
3540 IN HANDLE Event OPTIONAL,
3541 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
3542 IN PVOID ApcContext OPTIONAL,
3543 OUT PIO_STATUS_BLOCK IoStatusBlock,
3544 OUT PVOID Buffer,
3545 IN ULONG Length,
3546 IN PLARGE_INTEGER ByteOffset OPTIONAL,
3547 IN PULONG Key OPTIONAL);
3548
3549 NTSYSCALLAPI
3550 NTSTATUS
3551 NTAPI
3552 NtSetEvent(
3553 IN HANDLE EventHandle,
3554 OUT PLONG PreviousState OPTIONAL);
3555
3556 NTSYSAPI
3557 NTSTATUS
3558 NTAPI
3559 ZwSetEvent(
3560 IN HANDLE EventHandle,
3561 OUT PLONG PreviousState OPTIONAL);
3562
3563 NTSYSAPI
3564 NTSTATUS
3565 NTAPI
3566 ZwSetInformationThread(
3567 IN HANDLE ThreadHandle,
3568 IN THREADINFOCLASS ThreadInformationClass,
3569 IN PVOID ThreadInformation,
3570 IN ULONG ThreadInformationLength);
3571
3572 NTSYSAPI
3573 NTSTATUS
3574 NTAPI
3575 ZwSetTimer(
3576 IN HANDLE TimerHandle,
3577 IN PLARGE_INTEGER DueTime,
3578 IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
3579 IN PVOID TimerContext OPTIONAL,
3580 IN BOOLEAN WakeTimer,
3581 IN LONG Period OPTIONAL,
3582 OUT PBOOLEAN PreviousState OPTIONAL);
3583
3584 /* [Nt|Zw]MapViewOfSection.InheritDisposition constants */
3585 #define AT_EXTENDABLE_FILE 0x00002000
3586 #define AT_RESERVED 0x20000000
3587 #define AT_ROUND_TO_PAGE 0x40000000
3588
3589 NTSYSCALLAPI
3590 NTSTATUS
3591 NTAPI
3592 NtUnmapViewOfSection(
3593 IN HANDLE ProcessHandle,
3594 IN PVOID BaseAddress);
3595
3596 NTSYSCALLAPI
3597 NTSTATUS
3598 NTAPI
3599 NtWaitForSingleObject(
3600 IN HANDLE ObjectHandle,
3601 IN BOOLEAN Alertable,
3602 IN PLARGE_INTEGER TimeOut OPTIONAL);
3603
3604 NTSYSAPI
3605 NTSTATUS
3606 NTAPI
3607 ZwWaitForSingleObject(
3608 IN HANDLE ObjectHandle,
3609 IN BOOLEAN Alertable,
3610 IN PLARGE_INTEGER TimeOut OPTIONAL);
3611
3612 NTSYSCALLAPI
3613 NTSTATUS
3614 NTAPI
3615 NtWriteFile(
3616 IN HANDLE FileHandle,
3617 IN HANDLE Event OPTIONAL,
3618 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
3619 IN PVOID ApcContext OPTIONAL,
3620 OUT PIO_STATUS_BLOCK IoStatusBlock,
3621 IN PVOID Buffer,
3622 IN ULONG Length,
3623 IN PLARGE_INTEGER ByteOffset OPTIONAL,
3624 IN PULONG Key OPTIONAL);
3625
3626 /** Power management support routines **/
3627
3628 NTKERNELAPI
3629 NTSTATUS
3630 NTAPI
3631 PoRequestShutdownEvent(
3632 OUT PVOID *Event);
3633
3634 /** WMI library support routines **/
3635
3636 NTSTATUS
3637 NTAPI
3638 WmiCompleteRequest(
3639 IN PDEVICE_OBJECT DeviceObject,
3640 IN PIRP Irp,
3641 IN NTSTATUS Status,
3642 IN ULONG BufferUsed,
3643 IN CCHAR PriorityBoost);
3644
3645 NTSTATUS
3646 NTAPI
3647 WmiFireEvent(
3648 IN PDEVICE_OBJECT DeviceObject,
3649 IN LPGUID Guid,
3650 IN ULONG InstanceIndex,
3651 IN ULONG EventDataSize,
3652 IN PVOID EventData);
3653
3654 NTSTATUS
3655 NTAPI
3656 WmiSystemControl(
3657 IN PWMILIB_CONTEXT WmiLibInfo,
3658 IN PDEVICE_OBJECT DeviceObject,
3659 IN PIRP Irp,
3660 OUT PSYSCTL_IRP_DISPOSITION IrpDisposition);
3661
3662 /** Kernel debugger routines **/
3663
3664 ULONG
3665 NTAPI
3666 DbgPrompt(
3667 IN PCCH Prompt,
3668 OUT PCH Response,
3669 IN ULONG MaximumResponseLength
3670 );
3671
3672 /** Stuff from winnt4.h */
3673
3674 NTKERNELAPI
3675 NTSTATUS
3676 NTAPI
3677 IoAssignResources(
3678 IN PUNICODE_STRING RegistryPath,
3679 IN PUNICODE_STRING DriverClassName OPTIONAL,
3680 IN PDRIVER_OBJECT DriverObject,
3681 IN PDEVICE_OBJECT DeviceObject OPTIONAL,
3682 IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
3683 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3684
3685 NTKERNELAPI
3686 NTSTATUS
3687 NTAPI
3688 IoAttachDeviceByPointer(
3689 IN PDEVICE_OBJECT SourceDevice,
3690 IN PDEVICE_OBJECT TargetDevice);
3691
3692 NTKERNELAPI
3693 BOOLEAN
3694 NTAPI
3695 MmIsNonPagedSystemAddressValid(
3696 IN PVOID VirtualAddress);
3697
3698 #if defined(_AMD64_) || defined(_IA64_)
3699 //DECLSPEC_DEPRECATED_DDK_WINXP
3700 static __inline
3701 LARGE_INTEGER
3702 NTAPI_INLINE
3703 RtlLargeIntegerDivide(
3704 IN LARGE_INTEGER Dividend,
3705 IN LARGE_INTEGER Divisor,
3706 IN OUT PLARGE_INTEGER Remainder)
3707 {
3708 LARGE_INTEGER ret;
3709 ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
3710 if (Remainder)
3711 Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart;
3712 return ret;
3713 }
3714 #else
3715 NTSYSAPI
3716 LARGE_INTEGER
3717 NTAPI
3718 RtlLargeIntegerDivide(
3719 IN LARGE_INTEGER Dividend,
3720 IN LARGE_INTEGER Divisor,
3721 IN OUT PLARGE_INTEGER Remainder);
3722 #endif
3723
3724 NTKERNELAPI
3725 INTERLOCKED_RESULT
3726 NTAPI
3727 ExInterlockedDecrementLong(
3728 IN PLONG Addend,
3729 IN PKSPIN_LOCK Lock);
3730
3731 NTKERNELAPI
3732 ULONG
3733 NTAPI
3734 ExInterlockedExchangeUlong(
3735 IN PULONG Target,
3736 IN ULONG Value,
3737 IN PKSPIN_LOCK Lock);
3738
3739 NTKERNELAPI
3740 INTERLOCKED_RESULT
3741 NTAPI
3742 ExInterlockedIncrementLong(
3743 IN PLONG Addend,
3744 IN PKSPIN_LOCK Lock);
3745
3746 NTHALAPI
3747 VOID
3748 NTAPI
3749 HalAcquireDisplayOwnership(
3750 IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
3751
3752 NTHALAPI
3753 NTSTATUS
3754 NTAPI
3755 HalAllocateAdapterChannel(
3756 IN PADAPTER_OBJECT AdapterObject,
3757 IN PWAIT_CONTEXT_BLOCK Wcb,
3758 IN ULONG NumberOfMapRegisters,
3759 IN PDRIVER_CONTROL ExecutionRoutine);
3760
3761 NTHALAPI
3762 PVOID
3763 NTAPI
3764 HalAllocateCommonBuffer(
3765 IN PADAPTER_OBJECT AdapterObject,
3766 IN ULONG Length,
3767 OUT PPHYSICAL_ADDRESS LogicalAddress,
3768 IN BOOLEAN CacheEnabled);
3769
3770 NTHALAPI
3771 NTSTATUS
3772 NTAPI
3773 HalAssignSlotResources(
3774 IN PUNICODE_STRING RegistryPath,
3775 IN PUNICODE_STRING DriverClassName,
3776 IN PDRIVER_OBJECT DriverObject,
3777 IN PDEVICE_OBJECT DeviceObject,
3778 IN INTERFACE_TYPE BusType,
3779 IN ULONG BusNumber,
3780 IN ULONG SlotNumber,
3781 IN OUT PCM_RESOURCE_LIST *AllocatedResources);
3782
3783 NTHALAPI
3784 VOID
3785 NTAPI
3786 HalFreeCommonBuffer(
3787 IN PADAPTER_OBJECT AdapterObject,
3788 IN ULONG Length,
3789 IN PHYSICAL_ADDRESS LogicalAddress,
3790 IN PVOID VirtualAddress,
3791 IN BOOLEAN CacheEnabled);
3792
3793 NTHALAPI
3794 PADAPTER_OBJECT
3795 NTAPI
3796 HalGetAdapter(
3797 IN PDEVICE_DESCRIPTION DeviceDescription,
3798 IN OUT PULONG NumberOfMapRegisters);
3799
3800 NTHALAPI
3801 ULONG
3802 NTAPI
3803 HalGetBusData(
3804 IN BUS_DATA_TYPE BusDataType,
3805 IN ULONG BusNumber,
3806 IN ULONG SlotNumber,
3807 IN PVOID Buffer,
3808 IN ULONG Length);
3809
3810 NTHALAPI
3811 ULONG
3812 NTAPI
3813 HalGetBusDataByOffset(
3814 IN BUS_DATA_TYPE BusDataType,
3815 IN ULONG BusNumber,
3816 IN ULONG SlotNumber,
3817 IN PVOID Buffer,
3818 IN ULONG Offset,
3819 IN ULONG Length);
3820
3821 NTHALAPI
3822 ULONG
3823 NTAPI
3824 HalGetDmaAlignmentRequirement(
3825 VOID);
3826
3827 NTHALAPI
3828 ULONG
3829 NTAPI
3830 HalGetInterruptVector(
3831 IN INTERFACE_TYPE InterfaceType,
3832 IN ULONG BusNumber,
3833 IN ULONG BusInterruptLevel,
3834 IN ULONG BusInterruptVector,
3835 OUT PKIRQL Irql,
3836 OUT PKAFFINITY Affinity);
3837
3838 NTHALAPI
3839 ULONG
3840 NTAPI
3841 HalReadDmaCounter(
3842 IN PADAPTER_OBJECT AdapterObject);
3843
3844 NTHALAPI
3845 ULONG
3846 NTAPI
3847 HalSetBusData(
3848 IN BUS_DATA_TYPE BusDataType,
3849 IN ULONG BusNumber,
3850 IN ULONG SlotNumber,
3851 IN PVOID Buffer,
3852 IN ULONG Length);
3853
3854 NTHALAPI
3855 ULONG
3856 NTAPI
3857 HalSetBusDataByOffset(
3858 IN BUS_DATA_TYPE BusDataType,
3859 IN ULONG BusNumber,
3860 IN ULONG SlotNumber,
3861 IN PVOID Buffer,
3862 IN ULONG Offset,
3863 IN ULONG Length);
3864
3865 NTHALAPI
3866 BOOLEAN
3867 NTAPI
3868 HalTranslateBusAddress(
3869 IN INTERFACE_TYPE InterfaceType,
3870 IN ULONG BusNumber,
3871 IN PHYSICAL_ADDRESS BusAddress,
3872 IN OUT PULONG AddressSpace,
3873 OUT PPHYSICAL_ADDRESS TranslatedAddress);
3874
3875 NTSYSAPI
3876 BOOLEAN
3877 NTAPI
3878 RtlLargeIntegerEqualToZero(
3879 IN LARGE_INTEGER Operand);
3880
3881 NTSYSAPI
3882 BOOLEAN
3883 NTAPI
3884 RtlLargeIntegerGreaterOrEqualToZero(
3885 IN LARGE_INTEGER Operand);
3886
3887 NTSYSAPI
3888 BOOLEAN
3889 NTAPI
3890 RtlLargeIntegerGreaterThan(
3891 IN LARGE_INTEGER Operand1,
3892 IN LARGE_INTEGER Operand2);
3893
3894 NTSYSAPI
3895 BOOLEAN
3896 NTAPI
3897 RtlLargeIntegerGreaterThanOrEqualTo(
3898 IN LARGE_INTEGER Operand1,
3899 IN LARGE_INTEGER Operand2);
3900
3901 NTSYSAPI
3902 BOOLEAN
3903 NTAPI
3904 RtlLargeIntegerGreaterThanZero(
3905 IN LARGE_INTEGER Operand);
3906
3907 NTSYSAPI
3908 BOOLEAN
3909 NTAPI
3910 RtlLargeIntegerLessOrEqualToZero(
3911 IN LARGE_INTEGER Operand);
3912
3913 NTSYSAPI
3914 BOOLEAN
3915 NTAPI
3916 RtlLargeIntegerLessThan(
3917 IN LARGE_INTEGER Operand1,
3918 IN LARGE_INTEGER Operand2);
3919
3920 NTSYSAPI
3921 BOOLEAN
3922 NTAPI
3923 RtlLargeIntegerLessThanOrEqualTo(
3924 IN LARGE_INTEGER Operand1,
3925 IN LARGE_INTEGER Operand2);
3926
3927 NTSYSAPI
3928 BOOLEAN
3929 NTAPI
3930 RtlLargeIntegerLessThanZero(
3931 IN LARGE_INTEGER Operand);
3932
3933 NTSYSAPI
3934 LARGE_INTEGER
3935 NTAPI
3936 RtlLargeIntegerNegate(
3937 IN LARGE_INTEGER Subtrahend);
3938
3939 NTSYSAPI
3940 BOOLEAN
3941 NTAPI
3942 RtlLargeIntegerNotEqualTo(
3943 IN LARGE_INTEGER Operand1,
3944 IN LARGE_INTEGER Operand2);
3945
3946 NTSYSAPI
3947 BOOLEAN
3948 NTAPI
3949 RtlLargeIntegerNotEqualToZero(
3950 IN LARGE_INTEGER Operand);
3951
3952 NTSYSAPI
3953 LARGE_INTEGER
3954 NTAPI
3955 RtlLargeIntegerShiftLeft(
3956 IN LARGE_INTEGER LargeInteger,
3957 IN CCHAR ShiftCount);
3958
3959 NTSYSAPI
3960 LARGE_INTEGER
3961 NTAPI
3962 RtlLargeIntegerShiftRight(
3963 IN LARGE_INTEGER LargeInteger,
3964 IN CCHAR ShiftCount);
3965
3966 NTSYSAPI
3967 LARGE_INTEGER
3968 NTAPI
3969 RtlLargeIntegerSubtract(
3970 IN LARGE_INTEGER Minuend,
3971 IN LARGE_INTEGER Subtrahend);
3972
3973
3974 /*
3975 * ULONG
3976 * COMPUTE_PAGES_SPANNED(
3977 * IN PVOID Va,
3978 * IN ULONG Size)
3979 */
3980 #define COMPUTE_PAGES_SPANNED(Va, \
3981 Size) \
3982 (ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va, Size))
3983
3984
3985 /*
3986 ** Architecture specific structures
3987 */
3988
3989 #ifdef _X86_
3990
3991 NTKERNELAPI
3992 INTERLOCKED_RESULT
3993 FASTCALL
3994 Exfi386InterlockedIncrementLong(
3995 IN PLONG Addend);
3996
3997 NTKERNELAPI
3998 INTERLOCKED_RESULT
3999 FASTCALL
4000 Exfi386InterlockedDecrementLong(
4001 IN PLONG Addend);
4002
4003 NTKERNELAPI
4004 ULONG
4005 FASTCALL
4006 Exfi386InterlockedExchangeUlong(
4007 IN PULONG Target,
4008 IN ULONG Value);
4009
4010 #endif /* _X86_ */
4011
4012 #ifdef _M_ARM
4013 //
4014 // NT-ARM is not documented
4015 //
4016 #include <armddk.h>
4017 #endif
4018
4019 #ifdef __cplusplus
4020 }
4021 #endif
4022
4023 #endif /* __WINDDK_H */