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