Beispiel #1
0
static
void module_load_event2(void *drcontext, const module_data_t *info, bool loaded)
{
    inc_count_second(EVENT_MODULE_LOAD_2);
    if (!dr_unregister_module_load_event(module_load_event2))
        dr_fprintf(STDERR, "unregister failed!\n");
}
Beispiel #2
0
static void
event_module_load(void *drcontext, const module_data_t *info, bool loaded)
{
    uint64 early_inject;

    /* do some more dr_get_proc_address testing */
    if (strncmp(dr_module_preferred_name(info), "libc.", 5) == 0) {
        module_handle_t lib = info->handle;
        dr_export_info_t fn_info;
        dr_fprintf(STDERR, "found libc\n");
        if (dr_get_proc_address(lib, "malloc") == NULL)
            dr_fprintf(STDERR, "ERROR: can't find malloc in libc\n");
        if (dr_get_proc_address(lib, "free") == NULL)
            dr_fprintf(STDERR, "ERROR: can't find free in libc\n");
        if (dr_get_proc_address(lib, "printf") == NULL)
            dr_fprintf(STDERR, "ERROR: can't find printf in libc\n");

        /* i#884: gettimeofday is indirect code on my system, and calling it
         * will crash unless we wait until libc is fully relocated.
         * dr_get_proc_address() wraps the fault in a try/except and returns
         * NULL.  The _ex variant does not, so we use that to test the lookup.
         */
        if (!dr_get_proc_address_ex(lib, "gettimeofday", &fn_info, sizeof(fn_info)))
            dr_fprintf(STDERR, "ERROR: can't find gettimeofday in libc\n");

        dr_unregister_module_load_event(event_module_load);
    }
}