Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:Dobby

From ReverseEngineering.wiki
Library
Platforms Windows, macOS, iOS, Android, Linux
License Apache-2.0
Website https://github.com/jmpews/Dobby
On this wiki Facts · Code · Notes · Topics

Dobby (Apache-2.0) is a multi-platform inline-hook and instrumentation library for x86, x86-64, ARM and ARM64 on Windows, macOS, iOS, Android and Linux, with an instruction relocator and several trampoline shapes.

Public API (include/dobby.h): DobbyHook(address, fake_func, &origin_func), DobbyInstrument(address, pre_handler) (handler receives a DobbyRegisterContext), DobbyDestroy(address), DobbySymbolResolver(image, symbol), DobbyImportTableReplace(image, symbol, fake, &orig). On ARM64 the context holds sp, x0-x28, fp, lr and the q registers.

Layout of the source: source/InstructionRelocation/{arm,arm64,x64,x86}, source/InterceptRouting/NearBranchTrampoline, source/TrampolineBridge, builtin-plugin/ (ImportTableReplace, SymbolResolver, ObjcRuntimeReplace, BionicLinkerUtil, SupervisorCallMonitor, ApplicationEventMonitor). README credits frida-gum, MinHook, substrate, v8, dart and vixl.

ARM64 trampoline choice (trampoline_arm64.cc, near_trampoline_arm64.cc): if the detour is within the adrp range it writes adrp+add+br on a temporary register; otherwise ldr x?, #literal; br x? followed by the 8-byte target. The near variant is a single b when within +-128 MiB, else a b to a forward trampoline allocated near the source. The relocator (InstructionRelocationARM64.cc) has cases for b/bl, ldr literal, adr, adrp, b.cond, cbz/cbnz and tbz/tbnz.

See Technique:Function hooking/Unix and mobile, Library:MinHook.

Code & repositories