Convert Figma logo to code with AI

DynamoRIO logodynamorio

Dynamic Instrumentation Tool Platform

2,719
570
2,719
1,708

Top Related Projects

16,750

Clone this repo to build Frida

1,457

A Dynamic Binary Instrumentation framework based on LLVM.

7,805

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)

Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.

3,634

Fast and lightweight x86/x86-64 disassembler and code generation library

Quick Overview

DynamoRIO is a powerful runtime code manipulation system that supports code transformations on any part of a program, while it executes. It allows users to build dynamic instrumentation tools for a wide variety of uses such as program analysis, profiling, and behavior monitoring. DynamoRIO operates on native instruction streams as they are executed, efficiently manipulating an application's code without recompiling.

Pros

  • Highly efficient and low-overhead runtime code manipulation
  • Cross-platform support (Windows, Linux, macOS, Android)
  • Extensive API for building custom tools and instrumentations
  • Active development and community support

Cons

  • Steep learning curve for beginners
  • Limited documentation for advanced use cases
  • Can be complex to set up and configure for specific scenarios
  • Performance impact may vary depending on the extent of instrumentation

Code Examples

  1. Basic client to count dynamic instructions:
#include "dr_api.h"

static void event_exit(void);
static dr_emit_flags_t event_basic_block(void *drcontext, void *tag, instrlist_t *bb,
                                         bool for_trace, bool translating);

static int_least64_t count;

DR_EXPORT void
dr_client_main(client_id_t id, int argc, const char *argv[])
{
    dr_register_exit_event(event_exit);
    dr_register_bb_event(event_basic_block);
}

static void
event_exit(void)
{
    dr_fprintf(STDERR, "Dynamic instruction count: %lld\n", count);
}

static dr_emit_flags_t
event_basic_block(void *drcontext, void *tag, instrlist_t *bb,
                  bool for_trace, bool translating)
{
    for (instr_t *instr = instrlist_first(bb); instr != NULL; instr = instr_get_next(instr)) {
        count++;
    }
    return DR_EMIT_DEFAULT;
}
  1. Memory tracing example:
#include "dr_api.h"
#include "drmgr.h"
#include "drreg.h"
#include "drutil.h"

static void event_exit(void);
static dr_emit_flags_t event_app_instruction(void *drcontext, void *tag, instrlist_t *bb,
                                             instr_t *instr, bool for_trace, bool translating,
                                             void *user_data);

DR_EXPORT void
dr_client_main(client_id_t id, int argc, const char *argv[])
{
    drmgr_init();
    drreg_init();
    drutil_init();

    dr_register_exit_event(event_exit);
    drmgr_register_bb_instrumentation_event(NULL, event_app_instruction, NULL);
}

static void
event_exit(void)
{
    drmgr_exit();
    drreg_exit();
    drutil_exit();
}

static dr_emit_flags_t
event_app_instruction(void *drcontext, void *tag, instrlist_t *bb, instr_t *instr,
                      bool for_trace, bool translating, void *user_data)
{
    if (instr_reads_memory(instr) || instr_writes_memory(instr)) {
        dr_insert_clean_call(drcontext, bb, instr, (void *)log_mem_access, false, 1,
                             OPND_CREATE_INTPTR(instr_get_app_pc(instr)));
    }
    return DR_EMIT_DEFAULT;
}

static void
log_mem_access(app_pc instr_addr)
{
    dr_fprintf(STDERR, "Memory access at %p\n", instr_addr);
}

Getting Started

  1. Download and install DynamoRIO from the official GitHub repository.
  2. Set up your development environment (compiler, build tools).
  3. Write your client code (e.g., basic_count.c from the

Competitor Comparisons

16,750

Clone this repo to build Frida

Pros of Frida

  • Easier to use and more accessible for beginners
  • Supports a wider range of platforms, including mobile devices
  • Offers a powerful scripting API with JavaScript

Cons of Frida

  • Generally slower performance compared to DynamoRIO
  • Less fine-grained control over instrumentation
  • May have compatibility issues with some anti-debugging techniques

Code Comparison

Frida (JavaScript):

Interceptor.attach(ptr(0x1234), {
    onEnter: function(args) {
        console.log("Function called with args:", args[0], args[1]);
    },
    onLeave: function(retval) {
        console.log("Function returned:", retval);
    }
});

DynamoRIO (C):

static void event_app_instruction(void *drcontext, void *tag, instrlist_t *bb, instr_t *instr, bool for_trace, bool translating, void *user_data) {
    if (instr_get_app_pc(instr) == (app_pc)0x1234) {
        dr_insert_clean_call(drcontext, bb, instr, (void *)log_function_call, false, 0);
    }
}

Both tools allow for dynamic instrumentation, but Frida's scripting approach is more accessible, while DynamoRIO offers lower-level control at the cost of complexity.

1,457

A Dynamic Binary Instrumentation framework based on LLVM.

Pros of QBDI

  • Cross-platform support (x86, x86-64, ARM, and ARM64)
  • Easy-to-use API with Python and C++ bindings
  • Flexible instrumentation capabilities

Cons of QBDI

  • Less mature and less widely used compared to DynamoRIO
  • Limited documentation and community support
  • Fewer optimization features for performance-critical applications

Code Comparison

QBDI (C++ API):

#include "QBDI.h"

QBDI::VM vm;
vm.instrumentAllExecutableMaps();
vm.call(&function, {arg1, arg2});

DynamoRIO (C API):

#include "dr_api.h"

static void event_exit(void) {
    dr_exit_process(0);
}

DR_EXPORT void dr_init(client_id_t id) {
    dr_register_exit_event(event_exit);
}

Both QBDI and DynamoRIO are dynamic binary instrumentation frameworks, but they differ in their approach and target use cases. QBDI focuses on ease of use and cross-platform support, while DynamoRIO offers more advanced features and optimizations for complex instrumentation scenarios. The code examples demonstrate the difference in API complexity, with QBDI providing a more straightforward interface for basic instrumentation tasks.

7,805

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)

Pros of Unicorn

  • Lightweight and easy to integrate into existing projects
  • Supports multiple architectures (ARM, x86, MIPS, etc.) in a single framework
  • Provides a simple API for emulating code execution

Cons of Unicorn

  • Limited to emulation of CPU instructions, lacks full system emulation capabilities
  • May have performance limitations for large-scale or complex emulation tasks
  • Requires more manual setup for memory management and context

Code Comparison

Unicorn example:

from unicorn import *

# Initialize emulator in X86-32bit mode
mu = Uc(UC_ARCH_X86, UC_MODE_32)

# Map memory for this emulation
mu.mem_map(ADDRESS, 2 * 1024 * 1024)

# Write machine code to be emulated to memory
mu.mem_write(ADDRESS, X86_CODE32)

# Emulate machine code
mu.emu_start(ADDRESS, ADDRESS + len(X86_CODE32))

DynamoRIO example:

#include "dr_api.h"

static void event_exit(void);
static dr_emit_flags_t event_basic_block(void *drcontext, void *tag, instrlist_t *bb, bool for_trace, bool translating);

DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) {
    dr_register_exit_event(event_exit);
    dr_register_bb_event(event_basic_block);
}

Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.

Pros of Capstone

  • Lightweight and easy to integrate into existing projects
  • Supports a wide range of architectures (x86, ARM, MIPS, PowerPC, etc.)
  • Provides detailed information about disassembled instructions

Cons of Capstone

  • Limited to disassembly only, lacks dynamic instrumentation capabilities
  • May require additional tools for more complex analysis tasks
  • Less suitable for runtime code manipulation and optimization

Code Comparison

Capstone (disassembly):

