Object: NativeCall
Call a native function from Python.
Constructor
address: int|Symbol
- The address orSymbol
to call.*args
- AnyType
’s matching the corresponding native function’s argument types.**kwargs
-ret
for theType
return value, andconv
to change the calling convention.
Drop
The allocated code will automatically be freed when this is deleted or reclaimed.
Magic
This object implements __call__()
. You may call this object with your args and it will call the underlying native function.
Using the call function is unsafe 🐉
You must use the correct arguments / return types, otherwise calling this is ub.
Example
import modules
import symbols
import cffi
module = modules.load("Dll1.dll")
create = symbols.find(module, "createTestClass")
one = symbols.find(module, "callTestMethod")
two = symbols.find(module, "callTestMethod2")
create = cffi.NativeCall(create, ret = cffi.Type.U64)
obj = create()
one = cffi.NativeCall(one, cffi.Type.U64)
one(obj)
two = cffi.NativeCall(two, cffi.Type.U64)
two(obj)