diff --git a/game_re/gh_fix/r3_main.cxx b/game_re/gh_fix/r3_main.cxx index d3644787..db284e85 100644 --- a/game_re/gh_fix/r3_main.cxx +++ b/game_re/gh_fix/r3_main.cxx @@ -371,7 +371,7 @@ int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR *cmdline, strcpy(acStack_300, getDefaultConfig().gfxAdapter.c_str()); strcpy(acStack_100, getDefaultConfig().gfxIdentifier.c_str()); strcpy(acStack_200, getDefaultConfig().gfxGliMode.c_str()); - + /* If they're all set */ if (((acStack_300[0] != '\0') && (acStack_100[0] != '\0')) && (acStack_200[0] != '\0')) { diff --git a/game_re/gh_global.cxx b/game_re/gh_global.cxx index b5d7220b..b99c478f 100644 --- a/game_re/gh_global.cxx +++ b/game_re/gh_global.cxx @@ -1,48 +1,48 @@ // AUTO-GENERATED FILE #include -char(&s__s_not_initialized__005b63e0)[20] = *reinterpret_cast(GH_MEM(0x005b63e0)); -char(&s_Please_run_the__s_setup__005b63f4)[28] = *reinterpret_cast(GH_MEM(0x005b63f4)); -char(&s_dashCC)[4] = *reinterpret_cast(GH_MEM(0x005b6410)); -char(&s_Gli_Mode_005b6414)[12] = *reinterpret_cast(GH_MEM(0x005b6414)); -char(&s_Identifier_005b6420)[16] = *reinterpret_cast(GH_MEM(0x005b6420)); -char(&s_Check_your_version_of_DirectX__V_005b6430)[72] = *reinterpret_cast(GH_MEM(0x005b6430)); -char(&lpText_005b6478)[120] = *reinterpret_cast(GH_MEM(0x005b6478)); -char(&lpText_005b64f0)[80] = *reinterpret_cast(GH_MEM(0x005b64f0)); -char(&lpText_005b6540)[72] = *reinterpret_cast(GH_MEM(0x005b6540)); -char(&s_Rayman_3_005b6588)[16] = *reinterpret_cast(GH_MEM(0x005b6588)); -char(&lpText_005b6598)[76] = *reinterpret_cast(GH_MEM(0x005b6598)); -char(&s_Erreur_Rayman_3_005b65e4)[20] = *reinterpret_cast(GH_MEM(0x005b65e4)); -char(&s_dpnhpast_dll_005b65f8)[16] = *reinterpret_cast(GH_MEM(0x005b65f8)); -char(&s_DRAWSEM_005b6608)[8] = *reinterpret_cast(GH_MEM(0x005b6608)); -char(&s_Restoring_data_____005b6610)[20] = *reinterpret_cast(GH_MEM(0x005b6610)); -char(&s_QUIT)[8] = *reinterpret_cast(GH_MEM(0x005b6624)); -char(&s_or_press_ESC_to_quit_Rayman_3__005b662c)[32] = *reinterpret_cast(GH_MEM(0x005b662c)); -char(&s__s___Restoring_data____005b664c)[24] = *reinterpret_cast(GH_MEM(0x005b664c)); -char(&s_Daten_Reparatur____005b6664)[20] = *reinterpret_cast(GH_MEM(0x005b6664)); -char(&s_BEENDIGEN_005b6678)[12] = *reinterpret_cast(GH_MEM(0x005b6678)); +char(&s__s_not_initialized__005b63e0)[20] = reinterpret_cast(GH_MEM(0x005b63e0)); +char(&s_Please_run_the__s_setup__005b63f4)[28] = reinterpret_cast(GH_MEM(0x005b63f4)); +char(&s_dashCC)[4] = reinterpret_cast(GH_MEM(0x005b6410)); +char(&s_Gli_Mode_005b6414)[12] = reinterpret_cast(GH_MEM(0x005b6414)); +char(&s_Identifier_005b6420)[16] = reinterpret_cast(GH_MEM(0x005b6420)); +char(&s_Check_your_version_of_DirectX__V_005b6430)[72] = reinterpret_cast(GH_MEM(0x005b6430)); +char(&lpText_005b6478)[120] = reinterpret_cast(GH_MEM(0x005b6478)); +char(&lpText_005b64f0)[80] = reinterpret_cast(GH_MEM(0x005b64f0)); +char(&lpText_005b6540)[72] = reinterpret_cast(GH_MEM(0x005b6540)); +char(&s_Rayman_3_005b6588)[16] = reinterpret_cast(GH_MEM(0x005b6588)); +char(&lpText_005b6598)[76] = reinterpret_cast(GH_MEM(0x005b6598)); +char(&s_Erreur_Rayman_3_005b65e4)[20] = reinterpret_cast(GH_MEM(0x005b65e4)); +char(&s_dpnhpast_dll_005b65f8)[16] = reinterpret_cast(GH_MEM(0x005b65f8)); +char(&s_DRAWSEM_005b6608)[8] = reinterpret_cast(GH_MEM(0x005b6608)); +char(&s_Restoring_data_____005b6610)[20] = reinterpret_cast(GH_MEM(0x005b6610)); +char(&s_QUIT)[8] = reinterpret_cast(GH_MEM(0x005b6624)); +char(&s_or_press_ESC_to_quit_Rayman_3__005b662c)[32] = reinterpret_cast(GH_MEM(0x005b662c)); +char(&s__s___Restoring_data____005b664c)[24] = reinterpret_cast(GH_MEM(0x005b664c)); +char(&s_Daten_Reparatur____005b6664)[20] = reinterpret_cast(GH_MEM(0x005b6664)); +char(&s_BEENDIGEN_005b6678)[12] = reinterpret_cast(GH_MEM(0x005b6678)); char& CHAR_E_005b6684= (char&) GH_MEM(0x005b6684); -char(&s__s___Daten_Reparatur____005b66ac)[24] = *reinterpret_cast(GH_MEM(0x005b66ac)); -char(&s_German_005b66c4)[8] = *reinterpret_cast(GH_MEM(0x005b66c4)); -char(&s_Ripristino_dati____005b66cc)[20] = *reinterpret_cast(GH_MEM(0x005b66cc)); -char(&s__s___Pausa_005b66e0)[12] = *reinterpret_cast(GH_MEM(0x005b66e0)); -char(&s_USCIRE_005b66ec)[8] = *reinterpret_cast(GH_MEM(0x005b66ec)); -char(&s_Premi_ESC_per_uscire_da_Rayman_3_005b66f4)[36] = *reinterpret_cast(GH_MEM(0x005b66f4)); -char(&s__s___Ripristino_dati____005b6718)[24] = *reinterpret_cast(GH_MEM(0x005b6718)); -char(&s_Italian_005b6730)[8] = *reinterpret_cast(GH_MEM(0x005b6730)); -char(&s_Restablecer_datos____005b6738)[24] = *reinterpret_cast(GH_MEM(0x005b6738)); -char(&s__s___Rotura_005b6750)[12] = *reinterpret_cast(GH_MEM(0x005b6750)); -char(&s_SALIR_005b675c)[8] = *reinterpret_cast(GH_MEM(0x005b675c)); -char(&s_Pulsa_ESC_para_salir_Rayman_3__005b6764)[32] = *reinterpret_cast(GH_MEM(0x005b6764)); -char(&s__s___Restablecer_datos____005b6784)[28] = *reinterpret_cast(GH_MEM(0x005b6784)); -char(&s_Spanish_005b67a0)[8] = *reinterpret_cast(GH_MEM(0x005b67a0)); -char(&s_Restauration)[28] = *reinterpret_cast(GH_MEM(0x005b67a8)); -char(&s__s___Pause_005b67c4)[11] = *reinterpret_cast(GH_MEM(0x005b67c4)); -char(&s_ou_appuyez_sur_Echap_pour_quitte_005b67d0)[44] = *reinterpret_cast(GH_MEM(0x005b67d0)); -char(&s_QUITTER)[8] = *reinterpret_cast(GH_MEM(0x005b67fc)); -char(&s_Restauration_fmt)[36] = *reinterpret_cast(GH_MEM(0x005b6804)); -char(&s_French_005b6828)[8] = *reinterpret_cast(GH_MEM(0x005b6828)); -char(&s_windowTitle)[12] = *reinterpret_cast(GH_MEM(0x005b6830)); -char(&s_percents)[4] = *reinterpret_cast(GH_MEM(0x005b683c)); +char(&s__s___Daten_Reparatur____005b66ac)[24] = reinterpret_cast(GH_MEM(0x005b66ac)); +char(&s_German_005b66c4)[8] = reinterpret_cast(GH_MEM(0x005b66c4)); +char(&s_Ripristino_dati____005b66cc)[20] = reinterpret_cast(GH_MEM(0x005b66cc)); +char(&s__s___Pausa_005b66e0)[12] = reinterpret_cast(GH_MEM(0x005b66e0)); +char(&s_USCIRE_005b66ec)[8] = reinterpret_cast(GH_MEM(0x005b66ec)); +char(&s_Premi_ESC_per_uscire_da_Rayman_3_005b66f4)[36] = reinterpret_cast(GH_MEM(0x005b66f4)); +char(&s__s___Ripristino_dati____005b6718)[24] = reinterpret_cast(GH_MEM(0x005b6718)); +char(&s_Italian_005b6730)[8] = reinterpret_cast(GH_MEM(0x005b6730)); +char(&s_Restablecer_datos____005b6738)[24] = reinterpret_cast(GH_MEM(0x005b6738)); +char(&s__s___Rotura_005b6750)[12] = reinterpret_cast(GH_MEM(0x005b6750)); +char(&s_SALIR_005b675c)[8] = reinterpret_cast(GH_MEM(0x005b675c)); +char(&s_Pulsa_ESC_para_salir_Rayman_3__005b6764)[32] = reinterpret_cast(GH_MEM(0x005b6764)); +char(&s__s___Restablecer_datos____005b6784)[28] = reinterpret_cast(GH_MEM(0x005b6784)); +char(&s_Spanish_005b67a0)[8] = reinterpret_cast(GH_MEM(0x005b67a0)); +char(&s_Restauration)[28] = reinterpret_cast(GH_MEM(0x005b67a8)); +char(&s__s___Pause_005b67c4)[11] = reinterpret_cast(GH_MEM(0x005b67c4)); +char(&s_ou_appuyez_sur_Echap_pour_quitte_005b67d0)[44] = reinterpret_cast(GH_MEM(0x005b67d0)); +char(&s_QUITTER)[8] = reinterpret_cast(GH_MEM(0x005b67fc)); +char(&s_Restauration_fmt)[36] = reinterpret_cast(GH_MEM(0x005b6804)); +char(&s_French_005b6828)[8] = reinterpret_cast(GH_MEM(0x005b6828)); +char(&s_windowTitle)[12] = reinterpret_cast(GH_MEM(0x005b6830)); +char(&s_percents)[4] = reinterpret_cast(GH_MEM(0x005b683c)); const char* s_Language_005b6840 = "Language"; // 005b6840 const char* s_English_005b684c = "English"; // 005b684c const char* s_CompleteInstall_005b6854 = "CompleteInstall"; // 005b6854 @@ -75,6 +75,8 @@ undefined& DAT_005be500= (undefined&) GH_MEM(0x005be500); 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); +undefined2& DAT_005c0f20= (undefined2&) GH_MEM(0x005c0f20); +char& DAT_005c0f22= (char&) GH_MEM(0x005c0f22); HWND& g_gameHWND1= (HWND&) GH_MEM(0x005cf964); long& lpDefault_005cf96c= (long&) GH_MEM(0x005cf96c); undefined4& DAT_005d2660= (undefined4&) GH_MEM(0x005d2660); @@ -90,20 +92,20 @@ WPARAM& g_engineShouldRun= (WPARAM&) GH_MEM(0x0077d0b0); int& g_engineRunning= (int&) GH_MEM(0x0077d0b4); undefined4& DAT_0077d0b8= (undefined4&) GH_MEM(0x0077d0b8); HANDLE& g_drawSemaphore= (HANDLE&) GH_MEM(0x0077d0bc); -char(&g_mutexName_Rayman3)[256] = *reinterpret_cast(GH_MEM(0x0077d0c0)); -char(&g_windowTitle)[256] = *reinterpret_cast(GH_MEM(0x0077d1c0)); -char(&lpString_0077d2c0)[256] = *reinterpret_cast(GH_MEM(0x0077d2c0)); -char(&s_windowTitleRestoring)[256] = *reinterpret_cast(GH_MEM(0x0077d3c0)); +char(&g_mutexName_Rayman3)[256] = reinterpret_cast(GH_MEM(0x0077d0c0)); +char(&g_windowTitle)[256] = reinterpret_cast(GH_MEM(0x0077d1c0)); +char(&lpString_0077d2c0)[256] = reinterpret_cast(GH_MEM(0x0077d2c0)); +char(&s_windowTitleRestoring)[256] = reinterpret_cast(GH_MEM(0x0077d3c0)); HINSTANCE& g_hinstance= (HINSTANCE&) GH_MEM(0x0077d4c0); HWND& g_gameHWND= (HWND&) GH_MEM(0x0077d4c4); HANDLE& g_mainThreadHandle= (HANDLE&) GH_MEM(0x0077d4c8); word& WORD_0077d4d4= (word&) GH_MEM(0x0077d4d4); word& WORD_0077d4d6= (word&) GH_MEM(0x0077d4d6); dword& DWORD_0077d4d8= (dword&) GH_MEM(0x0077d4d8); -char(&g_appCmdLine)[256] = *reinterpret_cast(GH_MEM(0x0077d4e0)); -char(&s_wndStrRestoring)[256] = *reinterpret_cast(GH_MEM(0x0077d5e0)); -char(&s_quitting1)[64] = *reinterpret_cast(GH_MEM(0x007825c0)); -char(&s_wndStrQuiting)[56] = *reinterpret_cast(GH_MEM(0x00782600)); +char(&g_appCmdLine)[256] = reinterpret_cast(GH_MEM(0x0077d4e0)); +char(&s_wndStrRestoring)[256] = reinterpret_cast(GH_MEM(0x0077d5e0)); +char(&s_quitting1)[64] = reinterpret_cast(GH_MEM(0x007825c0)); +char(&s_wndStrQuiting)[56] = reinterpret_cast(GH_MEM(0x00782600)); undefined& DAT_007d7d84= (undefined&) GH_MEM(0x007d7d84); undefined2& DAT_007d7ea8= (undefined2&) GH_MEM(0x007d7ea8); short& DAT_007d80f8= (short&) GH_MEM(0x007d80f8); diff --git a/game_re/gh_global.h b/game_re/gh_global.h index 49f2801f..d1c75bda 100644 --- a/game_re/gh_global.h +++ b/game_re/gh_global.h @@ -4,6 +4,7 @@ #include + extern char(&s__s_not_initialized__005b63e0)[20]; // 005b63e0 extern char(&s_Please_run_the__s_setup__005b63f4)[28]; // 005b63f4 extern char(&s_dashCC)[4]; // 005b6410 @@ -79,6 +80,8 @@ extern undefined& DAT_005be500; // 005be500 extern const char* s_fmt_c_colon_s; // 005be540 extern const char* s_r3_program_files; // 005be548 extern undefined *& PTR_DAT_005be568; // 005be568 +extern undefined2& DAT_005c0f20; // 005c0f20 +extern char& DAT_005c0f22; // 005c0f22 extern HWND& g_gameHWND1; // 005cf964 extern long& lpDefault_005cf96c; // 005cf96c extern undefined4& DAT_005d2660; // 005d2660 diff --git a/game_re/gh_stub/checkMask_5d29c4.cxx b/game_re/gh_stub/checkMask_5d29c4.cxx new file mode 100644 index 00000000..97071d28 --- /dev/null +++ b/game_re/gh_stub/checkMask_5d29c4.cxx @@ -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 +#include +#include + +// 00445560 +// checkMask_5d29c4 +extern "C" bool checkMask_5d29c4(uint mask) { + // TODO: Implement this function + throw std::runtime_error("Function not implemented: checkMask_5d29c4"); +} diff --git a/game_re/globals.txt b/game_re/globals.txt index 4c8cd5eb..34016f95 100644 --- a/game_re/globals.txt +++ b/game_re/globals.txt @@ -73,6 +73,8 @@ 005be540 || s_fmt_c_colon_s || / || string 005be548 || s_r3_program_files || / || string 005be568 || PTR_DAT_005be568 || / || undefined * +005c0f20 || DAT_005c0f20 || / || undefined2 +005c0f22 || DAT_005c0f22 || / || char 005cf964 || g_gameHWND1 || /windef.h || HWND 005cf96c || lpDefault_005cf96c || / || long 005d2660 || DAT_005d2660 || / || undefined4 diff --git a/game_re/r3/binders/static_mem.cxx b/game_re/r3/binders/static_mem.cxx index ea937fee..21339daf 100644 --- a/game_re/r3/binders/static_mem.cxx +++ b/game_re/r3/binders/static_mem.cxx @@ -1,5 +1,6 @@ #include "static_mem.h" #include +#include unsigned char gh_static_mem[GH_DATA_SIZE]; void gh_init_data_segment() { @@ -12,5 +13,19 @@ void gh_init_data_segment() { if (actual != gh_data_size) { throw std::runtime_error("Failed to read gh_datasegment.bin"); } + fclose(f); -} \ No newline at end of file +} + +void gh_static_mem_check() { + // Quick check + const char *testValue = (const char *)&GH_MEM(0x5b68f8); + if (std::string_view(testValue) != "Directory") { + throw std::runtime_error("gh_datasegment.bin is corrupted"); + } + + const char *otherValue = (const char *)&GH_MEM(0x005b683c); + if (std::string_view(otherValue) != "%s") { + throw std::runtime_error("gh_datasegment.bin is corrupted"); + } +} diff --git a/game_re/r3/binders/static_mem.h b/game_re/r3/binders/static_mem.h index 8f37ec2d..b6350524 100644 --- a/game_re/r3/binders/static_mem.h +++ b/game_re/r3/binders/static_mem.h @@ -17,6 +17,9 @@ inline uint8_t *memoryMapSafe(size_t addr) { return (uint8_t *)(gh_static_mem + (addr - GH_DATA_START)); } +void gh_init_data_segment(); +void gh_static_mem_check(); + #define GH_MEM(addr) (checkMappedMemory(), *memoryMapSafe(addr)) #endif /* A18E3E17_2A80_4DBD_96CD_1CE0120A164E */ diff --git a/game_re/r3/main.cpp b/game_re/r3/main.cpp index f762b218..d1765d9e 100644 --- a/game_re/r3/main.cpp +++ b/game_re/r3/main.cpp @@ -2,11 +2,11 @@ #include #include #include +#include extern "C" int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR *cmdline, int showCmd); -extern void gh_init_data_segment(); int main() { try { gh_init_data_segment(); diff --git a/scripts/re3lib/GlobalDumper.java b/scripts/re3lib/GlobalDumper.java index 5855ef0c..7d680789 100644 --- a/scripts/re3lib/GlobalDumper.java +++ b/scripts/re3lib/GlobalDumper.java @@ -213,8 +213,8 @@ public class GlobalDumper { linkagePrefix + baseType.getDisplayName() + "(&" + name + ")[" + adt.getNumElements() + "]; // " + addr); cwriter.println( - baseType.getDisplayName() + "(&" + name + ")[" + adt.getNumElements() + "] = *reinterpret_cast<" - + baseType.getDisplayName() + "(*)[" + adt.getNumElements() + "]>(GH_MEM(0x" + addr + "));"); + baseType.getDisplayName() + "(&" + name + ")[" + adt.getNumElements() + "] = reinterpret_cast<" + + baseType.getDisplayName() + "(&)[" + adt.getNumElements() + "]>(GH_MEM(0x" + addr + "));"); } else { String refTypeStr = dt.getDisplayName() + "&"; hwriter.println(linkagePrefix + refTypeStr + " " + name + "; // " + addr);