Пример #1
0
        public bool AssembleFile()
        {
            IAssembleFileDialog dlg = null;

            try
            {
                dlg          = dlgFactory.CreateAssembleFileDialog();
                dlg.Services = sc;
                if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK)
                {
                    return(true);
                }
                mru.Use(dlg.FileName.Text);

                var typeName = dlg.SelectedArchitectureTypeName;
                var t        = Type.GetType(typeName, true);
                var asm      = (Assembler)t.GetConstructor(Type.EmptyTypes).Invoke(null);
                OpenBinary(dlg.FileName.Text, (f) => pageInitial.Assemble(f, asm, this));
            }
            catch (Exception e)
            {
                uiSvc.ShowError(e, "An error occurred while assembling {0}.", dlg.FileName.Text);
            }
            return(true);
        }
Пример #2
0
        public bool AssembleFile()
        {
            IAssembleFileDialog dlg = null;

            try
            {
                dlg          = dlgFactory.CreateAssembleFileDialog();
                dlg.Services = sc;
                if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK)
                {
                    return(true);
                }

                string fileName = dlg.FileName.Text;
                var    arch     = this.config.GetArchitecture(dlg.SelectedArchitectureName);
                var    asm      = arch.CreateAssembler(null);
                CloseProject();
                SwitchInteractor(InitialPageInteractor);
                InitialPageInteractor.Assemble(fileName, asm, null);
                RememberFilenameInMru(fileName);
                if (fileName.EndsWith(Project_v5.FileExtension))
                {
                    ProjectFileName = fileName;
                }
            }
            catch (Exception e)
            {
                uiSvc.ShowError(e, "An error occurred while assembling {0}.", dlg.FileName.Text);
            }
            return(true);
        }
Пример #3
0
 /// <summary>
 /// Shows UI and allows the user to edit the project properties.
 /// </summary>
 /// <param name="project"></param>
 public bool EditProjectProperties(
     IDecompilerShellUiService uiSvc,
     Project_v3 project,
     Action <Project_v3> updater)
 {
     using (var dlg = new EditProjectDialog())
     {
         Attach(dlg);
         LoadFieldsFromProject(project);
         if (uiSvc.ShowModalDialog(dlg) == Gui.DialogResult.OK)
         {
             updater(CreateProjectFromFields());
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
 /// <summary>
 /// Shows UI and allows the user to edit the project properties.
 /// </summary>
 /// <param name="project"></param>
 public bool EditProjectProperties(
     IDecompilerShellUiService uiSvc,
     Project_v3 project,
     Action<Project_v3> updater)
 {
     using (var dlg = new EditProjectDialog())
     {
         Attach(dlg);
         LoadFieldsFromProject(project);
         if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK)
         {
             updater(CreateProjectFromFields());
             return true;
         }
     }
     return false;
 }
        public void DviGotoAddress()
        {
            var dlg = repository.Stub <IAddressPromptDialog>();

            dlg.Stub(x => dlg.Address).Return(Address.Ptr32(0x41104110));
            dlgFactory.Stub(x => x.CreateAddressPromptDialog()).Return(dlg);
            uiSvc.Expect(x => uiSvc.ShowModalDialog(
                             Arg <IAddressPromptDialog> .Is.Same(dlg)))
            .Return(DialogResult.OK);
            dlg.Expect(x => x.Dispose());
            repository.ReplayAll();

            Initialize();
            interactor.Execute(new CommandID(CmdSets.GuidReko, CmdIds.ViewGoToAddress));

            repository.VerifyAll();
            Assert.AreEqual(0x41104110ul, interactor.StartAddress.ToLinear());
        }
Пример #6
0
        private void Rename()
        {
            Block block = GetSelectedBlock();

            if (block == null)
            {
                return;
            }
            IDecompilerShellUiService uiSvc = services.RequireService <IDecompilerShellUiService>();
            var dlgSvc = services.RequireService <IDialogFactory>();

            using (var dlg = dlgSvc.CreateBlockNameDialog(block.Procedure, block))
            {
                if (uiSvc.ShowModalDialog(dlg) == Gui.Services.DialogResult.OK)
                {
                    block.UserLabel = dlg.BlockName.Text;
                    program.User.BlockLabels[block.Id] = block.UserLabel;

                    //$TODO: notify the world.
                    ProgramChanged();
                }
            }
        }
 /// <summary>
 /// The UI thread requests a background operation by calling this method.
 /// </summary>
 /// <param name="caption"></param>
 /// <param name="backgroundTask"></param>
 /// <returns></returns>
 public bool StartBackgroundWork(string caption, Action backgroundTask)
 {
     lastException = null;
     try
     {
         this.task = backgroundTask;
         using (dlg = CreateDialog(caption))
         {
             if (uiSvc.ShowModalDialog(dlg) == DialogResult.OK)
             {
                 return(true);
             }
             if (lastException != null)
             {
                 uiSvc.ShowError(lastException, "{0}", caption);
             }
             return(false);
         }
     }
     finally
     {
         dlg = null;
     }
 }
Пример #8
0
        public bool AssembleFile()
        {
            IAssembleFileDialog dlg = null;

            try
            {
                dlg          = dlgFactory.CreateAssembleFileDialog();
                dlg.Services = sc;
                if (uiSvc.ShowModalDialog(dlg) != DialogResult.OK)
                {
                    return(true);
                }

                var arch = this.config.GetArchitecture(dlg.SelectedArchitectureName);
                var asm  = arch.CreateAssembler(null);
                OpenBinary(dlg.FileName.Text, (f) => pageInitial.Assemble(f, asm, null), f => false);
                RememberFilenameInMru(dlg.FileName.Text);
            }
            catch (Exception e)
            {
                uiSvc.ShowError(e, "An error occurred while assembling {0}.", dlg.FileName.Text);
            }
            return(true);
        }