Ejemplo n.º 1
0
        static bool GenerateSymbolFile(string symbol_dir)
        {
            try
            {
                Process proc  = Process.GetCurrentProcess();
                var     procs = COMUtilities.LoadProcesses(new Process[] { proc }, null, COMRegistry.Load(COMRegistryMode.UserOnly));
                if (!procs.Any())
                {
                    throw new ArgumentException("Couldn't parse the process information. Incorrect symbols?");
                }

                Dictionary <string, int> entries;
                if (Environment.Is64BitProcess)
                {
                    entries = SymbolResolverWrapper.GetResolvedNative();
                }
                else
                {
                    entries = SymbolResolverWrapper.GetResolved32Bit();
                }

                string        dll_name    = COMUtilities.GetCOMDllName();
                var           module      = SafeLoadLibraryHandle.GetModuleHandle(dll_name);
                string        output_file = Path.Combine(symbol_dir, $"{COMUtilities.GetFileMD5(module.FullPath)}.sym");
                List <string> lines       = new List <string>();
                lines.Add($"# {Environment.OSVersion.VersionString} {module.FullPath} {FileVersionInfo.GetVersionInfo(module.FullPath).FileVersion}");
                lines.AddRange(entries.Where(p => p.Key.StartsWith(dll_name)).Select(p => $"{p.Value} {p.Key}"));
                File.WriteAllLines(output_file, lines);
            }
            catch (Exception ex)
            {
                ShowError(null, ex);
                return(false);
            }
            return(true);
        }