Skip to content

Rename UNNAMED variables to generated identifiers #160

@kumarak

Description

@kumarak

Problem

Ghidra's decompiler cannot recover names for some local variables and emits them as literal `UNNAMED`. These appear as-is in the decompiled C output:

UNNAMED = *(undefined1 *)((long)local_88 + *(long *)(local_88 + 4));

Root Cause

PcodeSerializer.java emits `UNNAMED` when `HighVariable.getName()` returns `"UNNAMED"`. The C++ pipeline stores and uses this string directly as the variable identifier.

In the JSON, these show up as:

DECLARE_LOCAL  name=UNNAMED  key=unique:00410216:22:0
DECLARE_LOCAL  name=UNNAMED  key=unique:0041021b:27:0

Proposed Fix

In `JsonDeserialize.cpp` or `FunctionBuilder.cpp`, when a variable name is `"UNNAMED"`, generate a synthetic name like `local_N` (using a counter or derived from the variable key).

Files

  • `lib/patchestry/Ghidra/JsonDeserialize.cpp` — variable name handling (~line 715)
  • `lib/patchestry/AST/FunctionBuilder.cpp` — DECLARE_LOCAL handler

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions