public void DumpAssembler(SegmentMap map, IProcessorArchitecture arch, Address addrStart, Address addrLast, Formatter formatter) { if (!map.TryFindSegment(addrStart, out var segment)) { return; } var dasm = arch.CreateDisassembler(arch.CreateImageReader(segment.MemoryArea, addrStart)); try { var writer = new InstrWriter(formatter); var options = new MachineInstructionRendererOptions( flags: MachineInstructionRendererFlags.ResolvePcRelativeAddress, syntax: ""); foreach (var instr in dasm) { if (instr.Address ! >= addrLast) { break; } if (!DumpAssemblerLine(segment.MemoryArea, arch, instr, writer, options)) { break; } } } catch (Exception ex) { formatter.WriteLine(ex.Message); formatter.WriteLine(); } }
public void DumpAssembler(SegmentMap map, Address addrStart, Address addrLast, Formatter formatter) { ImageSegment segment; if (!map.TryFindSegment(addrStart, out segment)) { return; } var dasm = arch.CreateDisassembler(arch.CreateImageReader(segment.MemoryArea, addrStart)); try { var writer = new InstrWriter(formatter); foreach (var instr in dasm) { if (instr.Address >= addrLast) { break; } if (!DumpAssemblerLine(segment.MemoryArea, instr, writer)) { break; } } } catch (Exception ex) { formatter.WriteLine(ex.Message); formatter.WriteLine(); } }
public bool DumpAssemblerLine( MemoryArea mem, IProcessorArchitecture arch, MachineInstruction instr, InstrWriter writer, MachineInstructionRendererOptions options) { var instrAddress = instr.Address; Address addrBegin = instrAddress; if (ShowAddresses) { writer.WriteFormat("{0} ", addrBegin); } if (ShowCodeBytes) { WriteOpcodes(mem, arch, instrAddress, instrAddress + instr.Length, writer); if (instr.Length * 3 < 16) { writer.WriteString(new string(' ', 16 - (instr.Length * 3))); } } writer.WriteString("\t"); instr.Render(writer, options); writer.WriteLine(); return(true); }
public void DumpAssembler( IProcessorArchitecture arch, MemoryArea mem, Address addrStart, long cbBytes, Formatter formatter) { var dasm = arch.CreateDisassembler(arch.CreateImageReader(mem, addrStart)); try { var writer = new InstrWriter(formatter); var options = new MachineInstructionRendererOptions( flags: MachineInstructionRendererFlags.ResolvePcRelativeAddress, syntax: ""); foreach (var instr in dasm) { if (cbBytes <= 0) { break; } if (!DumpAssemblerLine(mem, arch, instr, writer, options)) { break; } cbBytes -= instr.Length; } } catch (Exception ex) { formatter.WriteLine(ex.Message); formatter.WriteLine(); } }
public void DumpAssembler(SegmentMap map, IProcessorArchitecture arch, Address addrStart, Address addrLast, Formatter formatter) { if (!map.TryFindSegment(addrStart, out var segment)) { return; } var dasm = arch.CreateDisassembler(arch.CreateImageReader(segment.MemoryArea, addrStart)); try { var writer = new InstrWriter(program.Platform, addrStart, formatter); foreach (var instr in dasm) { writer.Address = instr.Address; if (instr.Address ! >= addrLast) { break; } if (!DumpAssemblerLine(segment.MemoryArea, arch, instr, writer)) { break; } } } catch (Exception ex) { formatter.WriteLine(ex.Message); formatter.WriteLine(); } }
public void WriteByteRange(MemoryArea image, Address begin, Address addrEnd, InstrWriter writer) { EndianImageReader rdr = arch.CreateImageReader(image, begin); while (rdr.Address < addrEnd) { writer.Write(string.Format("{0:X2} ", rdr.ReadByte())); } }
public void WriteByteRange(MemoryArea image, Address begin, Address addrEnd, InstrWriter writer) { EndianImageReader rdr = arch.CreateImageReader(image, begin); while (rdr.Address < addrEnd) { var v = rdr.Read(this.instrByteSize); writer.WriteFormat(this.instrByteFormat, v.ToUInt64()); } }
public bool DumpAssemblerLine(MemoryArea mem, MachineInstruction instr, InstrWriter writer) { Address addrBegin = instr.Address; if (ShowAddresses) { writer.Write("{0} ", addrBegin); } if (ShowCodeBytes) { WriteByteRange(mem, instr.Address, instr.Address + instr.Length, writer); if (instr.Length * 3 < 16) { writer.Write(new string(' ', 16 - (instr.Length * 3))); } } writer.Write("\t"); instr.Render(writer); writer.WriteLine(); return(true); }
public void WriteOpcodes(MemoryArea image, IProcessorArchitecture arch, Address begin, Address addrEnd, InstrWriter writer) { EndianImageReader rdr = arch.CreateImageReader(image, begin); var byteSize = (7 + arch.InstructionBitSize) / 8; string instrByteFormat = $"{{0:X{byteSize * 2}}} "; // each byte is two nybbles. var instrByteSize = PrimitiveType.CreateWord(arch.InstructionBitSize); while (rdr.Address < addrEnd) { if (rdr.TryRead(instrByteSize, out var v)) { writer.WriteFormat(instrByteFormat, v.ToUInt64()); } } }
public void WriteByteRange(MemoryArea image, IProcessorArchitecture arch, Address begin, Address addrEnd, InstrWriter writer) { EndianImageReader rdr = arch.CreateImageReader(image, begin); var byteSize = (7 + arch.InstructionBitSize) / 8; this.instrByteFormat = $"{{0:X{byteSize * 2}}} "; // each byte is two nybbles. this.instrByteSize = PrimitiveType.CreateWord(arch.InstructionBitSize); while (rdr.Address < addrEnd) { var v = rdr.Read(this.instrByteSize); writer.WriteFormat(this.instrByteFormat, v.ToUInt64()); } }
public void WriteByteRange(MemoryArea image, Address begin, Address addrEnd, InstrWriter writer) { ImageReader rdr = arch.CreateImageReader(image, begin); while (rdr.Address < addrEnd) { writer.Write(string.Format("{0:X2} ", rdr.ReadByte())); } }
public bool DumpAssemblerLine(MemoryArea mem, MachineInstruction instr, InstrWriter writer) { Address addrBegin = instr.Address; if (ShowAddresses) writer.Write("{0} ", addrBegin); if (ShowCodeBytes) { WriteByteRange(mem, instr.Address, instr.Address + instr.Length, writer); if (instr.Length * 3 < 16) { writer.Write(new string(' ', 16 - (instr.Length * 3))); } } writer.Write("\t"); instr.Render(writer); writer.WriteLine(); return true; }
public void DumpAssembler(SegmentMap map, Address addrStart, Address addrLast, Formatter formatter) { ImageSegment segment; if (!map.TryFindSegment(addrStart, out segment)) return; var dasm = arch.CreateDisassembler(arch.CreateImageReader(segment.MemoryArea, addrStart)); try { var writer = new InstrWriter(formatter); foreach (var instr in dasm) { if (instr.Address >= addrLast) break; if (!DumpAssemblerLine(segment.MemoryArea, instr, writer)) break; } } catch (Exception ex) { formatter.WriteLine(ex.Message); formatter.WriteLine(); } }