Class: Opdis::Disassembler
- Inherits:
-
Object
- Object
- Opdis::Disassembler
- Defined in:
- lib/Opdis.rb
Class Method Summary collapse
-
.new(args = {}) {|dis| ... } ⇒ Object
The args parameter is a Hash which can contain any of the following members:.
-
.options ⇒ Object
Return array of available disassembler options, as printed by libopcodes.
Instance Method Summary collapse
-
#disasm_cflow(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_CFLOW.
-
#disasm_entry(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_ENTRY.
-
#disasm_linear(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_LINEAR.
-
#disasm_section(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_SECTION.
-
#disasm_single(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_SINGLE.
-
#disasm_symbol(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_SYMBOL.
-
#disassemble(target, args = {}, &block) ⇒ Object
(also: #disasm)
Disassemble all bytes in a buffer.
Class Method Details
.new(args = {}) {|dis| ... } ⇒ Object
The args parameter is a Hash which can contain any of the following members:
resolver:: AddressResolver object to use instead of the builtin
address resolver.
addr_tracker:: VisitedAddressTracker object to use instead of the built-in
address tracker.
insn_decoder:: InstructionDecoder object to use instead of the built-in
instruction decoder.
syntax:: Assembly language syntax to use; either SYNTAX_ATT (default) or
SYNTAX_INTEL.
debug:: Enable or disable libopdis debug mode.
options:: Options command-line string for libopcodes. See disassembler_usage()
in dis-asm.h for details.
arch:: The architecture to disassemble for. Use <i>arhcitectures</i> to
determine supported architectures.
37 38 39 40 41 |
# File 'lib/Opdis.rb', line 37 def self.new(args={}) dis = ext_new(args) yield dis if (dis and block_given?) return dis end |
.options ⇒ Object
Return array of available disassembler options, as printed by libopcodes.
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/Opdis.rb', line 109 def self.() opts = [] Tempfile.open("opcodes-options") do |tmp| tmp.close ext_usage(tmp) tmp.open opts.concat tmp.readlines end opts end |
Instance Method Details
#disasm_cflow(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_CFLOW.
72 73 74 75 |
# File 'lib/Opdis.rb', line 72 def disasm_cflow( target, args={}, &block ) args[:strategy] = STRATEGY_CFLOW disassemble(target, args, &block) end |
#disasm_entry(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_ENTRY.
96 97 98 99 |
# File 'lib/Opdis.rb', line 96 def disasm_entry( target, args={}, &block ) args[:strategy] = STRATEGY_ENTRY disassemble(target, args, &block) end |
#disasm_linear(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_LINEAR.
64 65 66 67 |
# File 'lib/Opdis.rb', line 64 def disasm_linear( target, args={}, &block ) args[:strategy] = STRATEGY_LINEAR disassemble(target, args, &block) end |
#disasm_section(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_SECTION.
80 81 82 83 |
# File 'lib/Opdis.rb', line 80 def disasm_section( target, args={}, &block ) args[:strategy] = STRATEGY_SECTION disassemble(target, args, &block) end |
#disasm_single(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_SINGLE.
56 57 58 59 |
# File 'lib/Opdis.rb', line 56 def disasm_single( target, args={}, &block ) args[:strategy] = STRATEGY_SINGLE disassemble(target, args, &block) end |
#disasm_symbol(target, args = {}, &block) ⇒ Object
Convenience method for invoking disassemble() with STRATEGY_SYMBOL.
88 89 90 91 |
# File 'lib/Opdis.rb', line 88 def disasm_symbol( target, args={}, &block ) args[:strategy] = STRATEGY_SYMBOL disassemble(target, args, &block) end |
#disassemble(target, args = {}, &block) ⇒ Object Also known as: disasm
Disassemble all bytes in a buffer. This is simply a wrapper for ext_disasm that provides a default value for args. See ext_disasm.
48 49 50 51 |
# File 'lib/Opdis.rb', line 48 def disassemble( target, args={}, &block ) # :yields: instruction # Wrapper provides a default option ext_disassemble(target, args, &block) end |