From a814012574221126ad003ce3cd3ce07f6047fb18 Mon Sep 17 00:00:00 2001 From: clement rouault Date: Tue, 7 Sep 2021 18:07:02 +0200 Subject: [PATCH] windows.native_exec.create_function can now accept ctypes calling convention as parameter --- windows/native_exec/native_function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windows/native_exec/native_function.py b/windows/native_exec/native_function.py index 38892b0..9a643f3 100644 --- a/windows/native_exec/native_function.py +++ b/windows/native_exec/native_function.py @@ -72,7 +72,7 @@ class CustomAllocator(object): allocator = CustomAllocator() -def create_function(code, types): +def create_function(code, types, calling_convention=ctypes.CFUNCTYPE): """Create a python function that call raw machine code :param str code: Raw machine code that will be called @@ -80,7 +80,7 @@ def create_function(code, types): :return: the created function :rtype: function """ - func_type = ctypes.CFUNCTYPE(*types) + func_type = calling_convention(*types) addr = allocator.write_code(code) res = func_type(addr) res.code_addr = addr