예제 #1
0
 private void Dlg_Load(object sender, EventArgs e)
 {
     this.fsSvc = dlg.Services.RequireService <IFileSystemService>();
     this.uiSvc = dlg.Services.RequireService <IDecompilerShellUiService>();
     PopulateSymbolSources();
     EnableControls();
 }
예제 #2
0
 public PhasePageInteractorImpl(IServiceProvider services)
 {
     this.Services   = services;
     decompilerSvc   = services.RequireService <IDecompilerService>();
     decompilerUiSvc = services.RequireService <IDecompilerShellUiService>();
     workerDlgSvc    = services.RequireService <IWorkerDialogService>();
 }
예제 #3
0
 public PhasePageInteractorImpl(IServiceProvider services)
 {
     this.Services = services;
     decompilerSvc = services.RequireService<IDecompilerService>();
     decompilerUiSvc = services.RequireService<IDecompilerShellUiService>();
     workerDlgSvc = services.RequireService<IWorkerDialogService>();
 }
예제 #4
0
 public void Setup()
 {
     mr          = new MockRepository();
     mockFactory = new MockFactory(mr);
     services    = new ServiceContainer();
     configSvc   = mr.Stub <IConfigurationService>();
     services.AddService <IConfigurationService>(configSvc);
     uiSvc = mr.Stub <IDecompilerShellUiService>();
 }
        public void Setup()
        {
            repository = new MockRepository();
            interactor = repository.Stub <DisassemblyViewInteractor>();
            sc         = new ServiceContainer();
            uiSvc      = repository.DynamicMock <IDecompilerShellUiService>();
            dcSvc      = repository.Stub <IDecompilerService>();
            dlgFactory = repository.DynamicMock <IDialogFactory>();
            sc.AddService <IDecompilerShellUiService>(uiSvc);

            sc.AddService <IDecompilerService>(dcSvc);
            sc.AddService <IDialogFactory>(dlgFactory);
        }
        public void Setup()
        {
            repository = new MockRepository();
            interactor = repository.Stub<DisassemblyViewInteractor>();
            sc = new ServiceContainer();
            uiSvc = repository.DynamicMock<IDecompilerShellUiService>();
            dcSvc = repository.Stub<IDecompilerService>();
            dlgFactory = repository.DynamicMock<IDialogFactory>();
            sc.AddService<IDecompilerShellUiService>(uiSvc);

            sc.AddService<IDecompilerService>(dcSvc);
            sc.AddService<IDialogFactory>(dlgFactory);
        }
예제 #7
0
 public void Setup()
 {
     mr        = new MockRepository();
     sc        = new ServiceContainer();
     mockTree  = mr.StrictMock <ITreeView>();
     mockNodes = mr.StrictMock <ITreeNodeCollection>();
     uiSvc     = mr.StrictMock <IDecompilerShellUiService>();
     uiPrefSvc = mr.Stub <IUiPreferencesService>();
     mockTree.Stub(t => t.Nodes).Return(mockNodes);
     uiSvc.Stub(u => u.SetContextMenu(null, 0)).IgnoreArguments();
     sc.AddService <IDecompilerShellUiService>(uiSvc);
     sc.AddService <IUiPreferencesService>(uiPrefSvc);
     fakeTree = new FakeTreeView();
 }
예제 #8
0
        public void Setup()
        {
            mr                    = new MockRepository();
            this.sc               = new ServiceContainer();
            this.node             = mr.StrictMock <ITreeNode>();
            this.host             = mr.StrictMock <ITreeNodeDesignerHost>();
            this.uiSvc            = mr.StrictMock <IDecompilerShellUiService>();
            this.cmdidLoadSymbols = new CommandID(CmdSets.GuidReko, CmdIds.LoadSymbols);
            this.slSvc            = mr.StrictMock <ISymbolLoadingService>();
            this.symSrc           = mr.StrictMock <ISymbolSource>();

            // Add services to the Service container (which in the real program is the Reko "main window")
            this.sc.AddService <ISymbolLoadingService>(slSvc);
            this.sc.AddService <IDecompilerShellUiService>(uiSvc);
        }
예제 #9
0
 public void Setup()
 {
     mr         = new MockRepository();
     sp         = new ServiceContainer();
     uiSvc      = mr.StrictMock <IDecompilerShellUiService>();
     uiPrefsSvc = mr.StrictMock <IUiPreferencesService>();
     dlgFactory = mr.StrictMock <IDialogFactory>();
     uiSvc.Stub(u => u.SetContextMenu(null, 0)).IgnoreArguments();
     uiSvc.Replay();
     uiPrefsSvc.Stub(u => u.Styles).Return(new Dictionary <string, UiStyle>());
     uiPrefsSvc.Replay();
     sp.AddService(typeof(IDecompilerShellUiService), uiSvc);
     sp.AddService(typeof(IDialogFactory), dlgFactory);
     sp.AddService(typeof(IUiPreferencesService), uiPrefsSvc);
     addrBase = Address.Ptr32(0x1000);
 }
