decompile.sh --case: decompile single switch cases of functions Ghidra times out on (Entity_Effect::Update 0x5d4380): DecompileCase.java patches the switch JMP at 0x5d47cc to jump straight to the case in a -readOnly copy and re-flows the body; all 139 cases decompile in ~90 s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
308b17336a
commit
9c1cc9c741
2 files changed
+78
-1
No files matched your search
+10
-1
@@ -1,13 +1,22 @@
|
||||
#!/bin/bash
|
||||
# Usage: decompile.sh [--live|--asm] QUERY [MAX]
|
||||
# Usage: decompile.sh [--live|--asm] QUERY [MAX] | decompile.sh --case CASEADDR...
|
||||
# QUERY = entry/inner address (0x6c0f30 / 006c0f30) or a regex on the qualified name (grep -E).
|
||||
# Default reads the pre-dumped corpus dump/all.c (instant, concurrency-safe).
|
||||
# --asm ADDR [N] prints N (default 20) instructions from ADDR (for functions the decompiler times out on).
|
||||
# --case decompiles single switch cases of a function the decompiler times out on (Entity_Effect::Update): each
|
||||
# CASEADDR is a jump-table target; the switch is patched to jump straight there in a throwaway copy (DecompileCase.java).
|
||||
# --live runs the Ghidra decompiler on a copy of the saved project (~25s; env DECOMP_TIMEOUT=secs, default 180).
|
||||
D="$(cd "$(dirname "$0")" && pwd)"
|
||||
LIVE=0; SCRIPT=Decompile.java
|
||||
[ "$1" = --live ] && { LIVE=1; shift; }
|
||||
[ "$1" = --asm ] && { LIVE=1; SCRIPT=Disasm.java; shift; }
|
||||
if [ "$1" = --case ]; then
|
||||
shift; TMP=$(mktemp -d); export JAVA_HOME="$D/jdk"
|
||||
cp -r "$D/project" "$TMP/project"; rm -f "$TMP"/project/*.lock*
|
||||
"$D/ghidra_12.2_PUBLIC/support/analyzeHeadless" "$TMP/project" isaac -process isaac-ng.exe -noanalysis -readOnly \
|
||||
-scriptPath "$D/scripts" -postScript DecompileCase.java "$TMP/out.c" "$@" >/dev/null 2>&1
|
||||
cat "$TMP/out.c"; rm -rf "$TMP"; exit
|
||||
fi
|
||||
Q="$1"; MAX="${2:-20}"
|
||||
[ -z "$Q" ] && { sed -n '2,7p' "$0"; exit 1; }
|
||||
if [[ "$Q" =~ ^(0x)?[0-9a-fA-F]{6,8}$ ]]; then
|
||||
|
||||
Reference in new issue
Block a user