|
5 | 5 |
|
6 | 6 |
|
7 | 7 | module Metasm |
8 | | - # root directory for metasm files |
9 | | - # used by some scripts, eg to find samples/dasm-plugin directory |
10 | | - Metasmdir = File.dirname(__FILE__) |
11 | | - # add it to the ruby library path |
12 | | - $: << Metasmdir |
| 8 | + # root directory for metasm files |
| 9 | + # used by some scripts, eg to find samples/dasm-plugin directory |
| 10 | + Metasmdir = File.dirname(__FILE__) |
| 11 | + # add it to the ruby library path |
| 12 | + $: << Metasmdir |
13 | 13 |
|
14 | | - # constants defined in the same file as another |
15 | | - Const_autorequire_equiv = { |
16 | | - 'X86' => 'Ia32', 'PPC' => 'PowerPC', |
17 | | - 'X64' => 'X86_64', 'AMD64' => 'X86_64', |
18 | | - 'MIPS64' => 'MIPS', |
19 | | - 'UniversalBinary' => 'MachO', 'COFFArchive' => 'COFF', |
20 | | - 'DEY' => 'DEX', |
21 | | - 'PTrace' => 'LinOS', 'FatELF' => 'ELF', |
22 | | - 'LoadedELF' => 'ELF', 'LoadedPE' => 'PE', |
23 | | - 'LoadedAutoExe' => 'AutoExe', |
24 | | - 'LinuxRemoteString' => 'LinOS', |
25 | | - 'LinDebugger' => 'LinOS', |
26 | | - 'WinAPI' => 'WinOS', |
27 | | - 'WindowsRemoteString' => 'WinOS', 'WinDbgAPI' => 'WinOS', |
28 | | - 'WinDebugger' => 'WinOS', |
29 | | - 'GdbRemoteString' => 'GdbClient', 'GdbRemoteDebugger' => 'GdbClient', |
30 | | - 'DecodedInstruction' => 'Disassembler', 'DecodedFunction' => 'Disassembler', |
31 | | - 'InstructionBlock' => 'Disassembler', |
32 | | - } |
| 14 | + # constants defined in the same file as another |
| 15 | + Const_autorequire_equiv = { |
| 16 | + 'X86' => 'Ia32', 'PPC' => 'PowerPC', |
| 17 | + 'X64' => 'X86_64', 'AMD64' => 'X86_64', |
| 18 | + 'MIPS64' => 'MIPS', |
| 19 | + 'UniversalBinary' => 'MachO', 'COFFArchive' => 'COFF', |
| 20 | + 'DEY' => 'DEX', |
| 21 | + 'PTrace' => 'LinOS', 'FatELF' => 'ELF', |
| 22 | + 'LoadedELF' => 'ELF', 'LoadedPE' => 'PE', |
| 23 | + 'LoadedAutoExe' => 'AutoExe', |
| 24 | + 'LinuxRemoteString' => 'LinOS', |
| 25 | + 'LinDebugger' => 'LinOS', |
| 26 | + 'WinAPI' => 'WinOS', |
| 27 | + 'WindowsRemoteString' => 'WinOS', 'WinDbgAPI' => 'WinOS', |
| 28 | + 'WinDebugger' => 'WinOS', |
| 29 | + 'GdbRemoteString' => 'GdbClient', 'GdbRemoteDebugger' => 'GdbClient', |
| 30 | + 'DecodedInstruction' => 'Disassembler', 'DecodedFunction' => 'Disassembler', |
| 31 | + 'InstructionBlock' => 'Disassembler', |
| 32 | + } |
33 | 33 |
|
34 | | - # files to require to get the definition of those constants |
35 | | - Const_autorequire = { |
36 | | - 'Ia32' => 'cpu/ia32', 'MIPS' => 'cpu/mips', 'PowerPC' => 'cpu/ppc', 'ARM' => 'cpu/arm', |
37 | | - 'X86_64' => 'cpu/x86_64', 'Sh4' => 'cpu/sh4', 'Dalvik' => 'cpu/dalvik', 'ARC' => 'cpu/arc', |
38 | | - 'Python' => 'cpu/python', 'Z80' => 'cpu/z80', 'CY16' => 'cpu/cy16', 'BPF' => 'cpu/bpf', |
39 | | - 'C' => 'compile_c', |
40 | | - 'MZ' => 'exe_format/mz', 'PE' => 'exe_format/pe', |
41 | | - 'ELF' => 'exe_format/elf', 'COFF' => 'exe_format/coff', |
42 | | - 'Shellcode' => 'exe_format/shellcode', 'AutoExe' => 'exe_format/autoexe', |
43 | | - 'AOut' => 'exe_format/a_out', 'MachO' => 'exe_format/macho', |
44 | | - 'DEX' => 'exe_format/dex', |
45 | | - 'NDS' => 'exe_format/nds', 'XCoff' => 'exe_format/xcoff', |
46 | | - 'GameBoyRom' => 'exe_format/gb', |
47 | | - 'Bflt' => 'exe_format/bflt', 'Dol' => 'exe_format/dol', |
48 | | - 'PYC' => 'exe_format/pyc', 'JavaClass' => 'exe_format/javaclass', |
49 | | - 'SWF' => 'exe_format/swf', 'ZIP' => 'exe_format/zip', |
50 | | - 'Shellcode_RWX' => 'exe_format/shellcode_rwx', |
51 | | - 'Gui' => 'gui', |
52 | | - 'WindowsExports' => 'os/windows_exports', |
53 | | - 'GNUExports' => 'os/gnu_exports', |
54 | | - 'Debugger' => 'debug', |
55 | | - 'LinOS' => 'os/linux', 'WinOS' => 'os/windows', |
56 | | - 'GdbClient' => 'os/remote', |
57 | | - 'Disassembler' => 'disassemble', |
58 | | - 'Decompiler' => 'decompile', |
59 | | - 'DynLdr' => 'dynldr', |
60 | | - } |
| 34 | + # files to require to get the definition of those constants |
| 35 | + Const_autorequire = { |
| 36 | + 'Ia32' => 'cpu/ia32', 'MIPS' => 'cpu/mips', 'PowerPC' => 'cpu/ppc', 'ARM' => 'cpu/arm', |
| 37 | + 'X86_64' => 'cpu/x86_64', 'Sh4' => 'cpu/sh4', 'Dalvik' => 'cpu/dalvik', 'ARC' => 'cpu/arc', |
| 38 | + 'Python' => 'cpu/python', 'Z80' => 'cpu/z80', 'CY16' => 'cpu/cy16', 'BPF' => 'cpu/bpf', |
| 39 | + 'C' => 'compile_c', |
| 40 | + 'MZ' => 'exe_format/mz', 'PE' => 'exe_format/pe', |
| 41 | + 'ELF' => 'exe_format/elf', 'COFF' => 'exe_format/coff', |
| 42 | + 'Shellcode' => 'exe_format/shellcode', 'AutoExe' => 'exe_format/autoexe', |
| 43 | + 'AOut' => 'exe_format/a_out', 'MachO' => 'exe_format/macho', |
| 44 | + 'DEX' => 'exe_format/dex', |
| 45 | + 'NDS' => 'exe_format/nds', 'XCoff' => 'exe_format/xcoff', |
| 46 | + 'GameBoyRom' => 'exe_format/gb', |
| 47 | + 'Bflt' => 'exe_format/bflt', 'Dol' => 'exe_format/dol', |
| 48 | + 'PYC' => 'exe_format/pyc', 'JavaClass' => 'exe_format/javaclass', |
| 49 | + 'SWF' => 'exe_format/swf', 'ZIP' => 'exe_format/zip', |
| 50 | + 'Shellcode_RWX' => 'exe_format/shellcode_rwx', |
| 51 | + 'Gui' => 'gui', |
| 52 | + 'WindowsExports' => 'os/windows_exports', |
| 53 | + 'GNUExports' => 'os/gnu_exports', |
| 54 | + 'Debugger' => 'debug', |
| 55 | + 'LinOS' => 'os/linux', 'WinOS' => 'os/windows', |
| 56 | + 'GdbClient' => 'os/remote', |
| 57 | + 'Disassembler' => 'disassemble', |
| 58 | + 'Decompiler' => 'decompile', |
| 59 | + 'DynLdr' => 'dynldr', |
| 60 | + } |
61 | 61 |
|
62 | | - # use the Module.autoload ruby functionnality to load framework components on demand |
63 | | - Const_autorequire.each { |cst, file| |
64 | | - autoload cst, File.join('metasm', file) |
65 | | - } |
| 62 | + # use the Module.autoload ruby functionnality to load framework components on demand |
| 63 | + Const_autorequire.each { |cst, file| |
| 64 | + autoload cst, File.join('metasm', file) |
| 65 | + } |
66 | 66 |
|
67 | | - Const_autorequire_equiv.each { |cst, eqv| |
68 | | - file = Const_autorequire[eqv] |
69 | | - autoload cst, File.join('metasm', file) |
70 | | - } |
| 67 | + Const_autorequire_equiv.each { |cst, eqv| |
| 68 | + file = Const_autorequire[eqv] |
| 69 | + autoload cst, File.join('metasm', file) |
| 70 | + } |
71 | 71 | end |
72 | 72 |
|
73 | 73 | # load Metasm core files |
74 | 74 | %w[main encode decode render exe_format/main os/main].each { |f| |
75 | | - require File.join('metasm', f) |
| 75 | + require File.join('metasm', f) |
76 | 76 | } |
77 | 77 |
|
78 | 78 |
|
79 | 79 | # remove an 1.9 warning, couldn't find a compatible way... |
80 | 80 | if Hash.new.respond_to?(:key) |
81 | | - puts "using ruby1.9 workaround for Hash#index warning" if $DEBUG |
82 | | - class Hash |
83 | | - alias index_premetasm index rescue nil |
84 | | - undef index rescue nil |
85 | | - alias index key |
86 | | - end |
| 81 | + puts "using ruby1.9 workaround for Hash#index warning" if $DEBUG |
| 82 | + class Hash |
| 83 | + alias index_premetasm index rescue nil |
| 84 | + undef index rescue nil |
| 85 | + alias index key |
| 86 | + end |
87 | 87 | end |
0 commit comments