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