internal unsafe static IntPtr ResolvePInvoke(MethodFixupCell* pCell) { if (pCell->Target != IntPtr.Zero) return pCell->Target; return ResolvePInvokeSlow(pCell); }
internal unsafe static IntPtr ResolvePInvokeSlow(MethodFixupCell* pCell) { ModuleFixupCell* pModuleCell = pCell->Module; IntPtr hModule = pModuleCell->Handle; if (hModule == IntPtr.Zero) { FixupModuleCell(pModuleCell); hModule = pModuleCell->Handle; } FixupMethodCell(hModule, pCell); return pCell->Target; }
internal unsafe static void FixupMethodCell(IntPtr hModule, MethodFixupCell* pCell) { byte* methodName = (byte*)pCell->MethodName; #if !PLATFORM_UNIX pCell->Target = Interop.mincore.GetProcAddress(hModule, methodName); #else pCell->Target = Interop.Sys.GetProcAddress(hModule, methodName); #endif if (pCell->Target == IntPtr.Zero) { // TODO: Shoud be EntryPointNotFoundException, but layering... throw new TypeLoadException(Encoding.UTF8.GetString(methodName, strlen(methodName))); } }