From 619f3c36dc577fd483fd9aacb480e895529ae8ee Mon Sep 17 00:00:00 2001 From: Guus Waals <_@guusw.nl> Date: Mon, 23 Sep 2024 02:21:50 +0800 Subject: [PATCH] WIP --- game_re/CMakeLists.txt | 9 +- game_re/binders/gh_auto_binder.h | 42 ++- game_re/binders/gh_base.h | 15 +- game_re/function_blacklist.txt | 5 +- game_re/gh_fix/r3_main.cxx | 418 ++++++++++++++++++++++++++++ game_re/gh_global.cxx | 91 +++--- game_re/gh_global.h | 91 +++--- game_re/gh_structs.h | 82 +++++- game_re/type_blacklist.txt | 33 ++- scripts/Decompile.java | 117 +++++--- scripts/re3lib/RecompileConfig.java | 4 + 11 files changed, 754 insertions(+), 153 deletions(-) create mode 100644 game_re/gh_fix/r3_main.cxx diff --git a/game_re/CMakeLists.txt b/game_re/CMakeLists.txt index 968f279a..e2df4622 100644 --- a/game_re/CMakeLists.txt +++ b/game_re/CMakeLists.txt @@ -1,3 +1,7 @@ +# Build for 32-bit compatibility +add_compile_options(-m32) +add_link_options(-m32) + add_subdirectory(third_party/spdlog) add_executable(game_re @@ -18,7 +22,10 @@ if(WIN32) ) endif() -# target_compile_options(game_re PRIVATE "-H") +target_compile_definitions(game_re PRIVATE + _CRT_SECURE_NO_WARNINGS=1 + _CRT_NONSTDC_NO_WARNINGS=1) + target_link_libraries(game_re PRIVATE spdlog) file(GLOB GH_AUTO_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gh_auto/*.cxx) diff --git a/game_re/binders/gh_auto_binder.h b/game_re/binders/gh_auto_binder.h index 4ab1983b..3b738cba 100644 --- a/game_re/binders/gh_auto_binder.h +++ b/game_re/binders/gh_auto_binder.h @@ -6,30 +6,28 @@ #include "gh_structs.h" #include "gh_global.h" -template -struct Field { +#include +#include + +template struct Field {}; + +template struct _FieldBinderSizeTraits { + using type = undefined; +}; +template <> struct _FieldBinderSizeTraits<4> { + using type = undefined4; +}; +template <> struct _FieldBinderSizeTraits<2> { + using type = undefined2; +}; +template <> struct _FieldBinderSizeTraits<3> { + using type = undefined3; }; -template -struct _FieldBinderSizeTraits { - using type = undefined; -}; -template<> -struct _FieldBinderSizeTraits<4> { - using type = undefined4; -}; -template<> -struct _FieldBinderSizeTraits<2> { - using type = undefined2; -}; -template<> -struct _FieldBinderSizeTraits<3> { - using type = undefined3; -}; - -template -inline uint32_t& operator+(const char* str, Field offset) { - return *(_FieldBinderSizeTraits*)(str + offset); +template +inline typename _FieldBinderSizeTraits::type & +operator+(const void *str, Field offset) { + return *reinterpret_cast::type *>((uint8_t *)str + offset); } #endif /* B8D59B54_1674_4C0F_AA2C_611385FF5D03 */ diff --git a/game_re/binders/gh_base.h b/game_re/binders/gh_base.h index 9fe1225b..ed8e8a14 100644 --- a/game_re/binders/gh_base.h +++ b/game_re/binders/gh_base.h @@ -13,13 +13,13 @@ #include // Fallback to int if type is not annotated -// typedef int64_t undefined; +typedef unsigned char undefined; typedef uint32_t undefined4; typedef uint16_t undefined2; struct undefined3 { - uint8_t _0; - uint8_t _1; - uint8_t _2; + uint8_t _0; + uint8_t _1; + uint8_t _2; }; typedef unsigned char byte; typedef byte undefined1; @@ -28,4 +28,11 @@ typedef void *pointer; typedef char *TerminatedCString; typedef char *string; +enum R3ModuleId : uint8_t { + R3ModId_unk = 0x00, + R3ModId_not_initialized = 0xff, +}; + +// Can not export enums for some reason + #endif /* A523F6DB_0645_4DEB_8AEB_3792CB732B49 */ diff --git a/game_re/function_blacklist.txt b/game_re/function_blacklist.txt index 9bf73a49..8220c792 100644 --- a/game_re/function_blacklist.txt +++ b/game_re/function_blacklist.txt @@ -72,7 +72,6 @@ 005514f0 // FUN_005514f0 00405ee2 // malloc? 00409ce2 // FUN_00409ce2 -004028e0 // FUN_004028e0 004052e0 // __aullrem 0055268a // FUN_0055268a 0040709e // FUN_0040709e @@ -201,4 +200,6 @@ 004029b2 // _execv 00402a78 // fopen 00408d30 // strcmp -0054c925 // _chdir \ No newline at end of file +0054c925 // _chdir +0054bce5 // strlwr +00402960 // sprintf \ No newline at end of file diff --git a/game_re/gh_fix/r3_main.cxx b/game_re/gh_fix/r3_main.cxx new file mode 100644 index 00000000..c9fa37a5 --- /dev/null +++ b/game_re/gh_fix/r3_main.cxx @@ -0,0 +1,418 @@ +// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! + +#include +#include "../gh_global.h" + +extern undefined r3_initEngine(void); // 00401220 // r3_initEngine +extern undefined r3_module0_init(void); // 00401000 // r3_module0_init +extern uint32_t __stdcall r3_containsCmdLine( + uint *param_1, char *param_2); // 004028e0 // r3_containsCmdLine +extern undefined FUN_004010b0(void); // 004010b0 // FUN_004010b0 +extern undefined FUN_004464f0(void); // 004464f0 // FUN_004464f0 +extern undefined FUN_00503710(void); // 00503710 // FUN_00503710 +extern undefined __stdcall r3_setupWindow( + HINSTANCE hInstance, undefined4 param_2, + undefined4 param_3); // 00402140 // r3_setupWindow +extern undefined FUN_00401320(void); // 00401320 // FUN_00401320 +extern undefined spawnThread(void); // 004477d0 // spawnThread +extern undefined FUN_005038e0(void); // 005038e0 // FUN_005038e0 +extern undefined FUN_004fb300(void); // 004fb300 // FUN_004fb300 +extern void __stdcall g_setInitVar0(void); // 00401310 // g_setInitVar0 +extern void __stdcall r3_noop(void *p_cTxt1, + void *p_cTxt2); // 00401100 // r3_noop +extern undefined gfx_init2(void); // 00470be0 // gfx_init2 +extern undefined4 __cdecl r3_get_gli_width( + void); // 0047baf0 // r3_get_gli_width +extern undefined FUN_00472150(void); // 00472150 // FUN_00472150 +extern undefined FUN_00470db0(void); // 00470db0 // FUN_00470db0 +extern int __cdecl r3_get_gli_height(void); // 0047bb00 // r3_get_gli_height +extern undefined FUN_0043e540(undefined4 param_1, undefined4 param_2, + undefined4 param_3); // 0043e540 // FUN_0043e540 +extern undefined FUN_004725a0(void); // 004725a0 // FUN_004725a0 + +// 00401630 + +int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR *cmdline, + int showCmd) + +{ + char cVar1; + undefined4 uVar2; + undefined4 uVar3; + undefined4 uVar4; + undefined2 uVar5; + undefined2 uVar6; + LPSTR pCVar7; + char *pcVar8; + FILE *file; + LONG LVar9; + HMODULE hLibModule; + DWORD DVar10; + HANDLE hTargetProcessHandle; + HANDLE hSourceHandle; + HANDLE hSourceProcessHandle; + LPSTR *ppCVar11; + uint32_t hasCCarg; + HWND hWnd; + int iVar12; + int iVar13; + int iVar14; + int iVar15; + uint uVar16; + void *unaff_ESI; + undefined4 *puVar17; + void *unaff_EDI; + undefined4 *puVar18; + char *pcVar19; + HANDLE *lpTargetHandle; + BOOL BVar20; + DWORD dwOptions; + tagRECT *lpRect; + undefined4 uStack_83c; + HKEY pHStack_838; + HANDLE pvStack_834; + UINT UStack_830; + BYTE aBStack_82c[4]; + DWORD DStack_828; + DWORD DStack_824; + tagRECT tStack_820; + char acStack_810[260]; + CHAR languageStr[256]; + CHAR pathToUbi_ini[260]; + char acStack_508[260]; + CHAR windowsDir[260]; + char acStack_300[256]; + char acStack_200[256]; + char acStack_100[256]; + + /* Append windows dir / ubi.ini */ + GetWindowsDirectoryA(pathToUbi_ini, 0x104); + iVar15 = -1; + pcVar8 = pathToUbi_ini; + do { + pcVar19 = pcVar8; + if (iVar15 == 0) + break; + iVar15 = iVar15 + -1; + pcVar19 = pcVar8 + 1; + cVar1 = *pcVar8; + pcVar8 = pcVar19; + } while (cVar1 != '\0'); + *(undefined4 *)(pcVar19 + -1) = s_UbiSoft_Ubi_ini + Field<0, 4>(); + *(undefined4 *)(pcVar19 + 3) = s_UbiSoft_Ubi_ini + Field<4, 4>(); + *(undefined4 *)(pcVar19 + 7) = s_UbiSoft_Ubi_ini + Field<8, 4>(); + *(undefined4 *)(pcVar19 + 0xb) = s_UbiSoft_Ubi_ini + Field<12, 4>(); + pcVar19[0xf] = s_UbiSoft_Ubi_ini[0x10]; + pCVar7 = GetCommandLineA(); + pcVar8 = pCVar7 + 1; + iVar15 = -(int)pcVar8; + do { + cVar1 = *pcVar8; + pcVar8[(int)(acStack_810 + iVar15)] = cVar1; + pcVar8 = pcVar8 + 1; + } while (cVar1 != '\0'); + pcVar8 = strrchr(acStack_810, 0x5c); + if (pcVar8 == (char *)0x0) { + /* Read from ubi.ini */ + GetPrivateProfileStringA(lpAppName_005b68f0, s_Directory_005b68f8, s_None, + acStack_810, 0xff, pathToUbi_ini); + iVar15 = strcmpi(acStack_810, s_None); + } else { + pcVar8 = strrchr(acStack_810, 0x5c); + *pcVar8 = '\0'; + iVar15 = chdir(acStack_810); + if (iVar15 != -1) + goto LAB_00401765; + /* Read from ubi.ini */ + GetPrivateProfileStringA(lpAppName_005b68f0, s_Directory_005b68f8, s_None, + acStack_810, 0xff, pathToUbi_ini); + iVar15 = strcmpi(acStack_810, s_None); + } + if (iVar15 != 0) { + chdir(acStack_810); + } +LAB_00401765: + /* strcpy */ + iVar15 = 0; + do { + cVar1 = acStack_810[iVar15]; + r3_main_data_005d28b6.gameDataDir[iVar15] = cVar1; + iVar15 = iVar15 + 1; + } while (cVar1 != '\0'); + strlwr(r3_main_data_005d28b6.gameDataDir); + iVar15 = -1; + pcVar8 = r3_main_data_005d28b6.gameDataDir; + do { + if (iVar15 == 0) + break; + iVar15 = iVar15 + -1; + cVar1 = *pcVar8; + pcVar8 = pcVar8 + 1; + } while (cVar1 != '\0'); +joined_r0x00401792: + if (iVar15 != -2) { + uVar16 = 0xffffffff; + pcVar8 = r3_main_data_005d28b6.gameDataDir; + do { + if (uVar16 == 0) + break; + uVar16 = uVar16 - 1; + cVar1 = *pcVar8; + pcVar8 = pcVar8 + 1; + } while (cVar1 != '\0'); + if (r3_main_data_005d28b6.gameDataDir[~uVar16 - 2] != '\\') + goto LAB_004017ce; + uVar16 = 0xffffffff; + pcVar8 = r3_main_data_005d28b6.gameDataDir; + do { + if (uVar16 == 0) + break; + uVar16 = uVar16 - 1; + cVar1 = *pcVar8; + pcVar8 = pcVar8 + 1; + } while (cVar1 != '\0'); + r3_main_data_005d28b6.gameDataDir[~uVar16 - 2] = '\0'; + iVar15 = -1; + pcVar8 = r3_main_data_005d28b6.gameDataDir; + do { + if (iVar15 == 0) + break; + iVar15 = iVar15 + -1; + cVar1 = *pcVar8; + pcVar8 = pcVar8 + 1; + } while (cVar1 != '\0'); + goto joined_r0x00401792; + } +LAB_004017ce: + file = fopen(pathToUbi_ini, fopen_mode_r_text); + GetPrivateProfileStringA(lpAppName_005b68f0, s_Adapter_005b68e4, + (LPCSTR)&lpDefault_005cf96c, acStack_300, 0xff, + pathToUbi_ini); + if ((file == (FILE *)0x0) || (acStack_300[0] == '\0')) { + /* Concat game data dir with r3 setup exe */ + iVar15 = 0; + do { + cVar1 = r3_main_data_005d28b6.gameDataDir[iVar15]; + acStack_508[iVar15] = cVar1; + iVar15 = iVar15 + 1; + } while (cVar1 != '\0'); + iVar15 = -1; + pcVar8 = acStack_508; + do { + pcVar19 = pcVar8; + if (iVar15 == 0) + break; + iVar15 = iVar15 + -1; + pcVar19 = pcVar8 + 1; + cVar1 = *pcVar8; + pcVar8 = pcVar19; + } while (cVar1 != '\0'); + *(undefined4 *)(pcVar19 + -1) = + s__R3_Setup_DX8_exe_005b68d0 + Field<0, 4>(); + *(undefined4 *)(pcVar19 + 3) = s__R3_Setup_DX8_exe_005b68d0 + Field<4, 4>(); + *(undefined4 *)(pcVar19 + 7) = s__R3_Setup_DX8_exe_005b68d0 + Field<8, 4>(); + *(undefined4 *)(pcVar19 + 0xb) = + s__R3_Setup_DX8_exe_005b68d0 + Field<12, 4>(); + *(undefined2 *)(pcVar19 + 0xf) = 0; + auto &q = (s__R3_Setup_DX8_exe_005b68d0 + Field<16, 2>()); + file = fopen(acStack_508, fopen_mode_r_binary); + if (file == (FILE *)0x0) { + MessageBoxA((HWND)0x0, s_Unable_to_find_R3_Setup_DX8_exe__005b6880, + s_Rayman_3_Error_005b68bc, 0x10); + return -1; + } + fclose(file); + spawnl(0, acStack_508, acStack_508, 0); + file = fopen(pathToUbi_ini, fopen_mode_r_text); + if (file == (FILE *)0x0) { + return -1; + } + } + fclose(file); + /* Open reg key + HKEY_LOCAL_MACHINE\\SOFTWARE\\UBI SOFT\\RAYMAN 3 */ + LVar9 = RegOpenKeyExA((HKEY)0x80000002, s_SOFTWARE_UBI_SOFT_RAYMAN_3_005b6864, + 0, 0x20019, &pHStack_838); + if (LVar9 == 0) { + LVar9 = + RegQueryValueExA(pHStack_838, s_CompleteInstall_005b6854, (LPDWORD)0x0, + &DStack_824, aBStack_82c, &DStack_828); + DAT_007d9cc4 = (uint)(LVar9 == 0); + if (pHStack_838 != (HKEY)0x0) { + RegCloseKey(pHStack_838); + } + } else { + DAT_007d9cc4 = 0; + } + GetPrivateProfileStringA(lpAppName_005b68f0, s_Language_005b6840, + s_English_005b684c, languageStr, 0xff, + pathToUbi_ini); + sprintf(g_mutexName_Rayman3, s_percents, lpAppName_005b68f0); + sprintf(g_windowTitle, s_percents, s_windowTitle); + /* Setup localized quiting/restoring strings */ + sprintf(s_windowTitleRestoring, s__s___Restoring_data____005b664c, + s_windowTitle); + uVar2 = s_QUIT + Field<0, 4>(); + puVar17 = (undefined4 *)s_or_press_ESC_to_quit_Rayman_3__005b662c; + puVar18 = (undefined4 *)&DAT_007825c0; + for (iVar15 = 7; cVar1 = s_QUIT[4], iVar15 != 0; iVar15 = iVar15 + -1) { + *puVar18 = *puVar17; + puVar17 = puVar17 + 1; + puVar18 = puVar18 + 1; + } + *(undefined2 *)puVar18 = *(undefined2 *)puVar17; + *(undefined *)((int)puVar18 + 2) = *(undefined *)((int)puVar17 + 2); + strcpy(s_wndStrQuiting, s_QUIT); + sprintf(lpString_0077d2c0, s__s___Pause_005b67c4, s_windowTitle); + strcpy(s_wndStrRestoring, s_Restoring_data_____005b6610); + /* Create draw semaphore + Initial count = 1 + Maximum count = 1 */ + g_drawSemaphore = + CreateSemaphoreA((LPSECURITY_ATTRIBUTES)0x0, 1, 1, s_DRAWSEM_005b6608); + if (hPrevInstance != (HINSTANCE)0x0) { + return -1; + } + /* Load DirectPlay probably unused */ + hLibModule = LoadLibraryA(s_dpnhpast_dll_005b65f8); + if (hLibModule == (HMODULE)0x0) { + iVar15 = strcmpi(languageStr, s_French_005b6828); + if (iVar15 == 0) { + MessageBoxA((HWND)0x0, lpText_005b6598, s_Erreur_Rayman_3_005b65e4, 0x10); + return -1; + } + iVar15 = strcmpi(languageStr, s_Spanish_005b67a0); + if (iVar15 == 0) { + MessageBoxA((HWND)0x0, lpText_005b6540, s_Rayman_3_005b6588, 0x10); + return -1; + } + iVar15 = strcmpi(languageStr, s_Italian_005b6730); + if (iVar15 == 0) { + MessageBoxA((HWND)0x0, lpText_005b64f0, s_Rayman_3_005b6588, 0x10); + return -1; + } + iVar15 = strcmpi(languageStr, s_German_005b66c4); + if (iVar15 != 0) { + MessageBoxA((HWND)0x0, s_Check_your_version_of_DirectX__V_005b6430, + s_Rayman_3_Error_005b68bc, 0x10); + return -1; + } + MessageBoxA((HWND)0x0, lpText_005b6478, s_Rayman_3_005b6588, 0x10); + return -1; + } + FreeLibrary(hLibModule); + CreateMutexA((LPSECURITY_ATTRIBUTES)0x0, 1, g_mutexName_Rayman3); + DVar10 = GetLastError(); + if (DVar10 == 0xb7) { + /* Mutex already exists */ + return -1; + } + GetWindowsDirectoryA(windowsDir, 0x104); + iVar15 = -1; + /* Append ubi.ini */ + pcVar8 = windowsDir; + do { + pcVar19 = pcVar8; + if (iVar15 == 0) + break; + iVar15 = iVar15 + -1; + pcVar19 = pcVar8 + 1; + cVar1 = *pcVar8; + pcVar8 = pcVar19; + } while (cVar1 != '\0'); + *(undefined4 *)(pcVar19 + -1) = s_UbiSoft_Ubi_ini + Field<0, 4>(); + *(undefined4 *)(pcVar19 + 3) = s_UbiSoft_Ubi_ini + Field<4, 4>(); + *(undefined4 *)(pcVar19 + 7) = s_UbiSoft_Ubi_ini + Field<8, 4>(); + *(undefined4 *)(pcVar19 + 0xb) = s_UbiSoft_Ubi_ini + Field<12, 4>(); + pcVar19[0xf] = s_UbiSoft_Ubi_ini[0x10]; + /* Read graphics settings */ + GetPrivateProfileStringA(lpAppName_005b68f0, s_Adapter_005b68e4, + (LPCSTR)&lpDefault_005cf96c, acStack_300, 0xff, + windowsDir); + GetPrivateProfileStringA(lpAppName_005b68f0, s_Identifier_005b6420, + (LPCSTR)&lpDefault_005cf96c, acStack_100, 0xff, + windowsDir); + GetPrivateProfileStringA(lpAppName_005b68f0, s_Gli_Mode_005b6414, + (LPCSTR)&lpDefault_005cf96c, acStack_200, 0xff, + windowsDir); + /* If they're all set */ + if (((acStack_300[0] != '\0') && (acStack_100[0] != '\0')) && + (acStack_200[0] != '\0')) { + /* always true */ + hasGLIMode = (uint)(acStack_200[0] != '0'); + FUN_004464f0(); + dwOptions = 0; + BVar20 = 0; + lpTargetHandle = &pvStack_834; + DVar10 = 0x1f03ff; + g_hinstance = hInstance; + hTargetProcessHandle = GetCurrentProcess(); + hSourceHandle = GetCurrentThread(); + hSourceProcessHandle = GetCurrentProcess(); + DuplicateHandle(hSourceProcessHandle, hSourceHandle, hTargetProcessHandle, + lpTargetHandle, DVar10, BVar20, dwOptions); + g_mainThreadHandle = pvStack_834; + /* Copy cmdline */ + ppCVar11 = cmdline; + do { + cVar1 = *(char *)ppCVar11; + *(char *)(((int)g_appCmdLine - (int)cmdline) + (int)ppCVar11) = cVar1; + ppCVar11 = (LPSTR *)((int)ppCVar11 + 1); + } while (cVar1 != '\0'); + SetErrorMode(1); + hasCCarg = r3_containsCmdLine((uint *)cmdline, s_dashCC); + if (hasCCarg == 0) { + r3_module0_init(); + iVar15 = r3_setupWindow(hInstance, showCmd, hasGLIMode); + if (iVar15 == 0) { + return -1; + } + g_setInitVar0(); + FUN_00401320(); + spawnThread(); + r3_noop(unaff_EDI, unaff_ESI); + gfx_init2(); + lpRect = &tStack_820; + hWnd = GetDesktopWindow(); + GetWindowRect(hWnd, lpRect); + BVar20 = 1; + iVar15 = r3_get_gli_height(); + iVar15 = iVar15 + 0x20; + iVar12 = r3_get_gli_width(); + iVar12 = iVar12 + 0xc; + iVar13 = r3_get_gli_height(); + iVar13 = (tStack_820.bottom - iVar13) / 2; + iVar14 = r3_get_gli_width(); + MoveWindow(g_gameHWND, (tStack_820.right - iVar14) / 2, iVar13, iVar12, + iVar15, BVar20); + FUN_004010b0(); + SystemParametersInfoA(0x10, 0, &UStack_830, 0); + SystemParametersInfoA(0x11, 0, (PVOID)0x0, 0); + ShowCursor(0); + uStack_83c = 0; + SystemParametersInfoA(0x61, 1, &uStack_83c, 0); + g_engineRunning = 1; + r3_initEngine(); + FUN_004725a0(); + FUN_005038e0(); + FUN_00503710(); + FUN_004fb300(); + FUN_00472150(); + FUN_00470db0(); + uStack_83c = 0; + SystemParametersInfoA(0x61, 0, &uStack_83c, 0); + ShowCursor(1); + SystemParametersInfoA(0x11, UStack_830, (PVOID)0x0, 0); + CloseHandle(pvStack_834); + } + return 0; + } + + // Please run the setup + sprintf(acStack_810, s_Please_run_the__s_setup__005b63f4, s_windowTitle); + sprintf(acStack_508, s__s_not_initialized__005b63e0, s_windowTitle); + // FUN_0043e540(acStack_810, acStack_508, 0); + MessageBoxA(g_gameHWND, acStack_810, acStack_508, + 0 | 0x10000); + exit(1); +} diff --git a/game_re/gh_global.cxx b/game_re/gh_global.cxx index 6fb57c62..23c0d4d0 100644 --- a/game_re/gh_global.cxx +++ b/game_re/gh_global.cxx @@ -1,93 +1,110 @@ // AUTO-GENERATED FILE #include -undefined s_QUITTER_005b67fc= (undefined&) GH_MEM(0x005b67fc); -undefined DAT_0077d5ec= (undefined&) GH_MEM(0x0077d5ec); +const char* s_R3_DVD_005be0ec = "R3_DVD"; // 005be0ec undefined s_USCIRE_005b66ec= (undefined&) GH_MEM(0x005b66ec); -const char* g_windowTitle = "Rayman III"; // 005b6830 -uint DAT_0077d0a8= (uint&) GH_MEM(0x0077d0a8); +undefined4 g_GLI_width1= (undefined4&) GH_MEM(0x007edd54); +int DAT_005bf71c= (int&) GH_MEM(0x005bf71c); +HANDLE g_mainThreadHandle= (HANDLE&) GH_MEM(0x0077d4c8); +char(&g_windowTitle)[256] = *reinterpret_cast(GH_MEM(0x0077d1c0)); +char(&s_windowTitle)[12] = *reinterpret_cast(GH_MEM(0x005b6830)); const char* s_ou_appuyez_sur_Echap_pour_quitte_005b67d0 = "ou appuyez sur Echap pour quitter Rayman 3."; // 005b67d0 +undefined3 UNK_007d9e71= (undefined3&) GH_MEM(0x007d9e71); +char(&g_mutexName_Rayman3)[256] = *reinterpret_cast(GH_MEM(0x0077d0c0)); +const char* s_Introduce_el_DVD_de_Rayman_3_en_l_005be4c0 = "Introduce el DVD de Rayman 3 en la unidad de DVD-ROM."; // 005be4c0 const char* s_SOFTWARE_UBI_SOFT_RAYMAN_3_005b6864 = "SOFTWARE\\UBI SOFT\\RAYMAN 3"; // 005b6864 undefined2 DAT_007825c0= (undefined2&) GH_MEM(0x007825c0); -char DAT_0077d5f2= (char&) GH_MEM(0x0077d5f2); -undefined DAT_0077d5f0= (undefined&) GH_MEM(0x0077d5f0); +R3ModuleId r3_module_id_ff= (R3ModuleId&) GH_MEM(0x005bd58c); const char* lpText_005b64f0 = "Controlla la tua versione di DirectX. ￈ necessaria la versione 8.1 o superiore."; // 005b64f0 const char* s_Ripristino_dati____005b66cc = "Ripristino dati..."; // 005b66cc const char* s__s___Pausa_005b66e0 = "%s - Pausa"; // 005b66e0 const char* s_CompleteInstall_005b6854 = "CompleteInstall"; // 005b6854 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_or_press_ESC_to_quit_Rayman_3__005b662c = "or press ESC to quit Rayman 3."; // 005b662c -undefined1 lpchText_0077d5e0= (undefined1&) GH_MEM(0x0077d5e0); const char* s_UbiSoft_Ubi_ini = "/UbiSoft/Ubi.ini"; // 005b690c +char(&s_QUIT)[8] = *reinterpret_cast(GH_MEM(0x005b6624)); const char* lpText_005b6540 = "Comprueba tu versi￳n de DirectX. Se necesita la versi￳n 8.1 o superior."; // 005b6540 const char* s_None = "None"; // 005b6904 const char* s_Rayman_3_Error_005b68bc = "Rayman 3 Error"; // 005b68bc const char* fopen_mode_r_binary = "rb"; // 005b68cc -undefined DAT_0077d5e8= (undefined&) GH_MEM(0x0077d5e8); -undefined DAT_0077d5e4= (undefined&) GH_MEM(0x0077d5e4); +const char* s__program_files_Ubi_Soft_Rayman3_005be548 = "\\program files\\Ubi Soft\\Rayman3"; // 005be548 const char* s_Adapter_005b68e4 = "Adapter"; // 005b68e4 const char* s_English_005b684c = "English"; // 005b684c +char(&s_QUITTER)[8] = *reinterpret_cast(GH_MEM(0x005b67fc)); const char* s_Italian_005b6730 = "Italian"; // 005b6730 -undefined DAT_0077d4e0= (undefined&) GH_MEM(0x0077d4e0); -undefined DAT_00782608= (undefined&) GH_MEM(0x00782608); -char DAT_00782606= (char&) GH_MEM(0x00782606); const char* s__s___Restablecer_datos____005b6784 = "%s - Restablecer datos..."; // 005b6784 const char* s_Restoring_data_____005b6610 = "Restoring data ..."; // 005b6610 -undefined DAT_00782604= (undefined&) GH_MEM(0x00782604); +char(&s_wndStrRestoring)[256] = *reinterpret_cast(GH_MEM(0x0077d5e0)); const char* s_Identifier_005b6420 = "Identifier"; // 005b6420 -undefined DAT_00782600= (undefined&) GH_MEM(0x00782600); -const char* lpText_005b6598 = "V←rifiez votre version de DirectX. La version 8.1 minimum est n←cessaire."; // 005b6598 +const char* s_Die__s_DVDROM_kann_nicht_gelesen_005be130 = "Die %s DVDROM kann nicht gelesen werden"; // 005be130 const char* s_French_005b6828 = "French"; // 005b6828 +uint hasGLIMode= (uint&) GH_MEM(0x0077d0a8); +const char* lpText_005b6598 = "V←rifiez votre version de DirectX. La version 8.1 minimum est n←cessaire."; // 005b6598 +char g_initVar0= (char&) GH_MEM(0x005cf960); undefined s_BEENDIGEN_005b6678= (undefined&) GH_MEM(0x005b6678); -undefined DAT_005b683c= (undefined&) GH_MEM(0x005b683c); +const char* s_Inserisci_il_DVD_di_Rayman_3_nel_005be484 = "Inserisci il DVD di Rayman 3 nel lettore DVD-ROM."; // 005be484 const char* s_DRAWSEM_005b6608 = "DRAWSEM"; // 005b6608 -undefined UNK_0077d5ed= (undefined&) GH_MEM(0x0077d5ed); +int DAT_005e6c50= (int&) GH_MEM(0x005e6c50); +undefined lpVolumeNameBuffer_005d27b0= (undefined&) GH_MEM(0x005d27b0); const char* s__s_not_initialized__005b63e0 = "%s not initialized."; // 005b63e0 -pointer PTR_DAT_005b6410= (pointer&) GH_MEM(0x005b6410); +undefined4 DAT_007eba20= (undefined4&) GH_MEM(0x007eba20); const char* s_Restauration_fmt = "%s - Restauration des donn←es..."; // 005b6804 const char* s__s___Rotura_005b6750 = "%s - Rotura"; // 005b6750 +HANDLE g_drawSemaphore= (HANDLE&) GH_MEM(0x0077d0bc); +undefined DAT_005be500= (undefined&) GH_MEM(0x005be500); const char* s_Please_run_the__s_setup__005b63f4 = "Please run the %s setup."; // 005b63f4 const char* s__s___Pause_005b67c4 = "%s - Pause"; // 005b67c4 +char(&s_percents)[4] = *reinterpret_cast(GH_MEM(0x005b683c)); +float FLOAT_005a9fb0= (float&) GH_MEM(0x005a9fb0); +undefined lpRootPathName_007d9e70= (undefined&) GH_MEM(0x007d9e70); const char* lpAppName_005b68f0 = "Rayman3"; // 005b68f0 uint DAT_007d9cc4= (uint&) GH_MEM(0x007d9cc4); -char UNK_0077d5f1= (char&) GH_MEM(0x0077d5f1); +const char* s__s_DVD_missing_005be0f4 = "%s DVD missing "; // 005be0f4 const char* s_Language_005b6840 = "Language"; // 005b6840 -HANDLE DAT_0077d4c8= (HANDLE&) GH_MEM(0x0077d4c8); +const char* s__c__s_005be540 = "%c:%s"; // 005be540 const char* fopen_mode_r_text = "rt"; // 005b68ec -HWND DAT_0077d4c4= (HWND&) GH_MEM(0x0077d4c4); -HINSTANCE DAT_0077d4c0= (HINSTANCE&) GH_MEM(0x0077d4c0); +char(&s_dashCC)[4] = *reinterpret_cast(GH_MEM(0x005b6410)); +uint DAT_007e5aa4= (uint&) GH_MEM(0x007e5aa4); +undefined g_perfCounterRate= (undefined&) GH_MEM(0x007e5ad8); +HINSTANCE g_hinstance= (HINSTANCE&) GH_MEM(0x0077d4c0); const char* s_Gli_Mode_005b6414 = "Gli_Mode"; // 005b6414 -HANDLE DAT_0077d0bc= (HANDLE&) GH_MEM(0x0077d0bc); -undefined UNK_0077d5e9= (undefined&) GH_MEM(0x0077d5e9); -undefined lpName_0077d0c0= (undefined&) GH_MEM(0x0077d0c0); r3_main_data r3_main_data_005d28b6= (r3_main_data&) GH_MEM(0x005d28b6); -undefined UNK_0077d5e5= (undefined&) GH_MEM(0x0077d5e5); +const char* s_R3_DVD_005bdfd8 = "R3_DVD"; // 005bdfd8 const char* s_Restauration = "Restauration des donn←es..."; // 005b67a8 const char* s__s___Daten_Reparatur____005b66ac = "%s - Daten-Reparatur..."; // 005b66ac undefined s_SALIR_005b675c= (undefined&) GH_MEM(0x005b675c); -undefined UNK_0077d5e1= (undefined&) GH_MEM(0x0077d5e1); +undefined4 g_perfCounterRateAdjusted= (undefined4&) GH_MEM(0x005e6b0c); const char* s_Daten_Reparatur____005b6664 = "Daten-Reparatur..."; // 005b6664 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* s__s___Restoring_data____005b664c = "%s - Restoring data..."; // 005b664c const char* s_Pulsa_ESC_para_salir_Rayman_3__005b6764 = "Pulsa ESC para salir Rayman 3."; // 005b6764 -char UNK_00782609= (char&) GH_MEM(0x00782609); -undefined UNK_00782605= (undefined&) GH_MEM(0x00782605); -const char* s_dpnhpast_dll_005b65f8 = "dpnhpast.dll"; // 005b65f8 +char(&g_appCmdLine)[256] = *reinterpret_cast(GH_MEM(0x0077d4e0)); +char(&s_wndStrQuiting)[56] = *reinterpret_cast(GH_MEM(0x00782600)); +undefined DAT_005be1ec= (undefined&) GH_MEM(0x005be1ec); +undefined1 DAT_005d26a8= (undefined1&) GH_MEM(0x005d26a8); +const char* s_Bitte_legen_Sie_DVD_von_Rayman_3_005be438 = "Bitte legen Sie DVD von Rayman 3 in Ihr DVD-ROM Laufwerk ein."; // 005be438 const char* s__s___Ripristino_dati____005b6718 = "%s - Ripristino dati..."; // 005b6718 -undefined UNK_00782601= (undefined&) GH_MEM(0x00782601); -undefined lpString_0077d3c0= (undefined&) GH_MEM(0x0077d3c0); +const char* s_dpnhpast_dll_005b65f8 = "dpnhpast.dll"; // 005b65f8 const char* s_Erreur_Rayman_3_005b65e4 = "Erreur Rayman 3 "; // 005b65e4 +undefined* PTR_DAT_005be568 = (undefined*)&GH_MEM(0x005be568); // 005be568 const char* s_Rayman_3_005b6588 = "Rayman 3"; // 005b6588 -undefined lpString_0077d2c0= (undefined&) GH_MEM(0x0077d2c0); +char(&lpString_0077d2c0)[256] = *reinterpret_cast(GH_MEM(0x0077d2c0)); +R3ModuleId DAT_005bd29c= (R3ModuleId&) GH_MEM(0x005bd29c); const char* s_German_005b66c4 = "German"; // 005b66c4 -undefined lpString_0077d1c0= (undefined&) GH_MEM(0x0077d1c0); -char DAT_005b6628= (char&) GH_MEM(0x005b6628); +int g_GLI_height1= (int&) GH_MEM(0x007edd58); +const char* s_Impossible_de_trouver_le_DVD_____005be238 = "Impossible de trouver le DVD : %s"; // 005be238 +undefined4 g_engineRunning= (undefined4&) GH_MEM(0x0077d0b4); const char* s_Spanish_005b67a0 = "Spanish"; // 005b67a0 -undefined4 DAT_005b6624= (undefined4&) GH_MEM(0x005b6624); +const char* s_Impossibile_trovare_il_DVD____s_005be198 = "Impossibile trovare il DVD : %s"; // 005be198 const char* s__R3_Setup_DX8_exe_005b68d0 = "\\R3_Setup_DX8.exe"; // 005b68d0 -undefined4 DAT_0077d0b4= (undefined4&) GH_MEM(0x0077d0b4); +char(&s_windowTitleRestoring)[256] = *reinterpret_cast(GH_MEM(0x0077d3c0)); +float FLOAT_005aa030= (float&) GH_MEM(0x005aa030); +HWND g_gameHWND= (HWND&) GH_MEM(0x0077d4c4); undefined2 DAT_005b6684= (undefined2&) GH_MEM(0x005b6684); const char* s_Premi_ESC_per_uscire_da_Rayman_3_005b66f4 = "Premi ESC per uscire da Rayman 3."; // 005b66f4 long lpDefault_005cf96c= (long&) GH_MEM(0x005cf96c); +int g_engine_= (int&) GH_MEM(0x007eba24); const char* s_Restablecer_datos____005b6738 = "Restablecer datos..."; // 005b6738 const char* s_Check_your_version_of_DirectX__V_005b6430 = "Check your version of DirectX. Version 8.1 or higher is required."; // 005b6430 +undefined4 DAT_007eb180= (undefined4&) GH_MEM(0x007eb180); const char* s_Directory_005b68f8 = "Directory"; // 005b68f8 +const char* s_Please_insert_the_DVD_in_the_DVD_005be400 = "Please insert the DVD in the DVD-Rom drive."; // 005be400 diff --git a/game_re/gh_global.h b/game_re/gh_global.h index e68ac170..6353c957 100644 --- a/game_re/gh_global.h +++ b/game_re/gh_global.h @@ -5,95 +5,112 @@ #include -extern undefined& s_QUITTER_005b67fc; // 005b67fc -extern undefined& DAT_0077d5ec; // 0077d5ec +extern const char* s_R3_DVD_005be0ec; // 005be0ec extern undefined& s_USCIRE_005b66ec; // 005b66ec -extern const char* g_windowTitle; // 005b6830 -extern uint& DAT_0077d0a8; // 0077d0a8 +extern undefined4& g_GLI_width1; // 007edd54 +extern int& DAT_005bf71c; // 005bf71c +extern HANDLE& g_mainThreadHandle; // 0077d4c8 +extern char(&g_windowTitle)[256]; // 0077d1c0 +extern char(&s_windowTitle)[12]; // 005b6830 extern const char* s_ou_appuyez_sur_Echap_pour_quitte_005b67d0; // 005b67d0 +extern undefined3& UNK_007d9e71; // 007d9e71 +extern char(&g_mutexName_Rayman3)[256]; // 0077d0c0 +extern const char* s_Introduce_el_DVD_de_Rayman_3_en_l_005be4c0; // 005be4c0 extern const char* s_SOFTWARE_UBI_SOFT_RAYMAN_3_005b6864; // 005b6864 extern undefined2& DAT_007825c0; // 007825c0 -extern char& DAT_0077d5f2; // 0077d5f2 -extern undefined& DAT_0077d5f0; // 0077d5f0 +extern R3ModuleId& r3_module_id_ff; // 005bd58c extern const char* lpText_005b64f0; // 005b64f0 extern const char* s_Ripristino_dati____005b66cc; // 005b66cc extern const char* s__s___Pausa_005b66e0; // 005b66e0 extern const char* s_CompleteInstall_005b6854; // 005b6854 extern const char* s_Unable_to_find_R3_Setup_DX8_exe__005b6880; // 005b6880 extern const char* s_or_press_ESC_to_quit_Rayman_3__005b662c; // 005b662c -extern undefined1& lpchText_0077d5e0; // 0077d5e0 extern const char* s_UbiSoft_Ubi_ini; // 005b690c +extern char(&s_QUIT)[8]; // 005b6624 extern const char* lpText_005b6540; // 005b6540 extern const char* s_None; // 005b6904 extern const char* s_Rayman_3_Error_005b68bc; // 005b68bc extern const char* fopen_mode_r_binary; // 005b68cc -extern undefined& DAT_0077d5e8; // 0077d5e8 -extern undefined& DAT_0077d5e4; // 0077d5e4 +extern const char* s__program_files_Ubi_Soft_Rayman3_005be548; // 005be548 extern const char* s_Adapter_005b68e4; // 005b68e4 extern const char* s_English_005b684c; // 005b684c +extern char(&s_QUITTER)[8]; // 005b67fc extern const char* s_Italian_005b6730; // 005b6730 -extern undefined& DAT_0077d4e0; // 0077d4e0 -extern undefined& DAT_00782608; // 00782608 -extern char& DAT_00782606; // 00782606 extern const char* s__s___Restablecer_datos____005b6784; // 005b6784 extern const char* s_Restoring_data_____005b6610; // 005b6610 -extern undefined& DAT_00782604; // 00782604 +extern char(&s_wndStrRestoring)[256]; // 0077d5e0 extern const char* s_Identifier_005b6420; // 005b6420 -extern undefined& DAT_00782600; // 00782600 -extern const char* lpText_005b6598; // 005b6598 +extern const char* s_Die__s_DVDROM_kann_nicht_gelesen_005be130; // 005be130 extern const char* s_French_005b6828; // 005b6828 +extern uint& hasGLIMode; // 0077d0a8 +extern const char* lpText_005b6598; // 005b6598 +extern char& g_initVar0; // 005cf960 extern undefined& s_BEENDIGEN_005b6678; // 005b6678 -extern undefined& DAT_005b683c; // 005b683c +extern const char* s_Inserisci_il_DVD_di_Rayman_3_nel_005be484; // 005be484 extern const char* s_DRAWSEM_005b6608; // 005b6608 -extern undefined& UNK_0077d5ed; // 0077d5ed +extern int& DAT_005e6c50; // 005e6c50 +extern undefined& lpVolumeNameBuffer_005d27b0; // 005d27b0 extern const char* s__s_not_initialized__005b63e0; // 005b63e0 -extern pointer& PTR_DAT_005b6410; // 005b6410 +extern undefined4& DAT_007eba20; // 007eba20 extern const char* s_Restauration_fmt; // 005b6804 extern const char* s__s___Rotura_005b6750; // 005b6750 +extern HANDLE& g_drawSemaphore; // 0077d0bc +extern undefined& DAT_005be500; // 005be500 extern const char* s_Please_run_the__s_setup__005b63f4; // 005b63f4 extern const char* s__s___Pause_005b67c4; // 005b67c4 +extern char(&s_percents)[4]; // 005b683c +extern float& FLOAT_005a9fb0; // 005a9fb0 +extern undefined& lpRootPathName_007d9e70; // 007d9e70 extern const char* lpAppName_005b68f0; // 005b68f0 extern uint& DAT_007d9cc4; // 007d9cc4 -extern char& UNK_0077d5f1; // 0077d5f1 +extern const char* s__s_DVD_missing_005be0f4; // 005be0f4 extern const char* s_Language_005b6840; // 005b6840 -extern HANDLE& DAT_0077d4c8; // 0077d4c8 +extern const char* s__c__s_005be540; // 005be540 extern const char* fopen_mode_r_text; // 005b68ec -extern HWND& DAT_0077d4c4; // 0077d4c4 -extern HINSTANCE& DAT_0077d4c0; // 0077d4c0 +extern char(&s_dashCC)[4]; // 005b6410 +extern uint& DAT_007e5aa4; // 007e5aa4 +extern undefined& g_perfCounterRate; // 007e5ad8 +extern HINSTANCE& g_hinstance; // 0077d4c0 extern const char* s_Gli_Mode_005b6414; // 005b6414 -extern HANDLE& DAT_0077d0bc; // 0077d0bc -extern undefined& UNK_0077d5e9; // 0077d5e9 -extern undefined& lpName_0077d0c0; // 0077d0c0 extern r3_main_data& r3_main_data_005d28b6; // 005d28b6 -extern undefined& UNK_0077d5e5; // 0077d5e5 +extern const char* s_R3_DVD_005bdfd8; // 005bdfd8 extern const char* s_Restauration; // 005b67a8 extern const char* s__s___Daten_Reparatur____005b66ac; // 005b66ac extern undefined& s_SALIR_005b675c; // 005b675c -extern undefined& UNK_0077d5e1; // 0077d5e1 +extern undefined4& g_perfCounterRateAdjusted; // 005e6b0c extern const char* s_Daten_Reparatur____005b6664; // 005b6664 extern const char* lpText_005b6478; // 005b6478 extern const char* s__s___Restoring_data____005b664c; // 005b664c extern const char* s_Pulsa_ESC_para_salir_Rayman_3__005b6764; // 005b6764 -extern char& UNK_00782609; // 00782609 -extern undefined& UNK_00782605; // 00782605 -extern const char* s_dpnhpast_dll_005b65f8; // 005b65f8 +extern char(&g_appCmdLine)[256]; // 0077d4e0 +extern char(&s_wndStrQuiting)[56]; // 00782600 +extern undefined& DAT_005be1ec; // 005be1ec +extern undefined1& DAT_005d26a8; // 005d26a8 +extern const char* s_Bitte_legen_Sie_DVD_von_Rayman_3_005be438; // 005be438 extern const char* s__s___Ripristino_dati____005b6718; // 005b6718 -extern undefined& UNK_00782601; // 00782601 -extern undefined& lpString_0077d3c0; // 0077d3c0 +extern const char* s_dpnhpast_dll_005b65f8; // 005b65f8 extern const char* s_Erreur_Rayman_3_005b65e4; // 005b65e4 +extern undefined* PTR_DAT_005be568; // 005be568 extern const char* s_Rayman_3_005b6588; // 005b6588 -extern undefined& lpString_0077d2c0; // 0077d2c0 +extern char(&lpString_0077d2c0)[256]; // 0077d2c0 +extern R3ModuleId& DAT_005bd29c; // 005bd29c extern const char* s_German_005b66c4; // 005b66c4 -extern undefined& lpString_0077d1c0; // 0077d1c0 -extern char& DAT_005b6628; // 005b6628 +extern int& g_GLI_height1; // 007edd58 +extern const char* s_Impossible_de_trouver_le_DVD_____005be238; // 005be238 +extern undefined4& g_engineRunning; // 0077d0b4 extern const char* s_Spanish_005b67a0; // 005b67a0 -extern undefined4& DAT_005b6624; // 005b6624 +extern const char* s_Impossibile_trovare_il_DVD____s_005be198; // 005be198 extern const char* s__R3_Setup_DX8_exe_005b68d0; // 005b68d0 -extern undefined4& DAT_0077d0b4; // 0077d0b4 +extern char(&s_windowTitleRestoring)[256]; // 0077d3c0 +extern float& FLOAT_005aa030; // 005aa030 +extern HWND& g_gameHWND; // 0077d4c4 extern undefined2& DAT_005b6684; // 005b6684 extern const char* s_Premi_ESC_per_uscire_da_Rayman_3_005b66f4; // 005b66f4 extern long& lpDefault_005cf96c; // 005cf96c +extern int& g_engine_; // 007eba24 extern const char* s_Restablecer_datos____005b6738; // 005b6738 extern const char* s_Check_your_version_of_DirectX__V_005b6430; // 005b6430 +extern undefined4& DAT_007eb180; // 007eb180 extern const char* s_Directory_005b68f8; // 005b68f8 +extern const char* s_Please_insert_the_DVD_in_the_DVD_005be400; // 005be400 #endif // GH_GENERATED_GLOBALS_H diff --git a/game_re/gh_structs.h b/game_re/gh_structs.h index 93bafb9d..a1261129 100644 --- a/game_re/gh_structs.h +++ b/game_re/gh_structs.h @@ -489,6 +489,39 @@ typedef struct AI_tdstMind_ AI_tdstMind_, *PAI_tdstMind_; struct AI_tdstMind_ { }; +typedef struct Float2 Float2, *PFloat2; + +struct Float2 { /* Vector (r3) */ + float x; + float y; +}; + +typedef struct Float3 Float3, *PFloat3; + +struct Float3 { /* Vector (r3) */ + float x; + float y; + float z; +}; + +typedef struct Float4 Float4, *PFloat4; + +struct Float4 { /* Vector (r3) */ + float x; + float y; + float z; + float w; +}; + +typedef struct Float4x4 Float4x4, *PFloat4x4; + +struct Float4x4 { /* Matrix (row major?) math type */ + struct Float4 x; + struct Float4 y; + struct Float4 z; + struct Float4 w; +}; + typedef struct HIE_tdstSuperObject HIE_tdstSuperObject, *PHIE_tdstSuperObject; struct HIE_tdstSuperObject { @@ -553,11 +586,50 @@ struct POS_stCompletePosition { MTH3D_tdstMatrix stTransformMatrix; }; -typedef struct r3_graphics_data r3_graphics_data, *Pr3_graphics_data; +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; + undefined field2_0x5; + undefined field3_0x6; + undefined field4_0x7; + undefined field5_0x8; + undefined field6_0x9; + undefined field7_0xa; + undefined field8_0xb; + undefined field9_0xc; + undefined field10_0xd; + undefined field11_0xe; + undefined field12_0xf; + undefined field13_0x10; + undefined field14_0x11; + undefined field15_0x12; + undefined field16_0x13; + undefined field17_0x14; + undefined field18_0x15; + undefined field19_0x16; + undefined field20_0x17; + undefined field21_0x18; + undefined field22_0x19; + undefined field23_0x1a; + undefined field24_0x1b; + undefined field25_0x1c; + undefined field26_0x1d; + undefined field27_0x1e; + char levelName[30]; + char prevLevelName[30]; + bool inputSuspended; + uint32_t field31_0x5c; +}; + +typedef struct r3_graphics_data r3_graphics_data, *Pr3_graphics_data; + struct r3_graphics_data { int field0_0x0; int field1_0x4; @@ -851,6 +923,14 @@ struct r3_math_interface { undefined *field117_0xd8; }; +typedef struct r3_TaggedFloatUnk r3_TaggedFloatUnk, *Pr3_TaggedFloatUnk; + +struct r3_TaggedFloatUnk { + uint32_t type; + struct Float4x4 mat0; + struct Float4 unk; +}; + typedef struct tdstAnim3d_ tdstAnim3d_, *PtdstAnim3d_; typedef struct tdstFrame3d_ tdstFrame3d_, *PtdstFrame3d_; diff --git a/game_re/type_blacklist.txt b/game_re/type_blacklist.txt index b12faf64..abbb102c 100644 --- a/game_re/type_blacklist.txt +++ b/game_re/type_blacklist.txt @@ -34,10 +34,6 @@ DOMFreeThreadedDocument DRVCONFIGINFOEX FIND_BY_SID_DATA FLASHWINFO -Float2 -Float3 -Float4 -Float4x4 HACCEL__ HBITMAP__ HBRUSH__ @@ -1894,4 +1890,31 @@ _struct_813 _struct_814 _struct_97 _struct_978 -_struct_99 \ No newline at end of file +_struct_99 +_CrtMemState +_CrtMemBlockHeader +_count_string +_finddata_t +__lc_time_data +transitiondate +tm +tagRGLOCINFO +tagLOCALETAB +tagLC_ID +tagLC_STRINGS +tagRegion +tagGroup +tagListHead +IMAGE_DATA_DIRECTORY +IMAGE_DEBUG_DIRECTORY +IMAGE_DOS_HEADER +IMAGE_FILE_HEADER +IMAGE_OPTIONAL_HEADER32 +IMAGE_NT_HEADERS32 +IMAGE_SECTION_HEADER +ioinfo +DOUBLE +_stati64 +_stat +_strflt +_tiddata \ No newline at end of file diff --git a/scripts/Decompile.java b/scripts/Decompile.java index 2ecd102e..8e9c692e 100644 --- a/scripts/Decompile.java +++ b/scripts/Decompile.java @@ -24,10 +24,13 @@ import ghidra.app.decompiler.PrettyPrinter; import ghidra.app.script.GhidraScript; import ghidra.program.model.address.Address; import ghidra.program.model.data.AbstractStringDataType; +import ghidra.program.model.data.Array; +import ghidra.program.model.data.ArrayDataType; import ghidra.program.model.data.BitFieldDataType; import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataTypeComponent; import ghidra.program.model.data.DataTypeManager; +import ghidra.program.model.data.EnumDataType; import ghidra.program.model.data.PointerDataType; import ghidra.program.model.data.ProgramBasedDataTypeManager; import ghidra.program.model.data.Structure; @@ -47,8 +50,21 @@ public class Decompile extends GhidraScript { private static final boolean AUTO_RENAME_SYMBOLS = true; private static final HashSet ONLY_SYMBOLS = new HashSet<>(Arrays.asList( - "r3_main", // - "_strrchr")); + "r3_main", + "r3_get_gli_width", + "r3_get_gli_height", + "r3_setup_dx8", + "r3_setup_window", + "r3_contains_cmd_line", + "r3_module0_init", + "r3_noop", + "gfx_init2", + "spawn_thread", + "FUN_004464f0", + "FUN_00401320", + "thunk_FUN_00401410" + )); + // private static final HashSet ONLY_SYMBOLS = null; static final boolean BUILD_BLACKLIST = true; @@ -151,15 +167,15 @@ public class Decompile extends GhidraScript { throws Exception { String fileName = sanitizeFunctionName(function.getName()) + ".cxx"; - File f1 = new File(RecompileConfig.INSTANCE.dirDecompFix, fileName); - if (f1.exists()) { - println("Func " + function.getName() + " skipped (gh_fix)"); - return; - } - - File f0 = new File(RecompileConfig.INSTANCE.dirDecompAuto, fileName); + File f0 = new File(RecompileConfig.INSTANCE.dirDecompFix, fileName); if (f0.exists()) { - f0.delete(); + println("Func " + function.getName() + " skipped (gh_fix)"); + f0 = new File(RecompileConfig.INSTANCE.dirDecompRef, fileName); + } else { + f0 = new File(RecompileConfig.INSTANCE.dirDecompAuto, fileName); + if (f0.exists()) { + f0.delete(); + } } println("Processing " + function.getName() + " => " + f0.toString()); @@ -218,8 +234,9 @@ public class Decompile extends GhidraScript { if (matcher.matches()) { int offset = Integer.parseInt(matcher.group(1)); int size = Integer.parseInt(matcher.group(2)); - // println("MATCHED: " + token.getText() + " - " + token.getSyntaxType() + " - " + token.getVarnode() + " - " - // + token.getPcodeOp()); + // println("MATCHED: " + token.getText() + " - " + token.getSyntaxType() + " - " + // + token.getVarnode() + " - " + // + token.getPcodeOp()); // Replace tokens with + Field ClangToken replacement = new ClangToken(token.Parent(), " + Field<" + offset + ", " + size + ">()"); @@ -423,7 +440,7 @@ public class Decompile extends GhidraScript { // DependencyTypeDumper dumper = new DependencyTypeDumper(dtm); while (it.hasNext()) { DataType dt = it.next(); - if (dt instanceof Structure || dt instanceof TypedefDataType) { + if (dt instanceof Structure || dt instanceof TypedefDataType || dt instanceof EnumDataType) { if (typeBlacklist.contains(dt.getDisplayName())) continue; // println("Adding: " + dt.getDisplayName() + " - " + @@ -472,44 +489,55 @@ public class Decompile extends GhidraScript { HighSymbol highSym = sym.highSymbol; DataType dt = highSym.getDataType(); String dataType = dt.getDisplayName(); - String name = highSym.getName(); String sanitizedName = sanitizeFunctionName(highSym.getName()); - if (!sanitizedName.equals(highSym.getName())) { - println("Invalid global symbol name: " + highSym.getName() + " - " - + highSym.getHighFunction().getFunction().getName()); - } else { - Address addr = sym.address; - // println("Symbol: " + symbol + " Addr: " + addr + " Size:" + symSize + " " + - // storage.getSerializationString()); - try { - String initBlk = " = "; - boolean fullyDefinedType = false; - if (dt instanceof AbstractStringDataType) { - AbstractStringDataType sdt = (AbstractStringDataType) dt; - dataType = "const char*"; - // String type - initBlk += "\"" + escapeCString(readCString(addr, 2048)) + "\""; - fullyDefinedType = true; - } else if (dt instanceof PointerDataType) { - PointerDataType pdt = (PointerDataType) dt; - DataType baseType = pdt.getDataType(); - dataType = baseType.getDisplayName() + "*"; - initBlk += "(" + dataType + ")&GH_MEM(0x" + addr + ")"; - fullyDefinedType = true; - } - if (fullyDefinedType) { - hwriter.println("extern " + dataType + " " + name + "; // " + addr); - cwriter.println(dataType + " " + name + initBlk + "; // " + addr); + String name = highSym.getName(); + if (!sanitizedName.equals(name)) { + println("Invalid global symbol name: " + name); + name = sanitizedName; + } + Address addr = sym.address; + // println("Symbol: " + symbol + " Addr: " + addr + " Size:" + symSize + " " + + // storage.getSerializationString()); + try { + String initBlk = " = "; + boolean fullyDefinedType = false; + if (dt instanceof AbstractStringDataType) { + AbstractStringDataType sdt = (AbstractStringDataType) dt; + dataType = "const char*"; + // String type + initBlk += "\"" + escapeCString(readCString(addr, 2048)) + "\""; + fullyDefinedType = true; + } else if (dt instanceof PointerDataType) { + PointerDataType pdt = (PointerDataType) dt; + DataType baseType = pdt.getDataType(); + dataType = baseType.getDisplayName() + "*"; + initBlk += "(" + dataType + ")&GH_MEM(0x" + addr + ")"; + fullyDefinedType = true; + } + if (fullyDefinedType) { + hwriter.println("extern " + dataType + " " + name + "; // " + addr); + cwriter.println(dataType + " " + name + initBlk + "; // " + addr); + } else { + if (dt instanceof Array) { + // println("Array: " + dt.getDisplayName() + " - " + addr + " - " + + // dt.getClass().getSimpleName()); + Array adt = (Array) dt; + DataType baseType = adt.getDataType(); + hwriter.println( + "extern " + baseType.getDisplayName() + "(&" + name + ")[" + adt.getNumElements() + "]; // " + addr); + cwriter.println( + baseType.getDisplayName() + "(&" + name + ")[" + adt.getNumElements() + "] = *reinterpret_cast<" + + baseType.getDisplayName() + "(*)[" + adt.getNumElements() + "]>(GH_MEM(0x" + addr + "));"); } else { String refTypeStr = dt.getDisplayName() + "&"; hwriter.println("extern " + refTypeStr + " " + name + "; // " + addr); cwriter.println(dataType + " " + name + "= (" + refTypeStr + ") GH_MEM(0x" + addr + ");"); } - } catch (Exception e) { - println("Error processing global symbol: " + e); - println("Symbol: " + highSym.getName() + " - " + addr + " - " - + highSym.getHighFunction().getFunction().getName()); } + } catch (Exception e) { + println("Error processing global symbol: " + e); + println("Symbol: " + highSym.getName() + " - " + addr + " - " + + highSym.getHighFunction().getFunction().getName()); } } @@ -544,6 +572,7 @@ public class Decompile extends GhidraScript { // Make sure to create output folders RecompileConfig.INSTANCE.dirDecompFix.mkdirs(); RecompileConfig.INSTANCE.dirDecompAuto.mkdirs(); + RecompileConfig.INSTANCE.dirDecompRef.mkdirs(); buildFunctionBlacklist(); diff --git a/scripts/re3lib/RecompileConfig.java b/scripts/re3lib/RecompileConfig.java index 4baf5bdc..825c8665 100644 --- a/scripts/re3lib/RecompileConfig.java +++ b/scripts/re3lib/RecompileConfig.java @@ -27,6 +27,9 @@ public class RecompileConfig { // The manually decompiled files (will not be overwritten by the auto // decompiler) public final File dirDecompFix; + // The automatically generated files get written here in case a gh_fix entry exists + // usable for referencing the modified function against the auto-decompiled one + public final File dirDecompRef; public final Program currentProgram; public final DecompileCache decompCache; @@ -50,6 +53,7 @@ public class RecompileConfig { dirDecompAuto = new File(outputDir, "gh_auto"); dirDecompFix = new File(outputDir, "gh_fix"); + dirDecompRef = new File(outputDir, "gh_ref"); currentProgram = script.getCurrentProgram();