Create a python function that call raw machine code :param str code: Raw machine code that will be called :param list types: Return type and parameters type (see :mod:`ctypes`) :return: the created function :rtype: function
(code, types, calling_convention=ctypes.CFUNCTYPE)
| 73 | |
| 74 | |
| 75 | def create_function(code, types, calling_convention=ctypes.CFUNCTYPE): |
| 76 | """Create a python function that call raw machine code |
| 77 | |
| 78 | :param str code: Raw machine code that will be called |
| 79 | :param list types: Return type and parameters type (see :mod:`ctypes`) |
| 80 | :return: the created function |
| 81 | :rtype: function |
| 82 | """ |
| 83 | func_type = calling_convention(*types) |
| 84 | addr = allocator.write_code(code) |
| 85 | res = func_type(addr) |
| 86 | res.code_addr = addr |
| 87 | return res |
nothing calls this directly
no test coverage detected