示例#1
0
 protected MachineInstruction Disassemble(uint instr)
 {
     var image = new LoadedImage(Address.Ptr32(0x00100000), new byte[4]);
     LeImageWriter w = new LeImageWriter(image.Bytes);
     w.WriteLeUInt32(0, instr);
     var arch = CreateArchitecture();
     var dasm = CreateDisassembler(arch, image.CreateLeReader(0));
     Assert.IsTrue(dasm.MoveNext());
     return dasm.Current;
 }
示例#2
0
 protected LoadedImage CreateImage(Address addr, params uint[] opcodes)
 {
     byte[] bytes = new byte[0x20];
     var writer = new LeImageWriter(bytes);
     uint offset = 0;
     for (int i = 0; i < opcodes.Length; ++i, offset += 4)
     {
         writer.WriteLeUInt32(offset, opcodes[i]);
     }
     return new LoadedImage(addr, bytes);
 }
示例#3
0
 protected MachineInstruction DisassembleBits(string bitPattern)
 {
     var image = new MemoryArea(Address.Ptr32(0x00100000), new byte[4]);
     LeImageWriter w = new LeImageWriter(image.Bytes);
     uint instr = ParseBitPattern(bitPattern);
     w.WriteLeUInt32(0, instr);
     var b = image.Bytes;
     //Debug.Print("Instruction bytes: {0:X2} {1:X2} {2:X2} {3:X2}", b[0], b[1], b[2], b[3]); // Spews in the unit tests
     var arch = CreateArchitecture();
     var dasm = arch.CreateDisassembler(image.CreateLeReader(0));
     return dasm.First();
 }
示例#4
0
 private void Given_IndirectTable_UInt32(Address address,  Address addrIndirect, params uint[] entries)
 {
     ImageSegment seg;
     program.SegmentMap.Segments.TryGetValue(address, out seg);
     var writer = new LeImageWriter(seg.MemoryArea, address);
     foreach (uint entry in entries)
     {
         writer.WriteLeUInt32(entry);
     }
     writer = new LeImageWriter(seg.MemoryArea, addrIndirect);
     for (int i = 0; i< entries.Length; ++i)
     {
         writer.WriteByte((byte)i);
     }
 }
示例#5
0
 private void Given_Table_UInt32(Address address, params uint[] entries)
 {
     ImageSegment seg;
     program.SegmentMap.Segments.TryGetValue(address, out seg);
     var writer = new LeImageWriter(seg.MemoryArea, address);
     foreach (uint entry in entries)
     {
         writer.WriteLeUInt32(entry);
     }
 }