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