private void Given_ProcedureName(uint addr, string name)
        {
            var address = Address32.Ptr32(addr);
            var proc    = new Procedure(name, null);

            program.Procedures[address] = proc;
        }
Beispiel #2
0
        public void Setup()
        {
            mockFactory = new CommonMockFactory();
            var platform = mockFactory.CreateMockPlatform();
            var imageMap = new SegmentMap(Address32.Ptr32(0x05));

            program    = new Program(imageMap, platform.Object.Architecture, platform.Object);
            interactor = new CombinedCodeViewInteractor();
            var uiPreferencesSvc = new Mock <IUiPreferencesService>();
            var uiSvc            = new Mock <IDecompilerShellUiService>();

            var styles = new Dictionary <string, UiStyle>()
            {
                {
                    UiStyles.CodeWindow,
                    new UiStyle
                    {
                        Background = new SolidBrush(Color.White),
                    }
                }
            };

            uiPreferencesSvc.Setup(u => u.Styles).Returns(styles);
            var sc = new ServiceContainer();

            sc.AddService <IUiPreferencesService>(uiPreferencesSvc.Object);
            sc.AddService <IDecompilerShellUiService>(uiSvc.Object);
            interactor.SetSite(sc);
        }
Beispiel #3
0
        public void Cvp_CreateGlobalsViewerIfNotVisible()
        {
            var segment = new ImageSegment(
                ".seg", Address32.Ptr32(0x17), 0, AccessMode.ReadWrite);
            var label = ".seg global variables";

            var uiSvc = AddMockService <IDecompilerShellUiService>();

            uiSvc.Expect(s => s.FindDocumentWindow(
                             "CombinedCodeViewInteractor", segment))
            .Return(null);
            var windowPane  = mr.Stub <CombinedCodeViewInteractor>();
            var windowFrame = mr.StrictMock <IWindowFrame>();

            windowFrame.Stub(f => f.Pane).Return(windowPane);
            uiSvc.Expect(s => s.CreateDocumentWindow(
                             Arg <string> .Is.Equal("CombinedCodeViewInteractor"),
                             Arg <string> .Is.Equal(segment),
                             Arg <string> .Is.Equal(label),
                             Arg <IWindowPane> .Is.Anything))
            .Return(windowFrame);
            windowFrame.Expect(s => s.Show());

            mr.ReplayAll();

            var codeViewerSvc = new CodeViewerServiceImpl(sc);

            codeViewerSvc.DisplayGlobals(program, segment);

            uiSvc.VerifyAllExpectations();
        }
        public void Setup()
        {
            mr              = new MockRepository();
            services        = new ServiceContainer();
            declarationForm = mr.Stub <IDeclarationForm>();
            textBox         = new FakeTextBox();
            declarationForm.Stub(f => f.TextBox).Return(textBox);
            declarationForm.Stub(f => f.ShowAt(new Point()));
            declarationForm.Stub(f => f.Hide());
            declarationForm.Stub(f => f.Dispose());
            var dlgFactory = mr.Stub <IDialogFactory>();

            dlgFactory.Stub(f => f.CreateDeclarationForm()).Return(declarationForm);
            services.AddService <IDialogFactory>(dlgFactory);
            mr.ReplayAll();
            interactor = new DeclarationFormInteractor(services);
            var mem        = new MemoryArea(Address32.Ptr32(0x10), new byte[40]);
            var seg        = new ImageSegment(".text", mem, AccessMode.ReadWrite);
            var segmentMap = new SegmentMap(Address32.Ptr32(0x05), seg);
            var arch       = new X86ArchitectureFlat32();
            var platform   = new Win32Platform(null, arch);

            program          = new Program(segmentMap, arch, platform);
            program.ImageMap = segmentMap.CreateImageMap();
        }
Beispiel #5
0
 public override Address ReadPreferredImageBase(ImageReader rdr)
 {
     {
         uint rvaBaseOfData = rdr.ReadLeUInt32();        // Only exists in PE32, not PE32+
         return(Address32.Ptr32(rdr.ReadLeUInt32()));
     }
 }
Beispiel #6
0
        public void Cvp_CreateGlobalsViewerIfNotVisible()
        {
            var segment = new ImageSegment(
                ".seg", Address32.Ptr32(0x17), 0, AccessMode.ReadWrite);
            var label = ".seg global variables";

            var uiSvc = AddMockService <IDecompilerShellUiService>();

            uiSvc.Setup(s => s.FindDocumentWindow(
                            "CombinedCodeViewInteractor", segment))
            .Returns((IWindowFrame)null)
            .Verifiable();
            var windowPane  = new Mock <CombinedCodeViewInteractor>();
            var windowFrame = new Mock <IWindowFrame>();

            windowFrame.Setup(f => f.Pane).Returns(windowPane.Object);
            uiSvc.Setup(s => s.CreateDocumentWindow(
                            "CombinedCodeViewInteractor",
                            segment,
                            label,
                            It.IsAny <IWindowPane>()))
            .Returns(windowFrame.Object);
            windowFrame.Setup(s => s.Show()).Verifiable();

            var codeViewerSvc = new CodeViewerServiceImpl(sc);

            codeViewerSvc.DisplayGlobals(program, segment);

            uiSvc.VerifyAll();
            windowFrame.VerifyAll();
        }
        private void Given_ImageSegment(uint addr, params byte[] bytes)
        {
            var mem = new MemoryArea(Address32.Ptr32(addr), bytes);
            var seg = new ImageSegment(".text", mem, AccessMode.ReadWrite);

            program.ImageMap.AddSegment(seg);
        }
        private void Given_ProcedureSignature(uint addr, string CSignature)
        {
            Given_ProcedureName(addr, "<unnamed>");

            var address = Address32.Ptr32(addr);
            var sProc   = new Procedure_v1()
            {
                CSignature = CSignature,
            };

            program.User.Procedures[address] = sProc;
        }
Beispiel #9
0
        private void Given_ImageMapItem(uint addr, DataType dataType, string name)
        {
            var address = Address32.Ptr32(addr);
            var item    = new ImageMapItem(address)
            {
                DataType = dataType,
                Name     = name,
                Size     = (uint)dataType.Size,
            };

            program.ImageMap.AddItem(address, item);
        }
        private void Given_StubProcedure(uint addr, uint size)
        {
            var address = Address32.Ptr32(addr);
            var m       = new ProcedureBuilder("fnTest");

            m.Return();
            this.proc = m.Procedure;
            this.program.Procedures[address] = proc;

            var item = new ImageMapBlock
            {
                Address = address,
                Size    = size,
                Block   = new Block(proc, "fakeBlock")
            };

            program.ImageMap.AddItemWithSize(address, item);
        }
 private void When_MovedTo(uint addr)
 {
     interactor.SelectedAddress = Address32.Ptr32(addr);
 }
 private void When_DeclarationFormCreated(uint addr)
 {
     interactor.Show(new Point(0, 0), program, Address32.Ptr32(addr));
 }
 public void ExaUsrGlobals_Real32()
 {
     Given_GlobalVariable(
         Address32.Ptr32(0x10001200), PrimitiveType.Real32);
     RunTest(Constant.Create(PrimitiveType.Real32, 0x10001200));
 }