예제 #10
0
 public void Setup()
 {
     mr = new MockRepository();
     codeViewer = new CodeViewerPane();
     decompilerSvc = mr.Stub<IDecompilerService>();
     decompiler = mr.Stub<IDecompiler>();
     uiPreferencesSvc = mr.Stub<IUiPreferencesService>();
     uiSvc = mr.Stub<IDecompilerShellUiService>();
     font = new Font("Arial", 10);
     var sc = new ServiceContainer();
     decompilerSvc.Decompiler = decompiler;
     sc.AddService<IDecompilerService>(decompilerSvc);
     sc.AddService<IUiPreferencesService>(uiPreferencesSvc);
     sc.AddService<IDecompilerShellUiService>(uiSvc);
     codeViewer.SetSite(sc);
 }
예제 #11
0
 public void Setup()
 {
     mr         = new MockRepository();
     sp         = new ServiceContainer();
     uiSvc      = mr.StrictMock <IDecompilerShellUiService>();
     uiPrefsSvc = mr.StrictMock <IUiPreferencesService>();
     dlgFactory = mr.StrictMock <IDialogFactory>();
     uiSvc.Stub(u => u.GetContextMenu(MenuIds.CtxMemoryControl)).Return(new ContextMenu());
     uiSvc.Stub(u => u.GetContextMenu(MenuIds.CtxDisassembler)).Return(new ContextMenu());
     uiSvc.Replay();
     uiPrefsSvc.Replay();
     sp.AddService(typeof(IDecompilerShellUiService), uiSvc);
     sp.AddService(typeof(IDialogFactory), dlgFactory);
     sp.AddService(typeof(IUiPreferencesService), uiPrefsSvc);
     addrBase = Address.Ptr32(0x1000);
 }
예제 #12
0
        public void Setup()
        {
            mr = new MockRepository();
            sc = new ServiceContainer();

            form = new MainForm();

            var platform = mr.Stub <IPlatform>();

            program = new Program();
            program.Architecture = new X86ArchitectureReal("x86-real-16");
            program.Platform     = platform;
            var mem = new MemoryArea(Address.SegPtr(0xC00, 0), new byte[10000]);

            program.SegmentMap = new SegmentMap(
                mem.BaseAddress,
                new ImageSegment("0C00", mem, AccessMode.ReadWriteExecute));

            program.SegmentMap.AddSegment(Address.SegPtr(0x0C10, 0), "0C10", AccessMode.ReadWrite, 0);
            program.SegmentMap.AddSegment(Address.SegPtr(0x0C20, 0), "0C20", AccessMode.ReadWrite, 0);
            mapSegment1 = program.SegmentMap.Segments.Values[0];
            mapSegment2 = program.SegmentMap.Segments.Values[1];

            decSvc = new DecompilerService();

            sc.AddService <IDecompilerService>(decSvc);
            sc.AddService <IWorkerDialogService>(new FakeWorkerDialogService());
            sc.AddService <DecompilerEventListener>(new FakeDecompilerEventListener());
            sc.AddService <IStatusBarService>(new FakeStatusBarService());
            sc.AddService <DecompilerHost>(new FakeDecompilerHost());
            uiSvc  = AddService <IDecompilerShellUiService>();
            memSvc = AddService <ILowLevelViewService>();

            ILoader ldr = mr.StrictMock <ILoader>();

            ldr.Stub(l => l.LoadImageBytes("test.exe", 0)).Return(new byte[400]);
            ldr.Stub(l => l.LoadExecutable(
                         Arg <string> .Is.NotNull,
                         Arg <byte[]> .Is.NotNull,
                         Arg <string> .Is.Null,
                         Arg <Address> .Is.Null)).Return(program);
            ldr.Replay();
            decSvc.Decompiler = new DecompilerDriver(ldr, sc);
            decSvc.Decompiler.Load("test.exe");

            interactor = new ScannedPageInteractor(sc);
        }
