MCPcopy Create free account
hub / github.com/clienthax/Ps3GhidraScripts / Ps3ElfUtils

Class Ps3ElfUtils

ghidra_scripts/Ps3ElfUtils.java:20–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18import static ghidra.app.util.bin.format.elf.ElfConstants.ET_EXEC;
19
20class Ps3ElfUtils {
21
22 private final static short ET_SCE_PPURELEXEC = (short) 0xffa4;
23
24 public final static long PT_PROC_PARAM = 0x60000001;
25 public final static long PT_PROC_PRX = 0x60000002;
26
27 private final GhidraScript script;
28 private final Program program;
29
30 private final MemoryBlock elfHeader;
31 private final short programType;
32 private final List<ElfSection> sections;
33
34
35 public Ps3ElfUtils(GhidraScript runningScript, Program program) throws Exception {
36 this.script = runningScript;
37 this.program = program;
38
39 this.elfHeader = findElfHeader();
40 this.sections = parseSections(script.getDataAt(elfHeader.getStart()));
41 programType = findPs3ProgramType();
42 }
43
44 private MemoryBlock findElfHeader() {
45 // Find elf header block
46 for (MemoryBlock block : program.getMemory().getBlocks()) {
47 final Data dataAt = script.getDataAt(block.getStart());
48 if(dataAt != null && dataAt.getDataType().getName().equals("Elf64_Ehdr")) {
49 return block;
50 }
51 }
52
53 return null;
54 }
55
56 public MemoryBlock getElfHeader() {
57 return elfHeader;
58 }
59
60 public short findPs3ProgramType() throws Exception {
61 if(getElfHeader() == null) {
62 script.printerr("Couldn't find Elf64_Ehdr\n");
63 return -1;
64 }
65
66 return script.getDataAt(elfHeader.getStart()).getComponent(8).getShort(0);// e_type
67 }
68
69 public boolean loadingExec() throws Exception {
70 return programType == ET_EXEC;
71 }
72
73 public boolean loadingPrx() throws Exception {
74 return programType == ET_SCE_PPURELEXEC;
75 }
76
77 // there should be a offset to this...

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected