miasm
Reverse engineering framework
|
Public Member Functions | |
def | __init__ (self, ir_arch) |
def | init_arch_C (self) |
def | dst_to_c (self, src) |
def | patch_c_id (self, expr) |
def | id_to_c (self, expr) |
def | add_label_index (self, dst2index, loc_key) |
def | assignblk_to_irbloc (self, instr, assignblk) |
def | block2assignblks (self, block) |
def | add_local_var (self, dst_var, dst_index, expr) |
def | get_mem_prefetch (self, assignblk) |
def | gen_c_assignments (self, assignblk) |
def | gen_check_memory_exception (self, address) |
def | gen_check_cpu_exception (self, address) |
def | traverse_expr_dst (self, expr, dst2index) |
def | gen_assignblk_dst (self, dst) |
def | gen_post_instr_checks (self, attrib) |
def | gen_pre_code (self, instr_attrib) |
def | gen_post_code (self, attrib, pc_value) |
def | gen_goto_code (self, attrib, instr_offsets, dst) |
def | gen_dst_goto (self, attrib, instr_offsets, dst2index) |
def | gen_c_code (self, attrib, c_dst, c_assignmnts) |
def | get_caracteristics (self, assignblk, attrib) |
def | get_attributes (self, instr, irblocks, log_mn=False, log_regs=False) |
def | gen_bad_block (self) |
def | get_block_post_label (self, block) |
def | gen_init (self, block) |
def | gen_irblock (self, instr_attrib, attributes, instr_offsets, irblock) |
def | gen_finalize (self, block) |
def | gen_c (self, block, log_mn=False, log_regs=False) |
Public Attributes | |
ir_arch | |
PC | |
translator | |
id_to_c_id | |
C_PC | |
Static Public Attributes | |
string | CODE_EXCEPTION_MEM_AT_INSTR |
string | CODE_EXCEPTION_AT_INSTR |
string | CODE_RETURN_EXCEPTION |
string | CODE_RETURN_NO_EXCEPTION |
string | CODE_CPU_EXCEPTION_POST_INSTR |
string | CODE_VM_EXCEPTION_POST_INSTR |
string | CODE_INIT |
string | CODE_BAD_BLOCK |
Helper to generate C code for a given AsmBlock
Translate native assembly block to C
def miasm.jitter.codegen.CGen.__init__ | ( | self, | |
ir_arch | |||
) |
Reimplemented in miasm.arch.x86.jit.x86_32_CGen, miasm.arch.mips32.jit.mipsCGen, and miasm.arch.mep.jit.mep_CGen.
def miasm.jitter.codegen.CGen.add_label_index | ( | self, | |
dst2index, | |||
loc_key | |||
) |
Insert @lbl to the dictionary @dst2index with a uniq value @dst2index: LocKey -> uniq value @loc_key: LocKey instance
def miasm.jitter.codegen.CGen.add_local_var | ( | self, | |
dst_var, | |||
dst_index, | |||
expr | |||
) |
Add local variable used to store temporary result @dst_var: dictionary of Expr -> local_var_expr @dst_index : dictionary of size -> local var count @expr: Expression source
def miasm.jitter.codegen.CGen.assignblk_to_irbloc | ( | self, | |
instr, | |||
assignblk | |||
) |
Ensure IRDst is always set in the head @assignblk of the @instr @instr: an instruction instance @assignblk: Assignblk instance
def miasm.jitter.codegen.CGen.block2assignblks | ( | self, | |
block | |||
) |
Return the list of irblocks for a native @block @block: AsmBlock
Reimplemented in miasm.arch.mips32.jit.mipsCGen, and miasm.arch.arm.jit.arm_CGen.
def miasm.jitter.codegen.CGen.dst_to_c | ( | self, | |
src | |||
) |
Translate Expr @src into C code
def miasm.jitter.codegen.CGen.gen_assignblk_dst | ( | self, | |
dst | |||
) |
Generate C code to handle instruction destination @dst: instruction destination Expr
def miasm.jitter.codegen.CGen.gen_bad_block | ( | self | ) |
Generate the C code for a bad_block instance
def miasm.jitter.codegen.CGen.gen_c | ( | self, | |
block, | |||
log_mn = False , |
|||
log_regs = False |
|||
) |
Generate the C code for the @block and return it as a list of lines @log_mn: log mnemonics @log_regs: log registers
def miasm.jitter.codegen.CGen.gen_c_assignments | ( | self, | |
assignblk | |||
) |
Return C information used to generate the C code of the @assignblk @assignblk: an AssignBlock instance
def miasm.jitter.codegen.CGen.gen_c_code | ( | self, | |
attrib, | |||
c_dst, | |||
c_assignmnts | |||
) |
Generate the C code for assignblk. @attrib: Attributes instance @c_dst: irdst C code
def miasm.jitter.codegen.CGen.gen_check_cpu_exception | ( | self, | |
address | |||
) |
Generate C code to check cpu exceptions @address: address of the faulty instruction
def miasm.jitter.codegen.CGen.gen_check_memory_exception | ( | self, | |
address | |||
) |
Generate C code to check memory exceptions @address: address of the faulty instruction
def miasm.jitter.codegen.CGen.gen_dst_goto | ( | self, | |
attrib, | |||
instr_offsets, | |||
dst2index | |||
) |
Generate code for possible @dst2index. @attrib: an Attributes instance @instr_offsets: list of instructions offsets @dst2index: link from destination to index
def miasm.jitter.codegen.CGen.gen_finalize | ( | self, | |
block | |||
) |
Generate the C code for the final block instruction
Reimplemented in miasm.arch.mips32.jit.mipsCGen.
def miasm.jitter.codegen.CGen.gen_goto_code | ( | self, | |
attrib, | |||
instr_offsets, | |||
dst | |||
) |
Generate C code for a potential destination @dst @attrib: instruction Attributes @instr_offsets: instructions offsets list @dst: potential instruction destination
def miasm.jitter.codegen.CGen.gen_init | ( | self, | |
block | |||
) |
Generate the init C code for a @block @block: an asm_bloc instance
def miasm.jitter.codegen.CGen.gen_irblock | ( | self, | |
instr_attrib, | |||
attributes, | |||
instr_offsets, | |||
irblock | |||
) |
Generate the C code for an @irblock @irblock: an irbloc instance @attributes: an Attributes instance list
def miasm.jitter.codegen.CGen.gen_post_code | ( | self, | |
attrib, | |||
pc_value | |||
) |
Callback to generate code AFTER the instruction execution @attrib: Attributes instance
Reimplemented in miasm.arch.x86.jit.x86_64_CGen, miasm.arch.x86.jit.x86_32_CGen, and miasm.arch.mep.jit.mep_CGen.
def miasm.jitter.codegen.CGen.gen_post_instr_checks | ( | self, | |
attrib | |||
) |
Generate C code for handling potential exceptions @attrib: Attributes instance
def miasm.jitter.codegen.CGen.gen_pre_code | ( | self, | |
instr_attrib | |||
) |
Callback to generate code BEFORE the instruction execution @instr_attrib: Attributes instance
Reimplemented in miasm.arch.mep.jit.mep_CGen.
def miasm.jitter.codegen.CGen.get_attributes | ( | self, | |
instr, | |||
irblocks, | |||
log_mn = False , |
|||
log_regs = False |
|||
) |
Get the carateristics of each @irblocks. Returns the corresponding attributes object. @irblock: a list of irbloc instance @log_mn: generate code to log instructions @log_regs: generate code to log registers states
def miasm.jitter.codegen.CGen.get_block_post_label | ( | self, | |
block | |||
) |
Get label next to the @block @block: AsmBlock instance
def miasm.jitter.codegen.CGen.get_caracteristics | ( | self, | |
assignblk, | |||
attrib | |||
) |
Set the carateristics in @attrib according to the @assignblk @assignblk: an AssignBlock instance @attrib: an Attributes instance
def miasm.jitter.codegen.CGen.get_mem_prefetch | ( | self, | |
assignblk | |||
) |
Generate temporary variables used to fetch memory used in the @assignblk Return a dictionary: ExprMem -> temporary variable @assignblk: AssignBlock instance
def miasm.jitter.codegen.CGen.id_to_c | ( | self, | |
expr | |||
) |
Translate Expr @expr into corresponding C code
def miasm.jitter.codegen.CGen.init_arch_C | ( | self | ) |
Iinitialize jitter internals
def miasm.jitter.codegen.CGen.patch_c_id | ( | self, | |
expr | |||
) |
Replace ExprId in @expr with corresponding C variables
def miasm.jitter.codegen.CGen.traverse_expr_dst | ( | self, | |
expr, | |||
dst2index | |||
) |
Generate the index of the destination label for the @expr @dst2index: dictionary to link label to its index
miasm.jitter.codegen.CGen.C_PC |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
miasm.jitter.codegen.CGen.id_to_c_id |
miasm.jitter.codegen.CGen.ir_arch |
miasm.jitter.codegen.CGen.PC |
miasm.jitter.codegen.CGen.translator |