예제 #13
0
        public void Setup()
        {
            mr               = new MockRepository();
            codeViewer       = new CodeViewerPane();
            decompilerSvc    = mr.Stub <IDecompilerService>();
            decompiler       = mr.Stub <IDecompiler>();
            uiPreferencesSvc = mr.Stub <IUiPreferencesService>();
            uiSvc            = mr.Stub <IDecompilerShellUiService>();
            font             = new Font("Arial", 10);
            var sc = new ServiceContainer();

            decompilerSvc.Decompiler = decompiler;
            sc.AddService <IDecompilerService>(decompilerSvc);
            sc.AddService <IUiPreferencesService>(uiPreferencesSvc);
            sc.AddService <IDecompilerShellUiService>(uiSvc);
            codeViewer.SetSite(sc);
        }
        public void Setup()
        {
            mr = new MockRepository();
            sp = new ServiceContainer();
            uiSvc = mr.StrictMock<IDecompilerShellUiService>();
            uiPrefsSvc = mr.StrictMock<IUiPreferencesService>();
            dlgFactory = mr.StrictMock<IDialogFactory>();
            uiSvc.Stub(u => u.GetContextMenu(MenuIds.CtxMemoryControl)).Return(new ContextMenu());
            uiSvc.Stub(u => u.GetContextMenu(MenuIds.CtxDisassembler)).Return(new ContextMenu());
            uiSvc.Replay();
            uiPrefsSvc.Stub(u => u.Styles).Return(new Dictionary<string, UiStyle>());
            uiPrefsSvc.Replay();
            sp.AddService(typeof(IDecompilerShellUiService), uiSvc);
			sp.AddService(typeof(IDialogFactory), dlgFactory);
            sp.AddService(typeof(IUiPreferencesService), uiPrefsSvc);
            addrBase = Address.Ptr32(0x1000);
        }
예제 #15
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);
 }
예제 #16
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;
 }
예제 #17
0
        public void Setup()
        {
            mr = new MockRepository();

            form  = mr.StrictMock <IMainForm>();
            sc    = new ServiceContainer();
            uiSvc = AddService <IDecompilerShellUiService>();
            sc.AddService(typeof(IDecompilerUIService), uiSvc);
            codeViewSvc   = AddService <ICodeViewerService>();
            memViewSvc    = AddService <ILowLevelViewService>();
            disasmViewSvc = AddService <IDisassemblyViewService>();
            pbSvc         = AddService <IProjectBrowserService>();

            form.Stub(f => f.Show());

            var     platform    = mr.Stub <IPlatform>();
            var     loadAddress = Address.Ptr32(0x100000);
            var     bytes       = new byte[4711];
            var     arch        = new X86ArchitectureFlat32();
            var     mem         = new MemoryArea(loadAddress, bytes);
            Program prog        = new Program
            {
                SegmentMap = new SegmentMap(
                    mem.BaseAddress,
                    new ImageSegment(".text", mem, AccessMode.ReadExecute)),
                Architecture = arch,
                Platform     = platform,
            };
            ILoader ldr = mr.StrictMock <ILoader>();

            ldr.Stub(l => l.LoadExecutable(null, null, null)).IgnoreArguments().Return(prog);
            ldr.Stub(l => l.LoadImageBytes(null, 0)).IgnoreArguments().Return(bytes);
            ldr.Replay();
            sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener());
            sc.AddService <DecompilerHost>(new FakeDecompilerHost());
            this.decSvc       = new DecompilerService();
            decSvc.Decompiler = new DecompilerDriver(ldr, sc);
            decSvc.Decompiler.Load("test.exe");
            program = decSvc.Decompiler.Project.Programs.First();
            decSvc.Decompiler.ScanPrograms();
            sc.AddService(typeof(IDecompilerService), decSvc);

            sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService());
        }
예제 #18
0
        public void Setup()
        {
            mr = new MockRepository();

            form = new MainForm();

            prog = new Program();
            prog.Architecture = new IntelArchitecture(ProcessorMode.Real);
            prog.Image        = new LoadedImage(Address.SegPtr(0xC00, 0), new byte[10000]);
            prog.ImageMap     = prog.Image.CreateImageMap();

            prog.ImageMap.AddSegment(Address.SegPtr(0x0C10, 0), "0C10", AccessMode.ReadWrite, 0);
            prog.ImageMap.AddSegment(Address.SegPtr(0x0C20, 0), "0C20", AccessMode.ReadWrite, 0);
            mapSegment1 = prog.ImageMap.Segments.Values[0];
            mapSegment2 = prog.ImageMap.Segments.Values[1];

            sc     = new ServiceContainer();
            decSvc = new DecompilerService();

            sc.AddService(typeof(IDecompilerService), decSvc);
            sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService());
            sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener());
            sc.AddService(typeof(IStatusBarService), new FakeStatusBarService());
            uiSvc  = AddService <IDecompilerShellUiService>();
            memSvc = AddService <ILowLevelViewService>();

            ILoader ldr = mr.StrictMock <ILoader>();

            ldr.Stub(l => l.LoadImageBytes("test.exe", 0)).Return(new byte[400]);
            ldr.Stub(l => l.LoadExecutable(
                         Arg <string> .Is.NotNull,
                         Arg <byte[]> .Is.NotNull,
                         Arg <Address> .Is.Null)).Return(prog);
            ldr.Replay();
            decSvc.Decompiler = new DecompilerDriver(ldr, new FakeDecompilerHost(), sc);
            decSvc.Decompiler.Load("test.exe");

            interactor = new LoadedPageInteractor(sc);
        }
