From 3ad0cb5bd1844d2c82f565a0f0f8023ca7252d73 Mon Sep 17 00:00:00 2001 From: Guus Waals <_@guusw.nl> Date: Sun, 1 Jun 2025 22:13:09 +0800 Subject: [PATCH] Upgrade stub --- game_re/gh_fix/entry.cxx | 42 ++++++++----------- game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx | 2 +- game_re/gh_stub/FUN_004010b0.cxx | 2 +- game_re/gh_stub/FUN_00401320.cxx | 2 +- game_re/gh_stub/FUN_0043e4f0.cxx | 2 +- game_re/gh_stub/FUN_00441d70.cxx | 2 +- game_re/gh_stub/FUN_0046fe20.cxx | 2 +- game_re/gh_stub/FUN_00470db0.cxx | 2 +- game_re/gh_stub/FUN_00472150.cxx | 2 +- game_re/gh_stub/FUN_004725a0.cxx | 2 +- game_re/gh_stub/FUN_004fb300.cxx | 2 +- game_re/gh_stub/FUN_00503710.cxx | 2 +- game_re/gh_stub/FUN_005038e0.cxx | 2 +- game_re/gh_stub/IPT_fn_vReadInput.cxx | 2 +- .../gh_stub/Mmg_fn_vFirstInitMmgModule.cxx | 2 +- .../gh_stub/fn_bCreateMainDisplayScreen.cxx | 2 +- game_re/gh_stub/g_setInitVar0.cxx | 2 +- game_re/gh_stub/gfx_init2.cxx | 2 +- game_re/gh_stub/loadSplashBitmap.cxx | 2 +- game_re/gh_stub/r3_config_setGLIMode.cxx | 2 +- game_re/gh_stub/r3_config_setIdentifier.cxx | 2 +- game_re/gh_stub/r3_config_setTexturesMem.cxx | 2 +- game_re/gh_stub/r3_engineLoop.cxx | 2 +- game_re/gh_stub/r3_get_gli_height1.cxx | 2 +- game_re/gh_stub/r3_get_gli_width1.cxx | 2 +- game_re/gh_stub/r3_gfxFrameUNK.cxx | 2 +- game_re/gh_stub/r3_module1_init.cxx | 2 +- game_re/gh_stub/r3_module_big_init.cxx | 2 +- game_re/gh_stub/r3_noop.cxx | 2 +- .../r3_read_game_config_modem_quality.cxx | 2 +- .../gh_stub/r3_read_game_config_udp_port.cxx | 2 +- game_re/gh_stub/r3_set_GameDataPath.cxx | 2 +- game_re/gh_stub/r3_windowUnlockCursor.cxx | 2 +- game_re/gh_stub/setGameHWND3.cxx | 2 +- game_re/gh_stub/spawnThread.cxx | 2 +- game_re/r3/binders/stub.h | 16 +++---- java/ghidra/RedumpStubFunctions.java | 4 +- java/ghidra/re3lib/FunctionDumper.java | 26 ++++++------ 38 files changed, 75 insertions(+), 81 deletions(-) diff --git a/game_re/gh_fix/entry.cxx b/game_re/gh_fix/entry.cxx index c49c6d78..7063e666 100644 --- a/game_re/gh_fix/entry.cxx +++ b/game_re/gh_fix/entry.cxx @@ -7,28 +7,20 @@ extern "C" { undefined4 crt_createProgramHeap(undefined4 param_1) { - return gh_stub_impl_cdecl((void *)0x00404902, param_1); -} -undefined4 ioinit(void) { - return gh_stub_impl_cdecl((void *)0x004046bf); -} -void crt_initConsole(void) { - return gh_stub_impl_cdecl((void *)0x00404503); -} -LPSTR crt_setupEnv(void) { - return gh_stub_impl_cdecl((void *)0x004043d1); + return gh_stub_impl_cdecl<0x00404902, undefined4>(param_1); } +undefined4 ioinit(void) { return gh_stub_impl_cdecl<0x004046bf, undefined4>(); } +void crt_initConsole(void) { return gh_stub_impl_cdecl<0x00404503, void>(); } +LPSTR crt_setupEnv(void) { return gh_stub_impl_cdecl<0x004043d1, LPSTR>(); } undefined4 crt_main2(void) { - return gh_stub_impl_cdecl((void *)0x00404184); + return gh_stub_impl_cdecl<0x00404184, undefined4>(); } undefined4 crt_main1(void) { - return gh_stub_impl_cdecl((void *)0x004040cb); -} -void crt_static_init(void) { - return gh_stub_impl_cdecl((void *)0x004027be); + return gh_stub_impl_cdecl<0x004040cb, undefined4>(); } +void crt_static_init(void) { return gh_stub_impl_cdecl<0x004027be, void>(); } -char *crt_0(void) { return gh_stub_impl_cdecl((void *)0x00404073); } +char *crt_0(void) { return gh_stub_impl_cdecl<0x00404073, char *>(); } void gh_pre_main(void) { DWORD DVar1; @@ -45,16 +37,16 @@ void gh_pre_main(void) { undefined4 local_8; local_8 = 0xffffffff; - // This sets up the unhandled exception handler i think? - // puStack_c = &DAT_00597ca0; - // puStack_10 = &LAB_00404a58; - // pvStack_14 = ExceptionList; - // local_1c = &stack0xffffff88; - // ExceptionList = &pvStack_14; - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdeprecated-declarations" +// This sets up the unhandled exception handler i think? +// puStack_c = &DAT_00597ca0; +// puStack_10 = &LAB_00404a58; +// pvStack_14 = ExceptionList; +// local_1c = &stack0xffffff88; +// ExceptionList = &pvStack_14; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" DVar1 = GetVersion(); - #pragma clang diagnostic pop +#pragma clang diagnostic pop DWORD_005cf980 = DVar1 >> 8 & 0xff; DWORD_005cf97c = DVar1 & 0xff; DWORD_005cf978 = DWORD_005cf97c * 0x100 + DWORD_005cf980; diff --git a/game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx b/game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx index 168c1f6a..0cc386e4 100644 --- a/game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx +++ b/game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx @@ -9,5 +9,5 @@ // 0043e1d0 // Erm_fn_ucInitErrMsg extern "C" byte Erm_fn_ucInitErrMsg(void) { - return gh_stub_impl_stdcall((void*)0x0043e1d0); + return gh_stub_impl_stdcall<0x0043e1d0, byte>(); } diff --git a/game_re/gh_stub/FUN_004010b0.cxx b/game_re/gh_stub/FUN_004010b0.cxx index 15cd9b37..502338c2 100644 --- a/game_re/gh_stub/FUN_004010b0.cxx +++ b/game_re/gh_stub/FUN_004010b0.cxx @@ -9,5 +9,5 @@ // 004010b0 // FUN_004010b0 extern "C" undefined FUN_004010b0(void) { - return gh_stub_impl_cdecl((void*)0x004010b0); + return gh_stub_impl_cdecl<0x004010b0, undefined>(); } diff --git a/game_re/gh_stub/FUN_00401320.cxx b/game_re/gh_stub/FUN_00401320.cxx index f5bc3e64..c7ac8fae 100644 --- a/game_re/gh_stub/FUN_00401320.cxx +++ b/game_re/gh_stub/FUN_00401320.cxx @@ -9,5 +9,5 @@ // 00401320 // FUN_00401320 extern "C" undefined FUN_00401320(void) { - return gh_stub_impl_cdecl((void*)0x00401320); + return gh_stub_impl_cdecl<0x00401320, undefined>(); } diff --git a/game_re/gh_stub/FUN_0043e4f0.cxx b/game_re/gh_stub/FUN_0043e4f0.cxx index 3fcd7726..e6f83a8d 100644 --- a/game_re/gh_stub/FUN_0043e4f0.cxx +++ b/game_re/gh_stub/FUN_0043e4f0.cxx @@ -9,5 +9,5 @@ // 0043e4f0 // FUN_0043e4f0 extern "C" undefined FUN_0043e4f0(void) { - return gh_stub_impl_cdecl((void*)0x0043e4f0); + return gh_stub_impl_cdecl<0x0043e4f0, undefined>(); } diff --git a/game_re/gh_stub/FUN_00441d70.cxx b/game_re/gh_stub/FUN_00441d70.cxx index 212137b7..82e3139d 100644 --- a/game_re/gh_stub/FUN_00441d70.cxx +++ b/game_re/gh_stub/FUN_00441d70.cxx @@ -9,5 +9,5 @@ // 00441d70 // FUN_00441d70 extern "C" undefined FUN_00441d70(undefined4 param_1, undefined4 param_2, undefined4 param_3, undefined4 param_4, undefined4 param_5) { - return gh_stub_impl_cdecl((void*)0x00441d70, param_1, param_2, param_3, param_4, param_5); + return gh_stub_impl_cdecl<0x00441d70, undefined>(param_1, param_2, param_3, param_4, param_5); } diff --git a/game_re/gh_stub/FUN_0046fe20.cxx b/game_re/gh_stub/FUN_0046fe20.cxx index 387d920a..dd901732 100644 --- a/game_re/gh_stub/FUN_0046fe20.cxx +++ b/game_re/gh_stub/FUN_0046fe20.cxx @@ -9,5 +9,5 @@ // 0046fe20 // FUN_0046fe20 extern "C" undefined FUN_0046fe20(undefined4 param_1, undefined4 param_2, undefined4 param_3) { - return gh_stub_impl_cdecl((void*)0x0046fe20, param_1, param_2, param_3); + return gh_stub_impl_cdecl<0x0046fe20, undefined>(param_1, param_2, param_3); } diff --git a/game_re/gh_stub/FUN_00470db0.cxx b/game_re/gh_stub/FUN_00470db0.cxx index 6f2503dc..36f1a5d2 100644 --- a/game_re/gh_stub/FUN_00470db0.cxx +++ b/game_re/gh_stub/FUN_00470db0.cxx @@ -9,5 +9,5 @@ // 00470db0 // FUN_00470db0 extern "C" undefined FUN_00470db0(void) { - return gh_stub_impl_cdecl((void*)0x00470db0); + return gh_stub_impl_cdecl<0x00470db0, undefined>(); } diff --git a/game_re/gh_stub/FUN_00472150.cxx b/game_re/gh_stub/FUN_00472150.cxx index f1c63be4..161e1c03 100644 --- a/game_re/gh_stub/FUN_00472150.cxx +++ b/game_re/gh_stub/FUN_00472150.cxx @@ -9,5 +9,5 @@ // 00472150 // FUN_00472150 extern "C" undefined FUN_00472150(void) { - return gh_stub_impl_cdecl((void*)0x00472150); + return gh_stub_impl_cdecl<0x00472150, undefined>(); } diff --git a/game_re/gh_stub/FUN_004725a0.cxx b/game_re/gh_stub/FUN_004725a0.cxx index e2059d34..b2e3a410 100644 --- a/game_re/gh_stub/FUN_004725a0.cxx +++ b/game_re/gh_stub/FUN_004725a0.cxx @@ -9,5 +9,5 @@ // 004725a0 // FUN_004725a0 extern "C" undefined FUN_004725a0(void) { - return gh_stub_impl_cdecl((void*)0x004725a0); + return gh_stub_impl_cdecl<0x004725a0, undefined>(); } diff --git a/game_re/gh_stub/FUN_004fb300.cxx b/game_re/gh_stub/FUN_004fb300.cxx index 733d346a..f4e9bd5f 100644 --- a/game_re/gh_stub/FUN_004fb300.cxx +++ b/game_re/gh_stub/FUN_004fb300.cxx @@ -9,5 +9,5 @@ // 004fb300 // FUN_004fb300 extern "C" undefined FUN_004fb300(void) { - return gh_stub_impl_cdecl((void*)0x004fb300); + return gh_stub_impl_cdecl<0x004fb300, undefined>(); } diff --git a/game_re/gh_stub/FUN_00503710.cxx b/game_re/gh_stub/FUN_00503710.cxx index 01eea361..9d31f05a 100644 --- a/game_re/gh_stub/FUN_00503710.cxx +++ b/game_re/gh_stub/FUN_00503710.cxx @@ -9,5 +9,5 @@ // 00503710 // FUN_00503710 extern "C" undefined FUN_00503710(void) { - return gh_stub_impl_cdecl((void*)0x00503710); + return gh_stub_impl_cdecl<0x00503710, undefined>(); } diff --git a/game_re/gh_stub/FUN_005038e0.cxx b/game_re/gh_stub/FUN_005038e0.cxx index dea394e9..145c3afc 100644 --- a/game_re/gh_stub/FUN_005038e0.cxx +++ b/game_re/gh_stub/FUN_005038e0.cxx @@ -9,5 +9,5 @@ // 005038e0 // FUN_005038e0 extern "C" undefined FUN_005038e0(void) { - return gh_stub_impl_cdecl((void*)0x005038e0); + return gh_stub_impl_cdecl<0x005038e0, undefined>(); } diff --git a/game_re/gh_stub/IPT_fn_vReadInput.cxx b/game_re/gh_stub/IPT_fn_vReadInput.cxx index 52e35b90..f8feeabf 100644 --- a/game_re/gh_stub/IPT_fn_vReadInput.cxx +++ b/game_re/gh_stub/IPT_fn_vReadInput.cxx @@ -9,5 +9,5 @@ // 00505fe0 // IPT_fn_vReadInput extern "C" void IPT_fn_vReadInput(void) { - gh_stub_impl_stdcall((void*)0x00505fe0); + gh_stub_impl_stdcall<0x00505fe0, void>(); } diff --git a/game_re/gh_stub/Mmg_fn_vFirstInitMmgModule.cxx b/game_re/gh_stub/Mmg_fn_vFirstInitMmgModule.cxx index 843e0852..39578e08 100644 --- a/game_re/gh_stub/Mmg_fn_vFirstInitMmgModule.cxx +++ b/game_re/gh_stub/Mmg_fn_vFirstInitMmgModule.cxx @@ -9,5 +9,5 @@ // 0043f830 // Mmg_fn_vFirstInitMmgModule extern "C" undefined Mmg_fn_vFirstInitMmgModule(undefined1 ucMaxNbChannel) { - return gh_stub_impl_stdcall((void*)0x0043f830, ucMaxNbChannel); + return gh_stub_impl_stdcall<0x0043f830, undefined>(ucMaxNbChannel); } diff --git a/game_re/gh_stub/fn_bCreateMainDisplayScreen.cxx b/game_re/gh_stub/fn_bCreateMainDisplayScreen.cxx index cb0d7207..8676299a 100644 --- a/game_re/gh_stub/fn_bCreateMainDisplayScreen.cxx +++ b/game_re/gh_stub/fn_bCreateMainDisplayScreen.cxx @@ -9,5 +9,5 @@ // 004022f0 // fn_bCreateMainDisplayScreen extern "C" undefined fn_bCreateMainDisplayScreen(void) { - return gh_stub_impl_cdecl((void*)0x004022f0); + return gh_stub_impl_cdecl<0x004022f0, undefined>(); } diff --git a/game_re/gh_stub/g_setInitVar0.cxx b/game_re/gh_stub/g_setInitVar0.cxx index 6ca90679..d7434bb4 100644 --- a/game_re/gh_stub/g_setInitVar0.cxx +++ b/game_re/gh_stub/g_setInitVar0.cxx @@ -9,5 +9,5 @@ // 00401310 // g_setInitVar0 extern "C" void g_setInitVar0(void) { - gh_stub_impl_stdcall((void*)0x00401310); + gh_stub_impl_stdcall<0x00401310, void>(); } diff --git a/game_re/gh_stub/gfx_init2.cxx b/game_re/gh_stub/gfx_init2.cxx index 11ebdad1..724c8568 100644 --- a/game_re/gh_stub/gfx_init2.cxx +++ b/game_re/gh_stub/gfx_init2.cxx @@ -9,5 +9,5 @@ // 00470be0 // gfx_init2 extern "C" undefined gfx_init2(void) { - return gh_stub_impl_cdecl((void*)0x00470be0); + return gh_stub_impl_cdecl<0x00470be0, undefined>(); } diff --git a/game_re/gh_stub/loadSplashBitmap.cxx b/game_re/gh_stub/loadSplashBitmap.cxx index 76626a93..31ec0c12 100644 --- a/game_re/gh_stub/loadSplashBitmap.cxx +++ b/game_re/gh_stub/loadSplashBitmap.cxx @@ -9,5 +9,5 @@ // 00402450 // loadSplashBitmap extern "C" void loadSplashBitmap(HWND unused) { - gh_stub_impl_stdcall((void*)0x00402450, unused); + gh_stub_impl_stdcall<0x00402450, void>(unused); } diff --git a/game_re/gh_stub/r3_config_setGLIMode.cxx b/game_re/gh_stub/r3_config_setGLIMode.cxx index afd7f5e5..dc1a7317 100644 --- a/game_re/gh_stub/r3_config_setGLIMode.cxx +++ b/game_re/gh_stub/r3_config_setGLIMode.cxx @@ -9,5 +9,5 @@ // 004704e0 // r3_config_setGLIMode extern "C" undefined r3_config_setGLIMode(char * param_1) { - return gh_stub_impl_cdecl((void*)0x004704e0, param_1); + return gh_stub_impl_cdecl<0x004704e0, undefined>(param_1); } diff --git a/game_re/gh_stub/r3_config_setIdentifier.cxx b/game_re/gh_stub/r3_config_setIdentifier.cxx index d6575d77..6ce5b076 100644 --- a/game_re/gh_stub/r3_config_setIdentifier.cxx +++ b/game_re/gh_stub/r3_config_setIdentifier.cxx @@ -9,5 +9,5 @@ // 00470570 // r3_config_setIdentifier extern "C" undefined r3_config_setIdentifier(char * param_1) { - return gh_stub_impl_cdecl((void*)0x00470570, param_1); + return gh_stub_impl_cdecl<0x00470570, undefined>(param_1); } diff --git a/game_re/gh_stub/r3_config_setTexturesMem.cxx b/game_re/gh_stub/r3_config_setTexturesMem.cxx index 80567a59..8cdd72af 100644 --- a/game_re/gh_stub/r3_config_setTexturesMem.cxx +++ b/game_re/gh_stub/r3_config_setTexturesMem.cxx @@ -9,5 +9,5 @@ // 00470f30 // r3_config_setTexturesMem extern "C" void r3_config_setTexturesMem(char * param_1) { - gh_stub_impl_cdecl((void*)0x00470f30, param_1); + gh_stub_impl_cdecl<0x00470f30, void>(param_1); } diff --git a/game_re/gh_stub/r3_engineLoop.cxx b/game_re/gh_stub/r3_engineLoop.cxx index edc0c523..207c1765 100644 --- a/game_re/gh_stub/r3_engineLoop.cxx +++ b/game_re/gh_stub/r3_engineLoop.cxx @@ -9,5 +9,5 @@ // 00401220 // r3_engineLoop extern "C" undefined r3_engineLoop(void) { - return gh_stub_impl_cdecl((void*)0x00401220); + return gh_stub_impl_cdecl<0x00401220, undefined>(); } diff --git a/game_re/gh_stub/r3_get_gli_height1.cxx b/game_re/gh_stub/r3_get_gli_height1.cxx index 7abb1045..de291801 100644 --- a/game_re/gh_stub/r3_get_gli_height1.cxx +++ b/game_re/gh_stub/r3_get_gli_height1.cxx @@ -9,5 +9,5 @@ // 0047bb00 // r3_get_gli_height1 extern "C" int r3_get_gli_height1(void) { - return gh_stub_impl_stdcall((void*)0x0047bb00); + return gh_stub_impl_stdcall<0x0047bb00, int>(); } diff --git a/game_re/gh_stub/r3_get_gli_width1.cxx b/game_re/gh_stub/r3_get_gli_width1.cxx index bfe6ce45..80627602 100644 --- a/game_re/gh_stub/r3_get_gli_width1.cxx +++ b/game_re/gh_stub/r3_get_gli_width1.cxx @@ -9,5 +9,5 @@ // 0047baf0 // r3_get_gli_width1 extern "C" int r3_get_gli_width1(void) { - return gh_stub_impl_stdcall((void*)0x0047baf0); + return gh_stub_impl_stdcall<0x0047baf0, int>(); } diff --git a/game_re/gh_stub/r3_gfxFrameUNK.cxx b/game_re/gh_stub/r3_gfxFrameUNK.cxx index 2db27a74..442dc605 100644 --- a/game_re/gh_stub/r3_gfxFrameUNK.cxx +++ b/game_re/gh_stub/r3_gfxFrameUNK.cxx @@ -9,5 +9,5 @@ // 0046fed0 // r3_gfxFrame? extern "C" undefined r3_gfxFrameUNK(void) { - return gh_stub_impl_cdecl((void*)0x0046fed0); + return gh_stub_impl_cdecl<0x0046fed0, undefined>(); } diff --git a/game_re/gh_stub/r3_module1_init.cxx b/game_re/gh_stub/r3_module1_init.cxx index 0b55fc92..cd7afd23 100644 --- a/game_re/gh_stub/r3_module1_init.cxx +++ b/game_re/gh_stub/r3_module1_init.cxx @@ -9,5 +9,5 @@ // 0043e630 // r3_module1_init extern "C" undefined r3_module1_init(void) { - return gh_stub_impl_cdecl((void*)0x0043e630); + return gh_stub_impl_cdecl<0x0043e630, undefined>(); } diff --git a/game_re/gh_stub/r3_module_big_init.cxx b/game_re/gh_stub/r3_module_big_init.cxx index a1dea834..ba2c7982 100644 --- a/game_re/gh_stub/r3_module_big_init.cxx +++ b/game_re/gh_stub/r3_module_big_init.cxx @@ -9,5 +9,5 @@ // 00443f10 // r3_module_big_init extern "C" undefined r3_module_big_init(void) { - return gh_stub_impl_cdecl((void*)0x00443f10); + return gh_stub_impl_cdecl<0x00443f10, undefined>(); } diff --git a/game_re/gh_stub/r3_noop.cxx b/game_re/gh_stub/r3_noop.cxx index c965128c..2c86ccbb 100644 --- a/game_re/gh_stub/r3_noop.cxx +++ b/game_re/gh_stub/r3_noop.cxx @@ -9,5 +9,5 @@ // 00401100 // r3_noop extern "C" void r3_noop(void * p_cTxt1, void * p_cTxt2) { - gh_stub_impl_stdcall((void*)0x00401100, p_cTxt1, p_cTxt2); + gh_stub_impl_stdcall<0x00401100, void>(p_cTxt1, p_cTxt2); } diff --git a/game_re/gh_stub/r3_read_game_config_modem_quality.cxx b/game_re/gh_stub/r3_read_game_config_modem_quality.cxx index ffc181ef..e220e764 100644 --- a/game_re/gh_stub/r3_read_game_config_modem_quality.cxx +++ b/game_re/gh_stub/r3_read_game_config_modem_quality.cxx @@ -9,5 +9,5 @@ // 00445fc0 // r3_read_game_config_modem_quality extern "C" undefined r3_read_game_config_modem_quality(void) { - return gh_stub_impl_cdecl((void*)0x00445fc0); + return gh_stub_impl_cdecl<0x00445fc0, undefined>(); } diff --git a/game_re/gh_stub/r3_read_game_config_udp_port.cxx b/game_re/gh_stub/r3_read_game_config_udp_port.cxx index 01439ae8..a942d18a 100644 --- a/game_re/gh_stub/r3_read_game_config_udp_port.cxx +++ b/game_re/gh_stub/r3_read_game_config_udp_port.cxx @@ -9,5 +9,5 @@ // 00446040 // r3_read_game_config_udp_port extern "C" undefined r3_read_game_config_udp_port(void) { - return gh_stub_impl_cdecl((void*)0x00446040); + return gh_stub_impl_cdecl<0x00446040, undefined>(); } diff --git a/game_re/gh_stub/r3_set_GameDataPath.cxx b/game_re/gh_stub/r3_set_GameDataPath.cxx index 18818ffa..800fe79f 100644 --- a/game_re/gh_stub/r3_set_GameDataPath.cxx +++ b/game_re/gh_stub/r3_set_GameDataPath.cxx @@ -9,5 +9,5 @@ // 0055a8d0 // r3_set_GameDataPath extern "C" void r3_set_GameDataPath(char * param_1) { - gh_stub_impl_cdecl((void*)0x0055a8d0, param_1); + gh_stub_impl_cdecl<0x0055a8d0, void>(param_1); } diff --git a/game_re/gh_stub/r3_windowUnlockCursor.cxx b/game_re/gh_stub/r3_windowUnlockCursor.cxx index 0937a522..ed17e2c2 100644 --- a/game_re/gh_stub/r3_windowUnlockCursor.cxx +++ b/game_re/gh_stub/r3_windowUnlockCursor.cxx @@ -9,5 +9,5 @@ // 004013a0 // r3_windowUnlockCursor extern "C" undefined r3_windowUnlockCursor(void) { - return gh_stub_impl_cdecl((void*)0x004013a0); + return gh_stub_impl_cdecl<0x004013a0, undefined>(); } diff --git a/game_re/gh_stub/setGameHWND3.cxx b/game_re/gh_stub/setGameHWND3.cxx index 0f7c98c5..0cbd6226 100644 --- a/game_re/gh_stub/setGameHWND3.cxx +++ b/game_re/gh_stub/setGameHWND3.cxx @@ -9,5 +9,5 @@ // 0043e620 // setGameHWND3 extern "C" void setGameHWND3(HWND wnd) { - gh_stub_impl_stdcall((void*)0x0043e620, wnd); + gh_stub_impl_stdcall<0x0043e620, void>(wnd); } diff --git a/game_re/gh_stub/spawnThread.cxx b/game_re/gh_stub/spawnThread.cxx index 4b3b7ca8..8c3c768f 100644 --- a/game_re/gh_stub/spawnThread.cxx +++ b/game_re/gh_stub/spawnThread.cxx @@ -9,5 +9,5 @@ // 004477d0 // spawnThread extern "C" undefined spawnThread(void) { - return gh_stub_impl_cdecl((void*)0x004477d0); + return gh_stub_impl_cdecl<0x004477d0, undefined>(); } diff --git a/game_re/r3/binders/stub.h b/game_re/r3/binders/stub.h index e58311f8..0b66e2ce 100644 --- a/game_re/r3/binders/stub.h +++ b/game_re/r3/binders/stub.h @@ -9,14 +9,14 @@ struct GHStubException : public std::exception { void *gh_stub_impl_ptr(void *ptr); -template -T gh_stub_impl_cdecl(void *ptr_, Args... args) { +template +T gh_stub_impl_cdecl(Args... args) { #if RE_DBG_INJECTED #if MSVC - static T (*__cdecl ptr)(Args...) = (T(*)(Args...))gh_stub_impl_ptr(ptr_); + static T (*__cdecl ptr)(Args...) = (T(*)(Args...))gh_stub_impl_ptr((void*)addr); #else using TFn = __cdecl T (*)(Args...); - static TFn ptr = (TFn)gh_stub_impl_ptr(ptr_); + static TFn ptr = (TFn)gh_stub_impl_ptr((void*)addr); #endif return ptr(args...); #else @@ -24,15 +24,15 @@ T gh_stub_impl_cdecl(void *ptr_, Args... args) { #endif } -template -T gh_stub_impl_stdcall(void *ptr_, Args... args) { +template +T gh_stub_impl_stdcall(Args... args) { #if RE_DBG_INJECTED #if MSVC static T (*__stdcall ptr)(Args...) = - (T(*__stdcall)(Args...))gh_stub_impl_ptr(ptr_); + (T(*__stdcall)(Args...))gh_stub_impl_ptr((void*)addr); #else using TFn = __stdcall T (*)(Args...); - static TFn ptr = (TFn)gh_stub_impl_ptr(ptr_); + static TFn ptr = (TFn)gh_stub_impl_ptr((void*)addr); #endif return ptr(args...); #else diff --git a/java/ghidra/RedumpStubFunctions.java b/java/ghidra/RedumpStubFunctions.java index ed5141cf..a2c01f08 100644 --- a/java/ghidra/RedumpStubFunctions.java +++ b/java/ghidra/RedumpStubFunctions.java @@ -28,8 +28,8 @@ public class RedumpStubFunctions extends GhidraScript { printerr("Function not found at address: " + entry.address); continue; } - println("Dumping stub function: " + function.getName()); - dumper.dumpStubFunction(function); + // println("Dumping stub function: " + function.getName()); + dumper.dumpStubFunction(function, true); } } } diff --git a/java/ghidra/re3lib/FunctionDumper.java b/java/ghidra/re3lib/FunctionDumper.java index 81e7a7bf..54d03193 100644 --- a/java/ghidra/re3lib/FunctionDumper.java +++ b/java/ghidra/re3lib/FunctionDumper.java @@ -108,20 +108,24 @@ public class FunctionDumper { } } - public void dumpStubFunction(Function externalFunction) throws Exception { + public void dumpStubFunction(Function externalFunction, boolean force) throws Exception { String sanitizedExtFunctionName = Utils.sanitizeIdentifier(externalFunction.getName()); List entries1 = functionDatabase .findEntriesByAddress(externalFunction.getEntryPoint()); boolean needStub = true; - for (FunctionDatabase.FunctionEntry entry : entries1) { - if (entry.type == FunctionDatabase.Type.Auto || entry.type == FunctionDatabase.Type.Fix) { - needStub = false; - break; + if (!force) { + for (FunctionDatabase.FunctionEntry entry : entries1) { + if (entry.type == FunctionDatabase.Type.Auto || entry.type == FunctionDatabase.Type.Fix) { + needStub = false; + break; + } + } + if (!needStub) { + script.println("Function exists for " + externalFunction.getName() + " - skipping generating stub"); + return; } } - if (!needStub) - return; String fileName = sanitizedExtFunctionName + ".cxx"; File f4 = new File(RemanConfig.INSTANCE.dirDecompStub, fileName); @@ -172,12 +176,10 @@ public class FunctionDumper { String addrString = "0x" + externalFunction.getEntryPoint().toString().replace("0x", ""); if (returnType.equals("void")) { - writer2.println(" " + stubFunction + "<" + addrString + ", void>(" + - (paramList.length() > 0 ? ", " + paramList.toString() : "") + ");"); + writer2.println(" " + stubFunction + "<" + addrString + ", void>(" + paramList.toString() + ");"); } else { writer2.println(" return " + stubFunction + "<" + addrString + ", " + returnType + ">(" + - externalFunction.getEntryPoint().toString().replace("0x", "") + - (paramList.length() > 0 ? ", " + paramList.toString() : "") + ");"); + paramList.toString() + ");"); } writer2.println("}"); @@ -431,7 +433,7 @@ public class FunctionDumper { // Possibly generate stubs for external functions for (Function externalFunction : externalFunctionCalls) { - dumpStubFunction(externalFunction); + dumpStubFunction(externalFunction, false); } } }