from ctypes import*import os
import math
add = CDLL("./libadd.dll")
override=CDLL("./liboverrid.dll")
add.add.argtypes =[POINTER(c_int32), POINTER(c_int32)]
add.add.restype = c_int32
defwarrperRestype(a:c_uint8,b:c_uint8)->c_int32:
override.result(1,2)returnint(math.pow(a,b))
cb=CFUNCTYPE(c_int32,c_uint8,c_uint8)(warrperRestype)
add.setCallback(cb)
t=add.test(6,2)print(t)# a = c_int32(1)# b = c_int32(2)# res = c_int32(0)# res = add.add(byref(a), byref(b))# print(res)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include#includeintresult(uint8_t a,uint8_t b){printf("I am Result For test \n");return0;}