Ejemplo n.º 1
0
		public void Setup()
		{
            mr = new MockRepository();
            form = new MainForm();
            sc = new ServiceContainer();
            loader = mr.StrictMock<ILoader>();
            dec = mr.StrictMock<IDecompiler>();
            sc = new ServiceContainer();
            uiSvc = new FakeShellUiService();
            host = mr.StrictMock<DecompilerHost>();
            memSvc = mr.StrictMock<ILowLevelViewService>();
            var mem = new MemoryArea(Address.Ptr32(0x10000), new byte[1000]);
            var imageMap = new SegmentMap(
                mem.BaseAddress,
                new ImageSegment("code", mem, AccessMode.ReadWriteExecute));
            var arch = mr.StrictMock<IProcessorArchitecture>();
            var platform = mr.StrictMock<IPlatform>();
            program = new Program(imageMap, arch, platform);
            project = new Project { Programs = { program } };

            browserSvc = mr.StrictMock<IProjectBrowserService>();

            sc.AddService<IDecompilerUIService>(uiSvc);
            sc.AddService(typeof(IDecompilerShellUiService), uiSvc);
            sc.AddService(typeof(IDecompilerService), new DecompilerService());
            sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService());
            sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener());
            sc.AddService(typeof(IProjectBrowserService), browserSvc);
            sc.AddService(typeof(ILowLevelViewService), memSvc);
            sc.AddService<ILoader>(loader);
            sc.AddService<DecompilerHost>(host);

            i = new TestInitialPageInteractor(sc, dec);

		}
Ejemplo n.º 2
0
		protected Program RewriteFile(string relativePath, Address addrBase)
		{
            var sc = new ServiceContainer();
            var config = new FakeDecompilerConfiguration();
            sc.AddService<IConfigurationService>(config);
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener());
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            ILoader ldr = new Loader(sc);
            var program = ldr.AssembleExecutable(
                FileUnitTester.MapTestPath(relativePath),
                new X86TextAssembler(sc, new IntelArchitecture(ProcessorMode.Real)),
                addrBase);
            program.Platform = new DefaultPlatform(sc, program.Architecture);
            var ep = new EntryPoint(program.Image.BaseAddress, program.Architecture.CreateProcessorState());
            var project = new Project { Programs = { program } };
            var scan = new Scanner(
                program,
                new Dictionary<Address, ProcedureSignature>(),
                new ImportResolver(project),
                sc);
			scan.EnqueueEntryPoint(ep);
			scan.ScanImage();

			var dfa = new DataFlowAnalysis(program, new FakeDecompilerEventListener());
			dfa.AnalyzeProgram();
            return program;
		}
Ejemplo n.º 3
0
		protected Program RewriteFile(string relativePath, Address addrBase)
		{
            sc = new ServiceContainer();
            var config = new FakeDecompilerConfiguration();
            var eventListener = new FakeDecompilerEventListener();
            sc.AddService<IConfigurationService>(config);
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<DecompilerEventListener>(eventListener);
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            ILoader ldr = new Loader(sc);
            var program = ldr.AssembleExecutable(
                FileUnitTester.MapTestPath(relativePath),
                new X86TextAssembler(sc, new X86ArchitectureReal()),
                addrBase);
            program.Platform = new DefaultPlatform(sc, program.Architecture);
            var ep = new ImageSymbol(program.SegmentMap.BaseAddress);
            var project = new Project { Programs = { program } };
            var scan = new Scanner(
                program,
                new ImportResolver(project, program, eventListener),
                sc);
			scan.EnqueueImageSymbol(ep, true);
			scan.ScanImage();

            var importResolver = new ImportResolver(project, program, eventListener);
            var dfa = new DataFlowAnalysis(program, importResolver, eventListener);
			dfa.AnalyzeProgram();
            return program;
		}
