Class: Relyze::ExecutableFileModel::Instruction
- Inherits:
-
Object
- Object
- Relyze::ExecutableFileModel::Instruction
- Defined in:
- C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb
Defined Under Namespace
Modules: RawDecodedInstructionMixin
Class Method Summary collapse
-
.assemble(source, arch, pc = 0, mode = nil, resolver = nil) ⇒ String, NilClass
Static method to assemble a source buffer.
-
.disassemble(buffer, arch, pc = 0, mode = nil) ⇒ Hash, NilClass
Static method to disassembles a single instruction and return a hash containing the raw decoded instruction.
-
.disassemble_all(buffer, arch, pc = 0, mode = nil) {|raw| ... } ⇒ Array<Hash>?
Disassembles a sequence of instructions and either yield each raw decoded instruction to a block or return an array of raw decoded instructions if no block is given.
-
.to_asm(raw) ⇒ String
Helper method to convert a raw decoded instruction Hash into its assembly String representation.
Instance Method Summary collapse
-
#add_operand_reference(operand_num, target_rva, target, flags = nil) ⇒ Relyze::ExecutableFileModel::Reference?
Add a new reference from an instruction operand to a target location.
-
#arch ⇒ Symbol
Get this instructions architecture.
-
#bits ⇒ Integer
Check if this instruction architecture is 32 or 64 bit.
-
#branch? ⇒ true, false
Check if this instruction is a branch instruction.
-
#branch_targets {|rva| ... } ⇒ Array<Integer>?
If this instruction is a branch instruction, get every known potential branch RVA, if ant.
-
#branch_type ⇒ Symbol?
If this instruction is a branch instruction, get the type of branch.
-
#color ⇒ Integer?
Get this instructions color, if any.
-
#color=(color) ⇒ Integer?
Set or clear this instructions color.
-
#length ⇒ Integer
Get this instructions byte length.
-
#mode ⇒ Symbol, NilClass
Get this instruction mode, if any.
-
#references(operand_num = nil) {|ref| ... } ⇒ Array<Relyze::ExecutableFileModel::Reference>?
Get every reference from this instruction.
-
#remove_operand_reference(operand_num) ⇒ true, false
Remove a reference from an instruction operand and destroy the reference.
-
#rva ⇒ Integer
Get the RVA location of this instruction.
-
#to_raw ⇒ Hash
Get a Hash containing the raw decoded instruction.
-
#to_s ⇒ String
Get a string representation of this instruction.
-
#to_tcg {|tinst| ... } ⇒ Object
Translate this instruction into a series of TCG instructions, which describe this instructions semantics.
Class Method Details
.assemble(source, arch, pc = 0, mode = nil, resolver = nil) ⇒ String, NilClass
Static method to assemble a source buffer.
1324 1325 1326 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1324 def Instruction.assemble( source, arch, pc=0, mode=nil, resolver=nil ) return nil end |
.disassemble(buffer, arch, pc = 0, mode = nil) ⇒ Hash, NilClass
Static method to disassembles a single instruction and return a hash containing the raw decoded instruction. Same as to_raw but for disassembling arbitrary data.
1429 1430 1431 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1429 def Instruction.disassemble( buffer, arch, pc=0, mode=nil ) return nil end |
.disassemble_all(buffer, arch, pc = 0, mode = nil) {|raw| ... } ⇒ Array<Hash>?
Disassembles a sequence of instructions and either yield each raw decoded instruction to a block or return an array of raw decoded instructions if no block is given.
1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1476 def Instruction.disassemble_all( buffer, arch, pc=0, mode=nil ) result = nil while buffer.length > 0 inst = Relyze::ExecutableFileModel::Instruction.disassemble( buffer, arch, pc, mode ) break if inst.nil? if( block_given? ) yield inst else if( result.nil? ) result = ::Array.new end result << inst end buffer = buffer[inst[:length]..buffer.length] pc += inst[:length] end result end |
.to_asm(raw) ⇒ String
Helper method to convert a raw decoded instruction Hash into its assembly String representation.
1437 1438 1439 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1437 def Instruction.to_asm( raw ) return nil end |
Instance Method Details
#add_operand_reference(operand_num, target_rva, target, flags = nil) ⇒ Relyze::ExecutableFileModel::Reference?
Add a new reference from an instruction operand to a target location.
1606 1607 1608 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1606 def add_operand_reference( operand_num, target_rva, target, flags = nil) return nil end |
#arch ⇒ Symbol
Get this instructions architecture.
1498 1499 1500 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1498 def arch return nil end |
#bits ⇒ Integer
Check if this instruction architecture is 32 or 64 bit.
1511 1512 1513 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1511 def bits return 0 end |
#branch? ⇒ true, false
Check if this instruction is a branch instruction.
1554 1555 1556 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1554 def branch? return false end |
#branch_targets {|rva| ... } ⇒ Array<Integer>?
If this instruction is a branch instruction, get every known potential branch RVA, if ant.
1570 1571 1572 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1570 def branch_targets return [] end |
#branch_type ⇒ Symbol?
If this instruction is a branch instruction, get the type of branch.
1561 1562 1563 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1561 def branch_type return nil end |
#color ⇒ Integer?
Get this instructions color, if any.
1577 1578 1579 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1577 def color return nil end |
#color=(color) ⇒ Integer?
Set or clear this instructions color.
1585 1586 1587 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1585 def color=( color ) return color end |
#length ⇒ Integer
Get this instructions byte length.
1525 1526 1527 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1525 def length return nil end |
#mode ⇒ Symbol, NilClass
Get this instruction mode, if any.
1505 1506 1507 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1505 def mode return nil end |
#references(operand_num = nil) {|ref| ... } ⇒ Array<Relyze::ExecutableFileModel::Reference>?
Get every reference from this instruction.
1595 1596 1597 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1595 def references( operand_num=nil ) return nil end |
#remove_operand_reference(operand_num) ⇒ true, false
Remove a reference from an instruction operand and destroy the reference.
1614 1615 1616 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1614 def remove_operand_reference( operand_num ) return false end |
#rva ⇒ Integer
Get the RVA location of this instruction.
1518 1519 1520 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1518 def rva return nil end |
#to_raw ⇒ Hash
Get a Hash containing the raw decoded instruction. See disassemble.
1539 1540 1541 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1539 def to_raw return nil end |
#to_s ⇒ String
Get a string representation of this instruction.
1532 1533 1534 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1532 def to_s return nil end |
#to_tcg {|tinst| ... } ⇒ Object
Translate this instruction into a series of TCG instructions, which describe this instructions semantics.
1547 1548 1549 |
# File 'C:/Program Files/Relyze/lib/relyze/core/executable_file_model.rb', line 1547 def to_tcg return [] end |