IFUNC = 10
FUNC = 2
+ @staticmethod
+ def __set_func_ret_types(lib):
+ lib.elfp_init.restype = c_void_p
+ lib.elfp_is_64bit.restype = c_bool
+ lib.elfp_syms_count.restype = c_uint
+ lib.elfp_syms_fill.restype = c_uint
+
+ @staticmethod
+ def __elfp_init(lib, filename):
+ return c_void_p(lib.elfp_init(filename))
+
+ @staticmethod
+ def __elfp_is_64bit(lib, elfp):
+ return c_bool(lib.elfp_is_64bit(elfp)).value
+
+ @staticmethod
+ def __elfp_uninit(lib, elfp):
+ lib.elfp_uninit(elfp)
+
+ @staticmethod
+ def __elfp_syms_count(lib, elfp):
+ return c_uint(lib.elfp_syms_count(elfp)).value
+
+ @staticmethod
+ def __elfp_syms_fill(lib, elfp, addr, name, type):
+ return c_uint(lib.elfp_syms_fill(elfp, addr, name, type)).value
+
+
def init_library(self):
parse_lib_list = [
"./elf_parsing/libparserelf.so",
try:
dbg_log("LOAD %s" % lib)
self.lib = cdll.LoadLibrary(lib)
+ self.__set_func_ret_types(self.lib)
return 0
except:
dbg_log("Cannot load %s" % lib)
return -1
def init(self, filename):
- self.elfp = self.lib.elfp_init(filename);
+ self.elfp = self.__elfp_init(self.lib, filename)
if bool(self.elfp):
- is64 = self.lib.elfp_is_64bit(self.elfp)
+ is64 = self.__elfp_is_64bit(self.lib, self.elfp)
self.prefix64 = 1 << 63 if is64 else 0
return 0
return -1
def uninit(self):
- self.lib.elfp_uninit(self.elfp)
+ self.__elfp_uninit(self.lib, self.elfp)
def get_all_symbols(self):
- count = self.lib.elfp_syms_count(self.elfp)
+ count = self.__elfp_syms_count(self.lib, self.elfp)
addr = (c_ulonglong * count)()
name = (c_char_p * count)()
type = (c_byte * count)()
ret = {}
- n = self.lib.elfp_syms_fill(self.elfp, addr, name, type)
+ n = self.__elfp_syms_fill(self.lib, self.elfp, addr, name, type)
for i in range(n):
# We never need undefined functions in headers generation
if addr[i] == 0: