diff options
| author | Ajax <commial@gmail.com> | 2017-04-05 15:51:14 +0200 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2017-04-06 13:47:38 +0200 |
| commit | 9ba85c8fb0e1e0bdcbeb93d500a6bebac963a0b0 (patch) | |
| tree | e29782e2699b1c6624489dae5c5635d3df7ad4eb /miasm2/arch/x86/jit.py | |
| parent | 620c96e891d0ad356332713a23b39b9d2382470c (diff) | |
| download | miasm-9ba85c8fb0e1e0bdcbeb93d500a6bebac963a0b0.tar.gz miasm-9ba85c8fb0e1e0bdcbeb93d500a6bebac963a0b0.zip | |
Introduce a new API 'func_prepare_<callingconv>' for calling a function
Diffstat (limited to 'miasm2/arch/x86/jit.py')
| -rw-r--r-- | miasm2/arch/x86/jit.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/miasm2/arch/x86/jit.py b/miasm2/arch/x86/jit.py index 4f50315f..ef1f162b 100644 --- a/miasm2/arch/x86/jit.py +++ b/miasm2/arch/x86/jit.py @@ -112,6 +112,11 @@ class jitter_x86_32(jitter): if ret_value2 is not None: self.cpu.EDX = ret_value2 + def func_prepare_stdcall(self, ret_addr, *args): + for arg in reversed(args): + self.push_uint32_t(arg) + self.push_uint32_t(ret_addr) + get_arg_n_stdcall = get_stack_arg # cdecl @@ -131,6 +136,7 @@ class jitter_x86_32(jitter): # System V func_args_systemv = func_args_cdecl func_ret_systemv = func_ret_cdecl + func_prepare_systemv = func_prepare_stdcall get_arg_n_systemv = get_stack_arg @@ -206,3 +212,12 @@ class jitter_x86_64(jitter): return ret_ad, args func_ret_systemv = func_ret_cdecl + + def func_prepare_systemv(self, ret_addr, *args): + args_regs = self.args_regs_systemv + self.push_uint64_t(ret_addr) + for i in xrange(min(len(args), len(args_regs))): + setattr(self.cpu, args_regs[i], args[i]) + remaining_args = args[len(args_regs):] + for arg in reversed(remaining_args): + self.push_uint64_t(arg) |