DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { /* We need 2 reg slots beyond drreg's eflags slots => 3 slots */ drreg_options_t ops = { sizeof(ops), 3, false }; dr_set_client_name("DynamoRIO Sample Client 'memtrace'", "http://dynamorio.org/issues"); if (!drmgr_init() || drreg_init(&ops) != DRREG_SUCCESS || !drutil_init()) DR_ASSERT(false); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_thread_init_event(event_thread_init) || !drmgr_register_thread_exit_event(event_thread_exit) || !drmgr_register_bb_app2app_event(event_bb_app2app, NULL) || !drmgr_register_bb_instrumentation_event(NULL /*analysis_func*/, event_app_instruction, NULL)) DR_ASSERT(false); client_id = id; mutex = dr_mutex_create(); tls_idx = drmgr_register_tls_field(); DR_ASSERT(tls_idx != -1); /* The TLS field provided by DR cannot be directly accessed from the code cache. * For better performance, we allocate raw TLS so that we can directly * access and update it with a single instruction. */ if (!dr_raw_tls_calloc(&tls_seg, &tls_offs, MEMTRACE_TLS_COUNT, 0)) DR_ASSERT(false); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'memtrace' initializing\n"); }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { drreg_options_t ops = {sizeof(ops), 1 /*max slots needed: aflags*/, false}; dr_set_client_name("DynamoRIO Sample Client 'bbcount'", "http://dynamorio.org/issues"); if (!drmgr_init() || drreg_init(&ops) != DRREG_SUCCESS) DR_ASSERT(false); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(NULL, event_app_instruction, NULL)) DR_ASSERT(false); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'bbcount' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client bbcount is running\n"); } #endif }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { drreg_options_t ops = { sizeof(ops), 4 /*max slots needed*/, false }; dr_set_client_name("DynamoRIO Sample Client 'memval'", "http://dynamorio.org/issues"); if (!drmgr_init() || !drutil_init() || !drx_init()) DR_ASSERT(false); if (drreg_init(&ops) != DRREG_SUCCESS) DR_ASSERT(false); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_thread_init_event(event_thread_init) || !drmgr_register_thread_exit_event(event_thread_exit) || !drmgr_register_bb_app2app_event(event_bb_app2app, NULL) || !drmgr_register_bb_instrumentation_event(event_app_analysis, event_app_instruction, NULL)) DR_ASSERT(false); client_id = id; tls_idx = drmgr_register_tls_field(); trace_buffer = drx_buf_create_trace_buffer(MEM_BUF_SIZE, trace_fault); /* We could make this a trace buffer and specially handle faults, but it is not yet * worth the effort. */ write_buffer = drx_buf_create_circular_buffer(WRT_BUF_SIZE); DR_ASSERT(tls_idx != -1 && trace_buffer != NULL && write_buffer != NULL); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'memval' initializing\n"); }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { drreg_options_t ops = { sizeof(ops), 1 /*max slots needed*/, false }; if (!drmgr_init()) CHECK(false, "drmgr init failed"); if (drreg_init(&ops) != DRREG_SUCCESS) CHECK(false, "drreg_init failed"); dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(NULL, event_app_instruction, NULL)) CHECK(false, "bb reg failed"); }
DR_EXPORT void dr_init(client_id_t id) { drreg_options_t ops = { sizeof(ops), 2 /*max slots needed*/, false }; drreg_status_t res; bool ok = drmgr_init(); CHECK(ok, "drmgr_init failed"); ok = drx_init(); CHECK(ok, "drx_init failed"); res = drreg_init(&ops); CHECK(res == DRREG_SUCCESS, "drreg_init failed"); dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(NULL, event_app_instruction, NULL)) DR_ASSERT(false); }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { /* We need 2 reg slots beyond drreg's eflags slots => 3 slots */ drreg_options_t ops = {sizeof(ops), 3, false}; /* Specify priority relative to other instrumentation operations: */ drmgr_priority_t priority = { sizeof(priority), /* size of struct */ "memtrace", /* name of our operation */ NULL, /* optional name of operation we should precede */ NULL, /* optional name of operation we should follow */ 0}; /* numeric priority */ dr_set_client_name("DynamoRIO Sample Client 'memtrace'", "http://dynamorio.org/issues"); page_size = dr_page_size(); drmgr_init(); drutil_init(); client_id = id; mutex = dr_mutex_create(); dr_register_exit_event(event_exit); if (!drmgr_register_thread_init_event(event_thread_init) || !drmgr_register_thread_exit_event(event_thread_exit) || !drmgr_register_bb_app2app_event(event_bb_app2app, &priority) || !drmgr_register_bb_instrumentation_event(NULL, event_bb_insert, &priority) || drreg_init(&ops) != DRREG_SUCCESS) { /* something is wrong: can't continue */ DR_ASSERT(false); return; } tls_index = drmgr_register_tls_field(); DR_ASSERT(tls_index != -1); code_cache_init(); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, DR_LOG_ALL, 1, "Client 'memtrace' initializing\n"); #ifdef SHOW_RESULTS if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client memtrace is running\n"); } #endif }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { /* We need no drreg slots ourselves, but we initialize drreg as we call * drreg_restore_app_values(), required since drx_insert_counter_update() * uses drreg when drmgr is used. */ drreg_options_t ops = {sizeof(ops)}; dr_set_client_name("DynamoRIO Sample Client 'modxfer'", "http://dynamorio.org/issues"); if (!drmgr_init() || drreg_init(&ops) != DRREG_SUCCESS) DR_ASSERT(false); drx_init(); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_bb_instrumentation_event(event_analyze_bb, event_insert_instrumentation, NULL)) DR_ASSERT(false); drmgr_register_module_load_event(event_module_load); drmgr_register_module_unload_event(event_module_unload); mod_lock = dr_mutex_create(); logfile = log_file_open(id, NULL /* drcontext */, NULL/* path */, "modxfer", #ifndef WINDOWS DR_FILE_CLOSE_ON_FORK | #endif DR_FILE_ALLOW_LARGE); DR_ASSERT(logfile != INVALID_FILE); /* make it easy to tell, by looking at log file, which client executed */ dr_log(NULL, LOG_ALL, 1, "Client 'modxfer' initializing\n"); #ifdef SHOW_RESULTS /* also give notification to stderr */ if (dr_is_notify_on()) { # ifdef WINDOWS /* ask for best-effort printing to cmd window. must be called at init. */ dr_enable_console_printing(); # endif dr_fprintf(STDERR, "Client modxfer is running\n"); } #endif }
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { drreg_options_t ops = {sizeof(ops), 2 /*max slots needed*/, false}; dr_set_client_name("DynamoRIO Sample Client 'bbbuf'", "http://dynamorio.org/issues"); if (!drmgr_init() || !drx_init() || drreg_init(&ops) != DRREG_SUCCESS) DR_ASSERT(false); buf = drx_buf_create_circular_buffer(DRX_BUF_FAST_CIRCULAR_BUFSZ); DR_ASSERT(buf); /* register events */ dr_register_exit_event(event_exit); if (!drmgr_register_thread_init_event(event_thread_init) || !drmgr_register_bb_instrumentation_event(NULL, event_app_instruction, NULL)) DR_ASSERT(false); }
/* * Main entry point that sets up all the facilities we need. */ DR_EXPORT void dr_client_main(client_id_t id, int argc, const char **argv) { dr_set_client_name( "Time-sensitive activity logger for PuTTY crypto testing", "https://www.chiark.greenend.org.uk/~sgtatham/putty/"); outfile = INVALID_FILE; bool ok = drmgr_init(); DR_ASSERT(ok); /* * Run our main instrumentation pass with lower priority than * drwrap, so that we don't start logging the inside of a function * whose drwrap pre-wrapper would have wanted to disable logging. */ drmgr_priority_t pri = {sizeof(pri), "sclog", NULL, NULL, DRMGR_PRIORITY_INSERT_DRWRAP+1}; ok = drmgr_register_bb_instrumentation_event( NULL, instrument_instr, &pri); DR_ASSERT(ok); ok = drutil_init(); DR_ASSERT(ok); ok = drwrap_init(); DR_ASSERT(ok); drsym_error_t symstatus = drsym_init(0); DR_ASSERT(symstatus == DRSYM_SUCCESS); dr_register_exit_event(exit_event); drreg_options_t ops = { sizeof(ops), 3, false }; drreg_status_t regstatus = drreg_init(&ops); DR_ASSERT(regstatus == DRREG_SUCCESS); drmgr_register_module_load_event(load_module); ok = drmgr_register_bb_app2app_event(expand_rep_movsb, NULL); DR_ASSERT(ok); }