Skip to main content
Glama

apply_hex_patch

Patch binary instructions at a specified address to bypass checks or alter return values. Write raw hex bytes into memory or files for reverse-engineering.

Instructions

[Binary/reverse-engineering tool. Use when: disassembly, radare2, r2, debugging, vulnerability research, ELF/PE/SO/DEX analysis.] 【r2ai 逆向工具】🔨 [修改指令] 对指定地址应用二进制 Patch (修改指令)。 用于绕过校验、修改返回值等。例如:将 '1a000034' (CBZ) 修改为 '1f2003d5' (NOP)。 ⚠️ 警告:此操作会直接修改内存/文件。如果不确定,请先使用模拟执行测试。 【触发场景】当用户询问二进制逆向分析、反汇编、漏洞挖掘、radare2命令执行、调 试相关问题时,必须优先调用此工具。 【使用规则】调用前必须确认用户提供了目标文件的绝对路径,禁止捏造不存在的文件路径或命令结果,session_id 不再使用时必须关闭。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesPatch 的起始地址 (例如 '0x00401a00')
hex_bytesYes要写入的十六进制机器码 (例如 '1f2003d5')。不需要空格。
session_idYes会话 ID

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.0.3

TDQS

A3.6/5.0
Behavior4/5

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

No annotations exist, so the description carries the full burden. It explicitly warns that the operation directly modifies memory/file and advises simulated execution first, plus instructs to confirm absolute paths and close session. It does not mention reversibility or error behavior, so not a perfect 5.

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?

Structured into intro, warning, and rules, but repeats the use-when list in the trigger scene and includes decorative/boilerplate text. It is not badly bloated, yet every sentence doesn't earn its place.

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 mutating r2 tool with no annotations and no output schema, the description gives enough to call safely: format of bytes, warning, path confirmation, session cleanup, and a simulation fallback. Missing return-value expectations and clear persistence semantics are minor gaps.

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

Parameters3/5

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

All 3 params are documented in the schema (100% coverage), so baseline is 3. The description adds example values and clarifies hex_bytes needs no spaces, but contributes nothing new for session_id and only loosely maps to the schema.

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?

States an explicit action—apply a binary patch at a given address—with concrete purposes (bypass checks, alter return values) and a concrete example. This clearly distinguishes it from sibling read/analysis tools like r2_disassemble.

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

Usage Guidelines2/5

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

Provides some context (patch for bypass checks, use simulation first if unsure), but the trigger scene says to 'must prioritize this tool' for all disassembly/debugging questions, which is overbroad and conflicts with siblings such as r2_disassemble. It lacks explicit when-not-to-use guidance, so selection among siblings is not reliably grounded.

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