Skip to content

Commit 3349cd1

Browse files
Vladimir KononovichVladimir Kononovich
authored andcommitted
Removed SYM support (for now), updated to 9.1.2. Added PsyQ sub version detection.
1 parent 231402b commit 3349cd1

17 files changed

+174
-1464
lines changed

.classpath

Lines changed: 167 additions & 167 deletions
Large diffs are not rendered by default.

.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<link>
1919
<name>Ghidra</name>
2020
<type>2</type>
21-
<location>D:/ghidra_9.1.1_PUBLIC</location>
21+
<location>D:/ghidra_9.1.2_PUBLIC</location>
2222
</link>
2323
</linkedResources>
2424
</projectDescription>

src/main/java/psx/PsxLoader.java

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515
*/
1616
package psx;
1717

18-
import java.io.File;
1918
import java.io.IOException;
2019
import java.io.InputStream;
2120
import java.math.BigInteger;
2221
import java.util.*;
2322
import java.util.concurrent.TimeUnit;
2423

25-
import javax.swing.JFileChooser;
26-
import javax.swing.filechooser.FileNameExtensionFilter;
27-
2824
import docking.widgets.OptionDialog;
2925
import ghidra.app.cmd.disassemble.DisassembleCommand;
3026
import ghidra.app.cmd.function.ApplyFunctionDataTypesCmd;
@@ -67,7 +63,6 @@
6763
import ghidra.util.exception.NotFoundException;
6864
import ghidra.util.task.TaskMonitor;
6965
import psyq.DetectPsyQ;
70-
import psyq.sym.SymFile;
7166

7267
public class PsxLoader extends AbstractLibrarySupportLoader {
7368

@@ -225,26 +220,6 @@ protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> optio
225220
}
226221

227222
monitor.setMessage("Loading PSX binary done.");
228-
229-
try {
230-
TimeUnit.SECONDS.sleep(1);
231-
} catch (InterruptedException e) {
232-
}
233-
234-
if (OptionDialog.YES_OPTION == OptionDialog.showYesNoDialogWithNoAsDefaultButton(null,
235-
"Question", "Do you have .SYM file for this executable?")) {
236-
String symPath = showSelectFile("Select file...", program.getExecutablePath());
237-
238-
if (symPath == null) {
239-
return;
240-
}
241-
242-
int transId = program.startTransaction("Load and apply SYM file...");
243-
SymFile symFile = SymFile.fromBinary(symPath, program, log, monitor);
244-
symFile.applyOverlays(program, log, monitor);
245-
symFile.apply(program, log, monitor);
246-
program.endTransaction(transId, true);
247-
}
248223
}
249224

250225
public static DataTypeManagerService getDataTypeManagerService(Program program) {
@@ -261,7 +236,8 @@ private static void addPsyqVerOption(Program program, long searchBase, MessageLo
261236
opts.registerOption(PSYQ_VER_OPTION, "", null, "PsyQ version");
262237

263238
if (!psyqVersion.isEmpty()) {
264-
String ver = String.format("%s.%s", psyqVersion.charAt(0), psyqVersion.charAt(1));
239+
char subVer = psyqVersion.charAt(2);
240+
String ver = String.format("%s.%s%s", psyqVersion.charAt(0), psyqVersion.charAt(1), subVer != '0' ? subVer : "");
265241
opts.setString(PSYQ_VER_OPTION, ver);
266242
}
267243
} catch (MemoryAccessException | AddressOutOfBoundsException ignored) {
@@ -338,20 +314,6 @@ public static String getProgramPsyqVersion(Program program) {
338314
return opts.getString(PsxLoader.PSYQ_VER_OPTION, "").replace(".", "");
339315
}
340316

341-
private static String showSelectFile(String title, String baseDir) {
342-
JFileChooser jfc = new JFileChooser(new File(baseDir));
343-
jfc.setDialogTitle(title);
344-
345-
jfc.setFileFilter(new FileNameExtensionFilter("Symbols File", "sym"));
346-
jfc.setMultiSelectionEnabled(false);
347-
348-
if (jfc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
349-
return jfc.getSelectedFile().getAbsolutePath();
350-
}
351-
352-
return null;
353-
}
354-
355317
private static void setRegisterValue(FlatProgramAPI fpa, String name, long startAddress, long value, MessageLog log) {
356318
Program program = fpa.getCurrentProgram();
357319

src/main/java/psyq/DetectPsyQ.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import ghidra.util.task.TaskMonitor;
88

99
public class DetectPsyQ {
10-
private final static byte[] VERSION_BYTES = new byte[] { 0x50, 0x73, 0x07, 0x00, 0x00, 0x00, 0x47, 0x00}; // 0x47 - a version
11-
private final static byte[] VERSION_MASK = new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, 0x00, 0x00, 0x00, 0x00, (byte)0xFF};
10+
private final static byte[] VERSION_BYTES = new byte[] { 0x50, 0x73, 0x07, 0x00, 0x00, 0x00, 0x47, 0x00}; // 0x47 - a version
11+
private final static byte[] VERSION_MASK = new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, 0x00, 0x00, 0x00, 0x00, (byte)0xF0};
1212
private final static long VERSION_OFFSET = 0x06L;
1313

1414
public static String getPsyqVersion(Memory mem, Address startAddress) throws MemoryAccessException, AddressOutOfBoundsException {
@@ -18,7 +18,7 @@ public static String getPsyqVersion(Memory mem, Address startAddress) throws Mem
1818
return "";
1919
}
2020

21-
byte version = mem.getByte(result.add(VERSION_OFFSET));
22-
return String.format("%02X", version);
21+
short version = mem.getShort(result.add(VERSION_OFFSET), true);
22+
return String.format("%03X", version >> 4);
2323
}
2424
}

src/main/java/psyq/sym/ISymObject.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/java/psyq/sym/SymClass.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/main/java/psyq/sym/SymDataTypeManagerType.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/java/psyq/sym/SymDefinition.java

Lines changed: 0 additions & 190 deletions
This file was deleted.

0 commit comments

Comments
 (0)