Ejemplo n.º 4
0
		public void Setup()
		{
            mr = new MockRepository();
            form = new MainForm();
            sc = new ServiceContainer();
            loader = mr.StrictMock<ILoader>();
            dec = mr.StrictMock<IDecompiler>();
            sc = new ServiceContainer();
            uiSvc = new FakeShellUiService();
            host = mr.StrictMock<DecompilerHost>();
            memSvc = mr.StrictMock<ILowLevelViewService>();
            var image = new LoadedImage(Address.Ptr32(0x10000), new byte[1000]);
            var imageMap = image.CreateImageMap();
            var arch = mr.StrictMock<IProcessorArchitecture>();
            arch.Stub(a => a.CreateRegisterBitset()).Return(new BitSet(32));
            arch.Replay();
            var platform = mr.StrictMock<Platform>(null, arch);
            arch.BackToRecord();
            program = new Program(image, imageMap, arch, platform);
            project = new Project { Programs = { program } };

            browserSvc = mr.StrictMock<IProjectBrowserService>();

            sc.AddService<IDecompilerUIService>(uiSvc);
            sc.AddService(typeof(IDecompilerShellUiService), uiSvc);
            sc.AddService(typeof(IDecompilerService), new DecompilerService());
            sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService());
            sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener());
            sc.AddService(typeof(IProjectBrowserService), browserSvc);
            sc.AddService(typeof(ILowLevelViewService), memSvc);
            sc.AddService<ILoader>(loader);

            i = new TestInitialPageInteractor(sc, dec);

		}
Ejemplo n.º 5
0
        private void BuildTest(Address addrBase, IPlatform platform , Action<X86Assembler> asmProg)
        {
            var sc = new ServiceContainer();
            sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener());
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            var entryPoints = new List<EntryPoint>();
            var asm = new X86Assembler(sc, platform, addrBase, entryPoints);
            asmProg(asm);

            var lr = asm.GetImage();
            program = new Program(
                lr.Image,
                lr.ImageMap,
                arch,
                platform);
            var project = new Project { Programs = { program } };
            scanner = new Scanner(
                program,
                new Dictionary<Address, ProcedureSignature>(),
                new ImportResolver(project),
                sc);
            scanner.EnqueueEntryPoint(new EntryPoint(addrBase, arch.CreateProcessorState()));
            scanner.ScanImage();
        }
Ejemplo n.º 6
0
        public void Impres_ProcedureByName()
        {
            var proj = new Project
            {
                MetadataFiles =
                {
                    new MetadataFile
                    {
                         ModuleName = "foo",
                         TypeLibrary = new TypeLibrary
                         {
                              ServicesByName =
                              {
                                  {
                                      "bar@4",
                                      new SystemService
                                      {
                                          Name = "bar", Signature= new ProcedureSignature()
                                      }
                                  }
                              }
                         }
                    }
                }
            };

            var impres = new ImportResolver(proj);
            var ep = impres.ResolveProcedure("foo", "bar@4", new DefaultPlatform(services, arch));
            Assert.AreEqual("bar", ep.Name);
        }
Ejemplo n.º 7
0
 public void Load(Project project)
 {
     var uiPrefsSvc = Services.RequireService<IUiPreferencesService>();
     uiPrefsSvc.UpdateControlStyle(UiStyles.Browser, tree);
     uiPrefsSvc.UiPreferencesChanged += delegate { uiPrefsSvc.UpdateControlStyle(UiStyles.Browser, tree); };
     tree.ContextMenu = Services.RequireService<IDecompilerShellUiService>().GetContextMenu(MenuIds.CtxBrowser);
     tree.Nodes.Clear();
     this.mpitemToDesigner = new Dictionary<object, TreeNodeDesigner>();
     if (project == null)
     {
         tree.ShowRootLines = false;
         tree.ShowNodeToolTips = false;
         tree.Nodes.Clear();
         tree.Nodes.Add(tree.CreateNode("(No project loaded)"));
     }
     else 
     {
         AddComponents(project.Programs);
         AddComponents(project.MetadataFiles);
         project.MetadataFiles.CollectionChanged += TypeLibraries_CollectionChanged;
         tree.ShowNodeToolTips = true;
         tree.ShowRootLines = true;
     }
     this.project = project;
 }
