From 4dded02b58e188d1b777ad5ba665aa009944571c Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Sun, 22 Feb 2026 19:26:09 -0500 Subject: [PATCH 1/6] Minor revisions to xapi0.c comments --- decompile/src/XDK/Xapi/xapi0.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/decompile/src/XDK/Xapi/xapi0.c b/decompile/src/XDK/Xapi/xapi0.c index d726005..ae97f97 100644 --- a/decompile/src/XDK/Xapi/xapi0.c +++ b/decompile/src/XDK/Xapi/xapi0.c @@ -71,7 +71,7 @@ the middle part of the function match is through writing the instructions directly. Given that the C parts of this function are so simple that a human and a compiler would reasonably produce the exact same code, and this function exhibits other oddities mentioned in the body, it's likely this whole function -was originally written purely in assemblys. In the spirit of decompilation, +was originally written purely in assembly. In the spirit of decompilation, however, we'll lift what we can into C. */ XapiInitProcess(); @@ -107,7 +107,7 @@ however, we'll lift what we can into C. written function. If it was a function, it must have been inlined, but it couldn't be because it must be called from assembly to use the value in ecx that never went on the stack - (as passing data from C to assembly has to do). Notably, this + (as passing data from assembly to C has to do). Notably, this function's calling convention does require edi to be preserved, but if left up to the compiler, it will push and pop edi in the prologue and epilogue, not here (which this function must be @@ -135,6 +135,7 @@ however, we'll lift what we can into C. _cinit(); main(0, NULL, NULL); + // main() is not supposed to return, so error out if it does XapiBootToDash(XLD_LAUNCH_DASHBOARD_ERROR, XLD_ERROR_INVALID_XBE, 0); // Return 0 to satisfy signature required for thread functions @@ -152,7 +153,7 @@ The linker automatically sets this function to the entrypoint. */ HANDLE thread; - // Figure out available thread-local storage + // Figure out available thread-local storage (used by CreateThread()) XapiTlsSize = 4 + (( (_tls_used.EndAddressOfRawData - _tls_used.StartAddressOfRawData) + _tls_used.SizeOfZeroFill From 6b12d397ff621c9424a2684ca792ad8322f5fce4 Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Fri, 20 Mar 2026 08:27:08 -0400 Subject: [PATCH 2/6] Update headers in make_header.sh Forgot to change after Std.hpp got turned into stddef.h. --- ghidra/make_header.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghidra/make_header.sh b/ghidra/make_header.sh index d2cae8a..1da52e7 100755 --- a/ghidra/make_header.sh +++ b/ghidra/make_header.sh @@ -8,7 +8,7 @@ printf '%s\n' '// Automatically generated mass header file for Ghidra' > jsrf.h # Figuring out include order programmatically is awful, so we'll have to add # all the headers here by hand in an order that functions properly HEADERS=" - Std.hpp + XDK/CRT/stddef.h XDK/Win32.h XDK/D3D.h MUSASHI/MMatrix.hpp From da67c782e37cf16369f9ad010e0501858cb605e9 Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Fri, 20 Mar 2026 10:03:24 -0400 Subject: [PATCH 3/6] Remove unneeded .gitkeep --- decompile/target/XDK/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 decompile/target/XDK/.gitkeep diff --git a/decompile/target/XDK/.gitkeep b/decompile/target/XDK/.gitkeep deleted file mode 100644 index e69de29..0000000 From c713c2c8ea11ecd95fcf4dd2709b1a65a06b4448 Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Fri, 20 Mar 2026 10:08:51 -0400 Subject: [PATCH 4/6] Fix permissions on symbol table --- ghidra/symboltable.tsv | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 ghidra/symboltable.tsv diff --git a/ghidra/symboltable.tsv b/ghidra/symboltable.tsv old mode 100755 new mode 100644 From 76e77147221b8ccce2868915c1ccec9b33b2a89c Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Fri, 20 Mar 2026 10:09:33 -0400 Subject: [PATCH 5/6] Typo --- decompile/src/JSRF/Core.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decompile/src/JSRF/Core.hpp b/decompile/src/JSRF/Core.hpp index cc56748..f77395e 100644 --- a/decompile/src/JSRF/Core.hpp +++ b/decompile/src/JSRF/Core.hpp @@ -233,7 +233,7 @@ struct Game { BOOL useFallbackBgColour; // Game state used to select GameObj methods to call in main loop - // If multiple states are acivated, the precedence is + // If multiple states are activated, the precedence is // coveredPause > Event > FreezeCam > UncoveredPause > Default BOOL coveredPause; // Game paused with world not visible BOOL event; // Events (cutscenes) From 98d88cc2122f0ea753f69027ccc43758a8060439 Mon Sep 17 00:00:00 2001 From: KeybadeBlox Date: Fri, 20 Mar 2026 13:20:51 -0400 Subject: [PATCH 6/6] Support earlier Java releases Existing code was written for Java 25, which is more recent than many people have on hand. The modified scripts appear to run well on Java 21. --- ghidra/ghidra_scripts/ClassFixup.java | 2 +- ghidra/ghidra_scripts/EnhancedImport.java | 7 ++--- ghidra/ghidra_scripts/MSVC7Mangle.java | 38 +++++++++++------------ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ghidra/ghidra_scripts/ClassFixup.java b/ghidra/ghidra_scripts/ClassFixup.java index fa11bc5..d47d5a7 100644 --- a/ghidra/ghidra_scripts/ClassFixup.java +++ b/ghidra/ghidra_scripts/ClassFixup.java @@ -1,4 +1,4 @@ -// Creates classes out namespaces with matching structs, and if they have a +// Creates classes out of namespaces with matching structs, and if they have a // vtable, sets the calling convention of the contained function typdefs to // __thiscall. // diff --git a/ghidra/ghidra_scripts/EnhancedImport.java b/ghidra/ghidra_scripts/EnhancedImport.java index 935ee87..6d1f117 100644 --- a/ghidra/ghidra_scripts/EnhancedImport.java +++ b/ghidra/ghidra_scripts/EnhancedImport.java @@ -20,20 +20,17 @@ import ghidra.program.model.symbol.SourceType; import ghidra.program.model.symbol.Symbol; import ghidra.util.StringUtilities; -import java.io.FileReader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; - public class EnhancedImport extends GhidraScript { @Override public void run() throws Exception { - final FileReader in = new FileReader(askFile("Select input file", "OK")); - final List lines = in.readAllLines(); - in.close(); + final List lines = Files.readAllLines(askFile("Select input file", "OK").toPath()); for (int i = 0; i < lines.size(); i++) { final String[] parts = lines.get(i).split("\t");; diff --git a/ghidra/ghidra_scripts/MSVC7Mangle.java b/ghidra/ghidra_scripts/MSVC7Mangle.java index f913567..ca55321 100644 --- a/ghidra/ghidra_scripts/MSVC7Mangle.java +++ b/ghidra/ghidra_scripts/MSVC7Mangle.java @@ -422,34 +422,34 @@ public class MSVC7Mangle extends GhidraScript { ); return switch(t) { - case SignedCharDataType _ -> "C"; - case UnsignedCharDataType _ -> "E"; - case CharDataType _ -> "D"; // Must come after its child types - case ShortDataType _ -> "F"; - case UnsignedShortDataType _ -> "G"; - case IntegerDataType _ -> "H"; - case UnsignedIntegerDataType _ -> "I"; - case LongDataType _ -> "J"; - case UnsignedLongDataType _ -> "K"; - case FloatDataType _ -> "M"; - case DoubleDataType _ -> "N"; - case LongDoubleDataType _ -> "O"; + case SignedCharDataType x -> "C"; + case UnsignedCharDataType x -> "E"; + case CharDataType x -> "D"; // Must come after its child types + case ShortDataType x -> "F"; + case UnsignedShortDataType x -> "G"; + case IntegerDataType x -> "H"; + case UnsignedIntegerDataType x -> "I"; + case LongDataType x -> "J"; + case UnsignedLongDataType x -> "K"; + case FloatDataType x -> "M"; + case DoubleDataType x -> "N"; + case LongDoubleDataType x -> "O"; case Pointer p -> "P" + (p.getDataType() instanceof FunctionSignature ? "6" : "A") + mangleType(p.getDataType(), dict, loc); case Union u -> "T" + mangleIdentifier(u.getName(), false, null, dict); case Structure s -> "U" + mangleIdentifier(s.getName(), false, null, dict); case Enum e -> "W4" + mangleIdentifier(e.getName(), false, null, dict); - case VoidDataType _ -> "X"; - case LongLongDataType _ -> "_J"; - case UnsignedLongLongDataType _ -> "_K"; - case BooleanDataType _ -> "_N"; - case WideCharDataType _ -> "_W"; + case VoidDataType x -> "X"; + case LongLongDataType x -> "_J"; + case UnsignedLongLongDataType x -> "_K"; + case BooleanDataType x -> "_N"; + case WideCharDataType x -> "_W"; case Array a -> "PA" + mangleArrDims(a) + mangleType(arrType(a), dict, loc); case FunctionSignature f -> mangleFnType(f, dict, "function typedef \"" + f.getName() + "\""); case TypeDef d -> mangleType(d.getBaseDataType(), dict, "typedef \"" + d.getName() + "\""); - case DefaultDataType _ -> throw new Exception ("Encountered data marked \"undefined\" at " + loc + ". Ensure that all data types in the code/data to mangle have been defined."); - case Undefined _ -> throw new Exception ("Encountered data marked \"undefined\" at " + loc + ". Ensure that all data types in the code/data to mangle have been defined."); + case DefaultDataType x -> throw new Exception ("Encountered data marked \"undefined\" at " + loc + ". Ensure that all data types in the code/data to mangle have been defined."); + case Undefined x -> throw new Exception ("Encountered data marked \"undefined\" at " + loc + ". Ensure that all data types in the code/data to mangle have been defined."); default -> throw new Exception ("Unknown type \"" + t.getClass().getName() + "\" at " + loc); }; }