private static bool TryLoadDemangleFunction(string libraryName, out CxaDemangleDelegate result) { IntPtr libraryAddress; if(!SharedLibraries.TryLoadLibrary(libraryName, out libraryAddress)) { result = null; return false; } var functionAddress = SharedLibraries.GetSymbolAddress(libraryAddress, "__cxa_demangle"); var delegateType = typeof(LibStdCppHelper.CxaDemangleDelegate); result = (LibStdCppHelper.CxaDemangleDelegate)Marshal.GetDelegateForFunctionPointer(functionAddress, delegateType); return true; }
private static bool TryLoadDemangleFunction(string libraryName, out CxaDemangleDelegate result) { IntPtr libraryAddress; if (!SharedLibraries.TryLoadLibrary(libraryName, out libraryAddress)) { result = null; return(false); } var functionAddress = SharedLibraries.GetSymbolAddress(libraryAddress, "__cxa_demangle"); var delegateType = typeof(LibStdCppHelper.CxaDemangleDelegate); result = (LibStdCppHelper.CxaDemangleDelegate)Marshal.GetDelegateForFunctionPointer(functionAddress, delegateType); return(true); }
public static bool TryGetCxaDemangle(out CxaDemangleDelegate result) { var name = GetLibName(); // first we try to get the library from the loader path if (TryLoadDemangleFunction(name, out result)) { return(true); } // then we search our own paths foreach (var path in gccPaths) { string libraryName; if (TryFindLibStdCppInDir(path, out libraryName) && TryLoadDemangleFunction(libraryName, out result)) { return(true); } } return(false); }
public static bool TryGetCxaDemangle(out CxaDemangleDelegate result) { var name = GetLibName(); // first we try to get the library from the loader path if(TryLoadDemangleFunction(name, out result)) { return true; } // then we search our own paths foreach(var path in gccPaths) { string libraryName; if(TryFindLibStdCppInDir(path, out libraryName) && TryLoadDemangleFunction(libraryName, out result)) { return true; } } return false; }