diff --git a/game_re/CMakeLists.txt b/game_re/CMakeLists.txt index e2df4622..5c9cc9bf 100644 --- a/game_re/CMakeLists.txt +++ b/game_re/CMakeLists.txt @@ -9,6 +9,8 @@ add_executable(game_re gh_global.cxx binders/gh_static_mem.cxx) +target_compile_features(game_re PUBLIC cxx_std_20) + target_include_directories(game_re PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/binders) @@ -22,7 +24,7 @@ if(WIN32) ) endif() -target_compile_definitions(game_re PRIVATE +target_compile_definitions(game_re PRIVATE _CRT_SECURE_NO_WARNINGS=1 _CRT_NONSTDC_NO_WARNINGS=1) diff --git a/game_re/binders/gh_auto_binder.h b/game_re/binders/gh_auto_binder.h index 3b738cba..00a36160 100644 --- a/game_re/binders/gh_auto_binder.h +++ b/game_re/binders/gh_auto_binder.h @@ -3,11 +3,15 @@ #include "gh_base.h" #include "gh_static_mem.h" -#include "gh_structs.h" +#include "gh_types.h" #include "gh_global.h" +#ifdef _WIN32 #include #include +#else +#include +#endif template struct Field {}; diff --git a/game_re/binders/gh_base.h b/game_re/binders/gh_base.h index ed8e8a14..598a0a3f 100644 --- a/game_re/binders/gh_base.h +++ b/game_re/binders/gh_base.h @@ -5,15 +5,36 @@ #include #else #include "../win32_shim.h" -#include -#include #endif #include #include #include // Fallback to int if type is not annotated -typedef unsigned char undefined; +struct undefined { + size_t _0; + undefined(int i) { + *this = i; + } + undefined(uint32_t i) { + *this = i; + } + undefined(void* i) { + reinterpret_cast(_0) = i; + } + undefined(uint64_t i) { + *this = i; + } + undefined() = default; + template operator T&() { + static_assert(sizeof(T) <= sizeof(_0), "Invalid assignment"); + return reinterpret_cast(_0); + } + template T& operator=(const T &other) { + static_assert(sizeof(T) <= sizeof(_0), "Invalid assignment"); + return reinterpret_cast(_0) = other; + } +}; typedef uint32_t undefined4; typedef uint16_t undefined2; struct undefined3 { diff --git a/game_re/binders/gh_global_binder.h b/game_re/binders/gh_global_binder.h index 39dcb680..3332c038 100644 --- a/game_re/binders/gh_global_binder.h +++ b/game_re/binders/gh_global_binder.h @@ -2,7 +2,7 @@ #define EDBE48FC_B879_4985_9274_B7ACF24AD024 #include "gh_base.h" -#include "gh_structs.h" +#include "gh_types.h" #include "gh_static_mem.h" #endif /* EDBE48FC_B879_4985_9274_B7ACF24AD024 */ diff --git a/game_re/gh_global.cxx b/game_re/gh_global.cxx index 2088e0d6..8fff4255 100644 --- a/game_re/gh_global.cxx +++ b/game_re/gh_global.cxx @@ -1,5 +1,76 @@ // AUTO-GENERATED FILE #include -undefined module0_id= (undefined&) GH_MEM(0x005bf5fc); -int DAT_005bf600= (int&) GH_MEM(0x005bf600); -undefined4 DAT_007edda0= (undefined4&) GH_MEM(0x007edda0); +const char* s__s_not_initialized__005b63e0 = "%s not initialized."; // 005b63e0 +const char* s_Please_run_the__s_setup__005b63f4 = "Please run the %s setup."; // 005b63f4 +char(&s_dashCC)[4] = *reinterpret_cast(GH_MEM(0x005b6410)); +const char* s_Gli_Mode_005b6414 = "Gli_Mode"; // 005b6414 +const char* s_Identifier_005b6420 = "Identifier"; // 005b6420 +const char* s_Check_your_version_of_DirectX__V_005b6430 = "Check your version of DirectX. Version 8.1 or higher is required."; // 005b6430 +const char* lpText_005b6478 = "ᅵberprfen Sie, welche DirectX-Version auf Ihrem PC derzeit installiert ist. Sie ben￶tigen DirectX 8.1 oder h￶her."; // 005b6478 +const char* lpText_005b64f0 = "Controlla la tua versione di DirectX. ￈ necessaria la versione 8.1 o superiore."; // 005b64f0 +const char* lpText_005b6540 = "Comprueba tu versi￳n de DirectX. Se necesita la versi￳n 8.1 o superior."; // 005b6540 +const char* s_Rayman_3_005b6588 = "Rayman 3"; // 005b6588 +const char* lpText_005b6598 = "V←rifiez votre version de DirectX. La version 8.1 minimum est n←cessaire."; // 005b6598 +const char* s_Erreur_Rayman_3_005b65e4 = "Erreur Rayman 3 "; // 005b65e4 +const char* s_dpnhpast_dll_005b65f8 = "dpnhpast.dll"; // 005b65f8 +const char* s_DRAWSEM_005b6608 = "DRAWSEM"; // 005b6608 +const char* s_Restoring_data_____005b6610 = "Restoring data ..."; // 005b6610 +char(&s_QUIT)[8] = *reinterpret_cast(GH_MEM(0x005b6624)); +const char* s_or_press_ESC_to_quit_Rayman_3__005b662c = "or press ESC to quit Rayman 3."; // 005b662c +const char* s__s___Restoring_data____005b664c = "%s - Restoring data..."; // 005b664c +const char* s_Daten_Reparatur____005b6664 = "Daten-Reparatur..."; // 005b6664 +undefined s_BEENDIGEN_005b6678= (undefined&) GH_MEM(0x005b6678); +undefined2 DAT_005b6684= (undefined2&) GH_MEM(0x005b6684); +const char* s__s___Daten_Reparatur____005b66ac = "%s - Daten-Reparatur..."; // 005b66ac +const char* s_German_005b66c4 = "German"; // 005b66c4 +const char* s_Ripristino_dati____005b66cc = "Ripristino dati..."; // 005b66cc +const char* s__s___Pausa_005b66e0 = "%s - Pausa"; // 005b66e0 +undefined s_USCIRE_005b66ec= (undefined&) GH_MEM(0x005b66ec); +const char* s_Premi_ESC_per_uscire_da_Rayman_3_005b66f4 = "Premi ESC per uscire da Rayman 3."; // 005b66f4 +const char* s__s___Ripristino_dati____005b6718 = "%s - Ripristino dati..."; // 005b6718 +const char* s_Italian_005b6730 = "Italian"; // 005b6730 +const char* s_Restablecer_datos____005b6738 = "Restablecer datos..."; // 005b6738 +const char* s__s___Rotura_005b6750 = "%s - Rotura"; // 005b6750 +undefined s_SALIR_005b675c= (undefined&) GH_MEM(0x005b675c); +const char* s_Pulsa_ESC_para_salir_Rayman_3__005b6764 = "Pulsa ESC para salir Rayman 3."; // 005b6764 +const char* s__s___Restablecer_datos____005b6784 = "%s - Restablecer datos..."; // 005b6784 +const char* s_Spanish_005b67a0 = "Spanish"; // 005b67a0 +const char* s_Restauration = "Restauration des donn←es..."; // 005b67a8 +const char* s__s___Pause_005b67c4 = "%s - Pause"; // 005b67c4 +const char* s_ou_appuyez_sur_Echap_pour_quitte_005b67d0 = "ou appuyez sur Echap pour quitter Rayman 3."; // 005b67d0 +char(&s_QUITTER)[8] = *reinterpret_cast(GH_MEM(0x005b67fc)); +const char* s_Restauration_fmt = "%s - Restauration des donn←es..."; // 005b6804 +const char* s_French_005b6828 = "French"; // 005b6828 +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 +const char* s_SOFTWARE_UBI_SOFT_RAYMAN_3_005b6864 = "SOFTWARE\\UBI SOFT\\RAYMAN 3"; // 005b6864 +const char* s_Unable_to_find_R3_Setup_DX8_exe__005b6880 = "Unable to find R3_Setup_DX8.exe. Please reinstall the game."; // 005b6880 +const char* s_Rayman_3_Error_005b68bc = "Rayman 3 Error"; // 005b68bc +const char* fopen_mode_r_binary = "rb"; // 005b68cc +const char* s__R3_Setup_DX8_exe_005b68d0 = "\\R3_Setup_DX8.exe"; // 005b68d0 +const char* s_Adapter_005b68e4 = "Adapter"; // 005b68e4 +const char* fopen_mode_r_text = "rt"; // 005b68ec +const char* lpAppName_005b68f0 = "Rayman3"; // 005b68f0 +const char* s_Directory_005b68f8 = "Directory"; // 005b68f8 +const char* s_None = "None"; // 005b6904 +const char* s_UbiSoft_Ubi_ini = "/UbiSoft/Ubi.ini"; // 005b690c +long lpDefault_005cf96c= (long&) GH_MEM(0x005cf96c); +r3_main_data r3_main_data_005d28b6= (r3_main_data&) GH_MEM(0x005d28b6); +uint hasGLIMode= (uint&) GH_MEM(0x0077d0a8); +undefined4 g_engineRunning= (undefined4&) GH_MEM(0x0077d0b4); +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)); +HINSTANCE g_hinstance= (HINSTANCE&) GH_MEM(0x0077d4c0); +HWND g_gameHWND= (HWND&) GH_MEM(0x0077d4c4); +HANDLE g_mainThreadHandle= (HANDLE&) GH_MEM(0x0077d4c8); +char(&g_appCmdLine)[256] = *reinterpret_cast(GH_MEM(0x0077d4e0)); +char(&s_wndStrRestoring)[256] = *reinterpret_cast(GH_MEM(0x0077d5e0)); +undefined2 DAT_007825c0= (undefined2&) GH_MEM(0x007825c0); +char(&s_wndStrQuiting)[56] = *reinterpret_cast(GH_MEM(0x00782600)); +uint DAT_007d9cc4= (uint&) GH_MEM(0x007d9cc4); diff --git a/game_re/gh_global.h b/game_re/gh_global.h index 8c5af587..38cbabb4 100644 --- a/game_re/gh_global.h +++ b/game_re/gh_global.h @@ -5,7 +5,78 @@ #include -extern undefined& module0_id; // 005bf5fc -extern int& DAT_005bf600; // 005bf600 -extern undefined4& DAT_007edda0; // 007edda0 +extern const char* s__s_not_initialized__005b63e0; // 005b63e0 +extern const char* s_Please_run_the__s_setup__005b63f4; // 005b63f4 +extern char(&s_dashCC)[4]; // 005b6410 +extern const char* s_Gli_Mode_005b6414; // 005b6414 +extern const char* s_Identifier_005b6420; // 005b6420 +extern const char* s_Check_your_version_of_DirectX__V_005b6430; // 005b6430 +extern const char* lpText_005b6478; // 005b6478 +extern const char* lpText_005b64f0; // 005b64f0 +extern const char* lpText_005b6540; // 005b6540 +extern const char* s_Rayman_3_005b6588; // 005b6588 +extern const char* lpText_005b6598; // 005b6598 +extern const char* s_Erreur_Rayman_3_005b65e4; // 005b65e4 +extern const char* s_dpnhpast_dll_005b65f8; // 005b65f8 +extern const char* s_DRAWSEM_005b6608; // 005b6608 +extern const char* s_Restoring_data_____005b6610; // 005b6610 +extern char(&s_QUIT)[8]; // 005b6624 +extern const char* s_or_press_ESC_to_quit_Rayman_3__005b662c; // 005b662c +extern const char* s__s___Restoring_data____005b664c; // 005b664c +extern const char* s_Daten_Reparatur____005b6664; // 005b6664 +extern undefined& s_BEENDIGEN_005b6678; // 005b6678 +extern undefined2& DAT_005b6684; // 005b6684 +extern const char* s__s___Daten_Reparatur____005b66ac; // 005b66ac +extern const char* s_German_005b66c4; // 005b66c4 +extern const char* s_Ripristino_dati____005b66cc; // 005b66cc +extern const char* s__s___Pausa_005b66e0; // 005b66e0 +extern undefined& s_USCIRE_005b66ec; // 005b66ec +extern const char* s_Premi_ESC_per_uscire_da_Rayman_3_005b66f4; // 005b66f4 +extern const char* s__s___Ripristino_dati____005b6718; // 005b6718 +extern const char* s_Italian_005b6730; // 005b6730 +extern const char* s_Restablecer_datos____005b6738; // 005b6738 +extern const char* s__s___Rotura_005b6750; // 005b6750 +extern undefined& s_SALIR_005b675c; // 005b675c +extern const char* s_Pulsa_ESC_para_salir_Rayman_3__005b6764; // 005b6764 +extern const char* s__s___Restablecer_datos____005b6784; // 005b6784 +extern const char* s_Spanish_005b67a0; // 005b67a0 +extern const char* s_Restauration; // 005b67a8 +extern const char* s__s___Pause_005b67c4; // 005b67c4 +extern const char* s_ou_appuyez_sur_Echap_pour_quitte_005b67d0; // 005b67d0 +extern char(&s_QUITTER)[8]; // 005b67fc +extern const char* s_Restauration_fmt; // 005b6804 +extern const char* s_French_005b6828; // 005b6828 +extern char(&s_windowTitle)[12]; // 005b6830 +extern char(&s_percents)[4]; // 005b683c +extern const char* s_Language_005b6840; // 005b6840 +extern const char* s_English_005b684c; // 005b684c +extern const char* s_CompleteInstall_005b6854; // 005b6854 +extern const char* s_SOFTWARE_UBI_SOFT_RAYMAN_3_005b6864; // 005b6864 +extern const char* s_Unable_to_find_R3_Setup_DX8_exe__005b6880; // 005b6880 +extern const char* s_Rayman_3_Error_005b68bc; // 005b68bc +extern const char* fopen_mode_r_binary; // 005b68cc +extern const char* s__R3_Setup_DX8_exe_005b68d0; // 005b68d0 +extern const char* s_Adapter_005b68e4; // 005b68e4 +extern const char* fopen_mode_r_text; // 005b68ec +extern const char* lpAppName_005b68f0; // 005b68f0 +extern const char* s_Directory_005b68f8; // 005b68f8 +extern const char* s_None; // 005b6904 +extern const char* s_UbiSoft_Ubi_ini; // 005b690c +extern long& lpDefault_005cf96c; // 005cf96c +extern r3_main_data& r3_main_data_005d28b6; // 005d28b6 +extern uint& hasGLIMode; // 0077d0a8 +extern undefined4& g_engineRunning; // 0077d0b4 +extern HANDLE& g_drawSemaphore; // 0077d0bc +extern char(&g_mutexName_Rayman3)[256]; // 0077d0c0 +extern char(&g_windowTitle)[256]; // 0077d1c0 +extern char(&lpString_0077d2c0)[256]; // 0077d2c0 +extern char(&s_windowTitleRestoring)[256]; // 0077d3c0 +extern HINSTANCE& g_hinstance; // 0077d4c0 +extern HWND& g_gameHWND; // 0077d4c4 +extern HANDLE& g_mainThreadHandle; // 0077d4c8 +extern char(&g_appCmdLine)[256]; // 0077d4e0 +extern char(&s_wndStrRestoring)[256]; // 0077d5e0 +extern undefined2& DAT_007825c0; // 007825c0 +extern char(&s_wndStrQuiting)[56]; // 00782600 +extern uint& DAT_007d9cc4; // 007d9cc4 #endif // GH_GENERATED_GLOBALS_H diff --git a/game_re/gh_types.h b/game_re/gh_types.h index a1261129..180a22bb 100644 --- a/game_re/gh_types.h +++ b/game_re/gh_types.h @@ -156,12 +156,6 @@ struct _SND_tdstFormat { typedef struct _SND_tdstInitStruct _SND_tdstInitStruct, *P_SND_tdstInitStruct; -typedef struct HINSTANCE__ *HINSTANCE; - -typedef struct HWND__ *HWND; - -typedef void *HANDLE; - struct _SND_tdstInitStruct { HINSTANCE hProcessInstance; HWND hMainWindow; @@ -591,8 +585,6 @@ typedef struct r3_engine r3_engine, *Pr3_engine; typedef unsigned int uint; typedef uint uint32_t; -typedef unsigned char undefined; - struct r3_engine { uint32_t initMask; /* isRunning? */ undefined field1_0x4; diff --git a/game_re/type_blacklist.txt b/game_re/type_blacklist.txt index abbb102c..7b0d83dd 100644 --- a/game_re/type_blacklist.txt +++ b/game_re/type_blacklist.txt @@ -1,3 +1,7 @@ +undefined +HINSTANCE +HWND +HANDLE ANON_OBJECT_HEADER ARRAY_INFO AsyncIAdviseSink @@ -1917,4 +1921,4 @@ DOUBLE _stati64 _stat _strflt -_tiddata \ No newline at end of file +_tiddata diff --git a/game_re/win32_shim.h b/game_re/win32_shim.h index c81c878c..7b431416 100644 --- a/game_re/win32_shim.h +++ b/game_re/win32_shim.h @@ -55,6 +55,7 @@ inline void GetWindowsDirectoryA(char* lpBuffer, DWORD nSize) { inline LPSTR GetCommandLineA() { // TODO + return const_cast(""); } inline void GetPrivateProfileStringA(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpBuffer, DWORD nSize, LPCSTR lpFileName) { @@ -67,14 +68,22 @@ inline void MessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) inline LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, DWORD samDesired, PHKEY phkResult) { // TODO + return -1; } inline LSTATUS RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData) { // TODO + return -1; } inline LSTATUS RegCloseKey(HKEY hKey) { // TODO + return -1; +} + +inline DWORD GetCurrentThreadId() { + // TODO + return 0; } #endif /* F69A0336_B517_4804_B49B_F4FBE6691DDB */ diff --git a/scripts/re3lib/FunctionDumper.java b/scripts/re3lib/FunctionDumper.java index 2eb7ef45..0d1a5cf8 100644 --- a/scripts/re3lib/FunctionDumper.java +++ b/scripts/re3lib/FunctionDumper.java @@ -209,7 +209,8 @@ public class FunctionDumper { Function calledFunction = script.getFunctionAt(callAddr); if (calledFunction != null) { if (isValidFunction(calledFunction)) { - headers.add("extern " + calledFunction.getSignature().getPrototypeString(true) + String proto = calledFunction.getSignature().getPrototypeString(false); + headers.add("extern " + proto + "; // " + calledFunction.getEntryPoint() + " // " + calledFunction.getName()); } diff --git a/scripts/re3lib/GlobalDumper.java b/scripts/re3lib/GlobalDumper.java index e5eb4172..64a2deda 100644 --- a/scripts/re3lib/GlobalDumper.java +++ b/scripts/re3lib/GlobalDumper.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileReader; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.Dictionary; import java.util.HashMap; @@ -173,8 +174,10 @@ public class GlobalDumper { public void saveGlobalManifest() throws Exception { try (PrintWriter writer = new PrintWriter(manifestFile)) { script.println("Saving global manifest to " + manifestFile); - for (Map.Entry entry : globalAddrs.entrySet()) { - writer.println(entry.getKey().toString() + " || " + entry.getValue().name + " || " + entry.getValue().type.getDisplayName()); + GlobalRec[] globals = globalAddrs.values().toArray(new GlobalRec[0]); + Arrays.sort(globals, (a, b) -> a.address.compareTo(b.address)); + for (GlobalRec global : globals) { + writer.println(global.address.toString() + " || " + global.name + " || " + global.type.getDisplayName()); } } }