From 7952a0a6506cfa67aa1f28d8cebb7d83079cb5ef Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 28 Oct 2026 19:40:06 +0100 Subject: [PATCH] Export originals with LF line endings Ghidra on Windows returns CRLF from the decompiler and listing; stored rows then render double-spaced in the review view. --- ghidra_scripts/ExportOriginals.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ghidra_scripts/ExportOriginals.java b/ghidra_scripts/ExportOriginals.java index 1a6eb14..e40d407 100644 --- a/ghidra_scripts/ExportOriginals.java +++ b/ghidra_scripts/ExportOriginals.java @@ -41,12 +41,12 @@ public class ExportOriginals extends GhidraScript { String c; DecompileResults r = ifc.decompileFunction(f, timeout, monitor); if (r.decompileCompleted() && r.getDecompiledFunction() != null) { - c = r.getDecompiledFunction().getC(); + c = r.getDecompiledFunction().getC().replace("\r\n", "\n"); } else { c = null; failed++; } - out.write("{\"addr\":\"0x" + Long.toHexString(f.getEntryPoint().getOffset()) + "\",\"asm\":" + json(disassemble(f)) + ",\"c\":" + (c == null ? "null" : json(c)) + "}\n"); + out.write("{\"addr\":\"0x" + Long.toHexString(f.getEntryPoint().getOffset()) + "\",\"asm\":" + json(disassemble(f).replace("\r\n", "\n")) + ",\"c\":" + (c == null ? "null" : json(c)) + "}\n"); if (++n % 1000 == 0) { println("exported " + n + " functions"); }