def afterUpdate(self): menu = self.refs.MainMenu if menu == ffi.NULL or menu.version == ffi.NULL: return menu.version.asUIElement.show = False if len(self.vtxt.text) == 0: sbver = ffi.string(menu.version.text.s).decode() self.vtxt.text = VTEMPLATE.format(sbver, self.refs)
def hook_LoadTextureFile(name, callback, userData): refs._tfname = ffi.string(name).decode() hook = lib.subhook_new(callback, lib.hook_textureCallback, 0) refs._orig_callback = ffi.cast('XDL_LoadTextureDoneCallback', lib.subhook_get_trampoline(hook)) lib.subhook_install(hook) ORIGS['XDL_LoadTextureFile'](name, callback, userData) lib.subhook_remove(hook) lib.subhook_free(hook)
def getClassName(obj): ''' class name of a C++ object (assuming gcc memory layout). doesn't demangle complicated names ''' if obj == ffi.NULL: return 'NULL' # class pointer is always at [0] classptr = ffi.cast('void****', obj)[0] # vtable (1 up) -> type -> name (1 down) nameptr = classptr[-1][1] cname = ffi.string(ffi.cast('char*', nameptr), 100) return cname[1 if len(cname) < 11 else 2:].decode()
def getstr(stdstring): if stdstring == ffi.NULL: return '(NULL)' return ffi.string(stdstring.s, 1000).decode('utf-8', errors='replace')