mirror of
https://codeberg.org/KeybadeBlox/JSRF-Decompilation.git
synced 2026-04-07 04:50:23 +03:00
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.
This commit is contained in:
parent
76e7714722
commit
98d88cc212
3 changed files with 22 additions and 25 deletions
|
|
@ -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
|
// vtable, sets the calling convention of the contained function typdefs to
|
||||||
// __thiscall.
|
// __thiscall.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,17 @@ 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.io.FileReader;
|
import java.nio.file.Files;
|
||||||
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 FileReader in = new FileReader(askFile("Select input file", "OK"));
|
final List<String> lines = Files.readAllLines(askFile("Select input file", "OK").toPath());
|
||||||
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");;
|
||||||
|
|
|
||||||
|
|
@ -422,34 +422,34 @@ public class MSVC7Mangle extends GhidraScript {
|
||||||
);
|
);
|
||||||
|
|
||||||
return switch(t) {
|
return switch(t) {
|
||||||
case SignedCharDataType _ -> "C";
|
case SignedCharDataType x -> "C";
|
||||||
case UnsignedCharDataType _ -> "E";
|
case UnsignedCharDataType x -> "E";
|
||||||
case CharDataType _ -> "D"; // Must come after its child types
|
case CharDataType x -> "D"; // Must come after its child types
|
||||||
case ShortDataType _ -> "F";
|
case ShortDataType x -> "F";
|
||||||
case UnsignedShortDataType _ -> "G";
|
case UnsignedShortDataType x -> "G";
|
||||||
case IntegerDataType _ -> "H";
|
case IntegerDataType x -> "H";
|
||||||
case UnsignedIntegerDataType _ -> "I";
|
case UnsignedIntegerDataType x -> "I";
|
||||||
case LongDataType _ -> "J";
|
case LongDataType x -> "J";
|
||||||
case UnsignedLongDataType _ -> "K";
|
case UnsignedLongDataType x -> "K";
|
||||||
case FloatDataType _ -> "M";
|
case FloatDataType x -> "M";
|
||||||
case DoubleDataType _ -> "N";
|
case DoubleDataType x -> "N";
|
||||||
case LongDoubleDataType _ -> "O";
|
case LongDoubleDataType x -> "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";
|
case VoidDataType x -> "X";
|
||||||
case LongLongDataType _ -> "_J";
|
case LongLongDataType x -> "_J";
|
||||||
case UnsignedLongLongDataType _ -> "_K";
|
case UnsignedLongLongDataType x -> "_K";
|
||||||
case BooleanDataType _ -> "_N";
|
case BooleanDataType x -> "_N";
|
||||||
case WideCharDataType _ -> "_W";
|
case WideCharDataType x -> "_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 _ -> 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 _ -> 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);
|
default -> throw new Exception ("Unknown type \"" + t.getClass().getName() + "\" at " + loc);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue