public bool OpenBinaryAs() { IOpenAsDialog dlg = null; IProcessorArchitecture arch = null; try { dlg = dlgFactory.CreateOpenAsDialog(); dlg.Services = sc; if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(true); } var rawFileOption = (ListOption)dlg.RawFileTypes.SelectedValue; string archName = null; string envName = null; string sAddr = null; string loader = null; EntryPointElement entry = null; if (rawFileOption != null && rawFileOption.Value != null) { RawFileElement raw = null; raw = (RawFileElement)rawFileOption.Value; loader = raw.Loader; archName = raw.Architecture; envName = raw.Environment; sAddr = raw.BaseAddress; entry = raw.EntryPoint; } archName = archName ?? (string)((ListOption)dlg.Architectures.SelectedValue).Value; var envOption = (OperatingEnvironment)((ListOption)dlg.Platforms.SelectedValue).Value; envName = envName ?? (envOption?.Name); sAddr = sAddr ?? dlg.AddressTextBox.Text.Trim(); arch = config.GetArchitecture(archName); if (arch == null) { throw new InvalidOperationException(string.Format("Unable to load {0} architecture.", archName)); } if (!arch.TryParseAddress(sAddr, out var addrBase)) { throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", sAddr)); } var details = new LoadDetails { LoaderName = loader, ArchitectureName = archName, PlatformName = envName, LoadAddress = sAddr, EntryPoint = entry, }; OpenBinary(dlg.FileName.Text, (f) => pageInitial.OpenBinaryAs( f, details)); } catch (Exception ex) { uiSvc.ShowError( ex, string.Format("An error occurred when opening the binary file {0}.", dlg.FileName.Text)); } return(true); }
private Annotation LoadAnnotation(Annotation_v3 annotation) { arch.TryParseAddress(annotation.Address, out var address); return(new Annotation(address, annotation.Text)); }
public bool OpenBinaryAs(string initialFilename) { IOpenAsDialog dlg = null; IProcessorArchitecture arch = null; try { dlg = dlgFactory.CreateOpenAsDialog(); dlg.FileName.Text = initialFilename; dlg.Services = sc; dlg.ArchitectureOptions = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(false); } var rawFileOption = (ListOption)dlg.RawFileTypes.SelectedValue; string archName = null; string envName = null; string sAddr = null; string loader = null; EntryPointDefinition entry = null; if (rawFileOption != null && rawFileOption.Value != null) { var raw = (RawFileDefinition)rawFileOption.Value; loader = raw.Loader; archName = raw.Architecture; envName = raw.Environment; sAddr = raw.BaseAddress; entry = raw.EntryPoint; } ArchitectureDefinition archOption = dlg.GetSelectedArchitecture(); PlatformDefinition envOption = dlg.GetSelectedEnvironment(); archName = archName ?? archOption?.Name; envName = envName ?? envOption?.Name; sAddr = sAddr ?? dlg.AddressTextBox.Text.Trim(); arch = config.GetArchitecture(archName); if (arch == null) { throw new InvalidOperationException(string.Format("Unable to load {0} architecture.", archName)); } arch.LoadUserOptions(dlg.ArchitectureOptions); if (!arch.TryParseAddress(sAddr, out var addrBase)) { throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", sAddr)); } var details = new LoadDetails { LoaderName = loader, ArchitectureName = archName, ArchitectureOptions = dlg.ArchitectureOptions, PlatformName = envName, LoadAddress = sAddr, EntryPoint = entry, }; OpenBinary(dlg.FileName.Text, (f) => pageInitial.OpenBinaryAs(f, details), f => false); } catch (Exception ex) { uiSvc.ShowError( ex, string.Format("An error occurred when opening the binary file {0}.", dlg.FileName.Text)); } return(true); }
public bool OpenBinaryAs() { IOpenAsDialog dlg = null; IProcessorArchitecture arch = null; try { dlg = dlgFactory.CreateOpenAsDialog(); dlg.Services = sc; if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(true); } mru.Use(dlg.FileName.Text); var rawFileOption = (ListOption)dlg.RawFileTypes.SelectedValue; string archName; string envName; string sAddr; RawFileElement raw = null; if (rawFileOption != null && rawFileOption.Value != null) { raw = (RawFileElement)rawFileOption.Value; archName = raw.Architecture; envName = raw.Environment; sAddr = raw.BaseAddress; } else { var archOption = (ListOption)dlg.Architectures.SelectedValue; archName = (string)archOption.Value; var envOption = (OperatingEnvironment)((ListOption)dlg.Platforms.SelectedValue).Value; envName = envOption != null? envOption.Name : null; sAddr = dlg.AddressTextBox.Text.Trim(); } arch = config.GetArchitecture(archName); if (arch == null) { throw new InvalidOperationException(string.Format("Unable to load {0} architecture.", archName)); } Address addrBase; if (!arch.TryParseAddress(sAddr, out addrBase)) { throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", sAddr)); } OpenBinary(dlg.FileName.Text, (f) => pageInitial.OpenBinaryAs( f, archName, envName, addrBase, raw)); } catch (Exception ex) { uiSvc.ShowError( ex, string.Format("An error occurred when opening the binary file {0}.", dlg.FileName.Text)); } return(true); }