Commit graph

94 commits

Author SHA1 Message Date
KeybadeBlox
522bf8be7f Fix static init/exit section names in objects.csv 2026-02-18 20:42:45 -05:00
KeybadeBlox
0b10a02ad7 Fix whitespace in Ghidra export script output
Functions with no arguments had a trailing tab.
2026-02-18 20:41:51 -05:00
KeybadeBlox
e0313fa0ba Add class fixup Ghidra script 2026-02-18 20:24:43 -05:00
KeybadeBlox
adc30bb531 Move Std.hpp into CRT directory
It's also been renamed to stddef.h since all it contained was the
definition of NULL, which lives in that header in a standard C library.
2026-02-18 19:22:13 -05:00
KeybadeBlox
3c4f0e72b8 Miscellaneous Ghidra script tweaks
No behavioural changes.
2026-02-18 18:18:24 -05:00
KeybadeBlox
c020c2e247 jsrf.h scalar deleting destructors return void *
They previously returned a pointer to the class type, but this isn't
accurate to the signature indicated by MSVC's name mangling.
2026-02-18 18:15:25 -05:00
KeybadeBlox
fd6815ae42 Complete Ghidra symbol import script 2026-02-17 22:30:10 -05:00
KeybadeBlox
92179ea9bd Add C symbol support to name mangling Ghida script 2026-02-17 20:19:14 -05:00
KeybadeBlox
d435282a8b Compile XDK code as C
It appears to be all C code (especially the non-C++ parts of the C
runtime, of course), so we'll compile it as such.
2026-02-17 10:27:50 -05:00
KeybadeBlox
149af27b9c Fix CRT calling conventions 2026-02-17 09:56:58 -05:00
KeybadeBlox
5d22c39db6 Finish Ghidra data symbol import
Function import still remains.
2026-02-16 21:38:28 -05:00
KeybadeBlox
0922356a40 Begin Ghidra symbol import script 2026-02-16 00:21:55 -05:00
KeybadeBlox
e0c9fc4c83 Use enhanced for loops in Ghidra mangler script 2026-02-16 00:21:22 -05:00
KeybadeBlox
1e8ae0f72f Finish Ghidra symbol export script 2026-02-16 00:20:57 -05:00
KeybadeBlox
d81bd646fa Tiny source tweaks
Fixing some errors in the C runtime and making the main() formatting
more similar to everything else.
2026-02-14 23:12:06 -05:00
KeybadeBlox
84c165a0af Complete basic build process
We now have generation of an import library for linking against the Xbox
kernel, linking together an .exe, and converting it to an .xbe via cxbe.
Some further development of tooling aside (including filling in some
features in cxbe to better match the original JSRF executable), all that
remains now is to write decompiled code.
2026-02-14 23:05:32 -05:00
KeybadeBlox
43f4d10461 Begin enhanced export Ghidra script 2026-02-14 23:02:55 -05:00
KeybadeBlox
c38d9b5628 Tiny steps towards implementing C runtime 2026-02-14 12:34:28 -05:00
KeybadeBlox
ccd2cd37a5 Defend against spurious references during mangling
Ghidra sometimes identifies random numbers as pointers, which trips up
our mangler script when it encounters them as they generally have no
type information.  We now use heuristics to ignore such references.
2026-02-13 23:43:35 -05:00
KeybadeBlox
022582003d objdiff symbol matching refinements
With name mangling, objdiff.json no longer needs massive lists of which
names to match to what.  Some function signatures were also minorly
refined.
2026-02-12 21:19:46 -05:00
KeybadeBlox
d372c17094 Miscellaneous name mangling improvements
Improved error reporting, skipping undesirable symbols like jump tables,
skipping special symbols like intrinsics, etc.
2026-02-12 21:15:52 -05:00
KeybadeBlox
78127e64ef Arguments via environment variables in delink.sh
It was really annoying having to type all that in every time.
2026-02-12 16:16:07 -05:00
KeybadeBlox
13048fef71 Tidy up compiler options
Nothing affecting codegen.
2026-02-12 16:07:14 -05:00
KeybadeBlox
05b4da2f78 Mangle referenced symbols in mangling script
This produces correct symbol names in disassembly in objdiff.
2026-02-12 00:36:40 -05:00
KeybadeBlox
0e84f9ab1f Refine for virtual method check in mangling script
We used the flimsy heuristic of a reference from non-executable memory
to try to guess at whether a reference was a vtable, but now we just
check whether it's been named as a vtable.
2026-02-11 21:14:46 -05:00
KeybadeBlox
53b0e82417 Include headless demangling in delink.sh
This means we get delinked objects with proper mangled names matching
our recompiled files.
2026-02-11 20:23:26 -05:00
KeybadeBlox
55046bf009 Better handle undefined types in mangling script 2026-02-11 20:17:22 -05:00
KeybadeBlox
e9b0c3c6bc Complete mangler script
Now to hook it up to the delinker script.

