This class is the parent of all executable format handlers.
It is defined in metasm/exe_format/main.rb.
It defines some standard shortcut functions, such as:
- Exe.decode_file(filename)
- Exe.assemble(cpu,asm_source)
- Exe.compile_c(cpu,c_source)
- Exe#encode_file(filename)
These methods will instanciate a new Exe, and call the corresponding
methods, e.g.
load with the file content, and
decode.
The handling of the different structures in the binary format should be
done using the SerialStruct
facility.
The subclasses are expected to implement various functions, depending on
the usage (refer to the ELF and COFF implementations for more details):
File decoding/disassembly
- #decode_header: parse the raw data in
#encoded only to parse the file header
- #decode: parse all the raw data in
#encoded
- #cpu_from_headers: return a
core/CPU.txt instance
according to the exe header information
- #get_default_entrypoints: the list of
entrypoints (exported functions, etc)
- #dump_section_header: return a string that
may be assembled to recreate the specified section
- #section_info: return a list of generic
section informations for the disassembler
File encoding/source parsing
- #tune_prepro: define exe-specific macros
for the preprocessor (optional)
- #parse_init: initialize the
@cursource array to receive the parsed asm
source
- #parse_parser_instruction: parse
exe-specific instructions, eg .text,
.import...
- #assemble: assemble the content of the
@cursource into binary section contents
- #encode: assemble the various sections and
a binary header into @encoded