Skip to main content
Glama

renef_hook_native

Installs a native hook at a library offset to run Lua callbacks on entry and exit, letting you inspect arguments and return values in Android processes.

Instructions

Install a native hook at offset (from library base) in lib, e.g. renef_hook_native("libc.so", "0x1234", on_enter="print('fopen path:', Memory.readString(args[0]))"). Callbacks are Lua statement strings using args[0..7] (onEnter) / retval (onLeave). Find offsets with renef_module_exports first. caller selects the upstream PLT/GOT backend (e.g. caller="libtarget.so"); omit it for a trampoline hook. There is no separate hook_type: upstream ignores the old --hook= argument and auto-selects from caller. WARNING: do not hook ultra-hot functions like clock_gettime/read/write - the agent's own output path may call them, causing recursive hooks that crash the target.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "lib": "<lib>",
      "offset": "<offset>"
    },
    "name": "renef_hook_native"
  }
}

Input Schema

NameRequiredDescriptionDefault
libYes
callerNo
offsetYes
on_enterNo
on_leaveNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.1

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden well: it discloses the two backend modes and that the backend is auto-selected, clarifies that there is no separate hook_type argument, and warns that hooking ultra-hot functions like clock_gettime/read/write can cause recursive hooks that crash the target. It does not cover persistence, teardown, or whether the target must be attached/paused first, leaving those behaviors undisclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The scoping statement, the offsets prerequisite, and the recursion warning are all front-loaded and earn their place. However, the aside explaining that upstream "ignores the old --hook= argument" is legacy meta-commentary that could be trimmed to a single clause, and the example text runs long inside the description rather than being confined to the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a five-parameter hooking tool with no annotations, the definition covers the essentials: what gets hooked, how callbacks are written, how the backend is chosen, and the one failure mode that can kill the target process. An output schema exists so return values need not be described, but the omission of attach/pause prerequisites and hook lifecycle (listing or removing installed hooks) leaves a small completeness gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must define the parameters itself, and it largely does: offset is relative to the library base, lib is shown as a module name like libc.so, caller is the backend selector with an explicit omit-for-trampoline rule, and on_enter/on_leave are Lua statement strings with args[0..7] available on enter and retval on leave. Gaps remain — the accepted offset string format and what on_leave has access to are not spelled out.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource — "Install a native hook at offset (from library base) in lib" — and immediately anchors it with a concrete call example. The word "native" plus the reference to renef_module_exports for offsets distinguishes it from the Java hooking sibling and from hook generation, so an agent can pick it without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It supplies a real prerequisite workflow ("Find offsets with renef_module_exports first") and a routing rule: supply caller for the upstream PLT/GOT backend, omit it for a trampoline hook. It never explicitly states when to prefer a different hooking tool or when not to install a hook at all, so it stops short of full when/when-not guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.