$ show std-microblock/chromatic
chromatic is a runtime instrumentation framework for Chromium/V8 processes that provides Frida-compatible APIs for memory inspection, function interception, breakpoint debugging, and code modification. The architecture consists of a core C++ implementation with TypeScript bindings that expose a JavaScript API. Key capabilities include process/module enumeration, memory read/write/allocation, native function calls, native callbacks, inline hooking via trampolines, software/hardware breakpoints, memory access monitoring, exception handling, and instruction disassembly. The project uses breeze-js (QuickJS) as its JavaScript engine, Capstone for disassembly, asmjit for runtime code generation, libffi for FFI, and TCC for runtime C compilation. Entry points include the chromatic-core library, chromatic-test binary, and chromatic-injectee shared library designed for fripack patching.
The LLM identified 4 files worth highlighting for reuse:
Implements architecture-specific code relocation and trampoline generation for inline hooking and breakpoints. Handles PC-relative instruction fixing and register preservation using asmjit for JIT compilation. Demonstrates advanced binary instrumentation techniques for safely modifying executable code at runtime.
Implements one-shot memory access monitoring using mprotect/VirtualProtect and signal handlers. Uses a lock-free ring buffer for safe communication between signal handler and JS context. Demonstrates skill in signal-safe programming and cross-platform memory protection techniques for tracking memory accesses without crashing the target process.
Provides a cross-platform console API with colors, grouping, timing, counters, profiling, and timestamps. Handles platform-specific output methods (Windows, Android, POSIX) using appropriate APIs. Demonstrates skill in creating a unified diagnostic interface across platforms with features like nested timers, call counting, and execution timing.
Implements cross-platform exception handling (Windows VEH, POSIX signals) with reference counting to manage handler lifetime. Provides both internal APIs for breakpoints/memory monitoring and JS-facing APIs. Demonstrates skill in safe signal handling, platform abstraction, and preventing use-after-free of exception handlers through reference counting.