Ejemplo n.º 8
0
        private void RunTest(string sExp, Action<ProcedureBuilder> builder)
        {
            var pb = new ProcedureBuilder(this.pb.Program.Architecture);
            builder(pb);
            var proc = pb.Procedure;
            var dg = new DominatorGraph<Block>(proc.ControlGraph, proc.EntryBlock);
            var project = new Project
            {
                Programs = { this.pb.Program }
            };
            var importResolver = new ImportResolver(
                project,
                this.pb.Program,
                new FakeDecompilerEventListener());
            var arch = new FakeArchitecture();
            
            var platform = new FakePlatform(null, arch);

            // Register r1 is assumed to always be implicit when calling
            // another procedure.
            var implicitRegs = new HashSet<RegisterStorage>
            {
                arch.GetRegister(1)
            };
            Debug.Print("GetRegister(1) {0}", arch.GetRegister(1));
            this.pb.Program.Platform = platform;
            this.pb.Program.Platform = new FakePlatform(null, new FakeArchitecture());
            this.pb.Program.SegmentMap = new SegmentMap(
                Address.Ptr32(0x0000),
                new ImageSegment(
                    ".text",
                    Address.Ptr32(0), 
                    0x40000,
                    AccessMode.ReadWriteExecute));

            // Perform the initial transformation
            var ssa = new SsaTransform(programFlow, proc, importResolver, dg, implicitRegs);

            // Propagate values and simplify the results.
            // We hope the the sequence
            //   esp = fp - 4
            //   mov [esp-4],eax
            // will become
            //   esp_2 = fp - 4
            //   mov [fp - 8],eax

            var vp = new ValuePropagator(this.pb.Program.Architecture, ssa.SsaState);
            vp.Transform();

            ssa.RenameFrameAccesses = true;
            ssa.AddUseInstructions = true;
            ssa.Transform();

            var writer = new StringWriter();
            proc.Write(false, writer);
            var sActual = writer.ToString();
            if (sActual != sExp)
                Debug.Print(sActual);
            Assert.AreEqual(sExp, sActual);
        }
Ejemplo n.º 9
0
 public ImportResolver(Project project, Program program, DecompilerEventListener eventListener)
 {
     if (project == null)
         throw new ArgumentNullException("project");
     this.project = project;
     this.program = program;
     this.eventListener = eventListener;
 }
Ejemplo n.º 10
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     var image = new LoadedImage(Address.Ptr32(0x12312300),new byte[0x1000]);
     var imageMap = image.CreateImageMap();
     var arch = new Reko.Arch.X86.X86ArchitectureFlat32();
     var program = new Core.Program(image, imageMap, arch, new DefaultPlatform(null, arch));
     var project = new Project { Programs = { program } };
     pbs.Load(project);
 }
Ejemplo n.º 11
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     var mem = new MemoryArea(Address.Ptr32(0x12312300),new byte[0x1000]);
     var imageMap = new SegmentMap(
             mem.BaseAddress,
             new ImageSegment("code", mem, AccessMode.ReadWriteExecute));
     var arch = new X86ArchitectureFlat32();
     var program = new Core.Program(imageMap, arch, new DefaultPlatform(null, arch));
     var project = new Project { Programs = { program } };
     pbs.Load(project);
 }
		private Program AssembleFile(string sourceFile, Address addr)
		{
            var ldr = new Loader(new ServiceContainer());
            var arch = new X86ArchitectureReal();
            Program program = ldr.AssembleExecutable(
                 FileUnitTester.MapTestPath(sourceFile),
                 new X86TextAssembler(sc, arch),
                addr);
            var project = new Project { Programs = { program } };
			var scan = new Scanner(program, new Dictionary<Address, ProcedureSignature>(), new ImportResolver(project), null);
			foreach (EntryPoint ep in program.EntryPoints)
			{
				scan.EnqueueEntryPoint(ep);
			}
			scan.ScanImage();
			return program;
		}
Ejemplo n.º 13
0
		private Program AssembleFile(string sourceFile, Address addr)
		{
            var ldr = new Loader(new ServiceContainer());
            var arch = new X86ArchitectureReal();
            Program program = ldr.AssembleExecutable(
                 FileUnitTester.MapTestPath(sourceFile),
                 new X86TextAssembler(sc, arch),
                addr);
            var project = new Project { Programs = { program } };
			var scan = new Scanner(
                program, 
                new ImportResolver(project, program, null), null);
			foreach (ImageSymbol ep in program.EntryPoints.Values)
			{
				scan.EnqueueImageSymbol(ep, true);
			}
			scan.ScanImage();
			return program;
		}
Ejemplo n.º 14
0
        protected void RunHexTest(string hexFile, string outputFile)
        {
            var svc = new ServiceContainer();
            var cfg = new FakeDecompilerConfiguration();
            svc.AddService<IConfigurationService>(cfg);
            ILoader ldr = new Loader(svc);
            var imgLoader = new DchexLoader(FileUnitTester.MapTestPath( hexFile), svc, null);
            var img = imgLoader.Load(null);
            var program = new Program(img.Image, img.Image.CreateImageMap(), img.Architecture, img.Platform);
            var project = new Project { Programs = { program } };
            var ep = new EntryPoint(program.Image.BaseAddress, program.Architecture.CreateProcessorState());
            var scan = new Scanner(program, new Dictionary<Address, ProcedureSignature>(), new ImportResolver(project), new FakeDecompilerEventListener());
            scan.EnqueueEntryPoint(ep);
            scan.ScanImage();

            var dfa = new DataFlowAnalysis(program, new FakeDecompilerEventListener());
            dfa.AnalyzeProgram();
            RunTest(program, outputFile);
        }
