1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| internal static class ModuleHelper { private static IDictionary<IntPtr, Module>? _mapAddressToModule; private static readonly FieldInfo m_pData; private static readonly MethodInfo GetHInstance;
private static readonly object LoadLock = new(); private static readonly object LockSelfMapsLinux = new object();
static ModuleHelper() { m_pData = Type.GetType("System.Reflection.RuntimeModule") .GetField("m_pData", BindingFlags.NonPublic | BindingFlags.Instance); GetHInstance = typeof(Marshal).GetMethod("GetHINSTANCE", new[] { typeof(Module) })!; LoadMapScopeToHandle(); } public static IntPtr GetAddressFromModule(Module module) { return (IntPtr)m_pData.GetValue(module); } }
|