public bool OpenBinaryAs(string initialFilename) { IOpenAsDialog dlg = null; try { dlg = dlgFactory.CreateOpenAsDialog(initialFilename); if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(false); } string fileName = dlg.FileName.Text; LoadDetails details = dlg.GetLoadDetails(); CloseProject(); SwitchInteractor(InitialPageInteractor); pageInitial.OpenBinaryAs(fileName, details); if (fileName.EndsWith(Project_v5.FileExtension)) { ProjectFileName = fileName; } } catch (Exception ex) { uiSvc.ShowError( ex, string.Format("An error occurred when opening the file {0}.", dlg.FileName.Text)); } return(true); }
public bool OpenBinaryAs() { IOpenAsDialog dlg = null; IProcessorArchitecture arch = null; Platform platform = null; try { dlg = dlgFactory.CreateOpenAsDialog(); dlg.Services = sc; if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK) { return(true); } mru.Use(dlg.FileName.Text); var archOption = (ListOption)dlg.Architectures.SelectedValue; Type t = Type.GetType((string)archOption.Value, true); arch = (IProcessorArchitecture)Activator.CreateInstance(t); arch.Description = archOption.Text; var envOption = (ListOption)dlg.Platforms.SelectedValue; t = Type.GetType((string)envOption.Value); if (t == null) { throw new TypeLoadException(string.Format("Unable to load type {0}.", envOption.Value)); } platform = (Platform)Activator.CreateInstance(t, sc, arch); platform.Description = envOption.Text; Address addrBase; var sAddr = dlg.AddressTextBox.Text.Trim(); 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, arch, platform, addrBase, this)); } 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(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); } 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 != null? envOption.Name : null); sAddr = 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)); } 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); }