diff options
| author | Theofilos Augoustis <theofilos.augoustis@gmail.com> | 2025-10-14 09:09:29 +0000 |
|---|---|---|
| committer | Theofilos Augoustis <theofilos.augoustis@gmail.com> | 2025-10-14 09:09:29 +0000 |
| commit | 579cf1d03fb932083e6317967d1613d5c2587fb6 (patch) | |
| tree | 629f039935382a2a7391bce9253f6c9968159049 /src/miasm/arch/x86/lifter_model_call.py | |
| parent | 51c15d3ea2e16d4fc5f0f01a3b9befc66b1f982e (diff) | |
| download | focaccia-miasm-579cf1d03fb932083e6317967d1613d5c2587fb6.tar.gz focaccia-miasm-579cf1d03fb932083e6317967d1613d5c2587fb6.zip | |
Convert to src-layout ta/nix
Diffstat (limited to 'src/miasm/arch/x86/lifter_model_call.py')
| -rw-r--r-- | src/miasm/arch/x86/lifter_model_call.py | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/miasm/arch/x86/lifter_model_call.py b/src/miasm/arch/x86/lifter_model_call.py new file mode 100644 index 00000000..e75f8c69 --- /dev/null +++ b/src/miasm/arch/x86/lifter_model_call.py @@ -0,0 +1,80 @@ +#-*- coding:utf-8 -*- + +from miasm.expression.expression import ExprAssign, ExprOp +from miasm.ir.ir import AssignBlock +from miasm.ir.analysis import LifterModelCall +from miasm.arch.x86.sem import Lifter_X86_16, Lifter_X86_32, Lifter_X86_64 + + +class LifterModelCall_x86_16(Lifter_X86_16, LifterModelCall): + + def __init__(self, loc_db): + Lifter_X86_16.__init__(self, loc_db) + self.ret_reg = self.arch.regs.AX + + def get_out_regs(self, _): + return set([self.ret_reg, self.sp]) + +class LifterModelCall_x86_32(Lifter_X86_32, LifterModelCall_x86_16): + + def __init__(self, loc_db): + Lifter_X86_32.__init__(self, loc_db) + self.ret_reg = self.arch.regs.EAX + + def sizeof_char(self): + return 8 + + def sizeof_short(self): + return 16 + + def sizeof_int(self): + return 32 + + def sizeof_long(self): + return 32 + + def sizeof_pointer(self): + return 32 + + +class LifterModelCall_x86_64(Lifter_X86_64, LifterModelCall_x86_16): + + def __init__(self, loc_db): + Lifter_X86_64.__init__(self, loc_db) + self.ret_reg = self.arch.regs.RAX + + def call_effects(self, ad, instr): + call_assignblk = AssignBlock( + [ + ExprAssign( + self.ret_reg, + ExprOp( + 'call_func_ret', + ad, + self.sp, + self.arch.regs.RCX, + self.arch.regs.RDX, + self.arch.regs.R8, + self.arch.regs.R9, + ) + ), + ExprAssign(self.sp, ExprOp('call_func_stack', ad, self.sp)), + ], + instr + ) + return [call_assignblk], [] + + def sizeof_char(self): + return 8 + + def sizeof_short(self): + return 16 + + def sizeof_int(self): + return 32 + + def sizeof_long(self): + return 64 + + def sizeof_pointer(self): + return 64 |