/*----------------------------------------------------------------------------*/
static void probe_def_init(void)
{
    probes[0].name = "chrome probe";
    probes[0].insert_loc.type = DR_PROBE_ADDR_LIB_OFFS;
    probes[0].insert_loc.lib_offs.library = "../mutatee/chrome";
    drsym_init(0);

    {
     size_t exe_export_offs;
     drsym_error_t r = drsym_lookup_symbol("../mutatee/chrome", "doubler",&exe_export_offs, DRSYM_DEMANGLE);
     if (r!=DRSYM_SUCCESS) {
      dr_fprintf(STDERR, "<FAILED to find gpu::gles2::GLES2Implementation::Viewport\n");
     } else {
      dr_printf("<Found Original symbol>\n");
      probes[0].insert_loc.lib_offs.offset = exe_export_offs;
     }
    }

    //probes[0].insert_loc.lib_offs.offset = 0x50530;



    probes[0].callback_func.type = DR_PROBE_ADDR_LIB_OFFS;
    probes[0].callback_func.lib_offs.library = "libhooks.so";
    {
     size_t exe_export_offs;
     drsym_error_t r = drsym_lookup_symbol("libhooks.so", "preHook",&exe_export_offs, DRSYM_DEMANGLE);
     if (r!=DRSYM_SUCCESS) {
      dr_fprintf(STDERR, "<FAILED to find gpu::gles2::GLES2Implementation::Viewport>\n");
     } else {
      dr_printf("<Found Hook symbol>\n");
      probes[0].callback_func.lib_offs.offset = exe_export_offs;
     }
    }
    drsym_exit();
/*
    probes[0].callback_func.lib_offs.offset = 0xe30;
*/
}
Beispiel #2
0
/*
 * Helper function for bulk use of drwrap.
 */
static void try_wrap_fn(const module_data_t *module, const char *name,
                        prewrapper_t pre, postwrapper_t post, bool *done)
{
    if (*done)
        return;

    size_t offset;
    drsym_error_t status = drsym_lookup_symbol(
        module->full_path, name, &offset, DRSYM_DEFAULT_FLAGS);
    if (status == DRSYM_SUCCESS) {
        app_pc notify_fn = module->start + offset;
        bool ok = drwrap_wrap(notify_fn, pre, post);
        DR_ASSERT(ok);
        *done = true;
    }
}
Beispiel #3
0
static void
lookup_symbol(const char *dllpath, const char *sym)
{
    size_t modoffs;
    drsym_error_t symres;
    if (verbose)
        get_and_print_debug_kind(dllpath);
    symres = drsym_lookup_symbol(dllpath, sym, &modoffs, DRSYM_DEMANGLE);
    if (symres == DRSYM_SUCCESS || symres == DRSYM_ERROR_LINE_NOT_AVAILABLE) {
        printf("+0x%x\n", (uint)modoffs);
    } else {
        if (verbose)
            printf("drsym error %d looking up \"%s\" in \"%s\"\n", symres, sym, dllpath);
        else
            printf("??\n");
    }
}
Beispiel #4
0
static void
symquery_lookup_symbol(const char *dllpath, const char *sym)
{
    size_t modoffs;
    drsym_error_t symres;
    if (verbose)
        get_and_print_debug_kind(dllpath);
    symres = drsym_lookup_symbol(dllpath, sym, &modoffs, demangle_flags);
    if (symres == DRSYM_SUCCESS || symres == DRSYM_ERROR_LINE_NOT_AVAILABLE) {
        printf("+"SIZE_FMTX"\n", modoffs);
    } else {
        if (verbose)
            printf("drsym error %d looking up \"%s\" in \"%s\"\n", symres, sym, dllpath);
        else
            printf("??\n");
    }
}
Beispiel #5
0
static void
process_symbols(void *dcontext, char *dllname, LOADED_IMAGE *img)
{
    /* We have to specify the module via "modname!symname".
     * We must use the same modname as in full_path.
     */
    char fullpath[MAX_PATH];
# define MAX_SYM_WITH_MOD_LEN 256
    char sym_with_mod[MAX_SYM_WITH_MOD_LEN];
    int len;
    drsym_error_t symres;
    char *fname = NULL, *c;
    search_data_t sd;

    if (drsym_init(NULL) != DRSYM_SUCCESS) {
        print("WARNING: unable to initialize symbol engine\n");
        return;
    }

    if (dllname == NULL)
        return;
    fname = dllname;
    for (c = dllname; *c != '\0'; c++) {
        if (*c == '/' || *c == '\\')
            fname = c + 1;
    }
    assert(fname != NULL && "unable to get fname for module");
    if (fname == NULL)
        return;
    /* now get rid of extension */
    for (; c > fname && *c != '.'; c--)
        ; /* nothing */

    assert(c > fname && "file has no extension");
    assert(c - fname < BUFFER_SIZE_ELEMENTS(sym_with_mod) && "sizes way off");
    len = dr_snprintf(sym_with_mod, BUFFER_SIZE_ELEMENTS(sym_with_mod), "%.*s!%s",
                      c - fname, fname, SYM_PATTERN);
    assert(len > 0 && "error printing modname!symname");
    NULL_TERMINATE_BUFFER(sym_with_mod);

    len = GetFullPathName(dllname, BUFFER_SIZE_ELEMENTS(fullpath), fullpath, NULL);
    assert(len > 0);
    NULL_TERMINATE_BUFFER(dllname);

    if (list_usercalls) {
        int i;
        for (i = 0; i < NUM_USERCALL; i++) {
            size_t offs;
            symres = drsym_lookup_symbol(fullpath, usercall_names[i], &offs, 0);
            if (symres == DRSYM_SUCCESS) {
                usercall_addr[i] = ImageRvaToVa(img->FileHeader, img->MappedAddress,
                                                (ULONG)offs, NULL);
                verbose_print("%s = %d +0x%x == "PFX"\n", usercall_names[i], symres,
                              offs, usercall_addr[i]);
            } else {
                dr_printf("Error locating usercall %s: aborting\n", usercall_names[i]);
                return;
            }
        }
    }

    sd.dcontext = dcontext;
    sd.img = img;
    sd.modpath = fullpath;
    verbose_print("Searching \"%s\" for \"%s\"\n", fullpath, sym_with_mod);
    symres = drsym_search_symbols(fullpath, sym_with_mod, true, search_syms_cb, &sd);
    if (symres != DRSYM_SUCCESS)
        print("Error %d searching \"%s\" for \"%s\"\n", symres, fullpath, sym_with_mod);
    drsym_exit();
}