1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
9 #include "staticcontract.h"
13 // This file is the result of some changes to the SDK header files.
14 // In particular, nt.h and some of its dependencies are no longer
15 // available except as "nonship" files. As a result, this file
16 // was created as a simple cut and past of structures and functions
17 // from NT that are either not yet documented or have been overlooked
18 // as being part of the platform SDK.
25 #define STATUS_INVALID_PARAMETER_3 ((NTSTATUS)0xC00000F1L)
26 #define STATUS_INVALID_PARAMETER_4 ((NTSTATUS)0xC00000F2L)
27 #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L)
28 #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
31 #define STATUS_UNWIND ((NTSTATUS)0x80000027L)
34 #ifndef DBG_PRINTEXCEPTION_C
35 #define DBG_PRINTEXCEPTION_C ((DWORD)0x40010006L)
38 #ifndef STATUS_UNWIND_CONSOLIDATE
39 #define STATUS_UNWIND_CONSOLIDATE ((NTSTATUS)0x80000029L)
42 #ifndef STATUS_LONGJUMP
43 #define STATUS_LONGJUMP ((NTSTATUS)0x80000026L)
46 #ifndef LOCALE_NAME_MAX_LENGTH
47 #define LOCALE_NAME_MAX_LENGTH 85
48 #endif // !LOCALE_NAME_MAX_LENGTH
50 #ifndef SUBLANG_CUSTOM_DEFAULT
51 #define SUBLANG_CUSTOM_DEFAULT 0x03 // default custom language/locale
52 #define SUBLANG_CUSTOM_UNSPECIFIED 0x04 // custom language/locale
53 #define LOCALE_CUSTOM_DEFAULT \
54 (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_DEFAULT), SORT_DEFAULT))
55 #define LOCALE_CUSTOM_UNSPECIFIED \
56 (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED), SORT_DEFAULT))
57 #endif // !SUBLANG_CUSTOM_DEFAULT
59 #ifndef __out_xcount_opt
60 #define __out_xcount_opt(var) __out
63 #ifndef __encoded_pointer
64 #define __encoded_pointer
68 #define __range(min, man)
71 #ifndef __field_bcount
72 #define __field_bcount(size)
75 #ifndef __field_ecount_opt
76 #define __field_ecount_opt(nFields)
79 #ifndef __field_ecount
80 #define __field_ecount(EHCount)
84 #define _Ret_bytecap_(_Size)
87 #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
90 #define ARGUMENT_PRESENT(ArgumentPointer) (\
91 (CHAR *)(ArgumentPointer) != (CHAR *)(NULL) )
93 #define EXCEPTION_CHAIN_END ((PEXCEPTION_REGISTRATION_RECORD)-1)
95 typedef signed char SCHAR;
96 typedef SCHAR *PSCHAR;
97 typedef LONG NTSTATUS;
101 #define TLS_MINIMUM_AVAILABLE 64 // winnt
102 #define TLS_EXPANSION_SLOTS 1024
104 typedef enum _THREADINFOCLASS {
105 ThreadBasicInformation,
110 ThreadImpersonationToken,
111 ThreadDescriptorTableEntry,
112 ThreadEnableAlignmentFaultFixup,
113 ThreadEventPair_Reusable,
114 ThreadQuerySetWin32StartAddress,
116 ThreadPerformanceCount,
118 ThreadIdealProcessor,
120 ThreadSetTlsArrayAddress,
122 ThreadHideFromDebugger,
123 ThreadBreakOnTermination,
127 typedef enum _SYSTEM_INFORMATION_CLASS {
128 SystemBasicInformation,
129 SystemProcessorInformation, // obsolete...delete
130 SystemPerformanceInformation,
131 SystemTimeOfDayInformation,
132 SystemPathInformation,
133 SystemProcessInformation,
134 SystemCallCountInformation,
135 SystemDeviceInformation,
136 SystemProcessorPerformanceInformation,
137 SystemFlagsInformation,
138 SystemCallTimeInformation,
139 SystemModuleInformation,
140 SystemLocksInformation,
141 SystemStackTraceInformation,
142 SystemPagedPoolInformation,
143 SystemNonPagedPoolInformation,
144 SystemHandleInformation,
145 SystemObjectInformation,
146 SystemPageFileInformation,
147 SystemVdmInstemulInformation,
148 SystemVdmBopInformation,
149 SystemFileCacheInformation,
150 SystemPoolTagInformation,
151 SystemInterruptInformation,
152 SystemDpcBehaviorInformation,
153 SystemFullMemoryInformation,
154 SystemLoadGdiDriverInformation,
155 SystemUnloadGdiDriverInformation,
156 SystemTimeAdjustmentInformation,
157 SystemSummaryMemoryInformation,
158 SystemMirrorMemoryInformation,
159 SystemPerformanceTraceInformation,
161 SystemExceptionInformation,
162 SystemCrashDumpStateInformation,
163 SystemKernelDebuggerInformation,
164 SystemContextSwitchInformation,
165 SystemRegistryQuotaInformation,
166 SystemExtendServiceTableInformation,
167 SystemPrioritySeperation,
168 SystemVerifierAddDriverInformation,
169 SystemVerifierRemoveDriverInformation,
170 SystemProcessorIdleInformation,
171 SystemLegacyDriverInformation,
172 SystemCurrentTimeZoneInformation,
173 SystemLookasideInformation,
174 SystemTimeSlipNotification,
177 SystemSessionInformation,
178 SystemRangeStartInformation,
179 SystemVerifierInformation,
180 SystemVerifierThunkExtend,
181 SystemSessionProcessInformation,
182 SystemLoadGdiDriverInSystemSpace,
183 SystemNumaProcessorMap,
184 SystemPrefetcherInformation,
185 SystemExtendedProcessInformation,
186 SystemRecommendedSharedDataAlignment,
187 SystemComPlusPackage,
188 SystemNumaAvailableMemory,
189 SystemProcessorPowerInformation,
190 SystemEmulationBasicInformation,
191 SystemEmulationProcessorInformation,
192 SystemExtendedHandleInformation,
193 SystemLostDelayedWriteInformation
194 } SYSTEM_INFORMATION_CLASS;
196 typedef enum _EVENT_INFORMATION_CLASS {
197 EventBasicInformation
198 } EVENT_INFORMATION_CLASS;
200 typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
201 LARGE_INTEGER IdleTime;
202 LARGE_INTEGER KernelTime;
203 LARGE_INTEGER UserTime;
204 LARGE_INTEGER DpcTime; // DEVL only
205 LARGE_INTEGER InterruptTime; // DEVL only
206 ULONG InterruptCount;
207 } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
209 typedef enum _EVENT_TYPE {
214 typedef struct _EVENT_BASIC_INFORMATION {
215 EVENT_TYPE EventType;
217 } EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION;
219 #define RTL_MEG (1024UL * 1024UL)
220 #define RTLP_IMAGE_MAX_DOS_HEADER ( 256UL * RTL_MEG)
222 typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION {
223 BOOLEAN KernelDebuggerEnabled;
224 BOOLEAN KernelDebuggerNotPresent;
225 } SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION;
227 typedef struct _STRING {
229 USHORT MaximumLength;
231 [size_is(MaximumLength), length_is(Length) ]
235 typedef STRING *PSTRING;
237 typedef STRING ANSI_STRING;
238 typedef PSTRING PANSI_STRING;
240 typedef STRING OEM_STRING;
241 typedef PSTRING POEM_STRING;
242 typedef CONST STRING* PCOEM_STRING;
244 typedef struct _UNICODE_STRING {
246 USHORT MaximumLength;
248 [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
253 typedef UNICODE_STRING *PUNICODE_STRING;
254 typedef const UNICODE_STRING *PCUNICODE_STRING;
255 #define UNICODE_NULL ((WCHAR)0) // winnt
257 typedef struct _STRING32 {
259 USHORT MaximumLength;
262 typedef STRING32 *PSTRING32;
264 typedef STRING32 UNICODE_STRING32;
265 typedef UNICODE_STRING32 *PUNICODE_STRING32;
267 typedef STRING32 ANSI_STRING32;
268 typedef ANSI_STRING32 *PANSI_STRING32;
271 typedef struct _STRING64 {
273 USHORT MaximumLength;
276 typedef STRING64 *PSTRING64;
278 typedef STRING64 UNICODE_STRING64;
279 typedef UNICODE_STRING64 *PUNICODE_STRING64;
281 typedef STRING64 ANSI_STRING64;
282 typedef ANSI_STRING64 *PANSI_STRING64;
284 #define GDI_HANDLE_BUFFER_SIZE32 34
285 #define GDI_HANDLE_BUFFER_SIZE64 60
287 #if !defined(_TARGET_AMD64_)
288 #define GDI_HANDLE_BUFFER_SIZE GDI_HANDLE_BUFFER_SIZE32
290 #define GDI_HANDLE_BUFFER_SIZE GDI_HANDLE_BUFFER_SIZE64
293 typedef ULONG GDI_HANDLE_BUFFER32[GDI_HANDLE_BUFFER_SIZE32];
294 typedef ULONG GDI_HANDLE_BUFFER64[GDI_HANDLE_BUFFER_SIZE64];
295 typedef ULONG GDI_HANDLE_BUFFER [GDI_HANDLE_BUFFER_SIZE ];
298 typedef struct _PEB_LDR_DATA {
302 LIST_ENTRY InLoadOrderModuleList;
303 LIST_ENTRY InMemoryOrderModuleList;
304 LIST_ENTRY InInitializationOrderModuleList;
305 PVOID EntryInProgress;
306 } PEB_LDR_DATA, *PPEB_LDR_DATA;
308 typedef struct _PEB_FREE_BLOCK {
309 struct _PEB_FREE_BLOCK *Next;
311 } PEB_FREE_BLOCK, *PPEB_FREE_BLOCK;
313 typedef PVOID* PPVOID;
317 (*PPS_POST_PROCESS_INIT_ROUTINE) (
321 typedef struct _LDR_DATA_TABLE_ENTRY {
322 LIST_ENTRY InLoadOrderLinks;
323 LIST_ENTRY InMemoryOrderLinks;
324 LIST_ENTRY InInitializationOrderLinks;
328 UNICODE_STRING FullDllName;
329 UNICODE_STRING BaseDllName;
334 LIST_ENTRY HashLinks;
336 PVOID SectionPointer;
348 PVOID EntryPointActivationContext;
349 } LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
351 #define TYPE3(arg) arg
353 typedef struct _PEB {
354 BOOLEAN InheritedAddressSpace; // These four fields cannot change unless the
355 BOOLEAN ReadImageFileExecOptions; //
356 BOOLEAN BeingDebugged; //
357 BOOLEAN SpareBool; //
358 HANDLE Mutant; // INITIAL_PEB structure is also updated.
360 PVOID ImageBaseAddress;
362 TYPE3(struct _RTL_USER_PROCESS_PARAMETERS*) ProcessParameters;
365 TYPE3(struct _RTL_CRITICAL_SECTION*) FastPebLock;
366 PVOID FastPebLockRoutine;
367 PVOID FastPebUnlockRoutine;
368 ULONG EnvironmentUpdateCount;
369 PVOID KernelCallbackTable;
370 ULONG SystemReserved[1];
373 ULONG ExecuteOptions : 2;
374 ULONG SpareBits : 30;
378 PPEB_FREE_BLOCK FreeList;
379 ULONG TlsExpansionCounter;
381 ULONG TlsBitmapBits[2]; // TLS_MINIMUM_AVAILABLE bits
382 PVOID ReadOnlySharedMemoryBase;
383 PVOID ReadOnlySharedMemoryHeap;
384 PPVOID ReadOnlyStaticServerData;
385 PVOID AnsiCodePageData;
386 PVOID OemCodePageData;
387 PVOID UnicodeCaseTableData;
390 // Useful information for LdrpInitialize
391 ULONG NumberOfProcessors;
395 // Passed up from MmCreatePeb from Session Manager registry key
398 LARGE_INTEGER CriticalSectionTimeout;
399 SIZE_T HeapSegmentReserve;
400 SIZE_T HeapSegmentCommit;
401 SIZE_T HeapDeCommitTotalFreeThreshold;
402 SIZE_T HeapDeCommitFreeBlockThreshold;
405 // Where heap manager keeps track of all heaps created for a process
406 // Fields initialized by MmCreatePeb. ProcessHeaps is initialized
407 // to point to the first free byte after the PEB and MaximumNumberOfHeaps
408 // is computed from the page size used to hold the PEB, less the fixed
409 // size of this data structure.
413 ULONG MaximumNumberOfHeaps;
418 PVOID GdiSharedHandleTable;
419 PVOID ProcessStarterHelper;
420 ULONG GdiDCAttributeList;
424 // Following fields filled in by MmCreatePeb from system values and/or
428 ULONG OSMajorVersion;
429 ULONG OSMinorVersion;
430 USHORT OSBuildNumber;
433 ULONG ImageSubsystem;
434 ULONG ImageSubsystemMajorVersion;
435 ULONG ImageSubsystemMinorVersion;
436 ULONG_PTR ImageProcessAffinityMask;
437 GDI_HANDLE_BUFFER GdiHandleBuffer;
438 PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine;
440 PVOID TlsExpansionBitmap;
441 ULONG TlsExpansionBitmapBits[32]; // TLS_EXPANSION_SLOTS bits
444 // Id of the Hydra session in which this process is running
449 // Filled in by LdrpInstallAppcompatBackend
451 ULARGE_INTEGER AppCompatFlags;
454 // ntuser appcompat flags
456 ULARGE_INTEGER AppCompatFlagsUser;
459 // Filled in by LdrpInstallAppcompatBackend
464 // Filled in by LdrQueryImageFileExecutionOptions
469 // Used by GetVersionExW as the szCSDVersion string
471 UNICODE_STRING CSDVersion;
476 PVOID ActivationContextData;
477 PVOID ProcessAssemblyStorageMap;
478 PVOID SystemDefaultActivationContextData;
479 PVOID SystemAssemblyStorageMap;
482 // Enforced minimum initial commit stack
484 SIZE_T MinimumStackCommit;
488 #define ACTIVATION_CONTEXT_STACK_FLAG_QUERIES_DISABLED (0x00000001)
490 typedef struct _ACTIVATION_CONTEXT_STACK {
492 ULONG NextCookieSequenceNumber;
494 LIST_ENTRY FrameListCache;
496 #if NT_SXS_PERF_COUNTERS_ENABLED
497 struct _ACTIVATION_CONTEXT_STACK_PERF_COUNTERS {
498 ULONGLONG Activations;
499 ULONGLONG ActivationCycles;
500 ULONGLONG Deactivations;
501 ULONGLONG DeactivationCycles;
503 #endif // NT_SXS_PERF_COUNTERS_ENABLED
504 } ACTIVATION_CONTEXT_STACK, *PACTIVATION_CONTEXT_STACK;
506 typedef const ACTIVATION_CONTEXT_STACK *PCACTIVATION_CONTEXT_STACK;
508 #define TEB_ACTIVE_FRAME_CONTEXT_FLAG_EXTENDED (0x00000001)
510 typedef struct _TEB_ACTIVE_FRAME_CONTEXT {
513 } TEB_ACTIVE_FRAME_CONTEXT, *PTEB_ACTIVE_FRAME_CONTEXT;
515 typedef const struct _TEB_ACTIVE_FRAME_CONTEXT *PCTEB_ACTIVE_FRAME_CONTEXT;
517 typedef struct _TEB_ACTIVE_FRAME_CONTEXT_EX {
518 TEB_ACTIVE_FRAME_CONTEXT BasicContext;
519 PCSTR SourceLocation; // e.g. "Z:\foo\bar\baz.c"
520 } TEB_ACTIVE_FRAME_CONTEXT_EX, *PTEB_ACTIVE_FRAME_CONTEXT_EX;
522 typedef const struct _TEB_ACTIVE_FRAME_CONTEXT_EX *PCTEB_ACTIVE_FRAME_CONTEXT_EX;
524 #define TEB_ACTIVE_FRAME_FLAG_EXTENDED (0x00000001)
526 typedef struct _TEB_ACTIVE_FRAME {
528 TYPE3(struct _TEB_ACTIVE_FRAME*) Previous;
529 PCTEB_ACTIVE_FRAME_CONTEXT Context;
530 } TEB_ACTIVE_FRAME, *PTEB_ACTIVE_FRAME;
532 typedef const struct _TEB_ACTIVE_FRAME *PCTEB_ACTIVE_FRAME;
534 typedef struct _TEB_ACTIVE_FRAME_EX {
535 TEB_ACTIVE_FRAME BasicFrame;
536 PVOID ExtensionIdentifier; // use address of your DLL Main or something unique to your mapping in the address space
537 } TEB_ACTIVE_FRAME_EX, *PTEB_ACTIVE_FRAME_EX;
539 typedef const struct _TEB_ACTIVE_FRAME_EX *PCTEB_ACTIVE_FRAME_EX;
541 typedef struct _CLIENT_ID {
542 HANDLE UniqueProcess;
545 typedef CLIENT_ID *PCLIENT_ID;
547 #define GDI_BATCH_BUFFER_SIZE 310
549 typedef struct _GDI_TEB_BATCH {
552 ULONG Buffer[GDI_BATCH_BUFFER_SIZE];
553 } GDI_TEB_BATCH,*PGDI_TEB_BATCH;
555 typedef struct _Wx86ThreadState {
557 PVOID DeallocationCpu;
558 BOOLEAN UseKnownWx86Dll;
560 } WX86THREAD, *PWX86THREAD;
562 #define STATIC_UNICODE_BUFFER_LENGTH 261
563 #define WIN32_CLIENT_INFO_LENGTH 62
565 typedef struct _PEB* PPEB;
567 typedef struct _TEB {
569 PVOID EnvironmentPointer;
571 PVOID ActiveRpcHandle;
572 PVOID ThreadLocalStoragePointer;
573 #if defined(PEBTEB_BITS)
574 PVOID ProcessEnvironmentBlock;
576 PPEB ProcessEnvironmentBlock;
578 ULONG LastErrorValue;
579 ULONG CountOfOwnedCriticalSections;
580 PVOID CsrClientThread;
581 PVOID Win32ThreadInfo; // PtiCurrent
582 ULONG User32Reserved[26]; // user32.dll items
583 ULONG UserReserved[5]; // Winsrv SwitchStack
584 PVOID WOW32Reserved; // used by WOW
586 ULONG FpSoftwareStatusRegister; // offset known by outsiders!
587 PVOID SystemReserved1[54]; // Used by FP emulator
588 NTSTATUS ExceptionCode; // for RaiseUserException
589 ACTIVATION_CONTEXT_STACK ActivationContextStack; // Fusion activation stack
590 // sizeof(PVOID) is a way to express processor-dependence, more generally than #ifdef _WIN64
591 UCHAR SpareBytes1[48 - sizeof(PVOID) - sizeof(ACTIVATION_CONTEXT_STACK)];
592 GDI_TEB_BATCH GdiTebBatch; // Gdi batching
593 CLIENT_ID RealClientId;
594 HANDLE GdiCachedProcessHandle;
597 PVOID GdiThreadLocalInfo;
598 ULONG_PTR Win32ClientInfo[WIN32_CLIENT_INFO_LENGTH]; // User32 Client Info
599 PVOID glDispatchTable[233]; // OpenGL
600 ULONG_PTR glReserved1[29]; // OpenGL
601 PVOID glReserved2; // OpenGL
602 PVOID glSectionInfo; // OpenGL
603 PVOID glSection; // OpenGL
604 PVOID glTable; // OpenGL
605 PVOID glCurrentRC; // OpenGL
606 PVOID glContext; // OpenGL
607 ULONG LastStatusValue;
608 UNICODE_STRING StaticUnicodeString;
609 WCHAR StaticUnicodeBuffer[STATIC_UNICODE_BUFFER_LENGTH];
610 PVOID DeallocationStack;
611 PVOID TlsSlots[TLS_MINIMUM_AVAILABLE];
614 PVOID ReservedForNtRpc;
615 PVOID DbgSsReserved[2];
616 ULONG HardErrorsAreDisabled;
617 PVOID Instrumentation[16];
618 PVOID WinSockData; // WinSock
621 BOOLEAN FreeStackOnTermination;
622 BOOLEAN HasFiberData;
623 BOOLEAN IdealProcessor;
625 PVOID ReservedForPerf;
626 PVOID ReservedForOle;
627 ULONG WaitingOnLoaderLock;
628 WX86THREAD Wx86Thread;
629 PPVOID TlsExpansionSlots;
630 LCID ImpersonationLocale; // Current locale of impersonated user
631 ULONG IsImpersonating; // Thread impersonation status
632 PVOID NlsCache; // NLS thread cache
633 PVOID pShimData; // Per thread data used in the shim
634 ULONG HeapVirtualAffinity;
635 HANDLE CurrentTransactionHandle;// reserved for TxF transaction context
636 PTEB_ACTIVE_FRAME ActiveFrame;
640 typedef struct _CURDIR {
641 UNICODE_STRING DosPath;
645 #define RTL_USER_PROC_CURDIR_CLOSE 0x00000002
646 #define RTL_USER_PROC_CURDIR_INHERIT 0x00000003
648 typedef struct _RTL_DRIVE_LETTER_CURDIR {
653 } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
656 #define RTL_MAX_DRIVE_LETTERS 32
657 #define RTL_DRIVE_LETTER_VALID (USHORT)0x0001
659 typedef struct _RTL_USER_PROCESS_PARAMETERS {
666 HANDLE ConsoleHandle;
668 HANDLE StandardInput;
669 HANDLE StandardOutput;
670 HANDLE StandardError;
672 CURDIR CurrentDirectory; // ProcessParameters
673 UNICODE_STRING DllPath; // ProcessParameters
674 UNICODE_STRING ImagePathName; // ProcessParameters
675 UNICODE_STRING CommandLine; // ProcessParameters
676 PVOID Environment; // NtAllocateVirtualMemory
687 ULONG ShowWindowFlags;
688 UNICODE_STRING WindowTitle; // ProcessParameters
689 UNICODE_STRING DesktopInfo; // ProcessParameters
690 UNICODE_STRING ShellInfo; // ProcessParameters
691 UNICODE_STRING RuntimeData; // ProcessParameters
692 RTL_DRIVE_LETTER_CURDIR CurrentDirectores[ RTL_MAX_DRIVE_LETTERS ];
693 } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
696 typedef enum _PROCESSINFOCLASS {
697 ProcessBasicInformation,
703 ProcessRaisePriority,
705 ProcessExceptionPort,
707 ProcessLdtInformation,
709 ProcessDefaultHardErrorMode,
710 ProcessIoPortHandlers, // Note: this is kernel mode only
711 ProcessPooledUsageAndLimits,
712 ProcessWorkingSetWatch,
714 ProcessEnableAlignmentFaultFixup,
715 ProcessPriorityClass,
716 ProcessWx86Information,
719 ProcessPriorityBoost,
721 ProcessSessionInformation,
722 ProcessForegroundInformation,
723 ProcessWow64Information,
724 ProcessImageFileName,
725 ProcessLUIDDeviceMapsEnabled,
726 ProcessBreakOnTermination,
727 ProcessDebugObjectHandle,
729 ProcessHandleTracing,
730 MaxProcessInfoClass // MaxProcessInfoClass should always be the last enum
734 typedef struct _VM_COUNTERS {
735 SIZE_T PeakVirtualSize;
737 ULONG PageFaultCount;
738 SIZE_T PeakWorkingSetSize;
739 SIZE_T WorkingSetSize;
740 SIZE_T QuotaPeakPagedPoolUsage;
741 SIZE_T QuotaPagedPoolUsage;
742 SIZE_T QuotaPeakNonPagedPoolUsage;
743 SIZE_T QuotaNonPagedPoolUsage;
744 SIZE_T PagefileUsage;
745 SIZE_T PeakPagefileUsage;
747 typedef VM_COUNTERS *PVM_COUNTERS;
751 #endif // !defined(FEATURE_PAL)
753 #if !defined(_TARGET_X86_)
755 typedef enum _FUNCTION_TABLE_TYPE {
759 } FUNCTION_TABLE_TYPE;
761 typedef struct _DYNAMIC_FUNCTION_TABLE {
763 PT_RUNTIME_FUNCTION FunctionTable;
764 LARGE_INTEGER TimeStamp;
767 ULONG MinimumAddress;
768 ULONG MaximumAddress;
771 ULONG64 MinimumAddress;
772 ULONG64 MaximumAddress;
776 PGET_RUNTIME_FUNCTION_CALLBACK Callback;
778 PWSTR OutOfProcessCallbackDll;
779 FUNCTION_TABLE_TYPE Type;
781 } DYNAMIC_FUNCTION_TABLE, *PDYNAMIC_FUNCTION_TABLE;
783 #endif // !_TARGET_X86_
788 #ifdef _TARGET_AMD64_
790 #define RUNTIME_FUNCTION__BeginAddress(prf) (prf)->BeginAddress
791 #define RUNTIME_FUNCTION__SetBeginAddress(prf,address) ((prf)->BeginAddress = (address))
793 #define RUNTIME_FUNCTION__EndAddress(prf, ImageBase) (prf)->EndAddress
795 #define RUNTIME_FUNCTION__GetUnwindInfoAddress(prf) (prf)->UnwindData
796 #define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf,address) do { (prf)->UnwindData = (address); } while (0)
797 #define OFFSETOF__RUNTIME_FUNCTION__UnwindInfoAddress offsetof(T_RUNTIME_FUNCTION, UnwindData)
799 #include "win64unwind.h"
803 (RtlVirtualUnwindFn) (
804 IN ULONG HandlerType,
805 IN ULONG64 ImageBase,
806 IN ULONG64 ControlPc,
807 IN PT_RUNTIME_FUNCTION FunctionEntry,
808 IN OUT PCONTEXT ContextRecord,
809 OUT PVOID *HandlerData,
810 OUT PULONG64 EstablisherFrame,
811 IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers OPTIONAL
815 extern RtlVirtualUnwindFn* RtlVirtualUnwind_Unsafe;
816 #else // !FEATURE_PAL
818 RtlVirtualUnwind_Unsafe(
819 IN ULONG HandlerType,
820 IN ULONG64 ImageBase,
821 IN ULONG64 ControlPc,
822 IN PT_RUNTIME_FUNCTION FunctionEntry,
823 IN OUT PCONTEXT ContextRecord,
824 OUT PVOID *HandlerData,
825 OUT PULONG64 EstablisherFrame,
826 IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers OPTIONAL
828 #endif // !FEATURE_PAL
830 #endif // _TARGET_AMD64_
839 // x86 ABI does not define RUNTIME_FUNCTION. Define our own to allow unification between x86 and other platforms.
841 typedef struct _RUNTIME_FUNCTION {
844 } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
846 typedef struct _DISPATCHER_CONTEXT {
847 _EXCEPTION_REGISTRATION_RECORD* RegistrationPointer;
848 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
850 #endif // !FEATURE_PAL
852 #define RUNTIME_FUNCTION__BeginAddress(prf) (prf)->BeginAddress
853 #define RUNTIME_FUNCTION__SetBeginAddress(prf,addr) ((prf)->BeginAddress = (addr))
855 #ifdef WIN64EXCEPTIONS
856 #include "win64unwind.h"
860 RtlpGetFunctionEndAddress (
861 __in PT_RUNTIME_FUNCTION FunctionEntry,
865 PTR_UNWIND_INFO pUnwindInfo = (PTR_UNWIND_INFO)(ImageBase + FunctionEntry->UnwindData);
867 return FunctionEntry->BeginAddress + pUnwindInfo->FunctionLength;
870 #define RUNTIME_FUNCTION__EndAddress(prf, ImageBase) RtlpGetFunctionEndAddress(prf, ImageBase)
872 #define RUNTIME_FUNCTION__GetUnwindInfoAddress(prf) (prf)->UnwindData
873 #define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf, addr) do { (prf)->UnwindData = (addr); } while(0)
880 __in DWORD HandlerType,
881 __in DWORD ImageBase,
882 __in DWORD ControlPc,
883 __in PRUNTIME_FUNCTION FunctionEntry,
884 __inout PT_CONTEXT ContextRecord,
885 __out PVOID *HandlerData,
886 __out PDWORD EstablisherFrame,
887 __inout_opt PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers
889 #endif // WIN64EXCEPTIONS
891 #endif // _TARGET_X86_
897 // Define unwind information flags.
900 #define UNW_FLAG_NHANDLER 0x0 /* any handler */
901 #define UNW_FLAG_EHANDLER 0x1 /* filter handler */
902 #define UNW_FLAG_UHANDLER 0x2 /* unwind handler */
904 // This function returns the length of a function using the new unwind info on arm.
905 // Taken from minkernel\ntos\rtl\arm\ntrtlarm.h.
908 RtlpGetFunctionEndAddress (
909 __in PT_RUNTIME_FUNCTION FunctionEntry,
913 ULONG FunctionLength;
915 FunctionLength = FunctionEntry->UnwindData;
916 if ((FunctionLength & 3) != 0) {
917 FunctionLength = (FunctionLength >> 2) & 0x7ff;
919 FunctionLength = *(PTR_ULONG)(ImageBase + FunctionLength) & 0x3ffff;
922 return FunctionEntry->BeginAddress + 2 * FunctionLength;
925 #define RUNTIME_FUNCTION__BeginAddress(FunctionEntry) ThumbCodeToDataPointer<DWORD,DWORD>((FunctionEntry)->BeginAddress)
926 #define RUNTIME_FUNCTION__SetBeginAddress(FunctionEntry,address) ((FunctionEntry)->BeginAddress = DataPointerToThumbCode<DWORD,DWORD>(address))
928 #define RUNTIME_FUNCTION__EndAddress(FunctionEntry, ImageBase) ThumbCodeToDataPointer<DWORD,DWORD>(RtlpGetFunctionEndAddress(FunctionEntry, ImageBase))
930 #define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf,address) do { (prf)->UnwindData = (address); } while (0)
932 typedef struct _UNWIND_INFO {
934 } UNWIND_INFO, *PUNWIND_INFO;
936 #if defined(FEATURE_PAL) || defined(_X86_)
942 __in_opt PVOID TargetFrame,
943 __in_opt PVOID TargetIp,
944 __in_opt PEXCEPTION_RECORD ExceptionRecord,
945 __in PVOID ReturnValue,
946 __in PT_CONTEXT ContextRecord,
947 __in_opt PUNWIND_HISTORY_TABLE HistoryTable
955 __in DWORD HandlerType,
956 __in DWORD ImageBase,
957 __in DWORD ControlPc,
958 __in PRUNTIME_FUNCTION FunctionEntry,
959 __inout PT_CONTEXT ContextRecord,
960 __out PVOID *HandlerData,
961 __out PDWORD EstablisherFrame,
962 __inout_opt PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers
964 #endif // FEATURE_PAL || _X86_
966 #define UNW_FLAG_NHANDLER 0x0
968 #endif // _TARGET_ARM_
970 #ifdef _TARGET_ARM64_
973 #define UNW_FLAG_NHANDLER 0x0 /* any handler */
974 #define UNW_FLAG_EHANDLER 0x1 /* filter handler */
975 #define UNW_FLAG_UHANDLER 0x2 /* unwind handler */
977 // This function returns the RVA of the end of the function (exclusive, so one byte after the actual end)
978 // using the unwind info on ARM64. (see ExternalAPIs\Win9CoreSystem\inc\winnt.h)
981 RtlpGetFunctionEndAddress (
982 __in PT_RUNTIME_FUNCTION FunctionEntry,
983 __in ULONG64 ImageBase
986 ULONG64 FunctionLength;
988 FunctionLength = FunctionEntry->UnwindData;
989 if ((FunctionLength & 3) != 0) {
990 FunctionLength = (FunctionLength >> 2) & 0x7ff;
992 FunctionLength = *(PTR_ULONG64)(ImageBase + FunctionLength) & 0x3ffff;
995 return FunctionEntry->BeginAddress + 4 * FunctionLength;
998 #define RUNTIME_FUNCTION__BeginAddress(FunctionEntry) ((FunctionEntry)->BeginAddress)
999 #define RUNTIME_FUNCTION__SetBeginAddress(FunctionEntry,address) ((FunctionEntry)->BeginAddress = (address))
1001 #define RUNTIME_FUNCTION__EndAddress(FunctionEntry, ImageBase) (RtlpGetFunctionEndAddress(FunctionEntry, (ULONG64)(ImageBase)))
1003 #define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf,address) do { (prf)->UnwindData = (address); } while (0)
1005 typedef struct _UNWIND_INFO {
1007 } UNWIND_INFO, *PUNWIND_INFO;
1014 IN ULONG HandlerType,
1015 IN ULONG64 ImageBase,
1016 IN ULONG64 ControlPc,
1017 IN PRUNTIME_FUNCTION FunctionEntry,
1018 IN OUT PCONTEXT ContextRecord,
1019 OUT PVOID *HandlerData,
1020 OUT PULONG64 EstablisherFrame,
1021 IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers OPTIONAL
1024 #ifndef IMAGE_FILE_MACHINE_ARM64
1025 #define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian
1028 #ifndef IMAGE_REL_ARM64_BRANCH26
1029 #define IMAGE_REL_ARM64_BRANCH26 0x0003 // 26 bit offset << 2 & sign ext. for B & BL
1032 #ifndef IMAGE_REL_ARM64_PAGEBASE_REL21
1033 #define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004 // ADRP 21 bit PC-relative page address
1036 #ifndef IMAGE_REL_ARM64_PAGEOFFSET_12A
1037 #define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006 // ADD 12 bit page offset