Ejemplo n.º 15
0
        private void BuildTest(Address addrBase, IPlatform platform , Action<X86Assembler> asmProg)
        {
            var sc = new ServiceContainer();
            var eventListener = new FakeDecompilerEventListener();
            sc.AddService<DecompilerEventListener>(eventListener);
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            var entryPoints = new List<ImageSymbol>();
            var asm = new X86Assembler(sc, platform, addrBase, entryPoints);
            asmProg(asm);

            program = asm.GetImage();
            var project = new Project { Programs = { program } };
            scanner = new Scanner(
                program,
                new ImportResolver(project, program, eventListener),
                sc);
            scanner.EnqueueImageSymbol(new ImageSymbol(addrBase), true);
            scanner.ScanImage();
        }
Ejemplo n.º 16
0
        public void NavigateToAddress()
        {
            var project = new Project { Programs = { program } };
            var memSvc = mr.DynamicMock<ILowLevelViewService>();
            var decSvc = mr.DynamicMock<IDecompilerService>();
            var dec = mr.DynamicMock<IDecompiler>();
            memSvc.Expect(x => x.ShowMemoryAtAddress(
                Arg<Program>.Is.NotNull,
                Arg<Address>.Matches(a => a.ToLinear() == 0x1234)));
            decSvc.Stub(d => d.Decompiler).Return(dec);
            dec.Stub(d => d.Project).Return(project);
            mr.ReplayAll();

            var sc = new ServiceContainer();
            sc.AddService<ILowLevelViewService>(memSvc);
            sc.AddService<IDecompilerService>(decSvc);
            var nav = new AddressNavigator(program, Address.Ptr32(0x1234), sc);
            nav.NavigateTo();

            mr.VerifyAll();
        }
Ejemplo n.º 17
0
        public void Impres_ProcedureByName()
        {
            var proj = new Project
            {
                MetadataFiles = 
                {
                    new MetadataFile
                    {
                         ModuleName = "foo"
                    }
                },
                Programs =
                {
                    program
                }
            };

            var module = new ModuleDescriptor("foo")
            {
                ServicesByName =
                {
                    {
                        "bar@4",
                         new SystemService
                         {
                            Name = "bar",
                            Signature = new ProcedureSignature()
                         }
                    }
                }
            };

            mockFactory.Given_UserDefinedMetafile("foo", null, null, module);

            var impres = new ImportResolver(proj);
            var ep = impres.ResolveProcedure("foo", "bar@4", platform);
            Assert.AreEqual("bar", ep.Name);
        }
Ejemplo n.º 18
0
        private void DecompileAssembler(string asmLabel, Address loadAddress)
        {
            var cfg = new DecompilerConfiguration();
            var asm = cfg.GetAssembler(asmLabel);
            var prog = asm.AssembleFragment(loadAddress, txtAssembler.Text + Environment.NewLine);
            var sc = new ServiceContainer();
            var loader = new Loader(sc);
            DecompilerDriver decomp = new DecompilerDriver(loader, sc);
            var proj = new Project {
                Programs = {
                    prog
                }
            };
            decomp.Project = proj;
            decomp.ScanPrograms();
            decomp.AnalyzeDataFlow();
            decomp.ReconstructTypes();
            decomp.StructureProgram();
            decomp.WriteDecompilerProducts();

            plcOutput.Text = host.DisassemblyWriter.ToString();
            plcDecompiled.Text = host.DecompiledCodeWriter.ToString();
        }
Ejemplo n.º 19
0
        public void Impres_ProcedureByName()
        {
            var proj = new Project
            {
                MetadataFiles = 
                {
                    new MetadataFile
                    {
                         ModuleName = "foo"
                    }
                },
                Programs =
                {
                    program
                }
            };

            var module = new ModuleDescriptor("foo")
            {
                ServicesByName =
                {
                    {
                        "bar@4",
                         new SystemService
                         {
                            Name = "bar",
                            Signature = new FunctionType()
                         }
                    }
                }
            };
            program.EnvironmentMetadata.Modules.Add("foo", module);

            var impres = new ImportResolver(proj, program, new FakeDecompilerEventListener());
            var ep = impres.ResolveProcedure("foo", "bar@4", platform);
            Assert.AreEqual("bar", ep.Name);
        }
