Exemple #1
0
        private DisasmProject InstantiateProject(string dataPathName,
                                                 out FileLoadReport projectLoadReport)
        {
            DisasmProject project = new DisasmProject();

            // always use AppDomain sandbox

            projectLoadReport = null;

            int testNum = GetTestNum(dataPathName);

            if (testNum < 2000)
            {
                // create new disasm project for data file
                byte[] fileData;
                try {
                    fileData = LoadDataFile(dataPathName);
                } catch (Exception ex) {
                    ReportErrMsg(ex.Message);
                    return(null);
                }

                project.Initialize(fileData.Length);
                project.PrepForNew(fileData, Path.GetFileName(dataPathName));
                // no platform symbols to load
            }
            else
            {
                // deserialize project file, failing if we can't find it
                string projectPathName = dataPathName + ProjectFile.FILENAME_EXT;
                if (!ProjectFile.DeserializeFromFile(projectPathName,
                                                     project, out projectLoadReport))
                {
                    ReportErrMsg(projectLoadReport.Format());
                    return(null);
                }

                byte[] fileData;
                try {
                    fileData = LoadDataFile(dataPathName);
                } catch (Exception ex) {
                    ReportErrMsg(ex.Message);
                    return(null);
                }

                project.SetFileData(fileData, Path.GetFileName(dataPathName));
                project.ProjectPathName = projectPathName;
                project.LoadExternalFiles();
            }

            TaskTimer genTimer = new TaskTimer();
            DebugLog  genLog   = new DebugLog();

            genLog.SetMinPriority(DebugLog.Priority.Silent);
            project.Analyze(UndoableChange.ReanalysisScope.CodeAndData, genLog, genTimer);

            return(project);
        }
