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