mirror of
https://github.com/Maschell/GhidraRPXLoader.git
synced 2024-11-14 20:35:11 +01:00
Create symbols for data exports.
This commit is contained in:
parent
df0b8cd768
commit
f9f61cdf2a
@ -1,5 +1,8 @@
|
||||
package cafeloader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ghidra.app.util.bin.BinaryReader;
|
||||
import ghidra.app.util.bin.format.elf.*;
|
||||
import ghidra.app.util.bin.format.elf.extend.*;
|
||||
import ghidra.program.model.address.*;
|
||||
@ -109,10 +112,43 @@ public class Cafe_ElfExtension extends ElfExtension {
|
||||
processRplCrcs(elfLoadHelper, sectionHeader);
|
||||
} else if (headertype == SHT_RPL_FILEINFO.value) {
|
||||
processRplFileInfo(elfLoadHelper, sectionHeader);
|
||||
} else if (headertype == SHT_RPL_EXPORTS.value) {
|
||||
processRplExports(elfLoadHelper, sectionHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processRplExports(ElfLoadHelper elfLoadHelper, ElfSectionHeader sectionHeader) {
|
||||
String sectionName = sectionHeader.getNameAsString();
|
||||
Address loadAddress = elfLoadHelper.findLoadAddress(sectionHeader, 0);
|
||||
Memory memory = elfLoadHelper.getProgram().getMemory();
|
||||
boolean isDataExports = sectionName.contentEquals(".dexports");
|
||||
if (!isDataExports) {
|
||||
// Function exports are already in symbol table
|
||||
return;
|
||||
}
|
||||
|
||||
// Create symbols for data exports
|
||||
BinaryReader reader = elfLoadHelper.getElfHeader().getReader();
|
||||
reader.setPointerIndex(sectionHeader.getOffset());
|
||||
|
||||
try {
|
||||
int count = reader.readNextInt();
|
||||
int signature = reader.readNextInt();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
int value = reader.readNextInt();
|
||||
int nameOffset = reader.readNextInt();
|
||||
boolean isTlsExport = (nameOffset & 0x80000000) != 0;
|
||||
String name = reader.readAsciiString(sectionHeader.getOffset() + (nameOffset & 0x7FFFFFFF));
|
||||
elfLoadHelper.createSymbol(elfLoadHelper.getDefaultAddress(value), name, true, false, null);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidInputException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void processRplCrcs(ElfLoadHelper elfLoadHelper, ElfSectionHeader sectionHeader) {
|
||||
Address address = elfLoadHelper.findLoadAddress(sectionHeader, 0);
|
||||
if (address == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user