![]() |
miasm
Reverse engineering framework
|


Public Member Functions | |
| def | __init__ (self, llvm_context, name="fc", new_module=True) |
| def | new_branch_name (self) |
| def | append_basic_block (self, label, overwrite=True) |
| def | CreateEntryBlockAlloca (self, var_type, default_value=None) |
| def | get_ptr_by_expr (self, expr) |
| def | update_cache (self, name, value) |
| def | set_ret (self, var) |
| def | get_basic_block_by_loc_key (self, loc_key) |
| def | global_constant (self, name, value) |
| def | make_bytearray (self, buf) |
| def | printf (self, format, *args) |
| def | assign (self, src, dst) |
| def | init_fc (self) |
| def | add_ir (self, expr) |
| def | check_memory_exception (self, offset, restricted_exception=False) |
| def | check_cpu_exception (self, offset, restricted_exception=False) |
| def | gen_pre_code (self, instr_attrib) |
| def | gen_post_code (self, attributes, pc_value) |
| def | gen_post_instr_checks (self, attrib, next_instr) |
| def | expr2cases (self, expr) |
| def | gen_jump2dst (self, attrib, instr_offsets, dst) |
| def | gen_irblock (self, instr_attrib, attributes, instr_offsets, irblock) |
| def | gen_bad_block (self, asmblock) |
| def | gen_finalize (self, asmblock, codegen) |
| def | from_asmblock (self, asmblock) |
| def | __str__ (self) |
| def | dot (self) |
| def | as_llvm_mod (self) |
| def | verify (self) |
| def | get_bytecode (self) |
| def | get_assembly (self) |
| def | optimise (self) |
| def | __call__ (self, *args) |
| def | get_function_pointer (self) |
Public Attributes | |
| llvm_context | |
| mod | |
| my_args | |
| ret_type | |
| builder | |
| entry_bbl | |
| branch_counter | |
| name | |
| local_vars | |
| local_vars_pointers | |
| expr_cache | |
| main_stream | |
| name2bbl | |
| fc | |
Static Public Attributes | |
| bool | log_mn = False |
| bool | log_regs = True |
| dictionary | op_translate |
| Basics. More... | |
| dictionary | op_translate_with_size = {} |
| Add the size as first argument. More... | |
| dictionary | op_translate_with_suffix_size |
| Add the size as suffix. More... | |
Represent a LLVM function Implementation note: A new module is created each time to avoid cumulative lag (if @new_module)
| def miasm.jitter.llvmconvert.LLVMFunction.__init__ | ( | self, | |
| llvm_context, | |||
name = "fc", |
|||
new_module = True |
|||
| ) |
| def miasm.jitter.llvmconvert.LLVMFunction.__call__ | ( | self, | |
| * | args | ||
| ) |
| def miasm.jitter.llvmconvert.LLVMFunction.__str__ | ( | self | ) |
| def miasm.jitter.llvmconvert.LLVMFunction.add_ir | ( | self, | |
| expr | |||
| ) |


| def miasm.jitter.llvmconvert.LLVMFunction.append_basic_block | ( | self, | |
| label, | |||
overwrite = True |
|||
| ) |
Add a new basic block to the current function. @label: str or asmlabel @overwrite: if False, do nothing if a bbl with the same name already exists Return the corresponding LLVM Basic Block

| def miasm.jitter.llvmconvert.LLVMFunction.as_llvm_mod | ( | self | ) |
Return a ModuleRef standing for the current function

| def miasm.jitter.llvmconvert.LLVMFunction.assign | ( | self, | |
| src, | |||
| dst | |||
| ) |


| def miasm.jitter.llvmconvert.LLVMFunction.check_cpu_exception | ( | self, | |
| offset, | |||
restricted_exception = False |
|||
| ) |
Add a check for CPU errors. @offset: offset of the current exception (int or Instruction) If restricted_exception, check only for exception which do not require a pc update


| def miasm.jitter.llvmconvert.LLVMFunction.check_memory_exception | ( | self, | |
| offset, | |||
restricted_exception = False |
|||
| ) |
Add a check for memory errors. @offset: offset of the current exception (int or Instruction) If restricted_exception, check only for exception which do not require a pc update, and do not consider automod exception


| def miasm.jitter.llvmconvert.LLVMFunction.CreateEntryBlockAlloca | ( | self, | |
| var_type, | |||
default_value = None |
|||
| ) |
Create an alloca instruction at the beginning of the current fc @default_value: if set, store the default_value just after the allocation

| def miasm.jitter.llvmconvert.LLVMFunction.dot | ( | self | ) |
| def miasm.jitter.llvmconvert.LLVMFunction.expr2cases | ( | self, | |
| expr | |||
| ) |
Evaluate @expr and return: - switch value -> dst - evaluation of the switch value (if any)


| def miasm.jitter.llvmconvert.LLVMFunction.from_asmblock | ( | self, | |
| asmblock | |||
| ) |
Build the function from an asmblock (asm_block instance). Prototype : f(i8* jitcpu, i8* vmcpu, i8* vmmngr, i8* status)

| def miasm.jitter.llvmconvert.LLVMFunction.gen_bad_block | ( | self, | |
| asmblock | |||
| ) |
Translate an asm_bad_block into a CPU exception


| def miasm.jitter.llvmconvert.LLVMFunction.gen_finalize | ( | self, | |
| asmblock, | |||
| codegen | |||
| ) |
In case of delayslot, generate a dummy BBL which return on the computed IRDst or on next_label


| def miasm.jitter.llvmconvert.LLVMFunction.gen_irblock | ( | self, | |
| instr_attrib, | |||
| attributes, | |||
| instr_offsets, | |||
| irblock | |||
| ) |
Generate the code for an @irblock @instr_attrib: an Attributes instance or the instruction to translate @attributes: list of Attributes corresponding to irblock assignments @instr_offsets: offset of all asmblock's instructions @irblock: an irblock instance


| def miasm.jitter.llvmconvert.LLVMFunction.gen_jump2dst | ( | self, | |
| attrib, | |||
| instr_offsets, | |||
| dst | |||
| ) |
Generate the code for a jump to @dst with final check for error Several cases have to be considered: - jump to an offset out of the current ASM BBL (JMP 0x11223344) - jump to an offset inside the current ASM BBL (Go to next instruction) - jump to an offset back in the current ASM BBL (For max_exec jit option on self loops) - jump to a generated IR label, which must be jitted in this same function (REP MOVSB) - jump to a computed offset (CALL @32[0x11223344])
Reimplemented in miasm.jitter.llvmconvert.LLVMFunction_IRCompilation.


| def miasm.jitter.llvmconvert.LLVMFunction.gen_post_code | ( | self, | |
| attributes, | |||
| pc_value | |||
| ) |


| def miasm.jitter.llvmconvert.LLVMFunction.gen_post_instr_checks | ( | self, | |
| attrib, | |||
| next_instr | |||
| ) |


| def miasm.jitter.llvmconvert.LLVMFunction.gen_pre_code | ( | self, | |
| instr_attrib | |||
| ) |


| def miasm.jitter.llvmconvert.LLVMFunction.get_assembly | ( | self | ) |

| def miasm.jitter.llvmconvert.LLVMFunction.get_basic_block_by_loc_key | ( | self, | |
| loc_key | |||
| ) |

| def miasm.jitter.llvmconvert.LLVMFunction.get_bytecode | ( | self | ) |

| def miasm.jitter.llvmconvert.LLVMFunction.get_function_pointer | ( | self | ) |

| def miasm.jitter.llvmconvert.LLVMFunction.get_ptr_by_expr | ( | self, | |
| expr | |||
| ) |
"Return a pointer casted corresponding to ExprId expr. If it is not already computed, compute it at the end of entry_bloc

| def miasm.jitter.llvmconvert.LLVMFunction.global_constant | ( | self, | |
| name, | |||
| value | |||
| ) |
Inspired from numba/cgutils.py Get or create a (LLVM module-)global constant with *name* or *value*.

| def miasm.jitter.llvmconvert.LLVMFunction.init_fc | ( | self | ) |
Reimplemented in miasm.jitter.llvmconvert.LLVMFunction_IRCompilation.

| def miasm.jitter.llvmconvert.LLVMFunction.make_bytearray | ( | self, | |
| buf | |||
| ) |
Inspired from numba/cgutils.py Make a byte array constant from *buf*.

| def miasm.jitter.llvmconvert.LLVMFunction.new_branch_name | ( | self | ) |

| def miasm.jitter.llvmconvert.LLVMFunction.optimise | ( | self | ) |

| def miasm.jitter.llvmconvert.LLVMFunction.printf | ( | self, | |
| format, | |||
| * | args | ||
| ) |
Inspired from numba/cgutils.py Calls printf(). Argument `format` is expected to be a Python string. Values to be printed are listed in `args`. Note: There is no checking to ensure there is correct number of values in `args` and there type matches the declaration in the format string.


| def miasm.jitter.llvmconvert.LLVMFunction.set_ret | ( | self, | |
| var | |||
| ) |


| def miasm.jitter.llvmconvert.LLVMFunction.update_cache | ( | self, | |
| name, | |||
| value | |||
| ) |

| def miasm.jitter.llvmconvert.LLVMFunction.verify | ( | self | ) |

| miasm.jitter.llvmconvert.LLVMFunction.branch_counter |
| miasm.jitter.llvmconvert.LLVMFunction.builder |
| miasm.jitter.llvmconvert.LLVMFunction.entry_bbl |
| miasm.jitter.llvmconvert.LLVMFunction.expr_cache |
| miasm.jitter.llvmconvert.LLVMFunction.fc |
| miasm.jitter.llvmconvert.LLVMFunction.llvm_context |
| miasm.jitter.llvmconvert.LLVMFunction.local_vars |
| miasm.jitter.llvmconvert.LLVMFunction.local_vars_pointers |
|
static |
|
static |
| miasm.jitter.llvmconvert.LLVMFunction.main_stream |
| miasm.jitter.llvmconvert.LLVMFunction.mod |
| miasm.jitter.llvmconvert.LLVMFunction.my_args |
| miasm.jitter.llvmconvert.LLVMFunction.name |
| miasm.jitter.llvmconvert.LLVMFunction.name2bbl |
|
static |
Basics.
|
static |
Add the size as first argument.
|
static |
Add the size as suffix.
| miasm.jitter.llvmconvert.LLVMFunction.ret_type |