cs_insn *insn;
size_t count = cs_disasm(handle, code, code_size, address, 0, &insn);
for (size_t j = 0; j < count; j++) {
    printf("0x%"PRIx64":\t%s\t\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
}

DynamoRIO (instrumentation):

dr_insert_clean_call(drcontext, bb, instr, (void *)analysis_func, false, 1, OPND_CREATE_INT32(opcode));
for (int i = 0; i < num_srcs; i++) {
    dr_insert_clean_call(drcontext, bb, instr, (void *)print_operand, false, 1, opnd_create_reg(src_regs[i]));
}

DynamoRIO offers more advanced features for runtime code manipulation and analysis, while Capstone focuses on efficient and accurate disassembly across multiple architectures. The choice between them depends on the specific requirements of the project and the level of analysis needed.

3,634

Fast and lightweight x86/x86-64 disassembler and code generation library

Pros of Zydis

  • Lightweight and focused solely on x86/x86-64 disassembly
  • Faster disassembly performance for specific use cases
  • Easier to integrate into existing projects due to its smaller scope

Cons of Zydis

  • Limited to disassembly, lacking the full dynamic instrumentation capabilities of DynamoRIO
  • Narrower platform support compared to DynamoRIO's cross-platform compatibility
  • Less extensive documentation and community support

Code Comparison

Zydis disassembly example:

ZydisDisassembledInstruction instruction;
ZydisDisassembleIntel(ZYDIS_MACHINE_MODE_LONG_64, runtime_address, buffer, length, &instruction);

DynamoRIO instrumentation example:

dr_insert_clean_call(drcontext, bb, instr, (void *)analysis_func, false, 1, OPND_CREATE_INT32(opcode));

While both projects deal with x86 instructions, Zydis focuses on disassembly, whereas DynamoRIO provides a comprehensive framework for dynamic instrumentation and analysis. Zydis offers a simpler API for quick disassembly tasks, while DynamoRIO enables more complex runtime code manipulation and analysis across multiple platforms.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

DynamoRIO

DynamoRIO logo

About DynamoRIO

DynamoRIO is a runtime code manipulation system that supports code transformations on any part of a program, while it executes. DynamoRIO exports an interface for building dynamic tools for a wide variety of uses: program analysis and understanding, profiling, instrumentation, optimization, translation, etc. Unlike many dynamic tool systems, DynamoRIO is not limited to insertion of callouts/trampolines and allows arbitrary modifications to application instructions via a powerful IA-32/AMD64/ARM/AArch64 instruction manipulation library. DynamoRIO provides efficient, transparent, and comprehensive manipulation of unmodified applications running on stock operating systems (Windows, Linux, or Android) and commodity IA-32, AMD64, ARM, and AArch64 hardware. Mac OSX support is in progress.

Existing DynamoRIO-based tools

DynamoRIO is the basis for some well-known external tools:

Tools built on DynamoRIO and available in the release package include:

  • The memory debugging tool Dr. Memory
  • The tracing and analysis framework drmemtrace with multiple tools that operate on both online (with multi-process support) and offline instruction and memory address traces:
  • The legacy processor emulator drcpusim
  • The "strace for Windows" tool drstrace
  • The code coverage tool drcov
  • The library tracing tool drltrace
  • The memory address tracing tool memtrace (drmemtrace's offline traces are faster with more surrounding infrastructure, but this is a simpler starting point for customized memory address tracing)
  • The memory value tracing tool memval
  • The instruction tracing tool instrace (drmemtrace's offline traces are faster with more surrounding infrastructure, but this is a simpler starting point for customized instruction tracing)
  • The basic block tracing tool bbbuf
  • The instruction counting tool inscount
  • The dynamic fuzz testing tool Dr. Fuzz
  • The disassembly tool drdisas
  • And more, including opcode counts, branch instrumentation, etc.: see API samples

Building your own custom tools

DynamoRIO's powerful API abstracts away the details of the underlying infrastructure and allows the tool builder to concentrate on analyzing or modifying the application's runtime code stream. API documentation is included in the release package and can also be browsed online. Slides from our past tutorials are also available.

Downloading DynamoRIO

DynamoRIO is available free of charge as a binary package for both Windows and Linux. DynamoRIO's source code is available primarily under a BSD license.

Obtaining Help

Use the discussion list to ask questions.

To report a bug, use the issue tracker.

See also the DynamoRIO home page: http://dynamorio.org/