| 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. |
| 4 | |
| 5 | |
| 6 | |
| 7 | #ifndef __RTLFUNCTIONS_H__ |
| 8 | #define __RTLFUNCTIONS_H__ |
| 9 | |
| 10 | #ifdef WIN64EXCEPTIONS |
| 11 | |
| 12 | enum EEDynamicFunctionTableType |
| 13 | { |
| 14 | DYNFNTABLE_JIT = 0, |
| 15 | DYNFNTABLE_STUB = 1, |
| 16 | DYNFNTABLE_INVALID = -1, |
| 17 | |
| 18 | DYNFNTABLE_FIRST = DYNFNTABLE_JIT, |
| 19 | DYNFNTABLE_LAST = DYNFNTABLE_STUB, |
| 20 | }; |
| 21 | |
| 22 | // Used by OutOfProcessFunctionTableCallback in DLLS\mscordbg\DebugSupport.cpp |
| 23 | // to figure out how to parse a dynamic function table that was registered |
| 24 | // with a callback. |
| 25 | inline |
| 26 | EEDynamicFunctionTableType IdentifyDynamicFunctionTableTypeFromContext (PVOID pvContext) |
| 27 | { |
| 28 | EEDynamicFunctionTableType type = (EEDynamicFunctionTableType)((SIZE_T)pvContext & 3); |
| 29 | if (type < DYNFNTABLE_FIRST || type > DYNFNTABLE_LAST) |
| 30 | type = DYNFNTABLE_INVALID; |
| 31 | return type; |
| 32 | } |
| 33 | |
| 34 | inline |
| 35 | PVOID EncodeDynamicFunctionTableContext (PVOID pvContext, EEDynamicFunctionTableType type) |
| 36 | { |
| 37 | _ASSERTE(type >= DYNFNTABLE_FIRST && type <= DYNFNTABLE_LAST); |
| 38 | return (PVOID)((SIZE_T)pvContext | type); |
| 39 | } |
| 40 | |
| 41 | inline |
| 42 | PVOID DecodeDynamicFunctionTableContext (PVOID pvContext) |
| 43 | { |
| 44 | return (PVOID)((SIZE_T)pvContext & ~3); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | #define DYNAMIC_FUNCTION_TABLE_MAX_RANGE LONG_MAX |
| 49 | |
| 50 | #endif // WIN64EXCEPTIONS |
| 51 | |
| 52 | |
| 53 | #if defined(WIN64EXCEPTIONS) && !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) && !defined(FEATURE_PAL) |
| 54 | |
| 55 | // Wrapper for RtlInstallFunctionTableCallback. |
| 56 | VOID InstallEEFunctionTable( |
| 57 | PVOID pvTableID, |
| 58 | PVOID pvStartRange, |
| 59 | ULONG cbRange, |
| 60 | PGET_RUNTIME_FUNCTION_CALLBACK pfnGetRuntimeFunctionCallback, |
| 61 | PVOID pvContext, |
| 62 | EEDynamicFunctionTableType TableType); |
| 63 | |
| 64 | inline |
| 65 | VOID DeleteEEFunctionTable( |
| 66 | PVOID pvTableID) |
| 67 | { |
| 68 | RtlDeleteFunctionTable((PT_RUNTIME_FUNCTION)((ULONG64)pvTableID | 3)); |
| 69 | } |
| 70 | |
| 71 | #else // WIN64EXCEPTIONS && !DACCESS_COMPILE && !CROSSGEN_COMPILE && !FEATURE_PAL |
| 72 | |
| 73 | #define InstallEEFunctionTable(pvTableID, pvStartRange, cbRange, pfnGetRuntimeFunctionCallback, pvContext, TableType) do { } while (0) |
| 74 | #define DeleteEEFunctionTable(pvTableID) do { } while (0) |
| 75 | |
| 76 | #endif // WIN64EXCEPTIONS && !DACCESS_COMPILE && !CROSSGEN_COMPILE && !FEATURE_PAL |
| 77 | |
| 78 | |
| 79 | #endif // !__RTLFUNCTIONS_H__ |
| 80 | |