예제 #19
0
파일: MenuSystem.cs 프로젝트: xor2003/reko
        public void ProcessKey(IDecompilerShellUiService uiSvc, KeyEventArgs e)
        {
            Dictionary <Keys, CommandID> bindings;
            var frame = uiSvc.ActiveFrame;

            if (frame != null)
            {
                var ct = frame.Pane as ICommandTarget;
                if (ct != null)
                {
                    if (bindingLists.TryGetValue(ct.GetType().FullName, out bindings))
                    {
                        CommandID cmdID;
                        if (bindings.TryGetValue(e.KeyData, out cmdID))
                        {
                            if (ct.Execute(cmdID))
                            {
                                e.Handled = true;
                                return;
                            }
                        }
                    }
                }
            }
            if (bindingLists.TryGetValue("", out bindings))
            {
                CommandID cmdID;
                if (bindings.TryGetValue(e.KeyData, out cmdID))
                {
                    if (this.target.Execute(cmdID))
                    {
                        e.Handled = true;
                        return;
                    }
                }
            }
            e.Handled = false;
        }
예제 #20
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();
                }
            }
        }
예제 #21
0
        public void Setup()
        {
            mr               = new MockRepository();
            program          = new Program();
            codeViewer       = new CodeViewerPane();
            decompilerSvc    = mr.Stub <IDecompilerService>();
            decompiler       = mr.Stub <IDecompiler>();
            uiPreferencesSvc = mr.Stub <IUiPreferencesService>();
            uiSvc            = mr.Stub <IDecompilerShellUiService>();
            frame            = mr.Stub <IWindowFrame>();
            font             = new Font("Arial", 10);
            var styles = new Dictionary <string, UiStyle>();

            uiPreferencesSvc.Stub(u => u.Styles).Return(styles);

            var sc = new ServiceContainer();

            decompilerSvc.Decompiler = decompiler;
            sc.AddService <IDecompilerService>(decompilerSvc);
            sc.AddService <IUiPreferencesService>(uiPreferencesSvc);
            sc.AddService <IDecompilerShellUiService>(uiSvc);
            codeViewer.SetSite(sc);
        }
예제 #22
0
        public void Setup()
        {
            mr = new MockRepository();

            form  = mr.StrictMock <IMainForm>();
            sc    = new ServiceContainer();
            uiSvc = AddService <IDecompilerShellUiService>();
            sc.AddService(typeof(IDecompilerUIService), uiSvc);
            codeViewSvc   = AddService <ICodeViewerService>();
            memViewSvc    = AddService <ILowLevelViewService>();
            disasmViewSvc = AddService <IDisassemblyViewService>();
            pbSvc         = AddService <IProjectBrowserService>();

            form.Stub(f => f.Show());

            var     loadAddress = Address.Ptr32(0x100000);
            var     bytes       = new byte[4711];
            Program prog        = new Program();

            prog.Image        = new LoadedImage(loadAddress, bytes);
            prog.ImageMap     = prog.Image.CreateImageMap();
            prog.Architecture = new IntelArchitecture(ProcessorMode.Protected32);
            ILoader ldr = mr.StrictMock <ILoader>();

            ldr.Stub(l => l.LoadExecutable(null, null, null)).IgnoreArguments().Return(prog);
            ldr.Stub(l => l.LoadImageBytes(null, 0)).IgnoreArguments().Return(bytes);
            ldr.Replay();
            sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener());
            this.decSvc       = new DecompilerService();
            decSvc.Decompiler = new DecompilerDriver(ldr, new FakeDecompilerHost(), sc);
            decSvc.Decompiler.Load("test.exe");
            program = decSvc.Decompiler.Project.Programs.First();
            decSvc.Decompiler.ScanPrograms();
            sc.AddService(typeof(IDecompilerService), decSvc);

            sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService());
        }
예제 #23
0
        public void Attach(IMainForm mainForm)
        {
            this.form = mainForm;

            uiSvc = sc.RequireService <IDecompilerShellUiService>();
            subWindowCommandTarget = uiSvc;

            var svcFactory = sc.RequireService <IServiceFactory>();

            CreateServices(svcFactory, sc);
            CreatePhaseInteractors(svcFactory);
            projectBrowserSvc.Clear();
            this.projectFilesWatcher = new ProjectFilesWatcher(sc);

            var uiPrefsSvc = sc.RequireService <IUiPreferencesService>();

            // It's ok if we can't load settings, just proceed with defaults.
            try
            {
                uiPrefsSvc.Load();
                if (uiPrefsSvc.WindowSize != new System.Drawing.Size())
                {
                    form.Size = uiPrefsSvc.WindowSize;
                }
                form.WindowState = uiPrefsSvc.WindowState;
            }
            catch { };
            SwitchInteractor(pageInitial);
            form.UpdateToolbarState();

            form.Closed += this.MainForm_Closed;

            //form.InitialPage.IsDirtyChanged += new EventHandler(InitialPage_IsDirtyChanged);//$REENABLE
            //MainForm.InitialPage.IsDirty = false;         //$REENABLE

            UpdateWindowTitle();
        }
예제 #24
0
        public void Setup()
        {
            mr = new MockRepository();
            mockFactory = new MockFactory(mr);
            var platform = mockFactory.CreatePlatform(); ;

            program = new Program
            {
                Architecture = platform.Architecture,
                Platform = platform,
            };
            codeViewer = new CodeViewerPane();
            decompilerSvc = mr.Stub<IDecompilerService>();
            decompiler = mr.Stub<IDecompiler>();
            uiPreferencesSvc = mr.Stub<IUiPreferencesService>();
            uiSvc = mr.Stub<IDecompilerShellUiService>();
            frame = mr.Stub<IWindowFrame>();
            font = new Font("Arial", 10);
            var styles = new Dictionary<string, UiStyle>()
            {
                {
                    UiStyles.CodeWindow,
                    new UiStyle
                    {
                        Background = new SolidBrush(Color.White),
                    }
                }
            };
            uiPreferencesSvc.Stub(u => u.Styles).Return(styles);
            var sc = new ServiceContainer();
            decompilerSvc.Decompiler = decompiler;
            sc.AddService<IDecompilerService>(decompilerSvc);
            sc.AddService<IUiPreferencesService>(uiPreferencesSvc);
            sc.AddService<IDecompilerShellUiService>(uiSvc);
            codeViewer.SetSite(sc);
        }