(I totally accidentally said "demangling" in the last commit)
2026-02-11 00:46:33 -05:00
KeybadeBlox
febf9fc172 Finish function demangling
Data demangling should be much easier.
2026-02-10 00:06:29 -05:00
KeybadeBlox
f193fef3ce Enable string pooling
JSRF evidently has string pooling enabled (i.e. program-wide
deduplication of strings), so we'll want it in our compiler settings as
well.
2026-02-09 23:53:24 -05:00
KeybadeBlox
e6d7acfa05 Fix some disconnected symbols in objdiff
This will be so much easier when we can export with name mangling.
2026-02-07 22:09:26 -05:00
KeybadeBlox
576a60d331 Mostly finish function name mangling
Still need to do function pointers.
2026-02-07 22:08:02 -05:00
KeybadeBlox
76e39fdd27 Begin Ghidra mangling script
Looks like we'll be writing our own Ghidra scripts.  At least these
should enable pretty thorough sharing of work and decent UX.
2026-02-05 22:31:36 -05:00
KeybadeBlox
e668b52cd0 Add to GameObj::removeChildrenFromObjList() 2026-02-05 21:11:11 -05:00
KeybadeBlox
35c8844529 Move everything else to ghidra/ directory
The only stuff left in delink/ was also for using with Ghidra, so we may
as well also put it in ghidra/.
2026-02-04 20:01:06 -05:00
KeybadeBlox
63002e0f08 Add data type import for Ghidra 2026-02-04 19:52:12 -05:00
KeybadeBlox
30f8a5879e Include namespace in symbol table
This introduces its own issues, but without namespaces, symbol names end
up repeated and delinking fails.  The delinked symbols also end up
without namespaces, introducing yet more problems.  This is an
improvement for now, but we'll need proper namespace importing into
Ghidra at some point.
2026-02-01 21:11:26 -05:00
KeybadeBlox
cef08bf624 Documentation enhancements for delink.sh
Thanks to Shanghao for helping find and test these different issues.
2026-02-01 17:35:49 -05:00
KeybadeBlox
91537e765a Fix unwanted delinking path expansion on Windows
In short, we ran afoul of this issue because the Ghidra delinking
headless script begins its arguments with slashes, making them look like
absolute paths:

    https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line
2026-02-01 17:02:13 -05:00
KeybadeBlox
a8b04d24d5 Fix POSIX shell compatibility of delink script
Accidentally used == for a comparison instead of =, while only the
latter is in the standard.

Ref. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
2026-02-01 15:36:35 -05:00
KeybadeBlox
ddc10a878c Minor correction to Decompiling C++
Destructors are not directly registered for exit, but instead called by a
tiny function that's registered.
2026-01-13 21:55:22 -05:00
KeybadeBlox
44a8d704ef Populate JSRF/GameData.cpp 2026-01-12 22:59:47 -05:00
KeybadeBlox
cbcc22ec9d Fix contribution guide link 2026-01-12 09:51:56 -05:00
KeybadeBlox
fbc5619d6a Begin populating JSRF/GameData.hpp 2026-01-12 09:46:56 -05:00
KeybadeBlox
d11f2fd538 Delink JSRF/GameData 2026-01-11 20:46:54 -05:00
KeybadeBlox
8c9f622ab5 Decompiling C++: Add static object initialization 2026-01-09 21:06:28 -05:00
KeybadeBlox
ee519090c1 Add "estimated total progress"
There have been cases of the "decompilation progress" metric being
confused for total progress, so a new figure has been added (in bold)
roughly estimating the total progress by multiplying the other two
together.
2026-01-09 19:29:44 -05:00
KeybadeBlox
d06de00855 Complete Decompiling C++ article (for now) 2026-01-05 23:04:51 -05:00
KeybadeBlox
547f2ba179 Create docs directory; begin "Decompiling C++" 2026-01-03 23:20:39 -05:00
KeybadeBlox
683818b637 Separate compiler optimization flags
The /O2 used before was actually a preset for a bunch of more specific
flags, which are now written explicitly for clarity and easier
modification later.
2026-01-03 16:13:44 -05:00