Exemplo n.º 1
0
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)
Exemplo n.º 2
0
Arquivo: zoom.py Projeto: ursi/sbpe
    def onInit(self):
        self.config.option('active', True, 'bool')
        self.config.option('level', -1, 'int')
        self.config.option('fast', True, 'bool')
        self.config.option('time', 0, 'float')

        self.start = 1
        self.target = 1
        self.stime = 0

        # allows to cleanly skip the worldclient event handler
        self._hook = lib.subhook_new(
            self.refs['WorldClient::handleWindowEvent'],
            self.refs['UIElementContainer::handleWindowEvent'], 1)
Exemplo n.º 3
0
    def addhook(fname, hookfunc, ret=False):
        hook = lib.subhook_new(refs[fname], hookfunc, 1)
        orig = ffi.cast('p' + fname, lib.subhook_get_trampoline(hook))
        if orig != ffi.NULL:
            ORIGS[fname] = orig
        else:
            logging.info('{}: no trampoline, using fallback'.format(fname))

            def call_orig(*args):
                lib.subhook_remove(hook)
                res = refs[fname](*args)
                lib.subhook_install(hook)
                if ret:
                    return res

            ORIGS[fname] = call_orig

        lib.subhook_install(hook)
        if not lib.subhook_is_installed(hook):
            logging.error('failed to hook {}'.format(fname))