예제 #1
0
 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;
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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;
        }