Add script to rebuild and regenerate function database

This commit is contained in:
Guus Waals 2024-09-30 22:47:09 +08:00
parent 48889fcf1d
commit 9a8f5253b9
14 changed files with 1745 additions and 117 deletions

View File

@ -59,6 +59,9 @@ char(&lpAppName_005b68f0)[8] = reinterpret_cast<char(&)[8]>(GH_MEM(0x005b68f0));
const char* s_Directory_005b68f8 = "Directory"; // 005b68f8
const char* s_None = "None"; // 005b6904
const char* s_UbiSoft_Ubi_ini = "/UbiSoft/Ubi.ini"; // 005b690c
undefined& DAT_005b6d10= (undefined&) GH_MEM(0x005b6d10);
undefined *& PTR_fassign= (undefined *&) GH_MEM(0x005b6de8);
char& DAT_005b93b0= (char&) GH_MEM(0x005b93b0);
undefined& s_percent_d= (undefined&) GH_MEM(0x005bad58);
byte& g_errMod0= (byte&) GH_MEM(0x005bd29c);
const char* s_Warning_error__005bd318 = "Warning error: "; // 005bd318
@ -88,6 +91,8 @@ undefined& DAT_005bda3c= (undefined&) GH_MEM(0x005bda3c);
char& DAT_005bda3e= (char&) GH_MEM(0x005bda3e);
undefined& s_DLL= (undefined&) GH_MEM(0x005bda40);
const char* s_UbiSoft_bmp_005bda4c = "UbiSoft.bmp"; // 005bda4c
UINT& g_modemQuality= (UINT&) GH_MEM(0x005bdca0);
UINT& g_UDPPort= (UINT&) GH_MEM(0x005bdca4);
const char* s_R3_DVD_005bdfd8 = "R3_DVD"; // 005bdfd8
const char* s_R3_DVD_005be0ec = "R3_DVD"; // 005be0ec
const char* s__s_DVD_missing_005be0f4 = "%s DVD missing "; // 005be0f4
@ -95,6 +100,8 @@ const char* s_Die__s_DVDROM_kann_nicht_gelesen_005be130 = "Die %s DVDROM kann ni
const char* s_Impossibile_trovare_il_DVD____s_005be198 = "Impossibile trovare il DVD : %s"; // 005be198
undefined& DAT_005be1ec= (undefined&) GH_MEM(0x005be1ec);
const char* s_Impossible_de_trouver_le_DVD_____005be238 = "Impossible de trouver le DVD : %s"; // 005be238
const char* s_ModemQuality_005be2ec = "ModemQuality"; // 005be2ec
const char* s_UDPPort_005be2fc = "UDPPort"; // 005be2fc
pointer& s_Yes= (pointer&) GH_MEM(0x005be304);
const char* s_SingleProcessor_005be308 = "SingleProcessor"; // 005be308
undefined& lpDefault_005be318= (undefined&) GH_MEM(0x005be318);
@ -125,6 +132,7 @@ const char* s_fmt_c_colon_s = "%c:%s"; // 005be540
const char* s_r3_program_files = "\\program files\\Ubi Soft\\Rayman3"; // 005be548
undefined *& PTR_DAT_005be568= (undefined *&) GH_MEM(0x005be568);
byte& g_errModFirst= (byte&) GH_MEM(0x005be6f0);
dword& g_modId4= (dword&) GH_MEM(0x005be8ac);
byte& g_errMod5= (byte&) GH_MEM(0x005befbc);
char(&s_M_005bf004)[2] = reinterpret_cast<char(&)[2]>(GH_MEM(0x005bf004));
char(&s_S_005bf008)[2] = reinterpret_cast<char(&)[2]>(GH_MEM(0x005bf008));
@ -142,20 +150,25 @@ char& DAT_005c0f22= (char&) GH_MEM(0x005c0f22);
byte& g_errMod17= (byte&) GH_MEM(0x005c1400);
byte& g_errMod8= (byte&) GH_MEM(0x005c4b0c);
byte& g_errMod9= (byte&) GH_MEM(0x005c4dcc);
byte& g_errMod7= (byte&) GH_MEM(0x005c506c);
byte& g_errMod3= (byte&) GH_MEM(0x005c506c);
byte& g_errMod10= (byte&) GH_MEM(0x005c51f4);
UINT& g_config_camera_hor_axis= (UINT&) GH_MEM(0x005c67c8);
UINT& g_config_camera_ver_axis= (UINT&) GH_MEM(0x005c67cc);
const char* s_____005ca864 = " \t-\r]"; // 005ca864
undefined1& DAT_005ca86c= (undefined1&) GH_MEM(0x005ca86c);
byte& g_errMod11= (byte&) GH_MEM(0x005caf2c);
byte& g_errMod12= (byte&) GH_MEM(0x005cb16c);
char& g_errMod12= (char&) GH_MEM(0x005cb16c);
byte& g_errMod14= (byte&) GH_MEM(0x005cf5d4);
byte& g_errMod15= (byte&) GH_MEM(0x005cf814);
byte& g_errMod16= (byte&) GH_MEM(0x005cf874);
HWND& g_gameHWND1= (HWND&) GH_MEM(0x005cf964);
long& lpDefault_005cf96c= (long&) GH_MEM(0x005cf96c);
dword& DWORD_005cfa20= (dword&) GH_MEM(0x005cfa20);
int& DAT_005cfb64= (int&) GH_MEM(0x005cfb64);
UINT& CodePage_005cfb74= (UINT&) GH_MEM(0x005cfb74);
byte& g_ucErmNbOfModule= (byte&) GH_MEM(0x005d2638);
mod1_ptrs& g_mod1_ptrs= (mod1_ptrs&) GH_MEM(0x005d2644);
undefined4& DAT_005d2660= (undefined4&) GH_MEM(0x005d2660);
windowCreationParams& g_currentBinkMovie= (windowCreationParams&) GH_MEM(0x005d2660);
undefined& DAT_005d266c= (undefined&) GH_MEM(0x005d266c);
undefined1& DAT_005d266d= (undefined1&) GH_MEM(0x005d266d);
undefined1& DAT_005d26a8= (undefined1&) GH_MEM(0x005d26a8);
@ -163,6 +176,7 @@ undefined& lpVolumeNameBuffer_005d27b0= (undefined&) GH_MEM(0x005d27b0);
r3_main_data& r3_main_data_005d28b6= (r3_main_data&) GH_MEM(0x005d28b6);
undefined& g_soundOnHD= (undefined&) GH_MEM(0x005d29bc);
undefined& g_complete= (undefined&) GH_MEM(0x005d29c0);
undefined4& DAT_005d29c8= (undefined4&) GH_MEM(0x005d29c8);
int& DAT_005e6b00= (int&) GH_MEM(0x005e6b00);
undefined& DAT_005e6b04= (undefined&) GH_MEM(0x005e6b04);
int& DAT_005f5e24= (int&) GH_MEM(0x005f5e24);
@ -186,7 +200,11 @@ word& WORD_0077d4d6= (word&) GH_MEM(0x0077d4d6);
dword& DWORD_0077d4d8= (dword&) GH_MEM(0x0077d4d8);
char(&g_appCmdLine)[256] = reinterpret_cast<char(&)[256]>(GH_MEM(0x0077d4e0));
char(&s_wndStrRestoring)[256] = reinterpret_cast<char(&)[256]>(GH_MEM(0x0077d5e0));
char(&g_gameDataBinPath)[64] = reinterpret_cast<char(&)[64]>(GH_MEM(0x00781660));
int& DAT_0077d704= (int&) GH_MEM(0x0077d704);
undefined& __unguarded_readlc_active= (undefined&) GH_MEM(0x0077d708);
undefined4& DAT_0077d960= (undefined4&) GH_MEM(0x0077d960);
FILE *& uNumber_0077da60= (FILE *&) GH_MEM(0x0077da60);
char(&g_gameDataPath)[64] = reinterpret_cast<char(&)[64]>(GH_MEM(0x00781660));
undefined& DAT_00782086= (undefined&) GH_MEM(0x00782086);
char(&lpBuffer_00782088)[260] = reinterpret_cast<char(&)[260]>(GH_MEM(0x00782088));
char(&s_quitting1)[64] = reinterpret_cast<char(&)[64]>(GH_MEM(0x007825c0));
@ -203,13 +221,22 @@ undefined4& DAT_00794cec= (undefined4&) GH_MEM(0x00794cec);
dword& DWORD_00794d00= (dword&) GH_MEM(0x00794d00);
dword& DWORD_00794d04= (dword&) GH_MEM(0x00794d04);
undefined1& DAT_007a0cd8= (undefined1&) GH_MEM(0x007a0cd8);
uint& DAT_007a2c14= (uint&) GH_MEM(0x007a2c14);
undefined4& g_windowClearColor= (undefined4&) GH_MEM(0x007a2c14);
byte& g_bink_videoBpp= (byte&) GH_MEM(0x007a2e00);
byte& g_bink_wantedVideoQuality= (byte&) GH_MEM(0x007a2e02);
byte& g_bink_realVideoQuality= (byte&) GH_MEM(0x007a2e03);
byte& g_bink_autoAdjustQuality= (byte&) GH_MEM(0x007a2e04);
uint& DAT_007a2e0c= (uint&) GH_MEM(0x007a2e0c);
int& g_bink_wantedVideoQualityPlus1= (int&) GH_MEM(0x007a2e10);
undefined& DAT_007d78b9= (undefined&) GH_MEM(0x007d78b9);
undefined& DAT_007d78ba= (undefined&) GH_MEM(0x007d78ba);
undefined& DAT_007d78bb= (undefined&) GH_MEM(0x007d78bb);
undefined& DAT_007d78bc= (undefined&) GH_MEM(0x007d78bc);
undefined& DAT_007d78bd= (undefined&) GH_MEM(0x007d78bd);
undefined& DAT_007d78be= (undefined&) GH_MEM(0x007d78be);
undefined4& DAT_007d79e8= (undefined4&) GH_MEM(0x007d79e8);
undefined4& DAT_007d79ec= (undefined4&) GH_MEM(0x007d79ec);
undefined4& DAT_007d79f0= (undefined4&) GH_MEM(0x007d79f0);
undefined& DAT_007d7d84= (undefined&) GH_MEM(0x007d7d84);
GAM_tdstEngineStructure& g_r3_engine= (GAM_tdstEngineStructure&) GH_MEM(0x007d7dc0);
undefined2& DAT_007d7ea8= (undefined2&) GH_MEM(0x007d7ea8);
@ -229,7 +256,7 @@ word& WORD_007d9e6c= (word&) GH_MEM(0x007d9e6c);
char(&sz_M)[2] = reinterpret_cast<char(&)[2]>(GH_MEM(0x007d9e6e));
undefined& lpRootPathName_007d9e70= (undefined&) GH_MEM(0x007d9e70);
undefined3& UNK_007d9e71= (undefined3&) GH_MEM(0x007d9e71);
dword& DWORD_007eb200= (dword&) GH_MEM(0x007eb200);
dword& g_unkModuleIdByte= (dword&) GH_MEM(0x007eb200);
undefined& g_GLI_fullscreen= (undefined&) GH_MEM(0x007edd40);
int& g_GLI_width0= (int&) GH_MEM(0x007edd44);
int& g_GLI_height0= (int&) GH_MEM(0x007edd48);
@ -244,5 +271,6 @@ undefined1& g_config_tex_compressed= (undefined1&) GH_MEM(0x007edd65);
undefined1& g_GLI_trilinear= (undefined1&) GH_MEM(0x007edd66);
GUID& g_GLI_identifier= (GUID&) GH_MEM(0x007edd70);
float& g_GLI_mode_float= (float&) GH_MEM(0x007edd80);
m7_init_struct& m7_init_struct_007edde0= (m7_init_struct&) GH_MEM(0x007edde0);
m7_init_struct& g_m7_init_struct= (m7_init_struct&) GH_MEM(0x007edde0);
undefined& m7_mmgBlockInitialized= (undefined&) GH_MEM(0x007eddf9);
undefined& g_mod7CriticalSection= (undefined&) GH_MEM(0x007ede20);

