|
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 |
| - 'MSP430' => 'cpu/msp430', |
40 |
| - 'C' => 'compile_c', |
41 |
| - 'MZ' => 'exe_format/mz', 'PE' => 'exe_format/pe', |
42 |
| - 'ELF' => 'exe_format/elf', 'COFF' => 'exe_format/coff', |
43 |
| - 'Shellcode' => 'exe_format/shellcode', 'AutoExe' => 'exe_format/autoexe', |
44 |
| - 'AOut' => 'exe_format/a_out', 'MachO' => 'exe_format/macho', |
45 |
| - 'DEX' => 'exe_format/dex', |
46 |
| - 'NDS' => 'exe_format/nds', 'XCoff' => 'exe_format/xcoff', |
47 |
| - 'GameBoyRom' => 'exe_format/gb', |
48 |
| - 'Bflt' => 'exe_format/bflt', 'Dol' => 'exe_format/dol', |
49 |
| - 'PYC' => 'exe_format/pyc', 'JavaClass' => 'exe_format/javaclass', |
50 |
| - 'SWF' => 'exe_format/swf', 'ZIP' => 'exe_format/zip', |
51 |
| - 'Shellcode_RWX' => 'exe_format/shellcode_rwx', |
52 |
| - 'Gui' => 'gui', |
53 |
| - 'WindowsExports' => 'os/windows_exports', |
54 |
| - 'GNUExports' => 'os/gnu_exports', |
55 |
| - 'Debugger' => 'debug', |
56 |
| - 'LinOS' => 'os/linux', 'WinOS' => 'os/windows', |
57 |
| - 'GdbClient' => 'os/remote', |
58 |
| - 'Disassembler' => 'disassemble', |
59 |
| - 'Decompiler' => 'decompile', |
60 |
| - 'DynLdr' => 'dynldr', |
61 |
| - } |
| 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 | + 'MSP430' => 'cpu/msp430', |
| 40 | + 'C' => 'compile_c', |
| 41 | + 'MZ' => 'exe_format/mz', 'PE' => 'exe_format/pe', |
| 42 | + 'ELF' => 'exe_format/elf', 'COFF' => 'exe_format/coff', |
| 43 | + 'Shellcode' => 'exe_format/shellcode', 'AutoExe' => 'exe_format/autoexe', |
| 44 | + 'AOut' => 'exe_format/a_out', 'MachO' => 'exe_format/macho', |
| 45 | + 'DEX' => 'exe_format/dex', |
| 46 | + 'NDS' => 'exe_format/nds', 'XCoff' => 'exe_format/xcoff', |
| 47 | + 'GameBoyRom' => 'exe_format/gb', |
| 48 | + 'Bflt' => 'exe_format/bflt', 'Dol' => 'exe_format/dol', |
| 49 | + 'PYC' => 'exe_format/pyc', 'JavaClass' => 'exe_format/javaclass', |
| 50 | + 'SWF' => 'exe_format/swf', 'ZIP' => 'exe_format/zip', |
| 51 | + 'Shellcode_RWX' => 'exe_format/shellcode_rwx', |
| 52 | + 'Gui' => 'gui', |
| 53 | + 'WindowsExports' => 'os/windows_exports', |
| 54 | + 'GNUExports' => 'os/gnu_exports', |
| 55 | + 'Debugger' => 'debug', |
| 56 | + 'LinOS' => 'os/linux', 'WinOS' => 'os/windows', |
| 57 | + 'GdbClient' => 'os/remote', |
| 58 | + 'Disassembler' => 'disassemble', |
| 59 | + 'Decompiler' => 'decompile', |
| 60 | + 'DynLdr' => 'dynldr', |
| 61 | + } |
62 | 62 |
|
63 |
| - # use the Module.autoload ruby functionnality to load framework components on demand |
64 |
| - Const_autorequire.each { |cst, file| |
65 |
| - autoload cst, File.join('metasm', file) |
66 |
| - } |
| 63 | + # use the Module.autoload ruby functionnality to load framework components on demand |
| 64 | + Const_autorequire.each { |cst, file| |
| 65 | + autoload cst, File.join('metasm', file) |
| 66 | + } |
67 | 67 |
|
68 |
| - Const_autorequire_equiv.each { |cst, eqv| |
69 |
| - file = Const_autorequire[eqv] |
70 |
| - autoload cst, File.join('metasm', file) |
71 |
| - } |
| 68 | + Const_autorequire_equiv.each { |cst, eqv| |
| 69 | + file = Const_autorequire[eqv] |
| 70 | + autoload cst, File.join('metasm', file) |
| 71 | + } |
72 | 72 | end
|
73 | 73 |
|
74 | 74 | # load Metasm core files
|
75 | 75 | %w[main encode decode render exe_format/main os/main].each { |f|
|
76 |
| - require File.join('metasm', f) |
| 76 | + require File.join('metasm', f) |
77 | 77 | }
|
78 | 78 |
|
79 | 79 |
|
80 | 80 | # remove an 1.9 warning, couldn't find a compatible way...
|
81 | 81 | if Hash.new.respond_to?(:key)
|
82 |
| - puts "using ruby1.9 workaround for Hash#index warning" if $DEBUG |
83 |
| - class Hash |
84 |
| - alias index_premetasm index rescue nil |
85 |
| - undef index rescue nil |
86 |
| - alias index key |
87 |
| - end |
| 82 | + puts "using ruby1.9 workaround for Hash#index warning" if $DEBUG |
| 83 | + class Hash |
| 84 | + alias index_premetasm index rescue nil |
| 85 | + undef index rescue nil |
| 86 | + alias index key |
| 87 | + end |
88 | 88 | end
|
0 commit comments