Exemple #1
0
void
ntdll_redir_init(void)
{
    uint i;
    ntdll_table =
        strhash_hash_create(GLOBAL_DCONTEXT,
                            hashtable_num_bits(REDIRECT_NTDLL_NUM*2),
                            80 /* load factor: not perf-critical, plus static */,
                            HASHTABLE_SHARED | HASHTABLE_PERSISTENT,
                            NULL _IF_DEBUG("ntdll redirection table"));
    TABLE_RWLOCK(ntdll_table, write, lock);
    for (i = 0; i < REDIRECT_NTDLL_NUM; i++) {
        strhash_hash_add(GLOBAL_DCONTEXT, ntdll_table, redirect_ntdll[i].name,
                         (void *) redirect_ntdll[i].func);
    }
    TABLE_RWLOCK(ntdll_table, write, unlock);

    if (get_os_version() >= WINDOWS_VERSION_7) {
        ntdll_win7_table =
            strhash_hash_create(GLOBAL_DCONTEXT, REDIRECT_NTDLL_WIN7_NUM*2,
                                80 /* load factor: not perf-critical, plus static */,
                                HASHTABLE_SHARED | HASHTABLE_PERSISTENT,
                                NULL _IF_DEBUG("ntdll win7 redirection table"));
        TABLE_RWLOCK(ntdll_win7_table, write, lock);
        for (i = 0; i < REDIRECT_NTDLL_WIN7_NUM; i++) {
            strhash_hash_add(GLOBAL_DCONTEXT, ntdll_win7_table,
                             redirect_ntdll_win7[i].name,
                             (void *) redirect_ntdll_win7[i].func);
        }
        TABLE_RWLOCK(ntdll_win7_table, write, unlock);
    }
}
Exemple #2
0
app_pc
advapi32_redir_lookup(const char *name)
{
    app_pc res;
    TABLE_RWLOCK(advapi32_table, read, lock);
    res = strhash_hash_lookup(GLOBAL_DCONTEXT, advapi32_table, name);
    TABLE_RWLOCK(advapi32_table, read, unlock);
    return res;
}
static callee_info_t *
callee_info_table_lookup(void *callee)
{
    callee_info_t *ci;
    TABLE_RWLOCK(callee_info_table, read, lock);
    ci = generic_hash_lookup(GLOBAL_DCONTEXT, callee_info_table, (ptr_uint_t)callee);
    TABLE_RWLOCK(callee_info_table, read, unlock);
    /* We only delete the callee_info from the callee_info_table
     * when destroy the table on exit, so we can keep the ci
     * without holding the lock.
     */
    return ci;
}
Exemple #4
0
app_pc
ntdll_redir_lookup(const char *name)
{
    app_pc res;
    if (ntdll_win7_table != NULL) {
        TABLE_RWLOCK(ntdll_win7_table, read, lock);
        res = strhash_hash_lookup(GLOBAL_DCONTEXT, ntdll_win7_table, name);
        TABLE_RWLOCK(ntdll_win7_table, read, unlock);
        if (res != NULL)
            return res;
    }
    TABLE_RWLOCK(ntdll_table, read, lock);
    res = strhash_hash_lookup(GLOBAL_DCONTEXT, ntdll_table, name);
    TABLE_RWLOCK(ntdll_table, read, unlock);
    return res;
}
Exemple #5
0
void
advapi32_redir_init(void)
{
    uint i;
    advapi32_table =
        strhash_hash_create(GLOBAL_DCONTEXT,
                            hashtable_num_bits(REDIRECT_ADVAPI32_NUM*2),
                            80 /* load factor: not perf-critical, plus static */,
                            HASHTABLE_SHARED | HASHTABLE_PERSISTENT,
                            NULL _IF_DEBUG("advapi32 redirection table"));
    TABLE_RWLOCK(advapi32_table, write, lock);
    for (i = 0; i < REDIRECT_ADVAPI32_NUM; i++) {
        strhash_hash_add(GLOBAL_DCONTEXT, advapi32_table, redirect_advapi32[i].name,
                         (void *) redirect_advapi32[i].func);
    }
    TABLE_RWLOCK(advapi32_table, write, unlock);
}
static callee_info_t *
callee_info_table_add(callee_info_t *ci)
{
    callee_info_t *info;
    TABLE_RWLOCK(callee_info_table, write, lock);
    info = generic_hash_lookup(GLOBAL_DCONTEXT, callee_info_table, (ptr_uint_t)ci->start);
    if (info == NULL) {
        info = ci;
        generic_hash_add(GLOBAL_DCONTEXT, callee_info_table, (ptr_uint_t)ci->start,
                         (void *)ci);
    } else {
        /* Have one in the table, free the new one and use existing one.
         * We cannot free the existing one in the table as it might be used by
         * other thread without holding the lock.
         * Since we assume callee should never be changed, they should have
         * the same content of ci.
         */
        callee_info_free(GLOBAL_DCONTEXT, ci);
    }
    TABLE_RWLOCK(callee_info_table, write, unlock);
    return info;
}