Ray3 main debug stub

This commit is contained in:
Guus Waals 2025-05-30 00:18:17 +08:00
parent ea677e6de7
commit acb9d47e0e
6 changed files with 50 additions and 27 deletions

View File

@ -13,6 +13,7 @@ function(setup_target TARGET DBG_MODE)
)
if(WIN32 AND R3_32BIT)
target_link_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../third_party/bink)
target_link_libraries(${TARGET} PRIVATE
binkw32
d3d8

View File

@ -220,16 +220,17 @@ LAB_004017ce:
}
}
fclose(pFVar5);
/* Open reg key
HKEY_LOCAL_MACHINE\\SOFTWARE\\UBI SOFT\\RAYMAN 3 */
LVar6 = RegOpenKeyExA((HKEY)0x80000002,s_SOFTWARE_UBI_SOFT_RAYMAN_3_005b6864,0,0x20019,
(PHKEY)&stack0xfffff7b8);
/* Open reg key
HKEY_LOCAL_MACHINE\\SOFTWARE\\UBI SOFT\\RAYMAN 3 */
HKEY key;
LVar6 = RegOpenKeyExA(HKEY_LOCAL_MACHINE,s_SOFTWARE_UBI_SOFT_RAYMAN_3_005b6864,0,0x20019,
&key);
if (LVar6 == 0) {
LVar6 = RegQueryValueExA(unaff_ESI,s_CompleteInstall_005b6854,(LPDWORD)0x0,&pvStack_834,
LVar6 = RegQueryValueExA(key,s_CompleteInstall_005b6854,(LPDWORD)0x0,&pvStack_834,
uStack_83c,&pHStack_838);
DAT_007d9cc4 = (uint)(LVar6 == 0);
if (unaff_ESI != (HKEY)0x0) {
RegCloseKey(unaff_ESI);
if (key != (HKEY)0x0) {
RegCloseKey(key);
}
}
else {
@ -540,25 +541,27 @@ LAB_004017ce:
r3_checkDisc();
dwOptions = 0;
BVar18 = 0;
lpTargetHandle = (LPHANDLE)&stack0xfffff7ac;
HANDLE duplicatedHandle;
DVar7 = 0x1f03ff;
g_hinstance = instance;
hTargetProcessHandle = GetCurrentProcess();
hSourceHandle = GetCurrentThread();
hSourceProcessHandle = GetCurrentProcess();
DuplicateHandle(hSourceProcessHandle,hSourceHandle,hTargetProcessHandle,lpTargetHandle,DVar7,
DuplicateHandle(hSourceProcessHandle,hSourceHandle,hTargetProcessHandle,&duplicatedHandle,DVar7,
BVar18,dwOptions);
/* Copy cmdline */
ppCVar8 = puStack_14;
g_mainThreadHandle = lpBuffer;
do {
uVar14 = *ppCVar8;
*(char *)(((int)g_appCmdLine - (int)puStack_14) + (int)ppCVar8) = (char)uVar14;
ppCVar8 = (uint *)((int)ppCVar8 + 1);
} while ((char)uVar14 != '\0');
g_mainThreadHandle = duplicatedHandle;
// do {
// uVar14 = *ppCVar8;
// *(char *)(((int)g_appCmdLine - (int)puStack_14) + (int)ppCVar8) =
// (char)uVar14; ppCVar8 = (uint *)((int)ppCVar8 + 1);
// } while ((char)uVar14 != '\0');
LPSTR cmdline = GetCommandLineA();
strncpy(g_appCmdLine, cmdline, std::size(g_appCmdLine));
/* SEM_FAILCRITICALERRORS */
SetErrorMode(1);
pcVar4 = strstr(puStack_14,s_dashCC);
pcVar4 = strstr(cmdline, s_dashCC);
if (pcVar4 == (char *)0x0) {
r3_initAllModules();
iVar13 = setupWindow(instance,uStack_10,g_runMaximized);
@ -570,21 +573,22 @@ LAB_004017ce:
spawnThread();
r3_noop(p_cTxt1,p_cTxt2);
gfx_init2();
lpRect = (LPRECT)&stack0xfffff7c0;
RECT rect;
hWnd = GetDesktopWindow();
GetWindowRect(hWnd,lpRect);
GetWindowRect(hWnd,&rect);
BVar18 = 1;
iVar13 = r3_get_gli_height1();
iVar13 = iVar13 + 0x20;
iVar10 = r3_get_gli_width1();
iVar10 = iVar10 + 0xc;
iVar11 = r3_get_gli_height1();
iVar11 = (int)(pvStack_834 - iVar11) / 2;
iVar11 = (int)(rect.top - iVar11) / 2;
iVar12 = r3_get_gli_width1();
MoveWindow(g_gameHWND,(int)(pHStack_838 - iVar12) / 2,iVar11,iVar10,iVar13,BVar18);
MoveWindow(g_gameHWND,(int)(rect.right - iVar12) / 2,iVar11,iVar10,iVar13,BVar18);
FUN_004010b0();
SystemParametersInfoA(0x10,0,&stack0xfffff7b0,0);
SystemParametersInfoA(0x11,0,(PVOID)0x0,0);
DWORD screensaveActive;
SystemParametersInfoA(SPI_GETSCREENSAVEACTIVE,0,&screensaveActive,0);
SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE,0,(PVOID)0x0,0);
ShowCursor(0);
uStack_85c = 0;
SystemParametersInfoA(0x61,1,&uStack_85c,0);

View File

@ -61,7 +61,7 @@ long& lpDefault_005cf96c= (long&) GH_MEM(0x005cf96c);
r3_main_data& r3_main_data_005d28b6= (r3_main_data&) GH_MEM(0x005d28b6);
int& g_runMaximized= (int&) GH_MEM(0x0077d0a8);
undefined4& g_engineRunning= (undefined4&) GH_MEM(0x0077d0b4);
undefined4& g_drawSemaphore= (undefined4&) GH_MEM(0x0077d0bc);
HANDLE& g_drawSemaphore= (HANDLE&) GH_MEM(0x0077d0bc);
char(&g_mutexName_Rayman3)[256] = reinterpret_cast<char(&)[256]>(GH_MEM(0x0077d0c0));
char(&g_windowTitle)[256] = reinterpret_cast<char(&)[256]>(GH_MEM(0x0077d1c0));
char(&g_windowTitle1)[256] = reinterpret_cast<char(&)[256]>(GH_MEM(0x0077d2c0));

View File

@ -66,7 +66,7 @@ extern long& lpDefault_005cf96c; // 005cf96c
extern r3_main_data& r3_main_data_005d28b6; // 005d28b6
extern int& g_runMaximized; // 0077d0a8
extern undefined4& g_engineRunning; // 0077d0b4
extern undefined4& g_drawSemaphore; // 0077d0bc
extern HANDLE& g_drawSemaphore; // 0077d0bc
extern char(&g_mutexName_Rayman3)[256]; // 0077d0c0
extern char(&g_windowTitle)[256]; // 0077d1c0
extern char(&g_windowTitle1)[256]; // 0077d2c0

View File

@ -1,4 +1,25 @@
#include "r3/config/static.hpp"
#include <spdlog/spdlog.h>
struct R3Bin {
R3Bin() { SPDLOG_DEBUG("R3Bin constructor"); }
static R3Bin& get() {
static R3Bin instance;
return instance;
}
};
uint8_t *gh_map_dbg_mem(size_t addr) {
R3Bin::get();
SPDLOG_DEBUG("Mapping debug memory at {}", addr);
return nullptr;
}
void *gh_stub_impl_ptr(void *ptr) {
R3Bin::get();
SPDLOG_DEBUG("Forwarding implementation at {}", ptr);
return nullptr;
}
void gh_init_dbg_loader() {
SPDLOG_DEBUG("Initializing debug loader");
}

View File

@ -10,9 +10,6 @@
#include <r3/binders/static_mem.h>
#endif
// Error reporting and such
extern "C" void r3_noop(void *, void *) {}
extern "C" int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR *cmdline, int showCmd);