Ejemplo n.º 1
0
bool hook_remove(WHook *hk, WHookDummy *fn)
{
    WHookItem *item=hook_find(hk, fn);
    if(item!=NULL)
        destroy_item(hk, item);
    return (item!=NULL);
}
Ejemplo n.º 2
0
void *get_hooked_symbol(char *sym)
{
    pthread_mutex_lock(&hook_mutex);
    static int counter = 0;
    int i;

    hooks_install();

    for (i=0; use_from_bionic[i]!=NULL; ++i) {
       if (!strcmp(sym,use_from_bionic[i])) {
           LOGD("from_bionic:%s",use_from_bionic[i]);
           pthread_mutex_unlock(&hook_mutex);
           return NULL;
       }
    }
    void *rv = hook_find(sym);
    if (rv != NULL) {
        pthread_mutex_unlock(&hook_mutex);
        return rv;
    }

    rv = hook_add_from_lib(sym, "librt.so");
    if (rv != NULL) {
        pthread_mutex_unlock(&hook_mutex);
        return rv;
    }

    rv = hook_add_from_lib(sym, "libc.so.6");
    if (rv != NULL) {
        pthread_mutex_unlock(&hook_mutex);
        return rv;
    }

    /*
     * functions we want to come from bionic
     * libsc-a3xx.so: fall back into bionic */
    if (!strcmp(sym, "pthread_sigmask")
       ) {
        pthread_mutex_unlock(&hook_mutex);
        return NULL;
    }

    /* strstr includes symbols such as __pthread */
    if (strstr(sym, "pthread_")) {
        hybris_missing_symbols[counter]=strdup(sym);
        pthread_mutex_unlock(&hook_mutex);
        return (void*)counter++;
    }

    if (rv == NULL) {
        LOGD("UNABLE TO FIND:%s",sym);
    }
    pthread_mutex_unlock(&hook_mutex);

    return rv;
}
Ejemplo n.º 3
0
bool hook_add(WHook *hk, WHookDummy *fn)
{
    WHookItem *item;
    
    if(hook_find(hk, fn))
        return FALSE;
    
    item=create_item(hk);
    if(item==NULL)
        return FALSE;
    item->fn=fn;
    return TRUE;
}