예제 #25
0
        private void Given_MainFormInteractor()
        {
            program       = CreateFakeProgram();
            svcFactory    = mr.StrictMock <IServiceFactory>();
            archSvc       = mr.StrictMock <IArchiveBrowserService>();
            dlgFactory    = mr.StrictMock <IDialogFactory>();
            uiSvc         = mr.StrictMock <IDecompilerShellUiService>();
            memSvc        = mr.StrictMock <ILowLevelViewService>();
            disasmSvc     = mr.StrictMock <IDisassemblyViewService>();
            typeLibSvc    = mr.StrictMock <ITypeLibraryLoaderService>();
            brSvc         = mr.Stub <IProjectBrowserService>();
            uiPrefs       = mr.StrictMock <IUiPreferencesService>();
            fsSvc         = mr.StrictMock <IFileSystemService>();
            tcHostSvc     = mr.StrictMock <ITabControlHostService>();
            dcSvc         = mr.StrictMock <IDecompilerService>();
            srSvc         = MockRepository.GenerateMock <ISearchResultService, IWindowPane>();
            diagnosticSvc = MockRepository.GenerateMock <IDiagnosticsService, IWindowPane>();
            resEditSvc    = mr.StrictMock <IResourceEditorService>();
            cgvSvc        = mr.StrictMock <ICallGraphViewService>();
            loader        = mr.StrictMock <ILoader>();
            vimpSvc       = mr.StrictMock <IViewImportsService>();
            symLdrSvc     = mr.StrictMock <ISymbolLoadingService>();

            svcFactory.Stub(s => s.CreateArchiveBrowserService()).Return(archSvc);
            svcFactory.Stub(s => s.CreateDecompilerConfiguration()).Return(new FakeDecompilerConfiguration());
            svcFactory.Stub(s => s.CreateDiagnosticsService(Arg <ListView> .Is.Anything)).Return(diagnosticSvc);
            svcFactory.Stub(s => s.CreateDecompilerService()).Return(dcSvc);
            svcFactory.Stub(s => s.CreateDisassemblyViewService()).Return(disasmSvc);
            svcFactory.Stub(s => s.CreateMemoryViewService()).Return(memSvc);
            svcFactory.Stub(s => s.CreateDecompilerEventListener()).Return(new FakeDecompilerEventListener());
            svcFactory.Stub(s => s.CreateInitialPageInteractor()).Return(new FakeInitialPageInteractor());
            svcFactory.Stub(s => s.CreateScannedPageInteractor()).Return(new FakeScannedPageInteractor());
            svcFactory.Stub(s => s.CreateAnalyzedPageInteractor()).Return(new FakeAnalyzedPageInteractor());
            svcFactory.Stub(s => s.CreateFinalPageInteractor()).Return(new FakeFinalPageInteractor());
            svcFactory.Stub(s => s.CreateTypeLibraryLoaderService()).Return(typeLibSvc);
            svcFactory.Stub(s => s.CreateProjectBrowserService(Arg <ITreeView> .Is.NotNull)).Return(brSvc);
            svcFactory.Stub(s => s.CreateUiPreferencesService()).Return(uiPrefs);
            svcFactory.Stub(s => s.CreateFileSystemService()).Return(fsSvc);
            svcFactory.Stub(s => s.CreateShellUiService(Arg <IMainForm> .Is.NotNull, Arg <DecompilerMenus> .Is.NotNull)).Return(uiSvc);
            svcFactory.Stub(s => s.CreateTabControlHost(Arg <TabControl> .Is.NotNull)).Return(tcHostSvc);
            svcFactory.Stub(s => s.CreateLoader()).Return(loader);
            svcFactory.Stub(s => s.CreateSearchResultService(Arg <ListView> .Is.NotNull)).Return(srSvc);
            svcFactory.Stub(s => s.CreateResourceEditorService()).Return(resEditSvc);
            svcFactory.Stub(s => s.CreateCallGraphViewService()).Return(cgvSvc);
            svcFactory.Stub(s => s.CreateViewImportService()).Return(vimpSvc);
            svcFactory.Stub(s => s.CreateSymbolLoadingService()).Return(symLdrSvc);
            services.AddService(typeof(IDialogFactory), dlgFactory);
            services.AddService(typeof(IServiceFactory), svcFactory);
            brSvc.Stub(b => b.Clear());

            form = mr.StrictMock <IMainForm>();
            var listView       = new ListView();
            var imagelist      = new ImageList();
            var tabResults     = new TabPage();
            var tabDiagnostics = new TabPage();
            var tabControl     = new TabControl {
                TabPages = { tabResults, tabDiagnostics }
            };
            var toolStrip   = new ToolStrip {
            };
            var statusStrip = new StatusStrip {
                Items = { new ToolStripLabel() }
            };
            var brToolbar      = new ToolStrip();
            var projectBrowser = mr.Stub <ITreeView>();

            form.Stub(f => f.DiagnosticsList).Return(listView);
            form.Stub(f => f.ImageList).Return(imagelist);
            form.Stub(f => f.Menu).SetPropertyAndIgnoreArgument();
            form.Stub(f => f.AddToolbar(null)).IgnoreArguments();
            form.Stub(f => f.AddProjectBrowserToolbar(null)).IgnoreArguments();
            form.Stub(f => f.Dispose());
            form.Stub(f => f.TabControl).Return(tabControl);
            form.Stub(f => f.FindResultsPage).Return(tabResults);
            form.Stub(f => f.DiagnosticsPage).Return(tabDiagnostics);
            form.Stub(f => f.FindResultsList).Return(listView);
            form.Stub(f => f.ToolBar).Return(toolStrip);
            form.Stub(f => f.ProjectBrowserToolbar).Return(toolStrip);
            form.Stub(f => f.ProjectBrowser).Return(projectBrowser);
            form.Stub(f => f.StatusStrip).Return(statusStrip);
            form.Stub(f => f.AddProjectBrowserToolbar(null)).IgnoreArguments();
            form.Stub(f => f.ProjectBrowserToolbar).Return(brToolbar);
            form.Stub(f => f.TitleText = "main.exe ").IgnoreArguments();
            form.Load += null;
            LastCall.IgnoreArguments();
            form.Closed += null;
            LastCall.IgnoreArguments();
            form.ProcessCommandKey += null;
            LastCall.IgnoreArguments();
            dlgFactory.Stub(d => d.CreateMainForm()).Return(form);
            tcHostSvc.Stub(t => t.Attach(Arg <IWindowPane> .Is.NotNull, Arg <TabPage> .Is.NotNull));
            tcHostSvc.Stub(t => t.QueryStatus(
                               Arg <CommandID> .Is.Anything,
                               Arg <CommandStatus> .Is.Anything,
                               Arg <CommandText> .Is.Anything)).Return(false);
            tcHostSvc.Stub(t => t.Execute(Arg <CommandID> .Is.Anything)).Return(false);

            uiSvc.Stub(u => u.DocumentWindows).Return(new List <IWindowFrame>());
        }
예제 #26
0
파일: ViewService.cs 프로젝트: nemerle/reko
 public ViewService(IServiceProvider sp)
 {
     this.sp = sp;
     this.shellUiSvc = sp.RequireService<IDecompilerShellUiService>();
 }
