public void Setup() { this.sc = new ServiceContainer(); var cfg = new Mock <IConfigurationService>(); var env = new Mock <PlatformDefinition>(); cfg.Setup(c => c.GetEnvironment(It.IsAny <string>())).Returns(env.Object); env.Setup(e => e.Architectures).Returns(new List <PlatformArchitectureDefinition>()); sc.AddService <IConfigurationService>(cfg.Object); this.win32 = new Win32Platform(sc, new X86ArchitectureFlat32("x86-protected-32")); this.win_x86_64 = new Win_x86_64_Platform(sc, new X86ArchitectureFlat64("x86-protected-64")); this.sysV_ppc = new SysVPlatform(sc, new PowerPcBe32Architecture("ppc-be-32")); this.m = new ProcedureBuilder(); this.printfChr = new ProcedureCharacteristics() { VarargsParserClass = "Reko.Libraries.Libc.PrintfFormatParser,Reko.Libraries.Libc" }; this.x86PrintfSig = new FunctionType( null, StackId(null, 4, CStringType32()), StackId("...", 8, new UnknownType())); this.x86SprintfSig = new FunctionType( null, StackId(null, 4, CStringType32()), StackId(null, 8, CStringType32()), StackId("...", 12, new UnknownType())); this.win_x86_64PrintfSig = new FunctionType( null, RegId(null, win_x86_64, "rcx", CStringType64()), RegId("...", win_x86_64, "rdx", new UnknownType())); this.ppcPrintfSig = new FunctionType( null, RegId(null, sysV_ppc, "r3", CStringType32()), RegId("...", sysV_ppc, "r4", new UnknownType())); this.addrInstr = Address.Ptr32(0x123400); this.listener = new FakeDecompilerEventListener(); sc.AddService <DecompilerEventListener>(listener); this.dummyPc = new ProcedureConstant(PrimitiveType.Ptr32, new ExternalProcedure("dummy", x86PrintfSig)); }
public void SlLookupType() { var slib = new SerializedLibrary { Types = new SerializedType[] { new SerializedTypedef { Name = "int", DataType = new PrimitiveType_v1 { Domain = Reko.Core.Types.Domain.SignedInt, ByteSize = 4 } } } }; var sc = new ServiceContainer(); var arch = new X86ArchitectureFlat32(sc, "x86-protected-32", new Dictionary <string, object>()); var platform = new SysVPlatform(null, arch); var tldser = new TypeLibraryDeserializer(platform, true, new TypeLibrary()); var lib = tldser.Load(slib); Assert.AreEqual(PrimitiveType.Int32, lib.LookupType("int")); }
public void Setup() { arch = new X86ArchitectureFlat64(); platform = new SysVPlatform(null, arch); }
public void SysV_TerminatingFunction() { var mr = new MockRepository(); var sc = new ServiceContainer(); var arch = mr.Stub <IProcessorArchitecture>(); var tlSvc = mr.Stub <ITypeLibraryLoaderService>(); var cfgSvc = mr.Stub <IConfigurationService>(); sc.AddService <IConfigurationService>(cfgSvc); sc.AddService <ITypeLibraryLoaderService>(tlSvc); cfgSvc.Stub(c => c.GetEnvironment(null)) .IgnoreArguments() .Return(new OperatingEnvironmentElement { TypeLibraries = { new TypeLibraryElement { Name = "libc.xml" } }, CharacteristicsLibraries = { new TypeLibraryElement { Name = "libcharacteristics.xml", } } }); tlSvc.Stub(t => t.LoadCharacteristics(null)) .IgnoreArguments() .Return(new CharacteristicsLibrary { Entries = { { "exit", new ProcedureCharacteristics { Terminates = true } } } }); tlSvc.Stub(t => t.LoadLibrary(null, null)) .IgnoreArguments() .Return(new TypeLibrary { Signatures = { { "exit", new ProcedureSignature(null) } } }); mr.ReplayAll(); var sysv = new SysVPlatform(sc, arch); var proc = sysv.LookupProcedureByName(null, "exit"); Assert.IsTrue(proc.Characteristics.Terminates, "exit should have been marked as terminating."); }
public void Setup() { arch = new PowerPcArchitecture32(); platform = new SysVPlatform(null, arch); }