michael@0: Libdisasm SWIG README michael@0: michael@0: The SWIG utility (www.swig.org) can be used to generate michael@0: michael@0: michael@0: Building SWIG Modules michael@0: --------------------- michael@0: michael@0: make michael@0: make install michael@0: michael@0: Make and Install both build Python, Perl, Ruby, and Tcl modules. If you michael@0: do not have one of these languages installed, comment out the relevant michael@0: target in the main Makefile. michael@0: michael@0: Install uses 'sudo' to put files in the correct locations; if you michael@0: do not have sudo installed, change the install targets. michael@0: michael@0: The Module API michael@0: -------------- michael@0: michael@0: The OOP API michael@0: ----------- michael@0: michael@0: michael@0: The Python Module michael@0: ----------------- michael@0: michael@0: To test that the module loads: michael@0: michael@0: bash# python michael@0: >>> import x86disasm michael@0: >>> x86disasm.version_string() michael@0: '0.21-pre' michael@0: >>>^D michael@0: bash# michael@0: michael@0: >>> import x86disasm michael@0: >>> import array michael@0: >>> disasm = x86disasm.X86_Disasm( ) michael@0: >>> tgt = open( "/tmp/a.out", "rb" ) michael@0: >>> tgt.seek( 0, 2 ) michael@0: >>> size = tgt.tell() michael@0: >>> tgt.seek( 0, 0 ) michael@0: >>> buf = array.array( 'B' ) michael@0: >>> buf.fromfile( tgt, size ) michael@0: >>> tgt.close() michael@0: >>> data = x86disasm.byteArray( size ) michael@0: >>> for i in range( size ): michael@0: ... data[i] = buf.pop(0) michael@0: ... michael@0: >>> del buf michael@0: >>> del tgt michael@0: >>> insn = disasm.disasm( data, size - 1, 0, 0 ) michael@0: >>> insn.format( x86disasm.att_syntax ) michael@0: 'jg\t0x00000047' michael@0: >>> insn.format( x86disasm.raw_syntax ) michael@0: '0x00000000|0x00000000|2|7F 45 |||controlflow|jcc|jg|80386|General Purpose|||zero_clear sign_eq_oflow |0|0|relative|sbyte|00000047|' michael@0: >>> ops = insn.operand_list() michael@0: >>> node = ops.first() michael@0: >>> while node is not None: michael@0: ... s = node.op.format(x86disasm.raw_syntax) michael@0: ... print s michael@0: ... node = ops.next() michael@0: ... michael@0: relative|sbyte|00000047| michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: The Perl Module michael@0: --------------- michael@0: michael@0: To test that the module loads: michael@0: michael@0: bash# perl michael@0: use x86disasm; michael@0: print x86disasm::version_string() . "\n"; michael@0: ^D michael@0: 0.21-pre michael@0: bash# michael@0: michael@0: The Ruby Module michael@0: --------------- michael@0: michael@0: To test that the module loads: michael@0: michael@0: bash# irb michael@0: irb(main):001:0> require 'x86disasm' michael@0: => true michael@0: irb(main):002:0> X86disasm.version_string() michael@0: => "0.21-pre" michael@0: irb(main):003:0> x = X86disasm::X86_Disasm.new michael@0: => # michael@0: irb(main):004:0> x.max_register_string() michael@0: => 8 michael@0: irb(main):003:0> ^D michael@0: bash# michael@0: michael@0: The Tcl Module michael@0: --------------- michael@0: michael@0: To test that the module loads: michael@0: michael@0: bash# tclsh michael@0: % load /usr/lib/tcl8.3/x86disasm.so X86disasm michael@0: % version_string michael@0: 0.21-pre michael@0: % ^D michael@0: bash# michael@0: michael@0: % x86_init 0 NULL NULL michael@0: OR michael@0: % x86disasm dis michael@0: _486b0708_p_x86disasm michael@0: % puts "[dis cget -last_error]" michael@0: 0 michael@0: michael@0: michael@0: michael@0: michael@0: The Interface Files michael@0: ------------------- michael@0: michael@0: libdisasm.i -- interface file without shadow classes michael@0: libdisasm_oop.i -- interface file with shadow classes