1 Libdisasm SWIG README 2 3The SWIG utility (www.swig.org) can be used to generate 4 5 6Building SWIG Modules 7--------------------- 8 9 make 10 make install 11 12Make and Install both build Python, Perl, Ruby, and Tcl modules. If you 13do not have one of these languages installed, comment out the relevant 14target in the main Makefile. 15 16Install uses 'sudo' to put files in the correct locations; if you 17do not have sudo installed, change the install targets. 18 19The Module API 20-------------- 21 22The OOP API 23----------- 24 25 26The Python Module 27----------------- 28 29To test that the module loads: 30 31 bash# python 32 >>> import x86disasm 33 >>> x86disasm.version_string() 34 '0.21-pre' 35 >>>^D 36 bash# 37 38 >>> import x86disasm 39 >>> import array 40 >>> disasm = x86disasm.X86_Disasm( ) 41 >>> tgt = open( "/tmp/a.out", "rb" ) 42 >>> tgt.seek( 0, 2 ) 43 >>> size = tgt.tell() 44 >>> tgt.seek( 0, 0 ) 45 >>> buf = array.array( 'B' ) 46 >>> buf.fromfile( tgt, size ) 47 >>> tgt.close() 48 >>> data = x86disasm.byteArray( size ) 49 >>> for i in range( size ): 50 ... data[i] = buf.pop(0) 51 ... 52 >>> del buf 53 >>> del tgt 54 >>> insn = disasm.disasm( data, size - 1, 0, 0 ) 55 >>> insn.format( x86disasm.att_syntax ) 56 'jg\t0x00000047' 57 >>> insn.format( x86disasm.raw_syntax ) 58 '0x00000000|0x00000000|2|7F 45 |||controlflow|jcc|jg|80386|General Purpose|||zero_clear sign_eq_oflow |0|0|relative|sbyte|00000047|' 59 >>> ops = insn.operand_list() 60 >>> node = ops.first() 61 >>> while node is not None: 62 ... s = node.op.format(x86disasm.raw_syntax) 63 ... print s 64 ... node = ops.next() 65 ... 66 relative|sbyte|00000047| 67 68 69 70 71 72 73The Perl Module 74--------------- 75 76To test that the module loads: 77 78 bash# perl 79 use x86disasm; 80 print x86disasm::version_string() . "\n"; 81 ^D 82 0.21-pre 83 bash# 84 85The Ruby Module 86--------------- 87 88To test that the module loads: 89 90 bash# irb 91 irb(main):001:0> require 'x86disasm' 92 => true 93 irb(main):002:0> X86disasm.version_string() 94 => "0.21-pre" 95 irb(main):003:0> x = X86disasm::X86_Disasm.new 96 => #<X86disasm::X86_Disasm:0xb7d624a4> 97 irb(main):004:0> x.max_register_string() 98 => 8 99 irb(main):003:0> ^D 100 bash# 101 102The Tcl Module 103--------------- 104 105To test that the module loads: 106 107 bash# tclsh 108 % load /usr/lib/tcl8.3/x86disasm.so X86disasm 109 % version_string 110 0.21-pre 111 % ^D 112 bash# 113 114 % x86_init 0 NULL NULL 115 OR 116 % x86disasm dis 117 _486b0708_p_x86disasm 118 % puts "[dis cget -last_error]" 119 0 120 121 122 123 124The Interface Files 125------------------- 126 127 libdisasm.i -- interface file without shadow classes 128 libdisasm_oop.i -- interface file with shadow classes 129