class Metasm::DecodedInstruction
holds information for decoded instructions: the original opcode, a pointer to the InstructionBlock, etc
update DecodedInstr.to_s to include instr length
Attributes
the address of the instruction's first byte in memory
a cache of the binding used by the backtracker to emulate this instruction
our, length in bytes
the instance of InstructionBlock this di is into
our offset (in bytes) from the start of the block, used only for hexdump
array of arbitrary strings
the disassembled data
the disassembled data
used during fixed-size instruction decoding to hold the decoded raw opcode
Public Class Methods
create a new DecodedInstruction with an Instruction whose cpu is the argument can take an existing Instruction as argument
# File metasm/disassemble.rb, line 32 def initialize(arg, addr=nil) case arg when Instruction @instruction = arg @opcode = @instruction.cpu.opcode_list.find { |op| op.name == @instruction.opname } if @instruction.cpu else @instruction = Instruction.new(arg) end @bin_length = 0 @address = addr if addr end
Public Instance Methods
# File metasm/disassemble.rb, line 69 def add_comment(c) @comment ||= [] @comment |= [c] end
checks if this instruction is the first of its IBlock
# File metasm/disassemble_api.rb, line 128 def block_head? self == @block.list.first end
returns a copy of the DecInstr, with duplicated instruction (“deep_copy”)
# File metasm/disassemble.rb, line 75 def dup new = super() new.instruction = @instruction.dup new end
# File metasm/disassemble.rb, line 44 def next_addr (@next_addr ||= nil) || (address + @bin_length) if address end
# File metasm/disassemble.rb, line 43 def next_addr=(a) @next_addr = a end
# File metasm/disassemble.rb, line 61 def render ret = [] ret << Expression[address] << ' ' if address ret << @instruction ret << ' ; ' << @comment if comment ret end
# File metasm/disassemble.rb, line 48 def show if block bin = @block.edata.data[@block.edata_ptr+@block_offset, @bin_length].unpack('C*').map { |c| '%02x' % c }.join if @bin_length > 12 bin = bin[0, 20] + "..<+#{@bin_length-10}>" end " #{@instruction.to_s.ljust(44)} ; @#{Expression[address]} #{bin} #{@comment.sort[0,6].join(' ') if comment}" else "#{@instruction}#{' ; ' + @comment.join(' ') if comment}" end end
# File samples/dasm-plugins/deobfuscate.rb, line 240 def to_s ; "#{Metasm::Expression[address] if address} +#{bin_length} #{instruction}" end