View File

@ -64,6 +64,9 @@ extern char(&lpAppName_005b68f0)[8]; // 005b68f0
extern const char* s_Directory_005b68f8; // 005b68f8
extern const char* s_None; // 005b6904
extern const char* s_UbiSoft_Ubi_ini; // 005b690c
extern undefined& DAT_005b6d10; // 005b6d10
extern undefined *& PTR_fassign; // 005b6de8
extern char& DAT_005b93b0; // 005b93b0
extern undefined& s_percent_d; // 005bad58
extern byte& g_errMod0; // 005bd29c
extern const char* s_Warning_error__005bd318; // 005bd318
@ -93,6 +96,8 @@ extern undefined& DAT_005bda3c; // 005bda3c
extern char& DAT_005bda3e; // 005bda3e
extern undefined& s_DLL; // 005bda40
extern const char* s_UbiSoft_bmp_005bda4c; // 005bda4c
extern UINT& g_modemQuality; // 005bdca0
extern UINT& g_UDPPort; // 005bdca4
extern const char* s_R3_DVD_005bdfd8; // 005bdfd8
extern const char* s_R3_DVD_005be0ec; // 005be0ec
extern const char* s__s_DVD_missing_005be0f4; // 005be0f4
@ -100,6 +105,8 @@ extern const char* s_Die__s_DVDROM_kann_nicht_gelesen_005be130; // 005be130
extern const char* s_Impossibile_trovare_il_DVD____s_005be198; // 005be198
extern undefined& DAT_005be1ec; // 005be1ec
extern const char* s_Impossible_de_trouver_le_DVD_____005be238; // 005be238
extern const char* s_ModemQuality_005be2ec; // 005be2ec
extern const char* s_UDPPort_005be2fc; // 005be2fc
extern pointer& s_Yes; // 005be304
extern const char* s_SingleProcessor_005be308; // 005be308
extern undefined& lpDefault_005be318; // 005be318
@ -130,6 +137,7 @@ extern const char* s_fmt_c_colon_s; // 005be540
extern const char* s_r3_program_files; // 005be548
extern undefined *& PTR_DAT_005be568; // 005be568
extern byte& g_errModFirst; // 005be6f0
extern dword& g_modId4; // 005be8ac
extern byte& g_errMod5; // 005befbc
extern char(&s_M_005bf004)[2]; // 005bf004
extern char(&s_S_005bf008)[2]; // 005bf008
@ -147,20 +155,25 @@ extern char& DAT_005c0f22; // 005c0f22
extern byte& g_errMod17; // 005c1400
extern byte& g_errMod8; // 005c4b0c
extern byte& g_errMod9; // 005c4dcc
extern byte& g_errMod7; // 005c506c
extern byte& g_errMod3; // 005c506c
extern byte& g_errMod10; // 005c51f4
extern UINT& g_config_camera_hor_axis; // 005c67c8
extern UINT& g_config_camera_ver_axis; // 005c67cc
extern const char* s_____005ca864; // 005ca864
extern undefined1& DAT_005ca86c; // 005ca86c
extern byte& g_errMod11; // 005caf2c
extern byte& g_errMod12; // 005cb16c
extern char& g_errMod12; // 005cb16c
extern byte& g_errMod14; // 005cf5d4
extern byte& g_errMod15; // 005cf814
extern byte& g_errMod16; // 005cf874
extern HWND& g_gameHWND1; // 005cf964
extern long& lpDefault_005cf96c; // 005cf96c
extern dword& DWORD_005cfa20; // 005cfa20
extern int& DAT_005cfb64; // 005cfb64
extern UINT& CodePage_005cfb74; // 005cfb74
extern byte& g_ucErmNbOfModule; // 005d2638
extern mod1_ptrs& g_mod1_ptrs; // 005d2644
extern undefined4& DAT_005d2660; // 005d2660
extern windowCreationParams& g_currentBinkMovie; // 005d2660
extern undefined& DAT_005d266c; // 005d266c
extern undefined1& DAT_005d266d; // 005d266d
extern undefined1& DAT_005d26a8; // 005d26a8
@ -168,6 +181,7 @@ extern undefined& lpVolumeNameBuffer_005d27b0; // 005d27b0
extern r3_main_data& r3_main_data_005d28b6; // 005d28b6
extern undefined& g_soundOnHD; // 005d29bc
extern undefined& g_complete; // 005d29c0
extern undefined4& DAT_005d29c8; // 005d29c8
extern int& DAT_005e6b00; // 005e6b00
extern undefined& DAT_005e6b04; // 005e6b04
extern int& DAT_005f5e24; // 005f5e24
@ -191,7 +205,11 @@ extern word& WORD_0077d4d6; // 0077d4d6
extern dword& DWORD_0077d4d8; // 0077d4d8
extern char(&g_appCmdLine)[256]; // 0077d4e0
extern char(&s_wndStrRestoring)[256]; // 0077d5e0
extern char(&g_gameDataBinPath)[64]; // 00781660
extern int& DAT_0077d704; // 0077d704
extern undefined& __unguarded_readlc_active; // 0077d708
extern undefined4& DAT_0077d960; // 0077d960
extern FILE *& uNumber_0077da60; // 0077da60
extern char(&g_gameDataPath)[64]; // 00781660
extern undefined& DAT_00782086; // 00782086
extern char(&lpBuffer_00782088)[260]; // 00782088
extern char(&s_quitting1)[64]; // 007825c0
@ -208,13 +226,22 @@ extern undefined4& DAT_00794cec; // 00794cec
extern dword& DWORD_00794d00; // 00794d00
extern dword& DWORD_00794d04; // 00794d04
extern undefined1& DAT_007a0cd8; // 007a0cd8
extern uint& DAT_007a2c14; // 007a2c14
extern undefined4& g_windowClearColor; // 007a2c14
extern byte& g_bink_videoBpp; // 007a2e00
extern byte& g_bink_wantedVideoQuality; // 007a2e02
extern byte& g_bink_realVideoQuality; // 007a2e03
extern byte& g_bink_autoAdjustQuality; // 007a2e04
extern uint& DAT_007a2e0c; // 007a2e0c
extern int& g_bink_wantedVideoQualityPlus1; // 007a2e10
extern undefined& DAT_007d78b9; // 007d78b9
extern undefined& DAT_007d78ba; // 007d78ba
extern undefined& DAT_007d78bb; // 007d78bb
extern undefined& DAT_007d78bc; // 007d78bc
extern undefined& DAT_007d78bd; // 007d78bd
extern undefined& DAT_007d78be; // 007d78be
extern undefined4& DAT_007d79e8; // 007d79e8
extern undefined4& DAT_007d79ec; // 007d79ec
extern undefined4& DAT_007d79f0; // 007d79f0
extern undefined& DAT_007d7d84; // 007d7d84
extern GAM_tdstEngineStructure& g_r3_engine; // 007d7dc0
extern undefined2& DAT_007d7ea8; // 007d7ea8
@ -234,7 +261,7 @@ extern word& WORD_007d9e6c; // 007d9e6c
extern char(&sz_M)[2]; // 007d9e6e
extern undefined& lpRootPathName_007d9e70; // 007d9e70
extern undefined3& UNK_007d9e71; // 007d9e71
extern dword& DWORD_007eb200; // 007eb200
extern dword& g_unkModuleIdByte; // 007eb200
extern undefined& g_GLI_fullscreen; // 007edd40
extern int& g_GLI_width0; // 007edd44
extern int& g_GLI_height0; // 007edd48
@ -249,6 +276,7 @@ extern undefined1& g_config_tex_compressed; // 007edd65
extern undefined1& g_GLI_trilinear; // 007edd66
extern GUID& g_GLI_identifier; // 007edd70
extern float& g_GLI_mode_float; // 007edd80
extern m7_init_struct& m7_init_struct_007edde0; // 007edde0
extern m7_init_struct& g_m7_init_struct; // 007edde0
extern undefined& m7_mmgBlockInitialized; // 007eddf9
extern undefined& g_mod7CriticalSection; // 007ede20
#endif // GH_GENERATED_GLOBALS_H

