public ModuleDefinitionLoader(TextReader rdr, string filename, IProcessorArchitecture arch) : base(null, filename, null) { this.filename = filename; this.lexer = new Lexer(rdr); this.bufferedTok = null; this.arch = arch; }
public Arm32ProcedureSerializer( IProcessorArchitecture arch, ISerializedTypeVisitor<DataType> typeLoader, string defaultConvention) : base(arch, typeLoader, defaultConvention) { }
public void Setup() { mr = new MockRepository(); program = new Program(); proc = new Procedure("testProc", new Frame(PrimitiveType.Word32)); block = proc.AddBlock("l00100000"); trace = new RtlTrace(0x00100000); r0 = new Identifier("r0", PrimitiveType.Word32, new RegisterStorage("r0", 0, 0, PrimitiveType.Word32)); r1 = new Identifier("r1", PrimitiveType.Word32, new RegisterStorage("r1", 1, 0, PrimitiveType.Word32)); r2 = new Identifier("r2", PrimitiveType.Word32, new RegisterStorage("r2", 2, 0, PrimitiveType.Word32)); sp = new Identifier("sp", PrimitiveType.Word32, new RegisterStorage("sp", 15, 0, PrimitiveType.Word32)); grf = proc.Frame.EnsureFlagGroup(Registers.eflags, 3, "SCZ", PrimitiveType.Byte); var sc = new ServiceContainer(); var listener = mr.Stub<DecompilerEventListener>(); scanner = mr.StrictMock<IScanner>(); arch = mr.Stub<IProcessorArchitecture>(); program.Architecture = arch; program.SegmentMap = new SegmentMap( Address.Ptr32(0x00100000), new ImageSegment( ".text", new MemoryArea(Address.Ptr32(0x00100000), new byte[0x20000]), AccessMode.ReadExecute)); arch.Replay(); program.Platform = new DefaultPlatform(null, arch); arch.BackToRecord(); arch.Stub(s => s.StackRegister).Return((RegisterStorage)sp.Storage); arch.Stub(s => s.PointerType).Return(PrimitiveType.Pointer32); scanner.Stub(s => s.Services).Return(sc); sc.AddService<DecompilerEventListener>(listener); }
private void Given_Architecture() { this.arch = mr.StrictMock<IProcessorArchitecture>(); this.arch.Stub(a => a.Name).Return("testArch"); this.arch.Stub(a => a.SaveUserOptions()).Return(null); this.cfgSvc.Stub(c => c.GetArchitecture("testArch")).Return(arch); }
public ArgumentSerializer(ProcedureSerializer procSer, IProcessorArchitecture arch, Frame frame, string callingConvention) { this.procSer = procSer; this.arch = arch; this.frame = frame; this.convention = callingConvention; }
public void Setup() { this.sc = new ServiceContainer(); sc.AddService<IFileSystemService>(new FileSystemServiceImpl()); this.arch = new X86ArchitectureReal(); this.platform = new MsdosPlatform(sc, arch); ArgumentSerializer argSer = new ArgumentSerializer(arch); svc = new SerializedService { Name = "msdos_ioctl_get_device_info", SyscallInfo = new SerializedSyscallInfo { Vector = "21", RegisterValues = new[] { new SerializedRegValue("ah", "44"), new SerializedRegValue("al", "00"), } }, Signature = new SerializedSignature { ReturnValue = argSer.Serialize( new Identifier("C", PrimitiveType.Bool, new FlagGroupStorage(Registers.eflags, (uint)FlagM.CF, "C", PrimitiveType.Byte))) } }; }
public Program(SegmentMap segmentMap, IProcessorArchitecture arch, IPlatform platform) : this() { this.SegmentMap = segmentMap; this.ImageMap = segmentMap.CreateImageMap(); this.Architecture = arch; this.Platform = platform; }
public Program(LoadedImage image, ImageMap imageMap, IProcessorArchitecture arch, Platform platform) : this() { this.Image = image; this.ImageMap = imageMap; this.Architecture = arch; this.Platform = platform; }
public SystemService Build(IProcessorArchitecture arch) { SystemService svc = new SystemService(); svc.Name = Name; svc.SyscallInfo = new SyscallInfo(); svc.SyscallInfo.Vector = Convert.ToInt32(SyscallInfo.Vector, 16); if (SyscallInfo.RegisterValues != null) { svc.SyscallInfo.RegisterValues = new RegValue[SyscallInfo.RegisterValues.Length]; for (int i = 0; i < SyscallInfo.RegisterValues.Length; ++i) { svc.SyscallInfo.RegisterValues[i] = new RegValue { Register = arch.GetRegister(SyscallInfo.RegisterValues[i].Register), Value = Convert.ToInt32(SyscallInfo.RegisterValues[i].Value, 16), }; } } else { svc.SyscallInfo.RegisterValues = new RegValue[0]; } TypeLibraryLoader loader = new TypeLibraryLoader(arch, true); ProcedureSerializer sser = arch.CreateProcedureSerializer(loader, "stdapi"); svc.Signature = sser.Deserialize(Signature, arch.CreateFrame()); svc.Characteristics = Characteristics != null ? Characteristics : DefaultProcedureCharacteristics.Instance; return svc; }
public RtlStatementStream(uint address, Frame frame) { this.linAddress = address; this.arch = new FakeArchitecture(); this.frame = frame; this.stms = new List<RtlInstructionCluster>(); }
public void LoadRealmodeServices(IProcessorArchitecture arch) { string prefix = Environment.GetEnvironmentVariable("DECOMPILERROOTDIR") ?? "."; // TODO: extract runtime files ( like "realmodeintservices.xml") to their own directory ? string libPath = Path.Combine(prefix,"src","Environments","Msdos","realmodeintservices.xml"); if (!File.Exists (libPath)) { prefix = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); libPath = Path.Combine(prefix,"realmodeintservices.xml"); if (!File.Exists(libPath)) { libPath = Path.Combine(Directory.GetCurrentDirectory() , "realmodeintservices.xml"); } } SerializedLibrary lib; using (FileStream stm = new FileStream(libPath, FileMode.Open)) { lib = SerializedLibrary.LoadFromStream(stm); } int i = 0; realModeServices = new SystemService[lib.Procedures.Count]; foreach (SerializedService ssvc in lib.Procedures) { realModeServices[i++] = ssvc.Build(arch); } }
public ExePackLoader(IServiceProvider services, string filename, byte[] imgRaw) : base(services, filename, imgRaw) { arch = new IntelArchitecture(ProcessorMode.Real); platform = new MsdosPlatform(Services, arch); var exe = new ExeImageLoader(services, filename, imgRaw); this.exeHdrSize = (uint)(exe.e_cparHeader * 0x10U); this.hdrOffset = (uint)(exe.e_cparHeader + exe.e_cs) * 0x10U; ImageReader rdr = new LeImageReader(RawImage, hdrOffset); this.ip = rdr.ReadLeUInt16(); this.cs = rdr.ReadLeUInt16(); rdr.ReadLeUInt16(); this.cbExepackHeader = rdr.ReadLeUInt16(); this.sp = rdr.ReadLeUInt16(); this.ss = rdr.ReadLeUInt16(); this.cpUncompressed = rdr.ReadLeUInt16(); int offset = ExePackHeaderOffset(exe); if (LoadedImage.CompareArrays(imgRaw, offset, signature, signature.Length)) { relocationsOffset = 0x012D; } else if (LoadedImage.CompareArrays(imgRaw, offset, signature2, signature2.Length)) { relocationsOffset = 0x0125; } else throw new ApplicationException("Not a recognized EXEPACK image."); }
public void Setup() { ssaIds = new SsaIdentifierCollection(); mr = new MockRepository(); arch = mr.Stub<IProcessorArchitecture>(); importResolver = mr.Stub<IImportResolver>(); }
//$TODO: http://www.delorie.com/djgpp/doc/rbinter/ix/29.html int 29 for console apps! //$TODO: http://msdn.microsoft.com/en-us/data/dn774154(v=vs.99).aspx public Win32Platform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch) { int3svc = new SystemService { SyscallInfo = new SyscallInfo { Vector = 3, RegisterValues = new RegValue[0], }, Name = "int3", Signature = new ProcedureSignature(null, new Identifier[0]), Characteristics = new ProcedureCharacteristics(), }; var frame = arch.CreateFrame(); int29svc = new SystemService { SyscallInfo = new SyscallInfo { Vector = 0x29, RegisterValues = new RegValue[0] }, Name = "__fastfail", Signature = new ProcedureSignature( null, frame.EnsureRegister(Registers.ecx)), //$bug what about win64? Characteristics = new ProcedureCharacteristics { Terminates = true } }; }
public ModuleDefinitionLoader(IServiceProvider services, string filename, byte[] bytes) : base(services, filename, bytes) { this.filename = filename; this.lexer = new Lexer( new StreamReader(new MemoryStream(bytes))); this.bufferedTok = null; this.arch = new Reko.Arch.X86.X86ArchitectureFlat32(); }
public void Setup() { this.mr = new MockRepository(); this.sc = new ServiceContainer(); loader = mr.Stub<ILoader>(); arch = mr.StrictMock<IProcessorArchitecture>(); Address dummy; arch.Stub(a => a.TryParseAddress(null, out dummy)).IgnoreArguments().WhenCalled(m => { Address addr; var sAddr = (string)m.Arguments[0]; var iColon = sAddr.IndexOf(':'); if (iColon > 0) { addr = Address.SegPtr( Convert.ToUInt16(sAddr.Remove(iColon)), Convert.ToUInt16(sAddr.Substring(iColon+1))); m.ReturnValue = true; } else { m.ReturnValue = Address32.TryParse32((string)m.Arguments[0], out addr); } m.Arguments[1] = addr; }).Return(false); }
public ExePackLoader(IServiceProvider services, string filename, byte[] imgRaw) : base(services, filename, imgRaw) { var cfgSvc = services.RequireService<IConfigurationService>(); arch = cfgSvc.GetArchitecture("x86-real-16"); platform =cfgSvc.GetEnvironment("ms-dos") .Load(Services, arch); var exe = new ExeImageLoader(services, filename, imgRaw); this.exeHdrSize = (uint)(exe.e_cparHeader * 0x10U); this.hdrOffset = (uint)(exe.e_cparHeader + exe.e_cs) * 0x10U; ImageReader rdr = new LeImageReader(RawImage, hdrOffset); this.ip = rdr.ReadLeUInt16(); this.cs = rdr.ReadLeUInt16(); rdr.ReadLeUInt16(); this.cbExepackHeader = rdr.ReadLeUInt16(); this.sp = rdr.ReadLeUInt16(); this.ss = rdr.ReadLeUInt16(); this.cpUncompressed = rdr.ReadLeUInt16(); int offset = ExePackHeaderOffset(exe); if (MemoryArea.CompareArrays(imgRaw, offset, signature, signature.Length)) { relocationsOffset = 0x012D; } else if (MemoryArea.CompareArrays(imgRaw, offset, signature2, signature2.Length)) { relocationsOffset = 0x0125; } else throw new ApplicationException("Not a recognized EXEPACK image."); }
public Win_x86_64_Platform(IServiceProvider sp, IProcessorArchitecture arch) : base(sp, arch, "win64") { int3svc = new SystemService { SyscallInfo = new SyscallInfo { Vector = 3, RegisterValues = new RegValue[0], }, Name = "int3", Signature = FunctionType.Action(new Identifier[0]), Characteristics = new ProcedureCharacteristics(), }; int29svc = new SystemService { SyscallInfo = new SyscallInfo { Vector = 0x29, RegisterValues = new RegValue[0] }, Name = "__fastfail", Signature = FunctionType.Action( new Identifier("ecx", PrimitiveType.Word32, Registers.ecx)), Characteristics = new ProcedureCharacteristics { Terminates = true } }; }
private void Given_ArchitectureStub() { arch = mr.DynamicMock<IProcessorArchitecture>(); var procSer = mr.StrictMock<ProcedureSerializer>(null, null, null); arch.Stub(a => a.CreateProcedureSerializer(null, null)).IgnoreArguments().Return(procSer); procSer.Stub(p => p.Deserialize(null, null)).IgnoreArguments().Return(new ProcedureSignature()); }
public LzExeUnpacker(IServiceProvider services, ExeImageLoader exe, string filename, byte [] rawImg) : base(services, filename, rawImg) { this.arch = new IntelArchitecture(ProcessorMode.Real); this.platform = new MsdosPlatform(services, arch); Validate(exe); }
public ExternalProcedure CreateExternalProcedure(IProcessorArchitecture arch) { if (Characteristics == null) return new ExternalProcedure(Name, Signature); else return new ExternalProcedure(Name, Signature, Characteristics); }
public LzExeUnpacker(IServiceProvider services, ExeImageLoader exe, string filename, byte [] rawImg) : base(services, filename, rawImg) { var cfgSvc = services.RequireService<IConfigurationService>(); this.arch = cfgSvc.GetArchitecture("x86-real-16"); this.platform = cfgSvc.GetEnvironment("ms-dos") .Load(services, arch); Validate(exe); }
public Platform Load(IServiceProvider services, IProcessorArchitecture arch) { var type = Type.GetType(TypeName); if (type == null) throw new TypeLoadException( string.Format("Unable to load {0} environment.", Description)); return (Platform) Activator.CreateInstance(type, services, arch); }
public MsdosImageLoader(IServiceProvider services, string filename, ExeImageLoader exe) : base(services, filename, exe.RawImage) { this.exe = exe; var cfgSvc = services.RequireService<IConfigurationService>(); this.arch = cfgSvc.GetArchitecture("x86-real-16"); this.platform = cfgSvc.GetEnvironment("ms-dos") .Load(services, arch); }
private void Given_i386_Architecture() { this.arch_386 = mr.StrictMock<IProcessorArchitecture>(); arch_386.Stub(a => a.CreateFrame()).Return(new Frame(PrimitiveType.Pointer32)); arch_386.Stub(a => a.WordWidth).Return(PrimitiveType.Word32); var state = mr.Stub<ProcessorState>(); arch_386.Stub(a => a.CreateProcessorState()).Return(state); }
public PowerPcProcedureSerializer( IProcessorArchitecture arch, ISerializedTypeVisitor<DataType> typeLoader, string defaultCc) : base(arch, typeLoader, defaultCc) { this.arch = arch; }
public ElfObjectLinker(ElfLoader loader, IProcessorArchitecture arch, byte[] rawImage) { if (rawImage == null) throw new ArgumentNullException("rawImage"); this.loader = loader; this.arch = arch; this.rawImage = rawImage; }
public IAssumedRegisterValuesDialog CreateAssumedRegisterValuesDialog( IProcessorArchitecture arch) { return new AssumedRegisterValuesDialog { Architecture = arch, }; }
public MsdosImageLoader(IServiceProvider services, string filename, ExeImageLoader exe) : base(services, filename, exe.RawImage) { this.exe = exe; this.arch = new IntelArchitecture(ProcessorMode.Real); this.platform = this.platform = services.RequireService<IConfigurationService>() .GetEnvironment("ms-dos") .Load(services, arch); }
public LzExeUnpacker(IServiceProvider services, ExeImageLoader exe, string filename, byte [] rawImg) : base(services, filename, rawImg) { this.arch = new IntelArchitecture(ProcessorMode.Real); this.platform = services.RequireService<IConfigurationService>() .GetEnvironment("ms-dos") .Load(services, arch); Validate(exe); }
public BackwalkerHost(IProcessorArchitecture arch) { this.arch = arch; }
public HpuxPlatform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "hpux") { this.r27 = Architecture.GetRegister("r27") ?? throw new InvalidOperationException("Expected architecture to have r27."); }
public SsaProcedureBuilder(IProcessorArchitecture arch = null, string name = nameof(SsaProcedureBuilder)) : base(arch ?? new FakeArchitecture(), name) { this.Ssa = new SsaState(Procedure); }
public List <ImageSymbol> LoadEntryPoints( uint offEntryTable, NeSegment [] segments, Dictionary <int, string> names, IProcessorArchitecture arch) { trace.Inform("== Loading entry points from offset {0:X}", offEntryTable); var rdr = new LeImageReader(RawImage, offEntryTable); var entries = new List <ImageSymbol>(); int bundleOrdinal = 1; int nextbundleOrdinal = 1; for (; ;) { var cBundleEntries = rdr.ReadByte(); if (cBundleEntries == 0) { break; } nextbundleOrdinal = bundleOrdinal + cBundleEntries; var segNum = rdr.ReadByte(); if (segNum != 0) { // If segNum had been 0, it would have // meant that all we want to do is allocate // (skip) some ordinal numbers. Since it wasn't 0, // we proceed to generate entry points. for (int i = 0; i < cBundleEntries; ++i) { byte flags = rdr.ReadByte(); (byte iSeg, ushort offset)entry; if (segNum == 0xFF) { entry = ReadMovableSegmentEntry(rdr); } else { entry = ReadFixedSegmentEntry(rdr, segNum); } var seg = segments[entry.iSeg - 1]; var addr = seg.Address + entry.offset; if (!names.TryGetValue(bundleOrdinal + i, out string name)) { name = null; } ImageSymbol ep; if (seg.IsData) { ep = ImageSymbol.DataObject(arch, addr, name, new UnknownType()); } else { ep = ImageSymbol.Procedure(arch, addr, name); ep.Ordinal = bundleOrdinal + i; ep.Type = SymbolType.Procedure; ep.ProcessorState = arch.CreateProcessorState(); } entries.Add(ep); imageSymbols[ep.Address] = ep; trace.Verbose(" {0:X2} {1} {2} - {3}", segNum, ep.Address, ep.Name, ep.Ordinal); } } else { // We have unused entries, they have to occupy a space in the resulting entries table. entries.AddRange(Enumerable.Range(0, cBundleEntries).Select(x => (ImageSymbol)null)); } bundleOrdinal = nextbundleOrdinal; } return(entries); }
public ExternalProcedure GetInterceptedCall(IProcessorArchitecture arch, Address addrImportThunk) { throw new NotImplementedException(); }
public void Bwslc_RepMovsd() { // Original i386 code: // shr ecx,02 // and edx,03 // cmp ecx,08 // jc 00002000 // rep movsd // jmp dword ptr[007862E8 + edx * 4] arch = new Reko.Arch.X86.X86ArchitectureReal("x86-real-16"); var ecx = binder.EnsureRegister(arch.GetRegister("ecx")); var edx = binder.EnsureRegister(arch.GetRegister("edx")); var esi = binder.EnsureRegister(arch.GetRegister("esi")); var edi = binder.EnsureRegister(arch.GetRegister("edi")); var C = binder.EnsureFlagGroup(arch.GetFlagGroup("C")); var SZO = binder.EnsureFlagGroup(arch.GetFlagGroup("SZO")); var SCZO = binder.EnsureFlagGroup(arch.GetFlagGroup("SCZO")); var tmp = binder.CreateTemporary(ecx.DataType); var b = Given_Block(0x1000); Given_Instrs(b, m => { m.Assign(ecx, m.Shr(ecx, 2)); m.Assign(SCZO, m.Cond(ecx)); }); Given_Instrs(b, m => { m.Assign(edx, m.And(edx, 3)); m.Assign(SZO, m.Cond(edx)); m.Assign(C, Constant.False()); }); Given_Instrs(b, m => { m.Assign(SCZO, m.Cond(m.ISub(ecx, 8))); }); Given_Instrs(b, m => { m.Branch(m.Test(ConditionCode.ULT, C), Address.Ptr32(0x2000), RtlClass.ConditionalTransfer); }); var b2 = Given_Block(0x1008); Given_Instrs(b2, m => { m.BranchInMiddleOfInstruction(m.Eq0(ecx), Address.Ptr32(0x1010), RtlClass.ConditionalTransfer); m.Assign(tmp, m.Mem32(esi)); m.Assign(m.Mem32(edi), tmp); m.Assign(esi, m.IAdd(esi, 4)); m.Assign(edi, m.IAdd(edi, 4)); m.Assign(ecx, m.ISub(ecx, 1)); m.Goto(Address.Ptr32(0x1008)); }); var b3 = Given_Block(0x1010); Given_Instrs(b3, m => { m.Goto(m.Mem32(m.IAdd(m.IMul(edx, 4), 0x00123400))); }); graph.Nodes.Add(b); graph.Nodes.Add(b2); graph.Nodes.Add(b3); graph.AddEdge(b, b2); graph.AddEdge(b2, b3); graph.AddEdge(b2, b2); var bwslc = new BackwardSlicer(host); Assert.IsTrue(bwslc.Start(b3, -1, Target(b3))); // indirect jump Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.IsTrue(bwslc.Step()); Assert.False(bwslc.Step()); // edx &= 3 Assert.AreEqual("Mem0[(edx & 0x00000003) * 0x00000004 + 0x00123400:word32]", bwslc.JumpTableFormat.ToString()); Assert.AreEqual("1[0,3]", bwslc.JumpTableIndexInterval.ToString()); }
public Ps3Platform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "ps3") { }
public CrayProcessorState(IProcessorArchitecture arch) { this.Architecture = arch; }
public ProcedureTests() { mr = new MockRepository(); arch = mr.Stub <IProcessorArchitecture>(); arch.Replay(); }
public SysVPlatform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "elf-neutral") { this.trashedRegs = LoadTrashedRegisters(); archSpecificFactory = new ArchSpecificFactory(services, arch); }
public void Bwslc_Dpbs() { // This test is derived from a m68k binary which originally looked like this: // cmpi.b #$17,d0 // bhi $0010F010 // // moveq #$00,d1 // move.b d0,d1 // add.w d1,d1 // move.w (06,pc,d1),d1 // jmp.l (pc,d1) // The code introduces a lot of DPB's, which must be dealt with appropriately. var W8 = PrimitiveType.Byte; var W16 = PrimitiveType.Word16; var W32 = PrimitiveType.Word32; var I16 = PrimitiveType.Int16; var I32 = PrimitiveType.Int32; arch = new Reko.Arch.M68k.M68kArchitecture("m68k"); var d0 = Reg("d0"); var d1 = Reg("d1"); var v2 = binder.CreateTemporary("v2", W8); var v3 = binder.CreateTemporary("v3", W8); var v4 = binder.CreateTemporary("v4", W16); var v5 = binder.CreateTemporary("v5", PrimitiveType.Word16); var CVZNX = Cc("CVZNX"); var CVZN = Cc("CVZN"); var CZ = Cc("CZ"); var b = Given_Block(0x00100000); Given_Instrs(b, m => { m.Assign(v2, m.ISub(m.Cast(PrimitiveType.Byte, d0), 0x17)); m.Assign(CVZN, m.Cond(v2)); }); Given_Instrs(b, m => { m.Branch(m.Test(ConditionCode.UGT, CZ), Address.Ptr32(0x00100040), RtlClass.ConditionalTransfer); }); var b2 = Given_Block(0x00100008); Given_Instrs(b2, m => { m.Assign(d1, m.Word32(0)); m.Assign(CVZN, m.Cond(d1)); }); Given_Instrs(b2, m => { m.Assign(v3, m.Cast(v3.DataType, d0)); m.Assign(d1, m.Dpb(d1, v3, 0)); m.Assign(CVZN, m.Cond(v3)); }); Given_Instrs(b2, m => { m.Assign(v4, m.IAdd(m.Cast(v4.DataType, d1), m.Cast(v4.DataType, d1))); m.Assign(d1, m.Dpb(d1, v4, 0)); m.Assign(CVZNX, m.Cond(v4)); }); Given_Instrs(b2, m => { m.Assign(v5, m.Mem16(m.IAdd(m.Word32(0x0010EC32), m.Cast(W32, m.Cast(W16, d1))))); m.Assign(d1, m.Dpb(d1, v5, 0)); m.Assign(CVZN, m.Cond(v5)); }); Given_Instrs(b2, m => { m.Goto(m.IAdd(m.Word32(0x0010EC30), m.Cast(I32, m.Cast(I16, d1)))); }); graph.Nodes.Add(b); graph.Nodes.Add(b2); graph.AddEdge(b, b2); var bwslc = new BackwardSlicer(host); Assert.IsTrue(bwslc.Start(b2, 10, Target(b2))); while (bwslc.Step()) { ; } Assert.AreEqual(2, bwslc.Live.Count); Assert.AreEqual("(int32) (int16) Mem0[(word32) (word16) ((word32) d0 * 0x00000002) + 0x0010EC32:word16] + 0x0010EC30", bwslc.JumpTableFormat.ToString()); Assert.AreEqual("d0", bwslc.JumpTableIndex.ToString()); Assert.AreEqual("(byte) d0", bwslc.JumpTableIndexToUse.ToString(), "Expression to use when indexing"); Assert.AreEqual("1[0,17]", bwslc.JumpTableIndexInterval.ToString()); }
protected override IEnumerator <MachineInstruction> CreateDisassembler(IProcessorArchitecture arch, EndianImageReader rdr) { return(arch.CreateDisassembler(rdr).GetEnumerator()); }
public static Procedure Create(IProcessorArchitecture arch, Address addr, Frame f) { return(new Procedure(arch, NamingPolicy.Instance.ProcedureName(addr), addr, f)); }
public bool TryRead(IProcessorArchitecture arch, Address addr, PrimitiveType dt, out Constant value) { throw new NotImplementedException(); }
public PrintfApplicationBuilder( IProcessorArchitecture arch, Frame frame, CallSite site, Expression callee, ProcedureSignature sigCallee, bool ensureVariables) : base(arch, frame, site, callee, sigCallee, ensureVariables) { }
public Win32MipsPlatform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "winMips") { }
private static ExternalProcedure FastcallSignature(string name, int argBytes, IProcessorArchitecture arch) { return(new ExternalProcedure(name, new FunctionType { ReturnAddressOnStack = arch.PointerType.Size, StackDelta = argBytes - 2 * arch.PointerType.Size, // ecx, edx })); }
private void Given_Architecture() { this.arch = mr.StrictMock <IProcessorArchitecture>(); }
public AtariTOSPlatform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "atariTOS") { }
public override Program Load(Address addrLoad) { var cfgSvc = Services.RequireService <IConfigurationService>(); this.arch = cfgSvc.GetArchitecture("x86-protected-16"); var rdr = new LeImageReader(RawImage, this.lfaNew); if (!LoadNeHeader(rdr)) { throw new BadImageFormatException("Unable to read NE header."); } switch (bTargetOs) { case NE_TARGETOS.Windows: case NE_TARGETOS.Windows386: this.platform = cfgSvc.GetEnvironment("win16").Load(Services, arch); break; case NE_TARGETOS.EuropeanDos: this.platform = cfgSvc.GetEnvironment("ms-dos").Load(Services, arch); break; case NE_TARGETOS.Os2: this.platform = cfgSvc.GetEnvironment("os2-16").Load(Services, arch); break; default: // Not implemented break; } var program = new Program( this.segmentMap, arch, platform); var rsrcLoader = new ResourceLoader(RawImage, this.lfaNew + offRsrcTable, cResourceTableEntries); switch (bTargetOs) { case NE_TARGETOS.Windows: case NE_TARGETOS.Windows386: program.Resources.Name = "NE resources"; if (offRsrcTable != offResidentNameTable) // Some NE images contain no resources (indicated by offRsrcTable == offResidentNameTable) { program.Resources.Resources.AddRange(rsrcLoader.LoadResources()); } break; case NE_TARGETOS.Os2: program.Resources.Name = "OS/2 resources"; program.Resources.Resources.AddRange(rsrcLoader.LoadOs2Resources(segments, cSeg, cbFileAlignmentShift)); break; default: // Don´t support resources break; } foreach (var impRef in this.importStubs.Values) { program.ImportReferences.Add(impRef.Item1, impRef.Item2); } return(program); }
public SegaGenesisPlatform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "sega-genesis") { }
public Win32ThumbPlatform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "winArm") { this.systemServices = new Dictionary <int, SystemService> { { 0x00FE, new SystemService { SyscallInfo = new SyscallInfo { Vector = 0x00FE, RegisterValues = new RegValue[0] }, Name = "__debugbreak", // Breaks into the debugger. Used by ntdll!DbgUserBreakPoint(). } }, { 0x00FC, new SystemService { SyscallInfo = new SyscallInfo { Vector = 0x00FC, RegisterValues = new RegValue[0], }, Name = "__assertfail", // Used to indicate critical assertion failures in the kernel debugger. Used by KeAccumulateTicks() } }, { 0x00FB, new SystemService { SyscallInfo = new SyscallInfo { Vector = 0x00FB, RegisterValues = new RegValue[0], }, Name = "__fastfail", // Indicates fast fail conditions resulting in KeBugCheckEx(KERNEL_SECURITY_CHECK_FAILURE). Called by functions like InsertTailList() upon detecting a corrupted list, as described in [9]. Characteristics = new ProcedureCharacteristics { Terminates = true, } } }, { 0x00FA, new SystemService { SyscallInfo = new SyscallInfo { Vector = 0x00FA, RegisterValues = new RegValue[0] }, Name = "__rdpmccntr64", // Reads the 64-bit performance counter co-processor register and returns the value in R0+R1. Used by ReadTimeStampCounter(), KiCacheFlushTrial() etc. } }, { 0x00FD, new SystemService { SyscallInfo = new SyscallInfo { Vector = 0x00FD, RegisterValues = new RegValue[0], }, Name = "__debugservice", // Invoke debugger breakpoint. Used by DbgBreakPointWithStatusEnd(), DebugPrompt() etc. } }, { 0x00F9, new SystemService { SyscallInfo = new SyscallInfo { Vector = 0x00F9, RegisterValues = new RegValue[0], }, Name = "__brkdiv0", // Divide By Zero Exception, used by functions like nt!_rt_udiv and nt!_rt_udiv. Also generated by the compiler to check the divisor before division operations. Characteristics = new ProcedureCharacteristics { Terminates = true, } } } }; }
public CpmPlatform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "cpm") { this.dispatchProcedures = new Dictionary <Address, DispatchProcedure>(); EnsureTypeLibraries(this.PlatformIdentifier); }
public TestProcessorState(IProcessorArchitecture arch) { this.arch = arch; }
protected virtual Address GetMainFunctionAddress(IProcessorArchitecture arch, MemoryArea mem, int offset, StartPattern sPattern) { return(null); }
public FakeProcessorState(IProcessorArchitecture arch) { this.arch = arch; this.regValues = new Dictionary <RegisterStorage, Constant>(); this.stackValues = new SortedList <int, Constant>(); }
public FakePlatform(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch) { }
public X86Specific(IProcessorArchitecture arch) : base(arch) { }
public LongAddRewriter(SsaState ssa, DecompilerEventListener listener) { this.ssa = ssa; this.arch = ssa.Procedure.Architecture; this.listener = listener; }
public ColorComputer(IServiceProvider services, IProcessorArchitecture arch) : base(services, arch, "coco") { }