Beispiel #1
0
        private void FinishPrep()
        {
            string messages = mProject.LoadExternalFiles();

            if (messages.Length != 0)
            {
                // ProjectLoadIssues isn't quite the right dialog, but it'll do.
                ProjectLoadIssues dlg = new ProjectLoadIssues(messages,
                                                              ProjectLoadIssues.Buttons.Continue);
                dlg.ShowDialog();
            }

            mDisplayList = new DisplayListGen(mProject, mOutputFormatter, mPseudoOpNames);

            // Prep the symbol table subset object.  Replace the old one with a new one.
            //mSymbolSubset = new SymbolTableSubset(mProject.SymbolTable);

            RefreshProject(UndoableChange.ReanalysisScope.CodeAndData);
            //ShowProject();
            //InvalidateControls(null);
            mMainWin.ShowCodeListView = true;
            mNavStack.Clear();

            // Want to do this after ShowProject() or we see a weird glitch.
            UpdateRecentProjectList(mProjectPathName);
        }
Beispiel #2
0
        /// <summary>
        /// Handles opening an existing project, given a pathname to the project file.
        /// </summary>
        private void DoOpenFile(string projPathName)
        {
            Debug.WriteLine("DoOpenFile: " + projPathName);
            Debug.Assert(mProject == null);

            if (!File.Exists(projPathName))
            {
                string msg = string.Format(Res.Strings.ERR_FILE_NOT_FOUND_FMT, projPathName);
                MessageBox.Show(msg, Res.Strings.ERR_FILE_GENERIC_CAPTION,
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            DisasmProject newProject = new DisasmProject();

            newProject.UseMainAppDomainForPlugins = mUseMainAppDomainForPlugins;

            // Deserialize the project file.  I want to do this before loading the data file
            // in case we decide to store the data file name in the project (e.g. the data
            // file is a disk image or zip archive, and we need to know which part(s) to
            // extract).
            if (!ProjectFile.DeserializeFromFile(projPathName, newProject,
                                                 out FileLoadReport report))
            {
                // Should probably use a less-busy dialog for something simple like
                // "permission denied", but the open file dialog handles most simple
                // stuff directly.
                ProjectLoadIssues dlg = new ProjectLoadIssues(report.Format(),
                                                              ProjectLoadIssues.Buttons.Cancel);
                dlg.ShowDialog();
                // ignore dlg.DialogResult
                return;
            }

            // Now open the data file, generating the pathname by stripping off the ".dis65"
            // extension.  If we can't find the file, show a message box and offer the option to
            // locate it manually, repeating the process until successful or canceled.
            const string UNKNOWN_FILE = "UNKNOWN";
            string       dataPathName;

            if (projPathName.Length <= ProjectFile.FILENAME_EXT.Length)
            {
                dataPathName = UNKNOWN_FILE;
            }
            else
            {
                dataPathName = projPathName.Substring(0,
                                                      projPathName.Length - ProjectFile.FILENAME_EXT.Length);
            }
            byte[] fileData;
            while ((fileData = FindValidDataFile(ref dataPathName, newProject,
                                                 out bool cancel)) == null)
            {
                if (cancel)
                {
                    // give up
                    Debug.WriteLine("Abandoning attempt to open project");
                    return;
                }
            }

            // If there were warnings, notify the user and give the a chance to cancel.
            if (report.Count != 0)
            {
                ProjectLoadIssues dlg = new ProjectLoadIssues(report.Format(),
                                                              ProjectLoadIssues.Buttons.ContinueOrCancel);
                bool?ok = dlg.ShowDialog();

                if (ok != true)
                {
                    return;
                }
            }

            mProject         = newProject;
            mProjectPathName = mProject.ProjectPathName = projPathName;
            mProject.SetFileData(fileData, Path.GetFileName(dataPathName));
            FinishPrep();
        }