From cde5c7c313c3a686a16af15c4b005b7efd43b41a Mon Sep 17 00:00:00 2001 From: Guus Waals <_@guusw.nl> Date: Sun, 1 Jun 2025 22:55:11 +0800 Subject: [PATCH] Remove type from java db --- game_re/gh_fix/r3_windowProc.cxx | 6 ++-- game_re/gh_global.cxx | 4 +-- game_re/gh_global.h | 4 +-- java/ghidra/re3lib/FunctionDatabase.java | 43 +++++------------------- 4 files changed, 15 insertions(+), 42 deletions(-) diff --git a/game_re/gh_fix/r3_windowProc.cxx b/game_re/gh_fix/r3_windowProc.cxx index 21cb071d..e2d7c447 100644 --- a/game_re/gh_fix/r3_windowProc.cxx +++ b/game_re/gh_fix/r3_windowProc.cxx @@ -4,11 +4,11 @@ #include extern "C" { -undefined r3_windowUnlockCursor(void); // 004013a0 // r3_windowUnlockCursor -undefined FUN_00401320(void); // 00401320 // FUN_00401320 +undefined FUN_00401320(void); // 00401320 // FUN_00401320 // cdecl +undefined r3_windowUnlockCursor(void); // 004013a0 // r3_windowUnlockCursor // cdecl // 004025e0 -long __stdcall r3_windowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) +long r3_windowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { long lVar1; diff --git a/game_re/gh_global.cxx b/game_re/gh_global.cxx index e047e535..59787acb 100644 --- a/game_re/gh_global.cxx +++ b/game_re/gh_global.cxx @@ -83,12 +83,12 @@ const char* lpDefault_005be370 = "1"; // 005be370 const char* s_SoundOnHD_005be374 = "SoundOnHD"; // 005be374 const char* lpDefault_005be380 = "0"; // 005be380 const char* s_TexturesMem_005be384 = "TexturesMem"; // 005be384 -pointer& s_Agp= (pointer&) GH_MEM(0x005be390); +const char* s_Agp = "Agp"; // 005be390 const char* s_Outline_005be394 = "Outline"; // 005be394 const char* s_StaticShadows_005be39c = "StaticShadows"; // 005be39c const char* s_DynamicShadows_005be3ac = "DynamicShadows"; // 005be3ac const char* s_TriLinear_005be3bc = "TriLinear"; // 005be3bc -pointer& s_Tnl= (pointer&) GH_MEM(0x005be3c8); +const char* s_Tnl = "TnL"; // 005be3c8 const char* s_TexturesCompressed_005be3cc = "TexturesCompressed"; // 005be3cc const char* s_GLI_Mode_005be3e0 = "GLI_Mode"; // 005be3e0 const char* g_default_display_mode = "1 - 640 x 480 x 16"; // 005be3ec diff --git a/game_re/gh_global.h b/game_re/gh_global.h index b1901cc5..740e1031 100644 --- a/game_re/gh_global.h +++ b/game_re/gh_global.h @@ -88,12 +88,12 @@ extern const char* lpDefault_005be370; // 005be370 extern const char* s_SoundOnHD_005be374; // 005be374 extern const char* lpDefault_005be380; // 005be380 extern const char* s_TexturesMem_005be384; // 005be384 -extern pointer& s_Agp; // 005be390 +extern const char* s_Agp; // 005be390 extern const char* s_Outline_005be394; // 005be394 extern const char* s_StaticShadows_005be39c; // 005be39c extern const char* s_DynamicShadows_005be3ac; // 005be3ac extern const char* s_TriLinear_005be3bc; // 005be3bc -extern pointer& s_Tnl; // 005be3c8 +extern const char* s_Tnl; // 005be3c8 extern const char* s_TexturesCompressed_005be3cc; // 005be3cc extern const char* s_GLI_Mode_005be3e0; // 005be3e0 extern const char* g_default_display_mode; // 005be3ec diff --git a/java/ghidra/re3lib/FunctionDatabase.java b/java/ghidra/re3lib/FunctionDatabase.java index eb6d2089..c5d51e08 100644 --- a/java/ghidra/re3lib/FunctionDatabase.java +++ b/java/ghidra/re3lib/FunctionDatabase.java @@ -122,13 +122,11 @@ public class FunctionDatabase implements AutoCloseable { public static class GlobalEntry { public Address address; public String name; - public String dataType; public File file; - public GlobalEntry(Address address, String name, String dataType, File file) { + public GlobalEntry(Address address, String name, File file) { this.address = address; this.name = name; - this.dataType = dataType; this.file = file; } } @@ -184,7 +182,8 @@ public class FunctionDatabase implements AutoCloseable { script.println("Connected to database: " + dbFile); } catch (SQLException e) { script.println("Error connecting to database: " + e.getMessage()); - throw new Exception("Failed to connect to database", e); + // throw new Exception("Failed to connect to database", e); + throw e; } } @@ -241,15 +240,15 @@ public class FunctionDatabase implements AutoCloseable { // Global statements findByNameGlobals = connection.prepareStatement( - "SELECT filepath, name, address, type FROM Globals WHERE name = ?"); + "SELECT filepath, name, address FROM Globals WHERE name = ?"); findByAddressGlobals = connection.prepareStatement( - "SELECT filepath, name, address, type FROM Globals WHERE address = ?"); + "SELECT filepath, name, address FROM Globals WHERE address = ?"); insertOrReplaceGlobals = connection.prepareStatement( - "INSERT OR REPLACE INTO Globals (filepath, name, address, type) VALUES (?, ?, ?, ?)"); + "INSERT OR REPLACE INTO Globals (filepath, name, address) VALUES (?, ?, ?)"); deleteByFilepathGlobals = connection.prepareStatement( "DELETE FROM Globals WHERE filepath = ?"); loadAllGlobals = connection.prepareStatement( - "SELECT filepath, name, address, type FROM Globals"); + "SELECT filepath, name, address FROM Globals"); } private void closePreparedStatements() throws SQLException { @@ -353,7 +352,6 @@ public class FunctionDatabase implements AutoCloseable { filepath TEXT, name TEXT, address TEXT, - type TEXT, PRIMARY KEY (name, filepath) )"""; @@ -456,29 +454,6 @@ public class FunctionDatabase implements AutoCloseable { } } - // Helper method to add import entry - public void addImportEntry(FunctionEntry entry) throws Exception { - ensureConnection(); - - String relativePath = new File(RemanConfig.INSTANCE.outputDir).toPath() - .relativize(entry.file.toPath()).toString().replace('\\', '/'); - - try { - insertOrReplaceImports.setString(1, relativePath); - insertOrReplaceImports.setString(2, entry.name); - insertOrReplaceImports.setString(3, entry.address.toString()); - insertOrReplaceImports.setInt(4, entry.type.getValue()); - insertOrReplaceImports.setInt(5, entry.callingConvention.getValue()); - insertOrReplaceImports.executeUpdate(); - - script.println("Added/updated import entry: " + entry.name + " at " + entry.address + " in " + relativePath - + " (calling convention: " + entry.callingConvention + ")"); - } catch (SQLException e) { - script.println("Error adding import entry: " + e.getMessage()); - throw new Exception("Failed to add import entry", e); - } - } - // Helper method to remove entry by file path public void removeEntryAt(String filePath) throws Exception { ensureConnection(); @@ -659,13 +634,12 @@ public class FunctionDatabase implements AutoCloseable { String filepath = rs.getString("filepath"); String name = rs.getString("name"); String addressStr = rs.getString("address"); - String typeStr = rs.getString("type"); if (addressStr != null && !addressStr.isEmpty()) { Address address = script.getCurrentProgram().getAddressFactory().getAddress(addressStr); File file = new File(RemanConfig.INSTANCE.outputDir, filepath); - return new GlobalEntry(address, name, typeStr, file); + return new GlobalEntry(address, name, file); } return null; } @@ -725,7 +699,6 @@ public class FunctionDatabase implements AutoCloseable { insertOrReplaceGlobals.setString(1, filepath); insertOrReplaceGlobals.setString(2, name); insertOrReplaceGlobals.setString(3, addressStr); - insertOrReplaceGlobals.setString(4, dataType); insertOrReplaceGlobals.executeUpdate(); script.println("Added/updated global: " + name + " at " + address + " with type " + dataType);