예제 #27
0
        private void CreateServices(IServiceFactory svcFactory, IServiceContainer sc, DecompilerMenus dm)
        {
            sc.AddService <DecompilerHost>(this);

            config = svcFactory.CreateDecompilerConfiguration();
            sc.AddService(typeof(IConfigurationService), config);

            var cmdFactory = new Commands.CommandFactory(sc);

            sc.AddService <ICommandFactory>(cmdFactory);

            sc.AddService(typeof(IStatusBarService), (IStatusBarService)this);

            diagnosticsSvc = svcFactory.CreateDiagnosticsService(form.DiagnosticsList);
            sc.AddService(typeof(IDiagnosticsService), diagnosticsSvc);

            decompilerSvc = svcFactory.CreateDecompilerService();
            sc.AddService(typeof(IDecompilerService), decompilerSvc);

            uiSvc = svcFactory.CreateShellUiService(form, dm);
            subWindowCommandTarget = uiSvc;
            sc.AddService(typeof(IDecompilerShellUiService), uiSvc);
            sc.AddService(typeof(IDecompilerUIService), uiSvc);

            var codeViewSvc = new CodeViewerServiceImpl(sc);

            sc.AddService <ICodeViewerService>(codeViewSvc);
            var segmentViewSvc = new ImageSegmentServiceImpl(sc);

            sc.AddService(typeof(ImageSegmentService), segmentViewSvc);

            var del = svcFactory.CreateDecompilerEventListener();

            workerDlgSvc = (IWorkerDialogService)del;
            sc.AddService(typeof(IWorkerDialogService), workerDlgSvc);
            sc.AddService(typeof(DecompilerEventListener), del);

            loader = svcFactory.CreateLoader();
            sc.AddService <ILoader>(loader);

            var abSvc = svcFactory.CreateArchiveBrowserService();

            sc.AddService <IArchiveBrowserService>(abSvc);

            sc.AddService <ILowLevelViewService>(svcFactory.CreateMemoryViewService());
            sc.AddService <IDisassemblyViewService>(svcFactory.CreateDisassemblyViewService());

            var tlSvc = svcFactory.CreateTypeLibraryLoaderService();

            sc.AddService <ITypeLibraryLoaderService>(tlSvc);

            this.projectBrowserSvc = svcFactory.CreateProjectBrowserService(form.ProjectBrowser);
            sc.AddService <IProjectBrowserService>(projectBrowserSvc);

            var upSvc = svcFactory.CreateUiPreferencesService();

            sc.AddService <IUiPreferencesService>(upSvc);

            var fsSvc = svcFactory.CreateFileSystemService();

            sc.AddService <IFileSystemService>(fsSvc);

            this.searchResultsTabControl = svcFactory.CreateTabControlHost(form.TabControl);
            sc.AddService <ITabControlHostService>(this.searchResultsTabControl);

            srSvc = svcFactory.CreateSearchResultService(form.FindResultsList);
            sc.AddService <ISearchResultService>(srSvc);
            searchResultsTabControl.Attach((IWindowPane)srSvc, form.FindResultsPage);
            searchResultsTabControl.Attach((IWindowPane)diagnosticsSvc, form.DiagnosticsPage);

            var resEditService = svcFactory.CreateResourceEditorService();

            sc.AddService <IResourceEditorService>(resEditService);

            var cgvSvc = svcFactory.CreateCallGraphViewService();

            sc.AddService <ICallGraphViewService>(cgvSvc);

            var viewImpSvc = svcFactory.CreateViewImportService();

            sc.AddService <IViewImportsService>(viewImpSvc);
        }
예제 #28
0
 public WindowsDecompilerEventListener(IServiceProvider sp)
 {
     this.sp = sp;
     uiSvc = sp.GetService<IDecompilerShellUiService>();
     diagnosticSvc = sp.GetService<IDiagnosticsService>();
 }
예제 #29
0
 public void ProcessKey(IDecompilerShellUiService uiSvc, KeyEventArgs e)
 {
     Dictionary<Keys, CommandID> bindings;
     var frame = uiSvc.ActiveFrame;
     if (frame != null)
     {
         var ct = frame.Pane as ICommandTarget;
         if (ct != null)
         {
             if (bindingLists.TryGetValue(ct.GetType().FullName, out bindings))
             {
                 CommandID cmdID;
                 if (bindings.TryGetValue(e.KeyData, out cmdID))
                 {
                     if (ct.Execute(cmdID))
                     {
                         e.Handled = true;
                         return;
                     }
                 }
             }
         }
     }
     if (bindingLists.TryGetValue("", out bindings))
     {
         CommandID cmdID;
         if (bindings.TryGetValue(e.KeyData, out cmdID))
         {
             if (this.target.Execute(cmdID))
             {
                 e.Handled = true;
                 return;
             }
         }
     }
     e.Handled = false;
 }
