Exemple #1
0
        private void OnArchitectureChanged()
        {
            var arch = dlg.GetSelectedArchitecture();

            PopulateModels(arch);
            if (arch != null && arch.Options?.Count > 0)
            {
                dlg.SetPropertyGrid(dlg.ArchitectureOptions, arch.Options);
            }
            else
            {
                dlg.PropertyGrid.SelectedObject = null;
            }
        }
Exemple #2
0
        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);
        }