Exemple #2
0
        private void ImportSymbolsButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDlg = new OpenFileDialog()
            {
                Filter      = ProjectFile.FILENAME_FILTER + "|" + Res.Strings.FILE_FILTER_ALL,
                FilterIndex = 1
            };

            if (fileDlg.ShowDialog() != true)
            {
                return;
            }
            string projPathName = Path.GetFullPath(fileDlg.FileName);

            DisasmProject newProject = new DisasmProject();

            if (!ProjectFile.DeserializeFromFile(projPathName, newProject,
                                                 out FileLoadReport report))
            {
                // Unable to open project file.  Report error and bail.
                ProjectLoadIssues dlg = new ProjectLoadIssues(this, report.Format(),
                                                              ProjectLoadIssues.Buttons.Cancel);
                dlg.ShowDialog();
                // ignore dlg.DialogResult
                return;
            }

            // Import all user labels that were marked as "global export".  These become
            // external-address project symbols with unspecified width.
            int foundCount = 0;

            foreach (KeyValuePair <int, Symbol> kvp in newProject.UserLabels)
            {
                if (kvp.Value.SymbolType == Symbol.Type.GlobalAddrExport)
                {
                    Symbol    sym    = kvp.Value;
                    DefSymbol defSym = new DefSymbol(sym.Label, sym.Value, Symbol.Source.Project,
                                                     Symbol.Type.ExternalAddr, FormatDescriptor.SubType.None);
                    mWorkProps.ProjectSyms[defSym.Label] = defSym;
                    foundCount++;
                }
            }
            if (foundCount != 0)
            {
                IsDirty = true;
                LoadProjectSymbols();   // just reload the whole set
                UpdateControls();
            }

            newProject.Cleanup();

            // Tell the user we did something.  Might be nice to tell them how many weren't
            // already present.
            string msg;

            if (foundCount == 0)
            {
                msg = Res.Strings.SYMBOL_IMPORT_NONE;
            }
            else
            {
                msg = string.Format(Res.Strings.SYMBOL_IMPORT_GOOD_FMT, foundCount);
            }
            MessageBox.Show(msg, Res.Strings.SYMBOL_IMPORT_CAPTION,
                            MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemple #3
0
        private void importSymbolsButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDlg = new OpenFileDialog();

            fileDlg.Filter = ProjectFile.FILENAME_FILTER + "|" +
                             Properties.Resources.FILE_FILTER_ALL;
            fileDlg.FilterIndex = 1;
            if (fileDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string projPathName = Path.GetFullPath(fileDlg.FileName);

            DisasmProject newProject = new DisasmProject();

            if (!ProjectFile.DeserializeFromFile(projPathName, newProject,
                                                 out FileLoadReport report))
            {
                ProjectLoadIssues dlg = new ProjectLoadIssues();
                dlg.Messages    = report.Format();
                dlg.CanContinue = false;
                dlg.ShowDialog();
                // ignore dlg.DialogResult
                dlg.Dispose();
                return;
            }

            // Import all user labels that were marked as "global export".  These become
            // external-address project symbols.
            int foundCount = 0;

            foreach (KeyValuePair <int, Symbol> kvp in newProject.UserLabels)
            {
                if (kvp.Value.SymbolType == Symbol.Type.GlobalAddrExport)
                {
                    Symbol    sym    = kvp.Value;
                    DefSymbol defSym = new DefSymbol(sym.Label, sym.Value, Symbol.Source.Project,
                                                     Symbol.Type.ExternalAddr, FormatDescriptor.SubType.None,
                                                     string.Empty, string.Empty);
                    WorkProps.ProjectSyms[defSym.Label] = defSym;
                    foundCount++;
                }
            }
            if (foundCount != 0)
            {
                mDirty = true;
                LoadProjectSymbols();
                UpdateControls();
            }

            newProject.Cleanup();

            // Tell the user we did something.  Might be nice to tell them how many weren't
            // already present.
            string msg;

            if (foundCount == 0)
            {
                msg = Properties.Resources.SYMBOL_IMPORT_NONE;
            }
            else
            {
                msg = string.Format(Properties.Resources.SYMBOL_IMPORT_GOOD, foundCount);
            }
            MessageBox.Show(msg, Properties.Resources.SYMBOL_IMPORT_CAPTION,
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #4
0
        private DisasmProject InstantiateProject(string dataPathName,
                                                 out FileLoadReport projectLoadReport)
        {
            DisasmProject project = new DisasmProject();

            // always use AppDomain sandbox

            projectLoadReport = null;

            int testNum = GetTestNum(dataPathName);

            CpuDef.CpuType cpuType = GetCpuTypeFromNum(testNum);

            if (testNum < 20000)
            {
                // create new disasm project for data file
                byte[] fileData;
                try {
                    fileData = LoadDataFile(dataPathName);
                } catch (Exception ex) {
                    ReportErrMsg(ex.Message);
                    return(null);
                }

                project.Initialize(fileData.Length);
                project.ProjectProps.CpuType = cpuType;
                project.ProjectProps.IncludeUndocumentedInstr = true;
                project.ProjectProps.TwoByteBrk = false;
                project.UpdateCpuDef();
                project.PrepForNew(fileData, Path.GetFileName(dataPathName));
                // no platform symbols to load
            }
            else
            {
                // deserialize project file, failing if we can't find it
                string projectPathName = dataPathName + ProjectFile.FILENAME_EXT;
                if (!ProjectFile.DeserializeFromFile(projectPathName,
                                                     project, out projectLoadReport))
                {
                    ReportErrMsg(projectLoadReport.Format());
                    return(null);
                }

                byte[] fileData;
                try {
                    fileData = LoadDataFile(dataPathName);
                } catch (Exception ex) {
                    ReportErrMsg(ex.Message);
                    return(null);
                }

                FileLoadReport unused = new FileLoadReport("test");
                project.SetFileData(fileData, Path.GetFileName(dataPathName), ref unused);
                project.ProjectPathName = projectPathName;
                string extMsgs = project.LoadExternalFiles();
                if (!string.IsNullOrEmpty(extMsgs))
                {
                    ReportErrMsg(extMsgs);
                    // keep going
                }

                if (project.ProjectProps.CpuType != cpuType)
                {
                    ReportErrMsg("Mismatch CPU type for test " + testNum + ": project wants " +
                                 project.ProjectProps.CpuType);
                    // keep going
                }
            }

            TaskTimer genTimer = new TaskTimer();
            DebugLog  genLog   = new DebugLog();

            genLog.SetMinPriority(DebugLog.Priority.Silent);
            project.Analyze(UndoableChange.ReanalysisScope.CodeAndData, genLog, genTimer);

            return(project);
        }