예제 #30
0
        private void CreateServices(IServiceFactory svcFactory, IServiceContainer sc, DecompilerMenus dm)
        {
            sc.AddService<DecompilerHost>(this);

            config = svcFactory.CreateDecompilerConfiguration();
            sc.AddService(typeof(IConfigurationService), config);

            var cmdFactory = new Commands.CommandFactory(sc);
            sc.AddService<ICommandFactory>(cmdFactory);

            sc.AddService(typeof(IStatusBarService), (IStatusBarService)this);

            diagnosticsSvc = svcFactory.CreateDiagnosticsService(form.DiagnosticsList);
            sc.AddService(typeof(IDiagnosticsService), diagnosticsSvc);

            decompilerSvc = svcFactory.CreateDecompilerService();
            sc.AddService(typeof(IDecompilerService), decompilerSvc);

            uiSvc = svcFactory.CreateShellUiService(form, dm);
            subWindowCommandTarget = uiSvc;
            sc.AddService(typeof(IDecompilerShellUiService), uiSvc);
            sc.AddService(typeof(IDecompilerUIService), uiSvc);

            var codeViewSvc = new CodeViewerServiceImpl(sc);
            sc.AddService(typeof(ICodeViewerService), codeViewSvc);
            var segmentViewSvc = new ImageSegmentServiceImpl(sc);
            sc.AddService(typeof(ImageSegmentService), segmentViewSvc);

            var del = svcFactory.CreateDecompilerEventListener();
            workerDlgSvc = (IWorkerDialogService)del;
            sc.AddService(typeof(IWorkerDialogService), workerDlgSvc);
            sc.AddService(typeof(DecompilerEventListener), del);

            loader = svcFactory.CreateLoader();
            sc.AddService(typeof(ILoader), loader);

            var abSvc = svcFactory.CreateArchiveBrowserService();
            sc.AddService(typeof(IArchiveBrowserService), abSvc);

            sc.AddService(typeof(ILowLevelViewService), svcFactory.CreateMemoryViewService());
            sc.AddService(typeof(IDisassemblyViewService), svcFactory.CreateDisassemblyViewService());

            var tlSvc = svcFactory.CreateTypeLibraryLoaderService();
            sc.AddService(typeof(ITypeLibraryLoaderService), tlSvc);

            this.projectBrowserSvc = svcFactory.CreateProjectBrowserService(form.ProjectBrowser);
            sc.AddService<IProjectBrowserService>(projectBrowserSvc);

            var upSvc = svcFactory.CreateUiPreferencesService();
            sc.AddService<IUiPreferencesService>(upSvc);

            var fsSvc = svcFactory.CreateFileSystemService();
            sc.AddService<IFileSystemService>(fsSvc);

            this.searchResultsTabControl = svcFactory.CreateTabControlHost(form.TabControl);
            sc.AddService<ITabControlHostService>(this.searchResultsTabControl);

            srSvc = svcFactory.CreateSearchResultService(form.FindResultsList);
            sc.AddService<ISearchResultService>(srSvc);
            searchResultsTabControl.Attach((IWindowPane) srSvc, form.FindResultsPage);
            searchResultsTabControl.Attach((IWindowPane) diagnosticsSvc, form.DiagnosticsPage);

            var resEditService = svcFactory.CreateResourceEditorService();
            sc.AddService<IResourceEditorService>(resEditService);
        }
 public WindowsDecompilerEventListener(IServiceProvider sp)
 {
     this.sp       = sp;
     uiSvc         = sp.GetService <IDecompilerShellUiService>();
     diagnosticSvc = sp.GetService <IDiagnosticsService>();
 }
예제 #32
0
 public ViewService(IServiceProvider sp)
 {
     this.sp         = sp;
     this.shellUiSvc = sp.RequireService <IDecompilerShellUiService>();
 }
예제 #33
0
        public void Setup()
        {
            mr = new MockRepository();
            program = new Program();
            codeViewer = new CodeViewerPane();
            decompilerSvc = mr.Stub<IDecompilerService>();
            decompiler = mr.Stub<IDecompiler>();
            uiPreferencesSvc = mr.Stub<IUiPreferencesService>();
            uiSvc = mr.Stub<IDecompilerShellUiService>();
            frame = mr.Stub<IWindowFrame>();
            font = new Font("Arial", 10);
            var styles = new Dictionary<string, UiStyle>();
            uiPreferencesSvc.Stub(u => u.Styles).Return(styles);

            var sc = new ServiceContainer();
            decompilerSvc.Decompiler = decompiler;
            sc.AddService<IDecompilerService>(decompilerSvc);
            sc.AddService<IUiPreferencesService>(uiPreferencesSvc);
            sc.AddService<IDecompilerShellUiService>(uiSvc);
            codeViewer.SetSite(sc);
        }