MCPcopy Create free account
hub / github.com/ELMERIKH/PyinMemoryPE / create_function

Function create_function

windows/native_exec/native_function.py:75–87  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

73
74
75def 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

Callers

nothing calls this directly

Calls 1

write_codeMethod · 0.80

Tested by

no test coverage detected