Compare commits

..

No commits in common. "98d88cc2122f0ea753f69027ccc43758a8060439" and "823b19371ccdf6dcef61f226edcd4973fa8f6222" have entirely different histories.

8 changed files with 30 additions and 28 deletions

View file

@ -233,7 +233,7 @@ struct Game {
BOOL useFallbackBgColour; BOOL useFallbackBgColour;
// Game state used to select GameObj methods to call in main loop // Game state used to select GameObj methods to call in main loop
// If multiple states are activated, the precedence is // If multiple states are acivated, the precedence is
// coveredPause > Event > FreezeCam > UncoveredPause > Default // coveredPause > Event > FreezeCam > UncoveredPause > Default
BOOL coveredPause; // Game paused with world not visible BOOL coveredPause; // Game paused with world not visible
BOOL event; // Events (cutscenes) BOOL event; // Events (cutscenes)

View file

@ -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 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 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 exhibits other oddities mentioned in the body, it's likely this whole function
was originally written purely in assembly. In the spirit of decompilation, was originally written purely in assemblys. In the spirit of decompilation,
however, we'll lift what we can into C. however, we'll lift what we can into C.
*/ */
XapiInitProcess(); 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 written function. If it was a function, it must have been
inlined, but it couldn't be because it must be called from 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 assembly to use the value in ecx that never went on the stack
(as passing data from assembly to C has to do). Notably, this (as passing data from C to assembly has to do). Notably, this
function's calling convention does require edi to be preserved, 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 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 prologue and epilogue, not here (which this function must be
@ -135,7 +135,6 @@ however, we'll lift what we can into C.
_cinit(); _cinit();
main(0, NULL, NULL); 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); XapiBootToDash(XLD_LAUNCH_DASHBOARD_ERROR, XLD_ERROR_INVALID_XBE, 0);
// Return 0 to satisfy signature required for thread functions // Return 0 to satisfy signature required for thread functions
@ -153,7 +152,7 @@ The linker automatically sets this function to the entrypoint.
*/ */
HANDLE thread; HANDLE thread;
// Figure out available thread-local storage (used by CreateThread()) // Figure out available thread-local storage
XapiTlsSize = 4 + (( XapiTlsSize = 4 + ((
(_tls_used.EndAddressOfRawData - _tls_used.StartAddressOfRawData) + (_tls_used.EndAddressOfRawData - _tls_used.StartAddressOfRawData) +
_tls_used.SizeOfZeroFill _tls_used.SizeOfZeroFill

View file

View file

@ -1,4 +1,4 @@
// Creates classes out of namespaces with matching structs, and if they have a // Creates classes out namespaces with matching structs, and if they have a
// vtable, sets the calling convention of the contained function typdefs to // vtable, sets the calling convention of the contained function typdefs to
// __thiscall. // __thiscall.
// //

View file

@ -20,17 +20,20 @@ import ghidra.program.model.symbol.SourceType;
import ghidra.program.model.symbol.Symbol; import ghidra.program.model.symbol.Symbol;
import ghidra.util.StringUtilities; import ghidra.util.StringUtilities;
import java.nio.file.Files; import java.io.FileReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
public class EnhancedImport extends GhidraScript { public class EnhancedImport extends GhidraScript {
@Override @Override
public void run() throws Exception { public void run() throws Exception {
final List<String> lines = Files.readAllLines(askFile("Select input file", "OK").toPath()); final FileReader in = new FileReader(askFile("Select input file", "OK"));
final List<String> lines = in.readAllLines();
in.close();
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
final String[] parts = lines.get(i).split("\t");; final String[] parts = lines.get(i).split("\t");;

View file

@ -422,34 +422,34 @@ public class MSVC7Mangle extends GhidraScript {
); );
return switch(t) { return switch(t) {
case SignedCharDataType x -> "C"; case SignedCharDataType _ -> "C";
case UnsignedCharDataType x -> "E"; case UnsignedCharDataType _ -> "E";
case CharDataType x -> "D"; // Must come after its child types case CharDataType _ -> "D"; // Must come after its child types
case ShortDataType x -> "F"; case ShortDataType _ -> "F";
case UnsignedShortDataType x -> "G"; case UnsignedShortDataType _ -> "G";
case IntegerDataType x -> "H"; case IntegerDataType _ -> "H";
case UnsignedIntegerDataType x -> "I"; case UnsignedIntegerDataType _ -> "I";
case LongDataType x -> "J"; case LongDataType _ -> "J";
case UnsignedLongDataType x -> "K"; case UnsignedLongDataType _ -> "K";
case FloatDataType x -> "M"; case FloatDataType _ -> "M";
case DoubleDataType x -> "N"; case DoubleDataType _ -> "N";
case LongDoubleDataType x -> "O"; case LongDoubleDataType _ -> "O";
case Pointer p -> "P" + case Pointer p -> "P" +
(p.getDataType() instanceof FunctionSignature ? "6" : "A") + (p.getDataType() instanceof FunctionSignature ? "6" : "A") +
mangleType(p.getDataType(), dict, loc); mangleType(p.getDataType(), dict, loc);
case Union u -> "T" + mangleIdentifier(u.getName(), false, null, dict); case Union u -> "T" + mangleIdentifier(u.getName(), false, null, dict);
case Structure s -> "U" + mangleIdentifier(s.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 Enum e -> "W4" + mangleIdentifier(e.getName(), false, null, dict);
case VoidDataType x -> "X"; case VoidDataType _ -> "X";
case LongLongDataType x -> "_J"; case LongLongDataType _ -> "_J";
case UnsignedLongLongDataType x -> "_K"; case UnsignedLongLongDataType _ -> "_K";
case BooleanDataType x -> "_N"; case BooleanDataType _ -> "_N";
case WideCharDataType x -> "_W"; case WideCharDataType _ -> "_W";
case Array a -> "PA" + mangleArrDims(a) + mangleType(arrType(a), dict, loc); case Array a -> "PA" + mangleArrDims(a) + mangleType(arrType(a), dict, loc);
case FunctionSignature f -> mangleFnType(f, dict, "function typedef \"" + f.getName() + "\""); case FunctionSignature f -> mangleFnType(f, dict, "function typedef \"" + f.getName() + "\"");
case TypeDef d -> mangleType(d.getBaseDataType(), dict, "typedef \"" + d.getName() + "\""); case TypeDef d -> mangleType(d.getBaseDataType(), dict, "typedef \"" + d.getName() + "\"");
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 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 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 _ -> 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); default -> throw new Exception ("Unknown type \"" + t.getClass().getName() + "\" at " + loc);
}; };
} }

View file

@ -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 # 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 # all the headers here by hand in an order that functions properly
HEADERS=" HEADERS="
XDK/CRT/stddef.h Std.hpp
XDK/Win32.h XDK/Win32.h
XDK/D3D.h XDK/D3D.h
MUSASHI/MMatrix.hpp MUSASHI/MMatrix.hpp

0
ghidra/symboltable.tsv Normal file → Executable file
View file

Can't render this file because it has a wrong number of fields in line 3.