private void selectDLLFilteredToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LibrarySelector selector = new LibrarySelector();

            selector.LoadedDlls = cachedDllMetadata;
            if (selector.ShowDialog() == DialogResult.OK)
            {
                currentDll = new DllContext(selector.SelectedFile);
                TryRefreshKey();
            }
        }
        private void LoadLibraryMetadata()
        {
            cachedDllMetadata = new List <DllContext>();
            foreach (string file in Program.GetLibraryFiles())
            {
                if (Path.GetExtension(file).ToLower() != ".dll")
                {
                    continue;
                }

                DllContext libraryToLoad = new DllContext(file, false);
                libraryToLoad.UnloadLibrary();
                cachedDllMetadata.Add(libraryToLoad);
            }
        }
        private void selectDLLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title            = "Select a compatible DLL file";
            ofd.Multiselect      = false;
            ofd.InitialDirectory = Program.GetStartupPath();
            ofd.Filter           = "DLL files (*.dll)|*.dll|All files (*.*)|*.*";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                currentDll = new DllContext(ofd.FileName);
                TryRefreshKey();
            }
        }
        private void DiagnosticsDumpReport()
        {
            List <DllContext> libraries = new List <DllContext>();

            foreach (string file in Program.GetLibraryFiles())
            {
                if (Path.GetExtension(file).ToLower() != ".dll")
                {
                    continue;
                }

                DllContext libraryToLoad = new DllContext(file);
                libraryToLoad.UnloadLibrary();
                libraries.Add(libraryToLoad);
            }

            string        divider = "==========================================================";
            StringBuilder sb      = new StringBuilder();

            foreach (DllContext library in libraries)
            {
                sb.AppendLine(divider);
                sb.AppendLine();
                sb.AppendLine(library.FileName);
                sb.AppendLine($"SHA1: {library.SHA1Hash}");
                sb.AppendLine($"ECUName: {library.ECUName}");
                sb.AppendLine($"Comment: {library.Comment}");
                sb.AppendLine($"Comment: {library.Comment}");
                sb.AppendLine($"Exports: [{string.Join(", ", library.DllExports)}]");
                string accessLevels = string.Join(", ", library.AccessLevels.Select(t => $"[Level: {t.Item1}, KeySize: {t.Item2}, SeedSize: {t.Item3}]"));
                sb.AppendLine($"Levels: [{accessLevels}]");
                sb.AppendLine();
            }

            string exportPath = Program.GetStartupPath() + "Report.txt";

            File.WriteAllText(exportPath, sb.ToString());
            MessageBox.Show($"Export OK : Report saved at \r\n{exportPath}", "Diagnostics");
        }