WIP setup CRT
This commit is contained in:
@@ -625,7 +625,7 @@ public class FunctionDatabase implements AutoCloseable {
|
||||
public void addGlobal(Address address, String name, String dataType) throws Exception {
|
||||
ensureConnection();
|
||||
|
||||
String filepath = "globals.h"; // Default filepath for globals
|
||||
String filepath = RemanConfig.GLOBAL_H_FILE; // Default filepath for globals
|
||||
String addressStr = address.toString();
|
||||
|
||||
try {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class GlobalDumper {
|
||||
public void removeGlobalManifest() {
|
||||
// Remove globals from database instead of file
|
||||
try {
|
||||
functionDatabase.removeGlobalsByFilepath("globals.h");
|
||||
functionDatabase.removeGlobalsByFilepath(RemanConfig.INSTANCE.GLOBAL_H_FILE);
|
||||
globalAddrs.clear();
|
||||
} catch (Exception e) {
|
||||
script.println("Error removing global manifest: " + e.getMessage());
|
||||
@@ -91,7 +91,13 @@ public class GlobalDumper {
|
||||
|
||||
if (type == null) {
|
||||
script.println("WARNING: Could not reconstruct type for global: " + entry.name + " at " + entry.address);
|
||||
continue;
|
||||
type = dtp.parse("undefined4");
|
||||
}
|
||||
|
||||
// Retrieve the name again
|
||||
Symbol sym = script.getSymbolAt(entry.address);
|
||||
if (sym != null) {
|
||||
entry.name = sym.getName();
|
||||
}
|
||||
|
||||
globalAddrs.put(entry.address, new GlobalRec(entry.address, entry.name, type));
|
||||
@@ -130,14 +136,14 @@ public class GlobalDumper {
|
||||
}
|
||||
|
||||
public void dumpGlobals() throws Exception {
|
||||
File globalSymbolsListH = new File(RemanConfig.INSTANCE.outputDir, "gh_global.h");
|
||||
File globalSymbolsListH = new File(RemanConfig.INSTANCE.outputDir, RemanConfig.GLOBAL_H_FILE);
|
||||
PrintWriter hwriter = new PrintWriter(globalSymbolsListH, "UTF-8");
|
||||
hwriter.println("// AUTO-GENERATED FILE ");
|
||||
Utils.headerGuardPre(hwriter, "GLOBALS");
|
||||
hwriter.println("#include <r3/binders/global.h>");
|
||||
hwriter.println();
|
||||
|
||||
File globalSymbolsListC = new File(RemanConfig.INSTANCE.outputDir, "gh_global.cxx");
|
||||
File globalSymbolsListC = new File(RemanConfig.INSTANCE.outputDir, RemanConfig.GLOBAL_CXX_FILE);
|
||||
PrintWriter cwriter = new PrintWriter(globalSymbolsListC, "UTF-8");
|
||||
cwriter.println("// AUTO-GENERATED FILE ");
|
||||
cwriter.println("#include <r3/binders/global.h>");
|
||||
@@ -216,7 +222,7 @@ public class GlobalDumper {
|
||||
script.println("Saving globals to database");
|
||||
|
||||
// Clear existing globals for the default filepath
|
||||
functionDatabase.removeGlobalsByFilepath("globals.h");
|
||||
functionDatabase.removeGlobalsByFilepath(RemanConfig.GLOBAL_H_FILE);
|
||||
|
||||
// Add all current globals to database
|
||||
for (GlobalRec global : globalAddrs.values()) {
|
||||
@@ -226,6 +232,10 @@ public class GlobalDumper {
|
||||
}
|
||||
|
||||
public void addGlobal(Address addr, HighSymbol sym) throws Exception {
|
||||
if (sym.getName().equals("ExceptionList")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (addr.compareTo(RemanConfig.INSTANCE.staticMemoryBlockStart) < 0
|
||||
|| addr.compareTo(RemanConfig.INSTANCE.staticMemoryBlockEnd) > 0) {
|
||||
throw new Exception("Global address out of range: " + addr);
|
||||
|
||||
@@ -55,8 +55,11 @@ public class RemanConfig {
|
||||
|
||||
public static RemanConfig INSTANCE;
|
||||
|
||||
public static final String GLOBAL_H_FILE = "gh_global.h"; // Default filepath for globals
|
||||
public static final String GLOBAL_CXX_FILE = "gh_global.cxx"; // Default filepath for globals
|
||||
|
||||
public RemanConfig(GhidraScript script) {
|
||||
staticMemoryBlockStart = script.getCurrentProgram().getAddressFactory().getAddress("00597000");
|
||||
staticMemoryBlockStart = script.getCurrentProgram().getAddressFactory().getAddress("00400000");
|
||||
staticMemoryBlockEnd = script.getCurrentProgram().getAddressFactory().getAddress("00843fff");
|
||||
|
||||
this.script = script;
|
||||
|
||||
Reference in New Issue
Block a user