about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm2/arch/aarch64/jit.py10
-rw-r--r--miasm2/arch/arm/jit.py7
-rw-r--r--miasm2/arch/x86/jit.py15
3 files changed, 31 insertions, 1 deletions
diff --git a/miasm2/arch/aarch64/jit.py b/miasm2/arch/aarch64/jit.py
index e3f3e3fa..31570f52 100644
--- a/miasm2/arch/aarch64/jit.py
+++ b/miasm2/arch/aarch64/jit.py
@@ -37,7 +37,7 @@ class jitter_aarch64l(jitter):
     def func_args_stdcall(self, n_args):
         args = []
         for i in xrange(min(n_args, self.max_reg_arg)):
-            args.append(self.cpu.get_gpreg()['X%d' % i])
+            args.append(getattr(self.cpu, 'X%d' % i))
         for i in xrange(max(0, n_args - self.max_reg_arg)):
             args.append(self.get_stack_arg(i))
         ret_ad = self.cpu.LR
@@ -56,9 +56,17 @@ class jitter_aarch64l(jitter):
             arg = self.get_stack_arg(index - self.max_reg_arg)
         return arg
 
+    def func_prepare_stdcall(self, ret_addr, *args):
+        for index in xrange(min(len(args), 4)):
+            setattr(self.cpu, 'X%d' % index, args[index])
+        for index in xrange(4, len(args)):
+            self.vm.set_mem(self.cpu.SP + 8 * (index - 4), pck64(args[index]))
+        self.cpu.LR = ret_addr
+
     func_args_systemv = func_args_stdcall
     func_ret_systemv = func_ret_stdcall
     get_arg_n_systemv = get_arg_n_stdcall
+    func_prepare_systemv = func_prepare_stdcall
 
     def init_run(self, *args, **kwargs):
         jitter.init_run(self, *args, **kwargs)
diff --git a/miasm2/arch/arm/jit.py b/miasm2/arch/arm/jit.py
index e0d08679..545d60de 100644
--- a/miasm2/arch/arm/jit.py
+++ b/miasm2/arch/arm/jit.py
@@ -44,6 +44,12 @@ class jitter_arml(jitter):
             self.cpu.R0 = ret_value
         return True
 
+    def func_prepare_stdcall(self, ret_addr, *args):
+        for index in xrange(min(len(args), 4)):
+            setattr(self.cpu, 'R%d' % index, args[index])
+        for index in xrange(4, len(args)):
+            self.vm.set_mem(self.cpu.SP + 4 * (index - 4), pck32(args[index]))
+        self.cpu.LR = ret_addr
 
     def get_arg_n_stdcall(self, index):
         if index < 4:
@@ -54,6 +60,7 @@ class jitter_arml(jitter):
 
     func_args_systemv = func_args_stdcall
     func_ret_systemv = func_ret_stdcall
+    func_prepare_systemv = func_prepare_stdcall
     get_arg_n_systemv = get_arg_n_stdcall
 
     def init_run(self, *args, **kwargs):
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)