Exemple #1
0
        public void CmdLine_EntryPoint()
        {
            var arch  = mr.Stub <IProcessorArchitecture>();
            var state = mr.Stub <ProcessorState>();

            configSvc.Stub(s => s.GetArchitecture("mmix")).Return(arch);
            arch.Stub(a => a.TryParseAddress(
                          Arg <string> .Is.Equal("010000"),
                          out Arg <Address> .Out(Address.Ptr32(0x010000)).Dummy))
            .Return(true);
            arch.Stub(a => a.TryParseAddress(
                          Arg <string> .Is.Equal("010100"),
                          out Arg <Address> .Out(Address.Ptr32(0x010100)).Dummy))
            .Return(true); mr.ReplayAll();
            arch.Stub(a => a.CreateProcessorState()).Return(state);
            decompiler.Stub(d => d.LoadRawImage(null, null))
            .IgnoreArguments()
            .Return(new Program());
            mr.ReplayAll();

            var cmdline = new CmdLineDriver(sc, ldr, decompiler, null);

            cmdline.Execute(new string[]
            {
                "--arch", "mmix",
                "--base", "010000",
                "--entry", "010100",
                "foo.exe"
            });

            mr.VerifyAll();
        }
Exemple #2
0
        public void Cvp_SetProcedure()
        {
            codeViewer.CreateControl();
            var m = new ProcedureBuilder();

            m.Return();

            using (mr.Record())
            {
                var project = new Project {
                    Programs = { new Program() }
                };
                decompiler.Stub(d => d.Project).Return(project);
                uiPreferencesSvc.SourceCodeFont = font;
            }

            codeViewer.DisplayProcedure(m.Procedure);

            string sExp =
                "void ProcedureBuilder()" + nl +
                "{" + nl +
                "ProcedureBuilder_entry:" + nl +
                "l1:" + nl +
                "    'return'" + nl +
                "ProcedureBuilder_exit:" + nl +
                "}" + nl;

            Assert.AreEqual(sExp, Flatten(codeViewer.TextView.Model));
        }
Exemple #3
0
        private void Given_DecompilerInstance()
        {
            this.decompiler = mr.StrictMock <IDecompiler>();
            // Having a compiler presupposes having a project.
            var project = new Project
            {
                Programs = { new Program
                             {
                                 Filename = "foo.exe",
                                 Image    = new LoadedImage(Address.Ptr32(0x00010000), new byte[100])
                             } }
            };

            dcSvc.Stub(d => d.Decompiler).Return(decompiler);
            decompiler.Stub(d => d.Project).Return(project);
            decompiler.Stub(d => d.Load(Arg <string> .Is.NotNull)).Return(false);
        }
Exemple #4
0
        private void Given_Program()
        {
            var project = new Project {
                Programs = { program }
            };

            decompiler.Stub(d => d.Project).Return(project);
        }
Exemple #5
0
        private void Given_DecompilerInstance()
        {
            this.decompiler = mr.StrictMock <IDecompiler>();
            // Having a compiler presupposes having a project.
            var platform = mockFactory.CreatePlatform();
            var mem      = new MemoryArea(Address.Ptr32(0x00010000), new byte[100]);
            var project  = new Project
            {
                Programs = { new Program
                             {
                                 Filename   = "foo.exe",
                                 SegmentMap = new SegmentMap(
                                     mem.BaseAddress,
                                     new ImageSegment(".text", mem, AccessMode.ReadExecute)),
                                 Platform     = platform,
                                 Architecture = platform.Architecture,
                             } }
            };

            dcSvc.Stub(d => d.Decompiler).Return(decompiler);
            decompiler.Stub(d => d.Project).Return(project);
            decompiler.Stub(d => d.Load(Arg <string> .Is.NotNull)).Return(false);
        }
        public void Mfi_FinishDecompilation()
        {
            Given_MainFormInteractor();
            Given_LoadPreferences();
            Given_DecompilerInstance();
            Given_XmlWriter();
            Given_SavePrompt(false);
            dcSvc.Stub(d => d.Decompiler = null).IgnoreArguments();
            decompiler.Stub(d => d.AnalyzeDataFlow());
            decompiler.Stub(d => d.ReconstructTypes());
            decompiler.Stub(d => d.StructureProgram());
            fsSvc.Stub(f => f.MakeRelativePath("foo.dcproject", "foo.exe")).Return("foo.exe");
            brSvc.Expect(b => b.Reload());
            mr.ReplayAll();

            When_CreateMainFormInteractor();
            interactor.OpenBinary("foo.exe");

            Assert.AreSame(interactor.InitialPageInteractor, interactor.CurrentPhase);
            interactor.FinishDecompilation();
            Assert.AreSame(interactor.FinalPageInteractor, interactor.CurrentPhase);

            mr.VerifyAll();
        }