View File

@ -6,9 +6,9 @@
#include <gh_global.h>
#include <stdexcept>
// 00445440
// FUN_00445440
extern "C" undefined FUN_00445440(void) {
// 004011e0
// FUN_004011e0
extern "C" undefined FUN_004011e0(void) {
// TODO: Implement this function
throw GHStubException("Function not implemented: FUN_00445440");
throw GHStubException("Function not implemented: FUN_004011e0");
}

View File

@ -6,9 +6,9 @@
#include <gh_global.h>
#include <stdexcept>
// 00449660
// r3_module4_init
extern "C" undefined r3_module4_init(void) {
// 00401110
// fn_vChooseTheGoodInit
extern "C" undefined fn_vChooseTheGoodInit(void) {
// TODO: Implement this function
throw GHStubException("Function not implemented: r3_module4_init");
throw GHStubException("Function not implemented: fn_vChooseTheGoodInit");
}

View File

@ -6,9 +6,9 @@
#include <gh_global.h>
#include <stdexcept>
// 00441e70
// r3_readBinkVideoConfig
extern "C" void r3_readBinkVideoConfig(void) {
// 00401130
// r3_checkEngineTermination
extern "C" int r3_checkEngineTermination(void) {
// TODO: Implement this function
throw GHStubException("Function not implemented: r3_readBinkVideoConfig");
throw GHStubException("Function not implemented: r3_checkEngineTermination");
}

View File

@ -0,0 +1,14 @@
// AUTO-GENERATED FILE!!!!
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00401150
// r3_engine_init_phase_adv2_is_2_6_8
extern "C" undefined r3_engine_init_phase_adv2_is_2_6_8(void) {
// TODO: Implement this function
throw GHStubException("Function not implemented: r3_engine_init_phase_adv2_is_2_6_8");
}

View File

@ -6,9 +6,9 @@
#include <gh_global.h>
#include <stdexcept>
// 0049b5a0
// FUN_0049b5a0
extern "C" undefined FUN_0049b5a0(void) {
// 00401120
// thunk_FUN_00444a80
extern "C" undefined thunk_FUN_00444a80(void) {
// TODO: Implement this function
throw GHStubException("Function not implemented: FUN_0049b5a0");
throw GHStubException("Function not implemented: thunk_FUN_00444a80");
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
0059733c || PTR__BinkOpenDirectSound@4_0059733c || / || undefined *
0059733c || PTR__BinkOpenDirectSound_4_0059733c || / || undefined *
005a9ed4 || DAT_005a9ed4 || / || undefined
005b63e0 || s__s_not_initialized__005b63e0 || / || char[20]
005b63f4 || s_Please_run_the__s_setup__005b63f4 || / || char[28]
@ -57,6 +57,9 @@
005b68f8 || s_Directory_005b68f8 || / || string
005b6904 || s_None || / || TerminatedCString
005b690c || s_UbiSoft_Ubi_ini || / || TerminatedCString
005b6d10 || DAT_005b6d10 || / || undefined
005b6de8 || PTR_fassign || / || undefined *
005b93b0 || DAT_005b93b0 || / || char
005bad58 || s_percent_d || / || undefined
005bd29c || g_errMod0 || / || byte
005bd318 || s_Warning_error__005bd318 || / || string
@ -86,6 +89,8 @@
005bda3e || DAT_005bda3e || / || char
005bda40 || s_DLL || / || undefined
005bda4c || s_UbiSoft_bmp_005bda4c || / || string
005bdca0 || g_modemQuality || /windef.h || UINT
005bdca4 || g_UDPPort || /windef.h || UINT
005bdfd8 || s_R3_DVD_005bdfd8 || / || string
005be0ec || s_R3_DVD_005be0ec || / || string
005be0f4 || s__s_DVD_missing_005be0f4 || / || string
@ -93,6 +98,8 @@
005be198 || s_Impossibile_trovare_il_DVD____s_005be198 || / || string
005be1ec || DAT_005be1ec || / || undefined
005be238 || s_Impossible_de_trouver_le_DVD_____005be238 || / || string
005be2ec || s_ModemQuality_005be2ec || / || string
005be2fc || s_UDPPort_005be2fc || / || string
005be304 || s_Yes || / || pointer
005be308 || s_SingleProcessor_005be308 || / || string
005be318 || lpDefault_005be318 || / || undefined
@ -123,6 +130,7 @@
005be548 || s_r3_program_files || / || string
005be568 || PTR_DAT_005be568 || / || undefined *
005be6f0 || g_errModFirst || / || byte
005be8ac || g_modId4 || / || dword
005befbc || g_errMod5 || / || byte
005bf004 || s_M_005bf004 || / || char[2]
005bf008 || s_S_005bf008 || / || char[2]
@ -140,20 +148,25 @@
005c1400 || g_errMod17 || / || byte
005c4b0c || g_errMod8 || / || byte
005c4dcc || g_errMod9 || / || byte
005c506c || g_errMod7 || / || byte
005c506c || g_errMod3 || / || byte
005c51f4 || g_errMod10 || / || byte
005c67c8 || g_config_camera_hor_axis || /windef.h || UINT
005c67cc || g_config_camera_ver_axis || /windef.h || UINT
005ca864 || s_____005ca864 || / || string
005ca86c || DAT_005ca86c || / || undefined1
005caf2c || g_errMod11 || / || byte
005cb16c || g_errMod12 || / || byte
005cb16c || g_errMod12 || / || char
005cf5d4 || g_errMod14 || / || byte
005cf814 || g_errMod15 || / || byte
005cf874 || g_errMod16 || / || byte
005cf964 || g_gameHWND1 || /windef.h || HWND
005cf96c || lpDefault_005cf96c || / || long
005cfa20 || DWORD_005cfa20 || / || dword
005cfb64 || DAT_005cfb64 || / || int
005cfb74 || CodePage_005cfb74 || /windef.h || UINT
005d2638 || g_ucErmNbOfModule || / || byte
005d2644 || g_mod1_ptrs || / || mod1_ptrs
005d2660 || DAT_005d2660 || / || undefined4
005d2660 || g_currentBinkMovie || /auto_structs || windowCreationParams
005d266c || DAT_005d266c || / || undefined
005d266d || DAT_005d266d || / || undefined1
005d26a8 || DAT_005d26a8 || / || undefined1
@ -161,6 +174,7 @@
005d28b6 || r3_main_data_005d28b6 || / || r3_main_data
005d29bc || g_soundOnHD || / || undefined
005d29c0 || g_complete || / || undefined
005d29c8 || DAT_005d29c8 || / || undefined4
005e6b00 || DAT_005e6b00 || / || int
005e6b04 || DAT_005e6b04 || / || undefined
005f5e24 || DAT_005f5e24 || / || int
@ -184,7 +198,11 @@
0077d4d8 || DWORD_0077d4d8 || / || dword
0077d4e0 || g_appCmdLine || / || char[256]
0077d5e0 || s_wndStrRestoring || / || char[256]
00781660 || g_gameDataBinPath || / || char[64]
0077d704 || DAT_0077d704 || / || int
0077d708 || __unguarded_readlc_active || / || undefined
0077d960 || DAT_0077d960 || / || undefined4
0077da60 || uNumber_0077da60 || /mbstring.h || FILE *
00781660 || g_gameDataPath || / || char[64]
00782086 || DAT_00782086 || / || undefined
00782088 || lpBuffer_00782088 || / || char[260]
007825c0 || s_quitting1 || / || char[64]
@ -201,13 +219,22 @@
00794d00 || DWORD_00794d00 || / || dword
00794d04 || DWORD_00794d04 || / || dword
007a0cd8 || DAT_007a0cd8 || / || undefined1
007a2c14 || DAT_007a2c14 || / || uint
007a2c14 || g_windowClearColor || / || undefined4
007a2e00 || g_bink_videoBpp || / || byte
007a2e02 || g_bink_wantedVideoQuality || / || byte
007a2e03 || g_bink_realVideoQuality || / || byte
007a2e04 || g_bink_autoAdjustQuality || / || byte
007a2e0c || DAT_007a2e0c || / || uint
007a2e10 || g_bink_wantedVideoQualityPlus1 || / || int
007d78b9 || DAT_007d78b9 || / || undefined
007d78ba || DAT_007d78ba || / || undefined
007d78bb || DAT_007d78bb || / || undefined
007d78bc || DAT_007d78bc || / || undefined
007d78bd || DAT_007d78bd || / || undefined
007d78be || DAT_007d78be || / || undefined
007d79e8 || DAT_007d79e8 || / || undefined4
007d79ec || DAT_007d79ec || / || undefined4
007d79f0 || DAT_007d79f0 || / || undefined4
007d7d84 || DAT_007d7d84 || / || undefined
007d7dc0 || g_r3_engine || /engine.h || GAM_tdstEngineStructure
007d7ea8 || DAT_007d7ea8 || / || undefined2
@ -227,7 +254,7 @@
007d9e6e || sz_M || / || char[2]
007d9e70 || lpRootPathName_007d9e70 || / || undefined
007d9e71 || UNK_007d9e71 || / || undefined3
007eb200 || DWORD_007eb200 || / || dword
007eb200 || g_unkModuleIdByte || / || dword
007edd40 || g_GLI_fullscreen || / || undefined
007edd44 || g_GLI_width0 || / || int
007edd48 || g_GLI_height0 || / || int
@ -242,5 +269,6 @@
007edd66 || g_GLI_trilinear || / || undefined1
007edd70 || g_GLI_identifier || /guiddef.h || GUID
007edd80 || g_GLI_mode_float || / || float
007edde0 || m7_init_struct_007edde0 || / || m7_init_struct
007edde0 || g_m7_init_struct || / || m7_init_struct
007eddf9 || m7_mmgBlockInitialized || / || undefined
007ede20 || g_mod7CriticalSection || / || undefined

View File

@ -11,6 +11,7 @@ import re3lib.FunctionDumper;
import re3lib.GlobalDumper;
import re3lib.PCallTracer;
import re3lib.RecompileConfig;
import re3lib.TypeDumper;
public class DumpCurrentFunctionRecursive extends GhidraScript {
@Override
@ -21,7 +22,10 @@ public class DumpCurrentFunctionRecursive extends GhidraScript {
GlobalDumper globalDumper = new GlobalDumper(this);
globalDumper.loadGlobalManifest();
FunctionDumper functionDumper = new FunctionDumper(this, globalDumper);
PCallTracer tracer = new PCallTracer();
tracer.setBlacklist(functionDumper.functionAddrBlackList);
tracer.traceCalls(getFunctionContaining(currentAddress));
List<Function> functionsToDump = new ArrayList<>();
@ -56,7 +60,6 @@ public class DumpCurrentFunctionRecursive extends GhidraScript {
return;
}
FunctionDumper functionDumper = new FunctionDumper(this, globalDumper);
for (Function func : functionsToDump) {
functionDumper.dump(func);
}
@ -67,5 +70,9 @@ public class DumpCurrentFunctionRecursive extends GhidraScript {
globalDumper.dumpGlobals();
globalDumper.saveGlobalManifest();
}
// Dump types
TypeDumper dumper = new TypeDumper(this);
dumper.run();
}
}

View File

@ -0,0 +1,114 @@
// @category _Reman3
// @menupath Reman3.Rebuild Function Database
import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address;
import re3lib.FunctionDatabase;
import re3lib.RecompileConfig;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RebuildFunctionDatabase extends GhidraScript {
FunctionDatabase functionDB;
@Override
public void run() throws Exception {
RecompileConfig.INSTANCE = new RecompileConfig(this);
functionDB = new FunctionDatabase(this);
scanDirectory(RecompileConfig.INSTANCE.dirDecompAuto);
scanDirectory(RecompileConfig.INSTANCE.dirDecompFix);
scanDirectory(RecompileConfig.INSTANCE.dirDecompStub);
println("Applying default filters...");
functionDB.applyDefaultFilters();
println("Saving function database...");
functionDB.save();
println("Function database rebuilt successfully.");
// for (FunctionDatabase.Entry entry : functionDB.entries) {
// println(entry.address + " " + entry.name + " " + entry.file.getName());
// for (FunctionDatabase.Dependency dependency : entry.dependencies) {
// println(" " + dependency.address + " " + dependency.name);
// }
// }
}
private void scanDirectory(File directory) throws Exception {
File[] files = directory.listFiles((dir, name) -> name.endsWith(".cxx"));
if (files == null)
return;
for (File file : files) {
scanFile(file);
}
}
private void scanFile(File file) throws Exception {
println("Scanning " + file);
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
String line;
Pattern dependencyPattern = Pattern.compile("(\\w+)\\s+(\\w+)\\(.*\\);\\s*//\\s*([0-9A-Fa-f]{8})\\s*//\\s*(.*)");
Pattern addressPattern = Pattern.compile("//\\s*([0-9A-Fa-f]{8})");
Pattern functionNamePattern = Pattern.compile("(\\S+)\\s+(\\S+)\\s*\\(");
List<FunctionDatabase.Dependency> dependencies = new ArrayList<>();
String address = null;
String functionName = null;
while ((line = reader.readLine()) != null) {
Matcher dependencyMatcher = dependencyPattern.matcher(line);
if (dependencyMatcher.find()) {
// println("Found dependency: " + dependencyMatcher.group(3));
Address depAddress = currentProgram.getAddressFactory().getAddress(dependencyMatcher.group(3));
String name = dependencyMatcher.group(2);
FunctionDatabase.Dependency dependency = functionDB.new Dependency(depAddress, name);
dependencies.add(dependency);
continue;
}
Matcher addressMatcher = addressPattern.matcher(line);
if (addressMatcher.find()) {
// println("Found address: " + addressMatcher.group(1));
address = addressMatcher.group(1);
// Skip any comments or newlines between address and function definition
while ((line = reader.readLine()) != null) {
line = line.trim();
// println("Line: " + line);
if (!line.isEmpty()) {
Matcher functionNameMatcher = functionNamePattern.matcher(line);
if (functionNameMatcher.find()) {
functionName = functionNameMatcher.group(2).trim();
break;
}
}
}
if (functionName != null) {
break;
}
}
}
if (address != null && functionName != null) {
Address functionAddress = currentProgram.getAddressFactory().getAddress(address);
FunctionDatabase.Entry entry = functionDB.new Entry();
entry.address = functionAddress;
entry.name = functionName;
entry.file = file;
entry.dependencies = dependencies;
functionDB.entries.add(entry);
} else {
throw new Exception("Failed to parse function at " + file.getName());
}
}
}
}

View File

@ -0,0 +1,223 @@
package re3lib;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Function;
public class FunctionDatabase {
public class Dependency implements java.io.Serializable {
private static final long serialVersionUID = 1L;
public Address address;
public String name;
public Dependency(Address address, String name) {
this.address = address;
this.name = name;
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
out.writeObject(address != null ? address.toString() : null);
out.writeObject(name);
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
String addressString = (String) in.readObject();
if (addressString != null) {
address = RecompileConfig.INSTANCE.script.getCurrentProgram().getAddressFactory().getAddress(addressString);
}
name = (String) in.readObject();
}
}
public class Entry implements java.io.Serializable {
private static final long serialVersionUID = 1L;
public Address address;
public String name;
public File file;
public List<Dependency> dependencies = new ArrayList<>();
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
out.writeObject(address != null ? address.toString() : null);
out.writeObject(name);
out.writeObject(file != null ? file.toString() : null);
out.writeObject(dependencies);
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
String addressString = (String) in.readObject();
if (addressString != null) {
address = RecompileConfig.INSTANCE.script.getCurrentProgram().getAddressFactory().getAddress(addressString);
}
name = (String) in.readObject();
String fileString = (String) in.readObject();
if (fileString != null) {
file = new File(fileString);
}
dependencies = (List<Dependency>) in.readObject();
}
}
public List<Entry> entries = new ArrayList<>();
private File file;
private transient GhidraScript script;
public FunctionDatabase(GhidraScript script) {
this.script = script;
file = new File(RecompileConfig.INSTANCE.outputDir, "functions.dat");
}
public void load() throws Exception {
if (!file.exists()) {
return;
}
try (java.io.ObjectInputStream ois = new java.io.ObjectInputStream(new java.io.FileInputStream(file))) {
entries = (List<Entry>) ois.readObject();
script.println("Loaded " + entries.size() + " function entries from " + file);
} catch (java.io.IOException | ClassNotFoundException e) {
script.println("Error loading function database: " + e.getMessage());
}
}
public void save() throws Exception {
try (java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(new java.io.FileOutputStream(file))) {
oos.writeObject(entries);
script.println("Saved " + entries.size() + " function entries to " + file);
} catch (java.io.IOException e) {
script.println("Error saving function database: " + e.getMessage());
}
}
public void add(Entry entry) {
entries.add(entry);
}
public void applyDefaultFilters() throws Exception {
GlobalDumper globalDumper = new GlobalDumper(script);
FunctionDumper dumper = new FunctionDumper(script, globalDumper);
boolean madeAnyChanges = false;
// Create a hash map to store symbol names
Map<Address, String> symbolNames = new HashMap<>();
Map<String, File> exportedFunctionNames = new HashMap<>();
for (Entry entry : entries) {
Function function = script.getFunctionAt(entry.address);
if (function != null) {
String dirComponent = entry.file.getParent().toString();
boolean isAuto = dirComponent.startsWith(RecompileConfig.INSTANCE.dirDecompAuto.toString());
boolean isFix = dirComponent.startsWith(RecompileConfig.INSTANCE.dirDecompFix.toString());
// Get the actual symbol name and store it in the hash map
String symbolName = function.getName();
symbolNames.put(entry.address, symbolName);
if (isAuto && !exportedFunctionNames.containsKey(entry.name)) {
exportedFunctionNames.put(entry.name, entry.file);
} else if (isFix) {
exportedFunctionNames.replace(entry.name, entry.file);
}
}
}
// Print the number of symbol names collected
script.println("Collected " + symbolNames.size() + " symbol names");
boolean dryMode = true;
HashSet<Function> functionsToRegenerate = new HashSet<>();
Iterator<Entry> iterator = entries.iterator();
while (iterator.hasNext()) {
Entry entry = iterator.next();
Function function = script.getFunctionAt(entry.address);
boolean pendingDelete = false;
boolean pendingRegenerate = false;
// Remove CRT and other blacklisted functions
if (function == null || !dumper.isValidFunction(function)) {
// Remove the file
if (entry.file != null && entry.file.exists()) {
script.println("Removed file: " + entry.file.getAbsolutePath());
pendingDelete = true;
}
// Remove entry from the list
script.println("Removed invalid function entry: " + entry.name + " at " + entry.address);
function = null;
}
// Check if symbol name matches the symbol name parsed from the file
if (function != null) {
String actualSymbolName = symbolNames.get(entry.address);
if (actualSymbolName == null) {
throw new Exception(
"Symbol name not found for function at " + entry.address + " in file " + entry.file.getAbsolutePath());
}
if (actualSymbolName != null && !actualSymbolName.equals(entry.name)) {
File fnExportedFile = exportedFunctionNames.get(entry.name);
if (fnExportedFile != null && fnExportedFile != entry.file) {
// Already exists elsewhere, so remove this file
script.println("Removing duplicate function: " + entry.name + " at " + entry.address + " overridden by "
+ fnExportedFile);
pendingDelete = true;
} else {
// Regeneral this function
script.println("Symbol name mismatch for function at " + entry.address + ": " +
"File name: " + entry.name + ", Actual symbol: " + actualSymbolName);
entry.name = actualSymbolName; // Update the entry name to match the actual symbol
pendingRegenerate = true;
}
}
// Check if dependencies are valid
for (Dependency dependency : entry.dependencies) {
Function depFunction = script.getFunctionAt(dependency.address);
if (depFunction == null) {
script.println("Dependency not found: " + dependency.name + " at " + dependency.address + " in " + entry.file);
pendingRegenerate = true;
} else if (!dumper.isValidFunction(depFunction) || !depFunction.getName().equals(dependency.name)) {
script
.println("Invalid dependency: " + dependency.name + " at " + dependency.address + " in " + entry.file + " should be " + dependency.name);
pendingRegenerate = true;
}
}
entry.name = actualSymbolName; // Update the entry name to match the actual symbol
madeAnyChanges = true;
}
if (pendingDelete) {
iterator.remove();
if (!dryMode) {
entry.file.delete();
madeAnyChanges = true;
}
} else if (pendingRegenerate) {
if (!dryMode) {
functionsToRegenerate.add(function);
madeAnyChanges = true;
}
}
}
for (Function function : functionsToRegenerate) {
script.println("Regenerating function: " + function.getName() + " at " + function.getEntryPoint());
dumper.dump(function);
}
if (madeAnyChanges) {
// Update CMake timestamp
RecompileConfig.INSTANCE.touchCMakeTimestamp();
}
}
}

View File

@ -28,7 +28,8 @@ import re3lib.GlobalDumper.GlobalRec;
public class FunctionDumper {
GhidraScript script;
GlobalDumper globalDumper;
HashSet<Address> functionAddrBlackList = new HashSet<>();
public HashSet<Address> functionAddrBlackList = new HashSet<>();
public boolean createdFile = false;
// Collects functions called by the current function
@ -188,7 +189,7 @@ public class FunctionDumper {
ClangToken token = tokens.get(t);
boolean thisDot = false;
// println("Token: " + token.toString());
script.println("Token: " + token.toString());
if (token.toString().equals(".")) {
// println("Found dot: " + token.toString() + " - " + token.getClass());
thisDot = true;
@ -232,10 +233,12 @@ public class FunctionDumper {
// Check if it's a function pointer, otherwise add to globals
if (address.isMemoryAddress()) {
// script.println("Address: " + address + " - " + sym.getName());
Function maybeFunction = script.getFunctionAt(address);
if (maybeFunction != null) {
externalFunctionCalls.add(maybeFunction);
} else {
script.println("Add globals " + address + " - " + gsym.getName() + " - " + token.getText());
globalDumper.addGlobal(address, gsym);
}
}

View File

@ -113,15 +113,11 @@ public class GlobalDumper {
// script.println("DATA: " + addr + " - " + dt.getDisplayName());
}
}
// if(sym.getName().startsWith("s_SALIR")) {
// script.println("SALIR: " + addr + " - " + dt.getDisplayName() + " - " +
// dt.getClass().getName());
// // script.println("SALIR: " + sym.getdata());
// }
if (dt == null) {
script.println("WARNING: Missing type for global: " + sym.getName() + " at " + addr);
return;
}
// script.println("Global: " + addr + " - " + sym.getName() + " - " + dt.getDisplayName());
globalAddrs.put(addr, new GlobalRec(addr, sym.getName(), dt));
}