Ejemplo n.º 20
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);
            }

            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));
        }
Ejemplo n.º 21
0
        public void Scanner_AddEntryPoint()
        {
            Given_Trace(new RtlTrace(0x12314)
            {
                m => { m.Return(4, 0); }
            });
            Given_Program(Address.Ptr32(0x12314));
            var project = new Project { Programs = { program } };

            var sc = new Scanner(
                program,
                null,
                new ImportResolver(project),
                new FakeDecompilerEventListener());
            sc.EnqueueEntryPoint(
                new EntryPoint(
                    Address.Ptr32(0x12314),
                    arch.CreateProcessorState()));
            sc.ScanImage();

            Assert.AreEqual(1, program.Procedures.Count);
            Assert.AreEqual(0x12314, program.Procedures.Keys[0].Offset);
            Assert.IsTrue(program.CallGraph.EntryPoints.Contains(program.Procedures.Values[0]));
        }
Ejemplo n.º 22
0
        private void RunTest(string sourceFile, string outputFile)
        {
            Program program;
            var asm = new X86TextAssembler(new X86ArchitectureFlat32());
            using (StreamReader rdr = new StreamReader(FileUnitTester.MapTestPath(sourceFile)))
            {
                program = asm.Assemble(Address.Ptr32(0x10000000), rdr);
                program.Platform = win32;
            }
            foreach (var item in asm.ImportReferences)
            {
                program.ImportReferences.Add(item.Key, item.Value);
            }
            var project = new Project { Programs = { program } };
            Scanner scan = new Scanner(
                program,
                new Dictionary<Address, ProcedureSignature>(),
                new ImportResolver(project),
                services);
            foreach (var ep in asm.EntryPoints)
            {
                scan.EnqueueEntryPoint(ep);
            }
            scan.ScanImage();

            using (FileUnitTester fut = new FileUnitTester(outputFile))
            {
                foreach (Procedure proc in program.Procedures.Values)
                {
                    proc.Write(true, fut.TextWriter);
                    fut.TextWriter.WriteLine();
                }
                fut.AssertFilesEqual();
            }
        }
Ejemplo n.º 23
0
        protected void RunHexTest(string hexFile, string outputFile)
        {
            var svc = new ServiceContainer();
            var cfg = new FakeDecompilerConfiguration();
            var eventListener = new FakeDecompilerEventListener();
            svc.AddService<IConfigurationService>(cfg);
            svc.AddService<DecompilerEventListener>(eventListener);
            svc.AddService<DecompilerHost>(new FakeDecompilerHost());
            ILoader ldr = new Loader(svc);
            var imgLoader = new DchexLoader(FileUnitTester.MapTestPath( hexFile), svc, null);
            var program = imgLoader.Load(null);
            var project = new Project { Programs = { program } };
            var ep = new ImageSymbol(program.ImageMap.BaseAddress);
            var importResolver = new ImportResolver(project, program, eventListener);
            var scan = new Scanner(program, importResolver, svc);
            scan.EnqueueImageSymbol(ep, true);
            scan.ScanImage();

            var dfa = new DataFlowAnalysis(program, null, eventListener);
            dfa.AnalyzeProgram();
            RunTest(program, outputFile);
        }
Ejemplo n.º 24
0
        public void Scanner_CallGraphTree()
        {
            Program prog = new Program();
            var addr = Address.SegPtr(0xC00, 0);
            var m = new X86Assembler(sc, new DefaultPlatform(sc, new X86ArchitectureReal()), addr, new List<EntryPoint>());
            m.i86();

            m.Proc("main");
            m.Call("baz");
            m.Ret();
            m.Endp("main");

            m.Proc("foo");
            m.Ret();
            m.Endp("foo");

            m.Proc("bar");
            m.Ret();
            m.Endp("bar");

            m.Proc("baz");
            m.Call("foo");
            m.Call("bar");
            m.Jmp("foo");
            m.Endp("baz");

            var lr = m.GetImage();
            prog.Image = lr.Image;
            prog.ImageMap = lr.ImageMap;
            prog.Architecture = lr.Architecture;
            prog.Platform = new FakePlatform(null, arch);
            var proj = new Project { Programs = { prog } };
            var scan = new Scanner(prog, new Dictionary<Address, ProcedureSignature>(), new ImportResolver(proj), sc);
            EntryPoint ep = new EntryPoint(addr, prog.Architecture.CreateProcessorState());
            scan.EnqueueEntryPoint(ep);
            scan.ScanImage();

            Assert.AreEqual(4, prog.Procedures.Count);
        }
Ejemplo n.º 25
0
 public void Sud_SaveMetadataReference()
 {
     var project = new Project
     {
         Programs =
         {
             new Program
             {
                 Filename = "c:\\test\\foo.exe",
             }
         },
         MetadataFiles =
         {
             new MetadataFile
             {
                 Filename = "c:\\test\\foo.def",
                 ModuleName = "foo.def",
             }
         }
     };
     var ps = new ProjectSaver();
     var sProject = ps.Save(project);
     Assert.AreEqual(1, project.MetadataFiles.Count);
     Assert.AreEqual("c:\\test\\foo.def", project.MetadataFiles[0].Filename);
     Assert.AreEqual("foo.def", project.MetadataFiles[0].ModuleName);
 }
Ejemplo n.º 26
0
 public void SudSaveProject()
 {
     Project project = new Project
     {
         Programs =
         {
             new Program
             {
                 Image = new LoadedImage(Address.SegPtr(0x1000, 0), new byte[100]),
                 DisassemblyFilename = "foo.asm",
                 IntermediateFilename = "foo.cod",
                 User = new UserData
                 {
                     Procedures =
                     {
                         {
                             Address.SegPtr(0x1000, 0x10),
                             new Procedure_v1
                             {
                                 Name = "foo",
                                 Signature = new SerializedSignature
                                 {
                                     ReturnValue = new Argument_v1 { Kind = new Register_v1("eax") },
                                     Arguments = new Argument_v1[]
                                     {
                                         new Argument_v1
                                         {
                                             Kind = new StackVariable_v1(),
                                             Type = new PrimitiveType_v1(Domain.SignedInt, 4)
                                         },
                                         new Argument_v1
                                         {
                                             Kind = new StackVariable_v1(),
                                             Type = new PrimitiveType_v1(Domain.SignedInt, 4)
                                         }
                                     }
                                 }
                             }
                         }
                     },
                     Globals =
                     {
                         {
                           Address.SegPtr(0x2000, 0),
                           new GlobalDataItem_v2 {
                                Address = Address.SegPtr(0x2000, 0).ToString(),
                                DataType = new StringType_v2 {
                                    Termination=StringType_v2.ZeroTermination,
                                    CharType = new PrimitiveType_v1 { Domain = Domain.Character, ByteSize = 1 }
                                }
                           }
                         }
                     }
                 }
             }
         }
     };
     using (FileUnitTester fut = new FileUnitTester("Core/SudSaveProject.txt"))
     {
         FilteringXmlWriter writer = new FilteringXmlWriter(fut.TextWriter);
         writer.Formatting = System.Xml.Formatting.Indented;
         XmlSerializer ser = SerializedLibrary.CreateSerializer_v3(typeof(Project_v3));
         Project_v3 ud = new ProjectSaver().Save(project);
         ser.Serialize(writer, ud);
         fut.AssertFilesEqual();
     }
 }
Ejemplo n.º 27
0
 public ImportResolver(Project project)
 {
     if (project == null)
         throw new ArgumentNullException("project");
     this.project = project;
 }
Ejemplo n.º 28
0
 public Project LoadProject(Project_v2 sp)
 {
     var typelibs = sp.Inputs.OfType<MetadataFile_v2>().Select(m => VisitMetadataFile(m));
     var programs = sp.Inputs.OfType<DecompilerInput_v2>().Select(s => VisitInputFile(s));
     var asm = sp.Inputs.OfType<AssemblerFile_v2>().Select(s => VisitAssemblerFile(s));
     var project = new Project();
     project.Programs.AddRange(programs);
     project.MetadataFiles.AddRange(typelibs);
     return project;
 }
Ejemplo n.º 29
0
 private void Given_Program()
 {
     var project = new Project { Programs = { program } };
     decompiler.Stub(d => d.Project).Return(project);
 }
Ejemplo n.º 30
0
        protected Project CreateDefaultProject(string fileName, Program program)
        {
            program.Filename = fileName;
            program.EnsureFilenames(fileName);

            var project = new Project
            {
                Programs = { program },
            };
            return project;
        }