Upgrade stub
This commit is contained in:
parent
7a7c907abb
commit
3ad0cb5bd1
|
@ -7,28 +7,20 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
undefined4 crt_createProgramHeap(undefined4 param_1) {
|
undefined4 crt_createProgramHeap(undefined4 param_1) {
|
||||||
return gh_stub_impl_cdecl<undefined4>((void *)0x00404902, param_1);
|
return gh_stub_impl_cdecl<0x00404902, undefined4>(param_1);
|
||||||
}
|
|
||||||
undefined4 ioinit(void) {
|
|
||||||
return gh_stub_impl_cdecl<undefined4>((void *)0x004046bf);
|
|
||||||
}
|
|
||||||
void crt_initConsole(void) {
|
|
||||||
return gh_stub_impl_cdecl<void>((void *)0x00404503);
|
|
||||||
}
|
|
||||||
LPSTR crt_setupEnv(void) {
|
|
||||||
return gh_stub_impl_cdecl<LPSTR>((void *)0x004043d1);
|
|
||||||
}
|
}
|
||||||
|
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) {
|
undefined4 crt_main2(void) {
|
||||||
return gh_stub_impl_cdecl<undefined4>((void *)0x00404184);
|
return gh_stub_impl_cdecl<0x00404184, undefined4>();
|
||||||
}
|
}
|
||||||
undefined4 crt_main1(void) {
|
undefined4 crt_main1(void) {
|
||||||
return gh_stub_impl_cdecl<undefined4>((void *)0x004040cb);
|
return gh_stub_impl_cdecl<0x004040cb, undefined4>();
|
||||||
}
|
|
||||||
void crt_static_init(void) {
|
|
||||||
return gh_stub_impl_cdecl<void>((void *)0x004027be);
|
|
||||||
}
|
}
|
||||||
|
void crt_static_init(void) { return gh_stub_impl_cdecl<0x004027be, void>(); }
|
||||||
|
|
||||||
char *crt_0(void) { return gh_stub_impl_cdecl<char *>((void *)0x00404073); }
|
char *crt_0(void) { return gh_stub_impl_cdecl<0x00404073, char *>(); }
|
||||||
|
|
||||||
void gh_pre_main(void) {
|
void gh_pre_main(void) {
|
||||||
DWORD DVar1;
|
DWORD DVar1;
|
||||||
|
@ -45,16 +37,16 @@ void gh_pre_main(void) {
|
||||||
undefined4 local_8;
|
undefined4 local_8;
|
||||||
|
|
||||||
local_8 = 0xffffffff;
|
local_8 = 0xffffffff;
|
||||||
// This sets up the unhandled exception handler i think?
|
// This sets up the unhandled exception handler i think?
|
||||||
// puStack_c = &DAT_00597ca0;
|
// puStack_c = &DAT_00597ca0;
|
||||||
// puStack_10 = &LAB_00404a58;
|
// puStack_10 = &LAB_00404a58;
|
||||||
// pvStack_14 = ExceptionList;
|
// pvStack_14 = ExceptionList;
|
||||||
// local_1c = &stack0xffffff88;
|
// local_1c = &stack0xffffff88;
|
||||||
// ExceptionList = &pvStack_14;
|
// ExceptionList = &pvStack_14;
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
DVar1 = GetVersion();
|
DVar1 = GetVersion();
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
DWORD_005cf980 = DVar1 >> 8 & 0xff;
|
DWORD_005cf980 = DVar1 >> 8 & 0xff;
|
||||||
DWORD_005cf97c = DVar1 & 0xff;
|
DWORD_005cf97c = DVar1 & 0xff;
|
||||||
DWORD_005cf978 = DWORD_005cf97c * 0x100 + DWORD_005cf980;
|
DWORD_005cf978 = DWORD_005cf97c * 0x100 + DWORD_005cf980;
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0043e1d0
|
// 0043e1d0
|
||||||
// Erm_fn_ucInitErrMsg
|
// Erm_fn_ucInitErrMsg
|
||||||
extern "C" byte Erm_fn_ucInitErrMsg(void) {
|
extern "C" byte Erm_fn_ucInitErrMsg(void) {
|
||||||
return gh_stub_impl_stdcall<byte>((void*)0x0043e1d0);
|
return gh_stub_impl_stdcall<0x0043e1d0, byte>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 004010b0
|
// 004010b0
|
||||||
// FUN_004010b0
|
// FUN_004010b0
|
||||||
extern "C" undefined FUN_004010b0(void) {
|
extern "C" undefined FUN_004010b0(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x004010b0);
|
return gh_stub_impl_cdecl<0x004010b0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00401320
|
// 00401320
|
||||||
// FUN_00401320
|
// FUN_00401320
|
||||||
extern "C" undefined FUN_00401320(void) {
|
extern "C" undefined FUN_00401320(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00401320);
|
return gh_stub_impl_cdecl<0x00401320, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0043e4f0
|
// 0043e4f0
|
||||||
// FUN_0043e4f0
|
// FUN_0043e4f0
|
||||||
extern "C" undefined FUN_0043e4f0(void) {
|
extern "C" undefined FUN_0043e4f0(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x0043e4f0);
|
return gh_stub_impl_cdecl<0x0043e4f0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00441d70
|
// 00441d70
|
||||||
// FUN_00441d70
|
// FUN_00441d70
|
||||||
extern "C" undefined FUN_00441d70(undefined4 param_1, undefined4 param_2, undefined4 param_3, undefined4 param_4, undefined4 param_5) {
|
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<undefined>((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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0046fe20
|
// 0046fe20
|
||||||
// FUN_0046fe20
|
// FUN_0046fe20
|
||||||
extern "C" undefined FUN_0046fe20(undefined4 param_1, undefined4 param_2, undefined4 param_3) {
|
extern "C" undefined FUN_0046fe20(undefined4 param_1, undefined4 param_2, undefined4 param_3) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x0046fe20, param_1, param_2, param_3);
|
return gh_stub_impl_cdecl<0x0046fe20, undefined>(param_1, param_2, param_3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00470db0
|
// 00470db0
|
||||||
// FUN_00470db0
|
// FUN_00470db0
|
||||||
extern "C" undefined FUN_00470db0(void) {
|
extern "C" undefined FUN_00470db0(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00470db0);
|
return gh_stub_impl_cdecl<0x00470db0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00472150
|
// 00472150
|
||||||
// FUN_00472150
|
// FUN_00472150
|
||||||
extern "C" undefined FUN_00472150(void) {
|
extern "C" undefined FUN_00472150(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00472150);
|
return gh_stub_impl_cdecl<0x00472150, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 004725a0
|
// 004725a0
|
||||||
// FUN_004725a0
|
// FUN_004725a0
|
||||||
extern "C" undefined FUN_004725a0(void) {
|
extern "C" undefined FUN_004725a0(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x004725a0);
|
return gh_stub_impl_cdecl<0x004725a0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 004fb300
|
// 004fb300
|
||||||
// FUN_004fb300
|
// FUN_004fb300
|
||||||
extern "C" undefined FUN_004fb300(void) {
|
extern "C" undefined FUN_004fb300(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x004fb300);
|
return gh_stub_impl_cdecl<0x004fb300, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00503710
|
// 00503710
|
||||||
// FUN_00503710
|
// FUN_00503710
|
||||||
extern "C" undefined FUN_00503710(void) {
|
extern "C" undefined FUN_00503710(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00503710);
|
return gh_stub_impl_cdecl<0x00503710, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 005038e0
|
// 005038e0
|
||||||
// FUN_005038e0
|
// FUN_005038e0
|
||||||
extern "C" undefined FUN_005038e0(void) {
|
extern "C" undefined FUN_005038e0(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x005038e0);
|
return gh_stub_impl_cdecl<0x005038e0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00505fe0
|
// 00505fe0
|
||||||
// IPT_fn_vReadInput
|
// IPT_fn_vReadInput
|
||||||
extern "C" void IPT_fn_vReadInput(void) {
|
extern "C" void IPT_fn_vReadInput(void) {
|
||||||
gh_stub_impl_stdcall<void>((void*)0x00505fe0);
|
gh_stub_impl_stdcall<0x00505fe0, void>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0043f830
|
// 0043f830
|
||||||
// Mmg_fn_vFirstInitMmgModule
|
// Mmg_fn_vFirstInitMmgModule
|
||||||
extern "C" undefined Mmg_fn_vFirstInitMmgModule(undefined1 ucMaxNbChannel) {
|
extern "C" undefined Mmg_fn_vFirstInitMmgModule(undefined1 ucMaxNbChannel) {
|
||||||
return gh_stub_impl_stdcall<undefined>((void*)0x0043f830, ucMaxNbChannel);
|
return gh_stub_impl_stdcall<0x0043f830, undefined>(ucMaxNbChannel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 004022f0
|
// 004022f0
|
||||||
// fn_bCreateMainDisplayScreen
|
// fn_bCreateMainDisplayScreen
|
||||||
extern "C" undefined fn_bCreateMainDisplayScreen(void) {
|
extern "C" undefined fn_bCreateMainDisplayScreen(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x004022f0);
|
return gh_stub_impl_cdecl<0x004022f0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00401310
|
// 00401310
|
||||||
// g_setInitVar0
|
// g_setInitVar0
|
||||||
extern "C" void g_setInitVar0(void) {
|
extern "C" void g_setInitVar0(void) {
|
||||||
gh_stub_impl_stdcall<void>((void*)0x00401310);
|
gh_stub_impl_stdcall<0x00401310, void>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00470be0
|
// 00470be0
|
||||||
// gfx_init2
|
// gfx_init2
|
||||||
extern "C" undefined gfx_init2(void) {
|
extern "C" undefined gfx_init2(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00470be0);
|
return gh_stub_impl_cdecl<0x00470be0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00402450
|
// 00402450
|
||||||
// loadSplashBitmap
|
// loadSplashBitmap
|
||||||
extern "C" void loadSplashBitmap(HWND unused) {
|
extern "C" void loadSplashBitmap(HWND unused) {
|
||||||
gh_stub_impl_stdcall<void>((void*)0x00402450, unused);
|
gh_stub_impl_stdcall<0x00402450, void>(unused);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 004704e0
|
// 004704e0
|
||||||
// r3_config_setGLIMode
|
// r3_config_setGLIMode
|
||||||
extern "C" undefined r3_config_setGLIMode(char * param_1) {
|
extern "C" undefined r3_config_setGLIMode(char * param_1) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x004704e0, param_1);
|
return gh_stub_impl_cdecl<0x004704e0, undefined>(param_1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00470570
|
// 00470570
|
||||||
// r3_config_setIdentifier
|
// r3_config_setIdentifier
|
||||||
extern "C" undefined r3_config_setIdentifier(char * param_1) {
|
extern "C" undefined r3_config_setIdentifier(char * param_1) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00470570, param_1);
|
return gh_stub_impl_cdecl<0x00470570, undefined>(param_1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00470f30
|
// 00470f30
|
||||||
// r3_config_setTexturesMem
|
// r3_config_setTexturesMem
|
||||||
extern "C" void r3_config_setTexturesMem(char * param_1) {
|
extern "C" void r3_config_setTexturesMem(char * param_1) {
|
||||||
gh_stub_impl_cdecl<void>((void*)0x00470f30, param_1);
|
gh_stub_impl_cdecl<0x00470f30, void>(param_1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00401220
|
// 00401220
|
||||||
// r3_engineLoop
|
// r3_engineLoop
|
||||||
extern "C" undefined r3_engineLoop(void) {
|
extern "C" undefined r3_engineLoop(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00401220);
|
return gh_stub_impl_cdecl<0x00401220, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0047bb00
|
// 0047bb00
|
||||||
// r3_get_gli_height1
|
// r3_get_gli_height1
|
||||||
extern "C" int r3_get_gli_height1(void) {
|
extern "C" int r3_get_gli_height1(void) {
|
||||||
return gh_stub_impl_stdcall<int>((void*)0x0047bb00);
|
return gh_stub_impl_stdcall<0x0047bb00, int>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0047baf0
|
// 0047baf0
|
||||||
// r3_get_gli_width1
|
// r3_get_gli_width1
|
||||||
extern "C" int r3_get_gli_width1(void) {
|
extern "C" int r3_get_gli_width1(void) {
|
||||||
return gh_stub_impl_stdcall<int>((void*)0x0047baf0);
|
return gh_stub_impl_stdcall<0x0047baf0, int>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0046fed0
|
// 0046fed0
|
||||||
// r3_gfxFrame?
|
// r3_gfxFrame?
|
||||||
extern "C" undefined r3_gfxFrameUNK(void) {
|
extern "C" undefined r3_gfxFrameUNK(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x0046fed0);
|
return gh_stub_impl_cdecl<0x0046fed0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0043e630
|
// 0043e630
|
||||||
// r3_module1_init
|
// r3_module1_init
|
||||||
extern "C" undefined r3_module1_init(void) {
|
extern "C" undefined r3_module1_init(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x0043e630);
|
return gh_stub_impl_cdecl<0x0043e630, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00443f10
|
// 00443f10
|
||||||
// r3_module_big_init
|
// r3_module_big_init
|
||||||
extern "C" undefined r3_module_big_init(void) {
|
extern "C" undefined r3_module_big_init(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00443f10);
|
return gh_stub_impl_cdecl<0x00443f10, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00401100
|
// 00401100
|
||||||
// r3_noop
|
// r3_noop
|
||||||
extern "C" void r3_noop(void * p_cTxt1, void * p_cTxt2) {
|
extern "C" void r3_noop(void * p_cTxt1, void * p_cTxt2) {
|
||||||
gh_stub_impl_stdcall<void>((void*)0x00401100, p_cTxt1, p_cTxt2);
|
gh_stub_impl_stdcall<0x00401100, void>(p_cTxt1, p_cTxt2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00445fc0
|
// 00445fc0
|
||||||
// r3_read_game_config_modem_quality
|
// r3_read_game_config_modem_quality
|
||||||
extern "C" undefined r3_read_game_config_modem_quality(void) {
|
extern "C" undefined r3_read_game_config_modem_quality(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00445fc0);
|
return gh_stub_impl_cdecl<0x00445fc0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 00446040
|
// 00446040
|
||||||
// r3_read_game_config_udp_port
|
// r3_read_game_config_udp_port
|
||||||
extern "C" undefined r3_read_game_config_udp_port(void) {
|
extern "C" undefined r3_read_game_config_udp_port(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x00446040);
|
return gh_stub_impl_cdecl<0x00446040, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0055a8d0
|
// 0055a8d0
|
||||||
// r3_set_GameDataPath
|
// r3_set_GameDataPath
|
||||||
extern "C" void r3_set_GameDataPath(char * param_1) {
|
extern "C" void r3_set_GameDataPath(char * param_1) {
|
||||||
gh_stub_impl_cdecl<void>((void*)0x0055a8d0, param_1);
|
gh_stub_impl_cdecl<0x0055a8d0, void>(param_1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 004013a0
|
// 004013a0
|
||||||
// r3_windowUnlockCursor
|
// r3_windowUnlockCursor
|
||||||
extern "C" undefined r3_windowUnlockCursor(void) {
|
extern "C" undefined r3_windowUnlockCursor(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x004013a0);
|
return gh_stub_impl_cdecl<0x004013a0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 0043e620
|
// 0043e620
|
||||||
// setGameHWND3
|
// setGameHWND3
|
||||||
extern "C" void setGameHWND3(HWND wnd) {
|
extern "C" void setGameHWND3(HWND wnd) {
|
||||||
gh_stub_impl_stdcall<void>((void*)0x0043e620, wnd);
|
gh_stub_impl_stdcall<0x0043e620, void>(wnd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
// 004477d0
|
// 004477d0
|
||||||
// spawnThread
|
// spawnThread
|
||||||
extern "C" undefined spawnThread(void) {
|
extern "C" undefined spawnThread(void) {
|
||||||
return gh_stub_impl_cdecl<undefined>((void*)0x004477d0);
|
return gh_stub_impl_cdecl<0x004477d0, undefined>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,14 @@ struct GHStubException : public std::exception {
|
||||||
|
|
||||||
void *gh_stub_impl_ptr(void *ptr);
|
void *gh_stub_impl_ptr(void *ptr);
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <uintptr_t addr, typename T, typename... Args>
|
||||||
T gh_stub_impl_cdecl(void *ptr_, Args... args) {
|
T gh_stub_impl_cdecl(Args... args) {
|
||||||
#if RE_DBG_INJECTED
|
#if RE_DBG_INJECTED
|
||||||
#if MSVC
|
#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
|
#else
|
||||||
using TFn = __cdecl T (*)(Args...);
|
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
|
#endif
|
||||||
return ptr(args...);
|
return ptr(args...);
|
||||||
#else
|
#else
|
||||||
|
@ -24,15 +24,15 @@ T gh_stub_impl_cdecl(void *ptr_, Args... args) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <uintptr_t addr, typename T, typename... Args>
|
||||||
T gh_stub_impl_stdcall(void *ptr_, Args... args) {
|
T gh_stub_impl_stdcall(Args... args) {
|
||||||
#if RE_DBG_INJECTED
|
#if RE_DBG_INJECTED
|
||||||
#if MSVC
|
#if MSVC
|
||||||
static T (*__stdcall ptr)(Args...) =
|
static T (*__stdcall ptr)(Args...) =
|
||||||
(T(*__stdcall)(Args...))gh_stub_impl_ptr(ptr_);
|
(T(*__stdcall)(Args...))gh_stub_impl_ptr((void*)addr);
|
||||||
#else
|
#else
|
||||||
using TFn = __stdcall T (*)(Args...);
|
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
|
#endif
|
||||||
return ptr(args...);
|
return ptr(args...);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -28,8 +28,8 @@ public class RedumpStubFunctions extends GhidraScript {
|
||||||
printerr("Function not found at address: " + entry.address);
|
printerr("Function not found at address: " + entry.address);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
println("Dumping stub function: " + function.getName());
|
// println("Dumping stub function: " + function.getName());
|
||||||
dumper.dumpStubFunction(function);
|
dumper.dumpStubFunction(function, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
String sanitizedExtFunctionName = Utils.sanitizeIdentifier(externalFunction.getName());
|
||||||
|
|
||||||
List<FunctionDatabase.FunctionEntry> entries1 = functionDatabase
|
List<FunctionDatabase.FunctionEntry> entries1 = functionDatabase
|
||||||
.findEntriesByAddress(externalFunction.getEntryPoint());
|
.findEntriesByAddress(externalFunction.getEntryPoint());
|
||||||
boolean needStub = true;
|
boolean needStub = true;
|
||||||
for (FunctionDatabase.FunctionEntry entry : entries1) {
|
if (!force) {
|
||||||
if (entry.type == FunctionDatabase.Type.Auto || entry.type == FunctionDatabase.Type.Fix) {
|
for (FunctionDatabase.FunctionEntry entry : entries1) {
|
||||||
needStub = false;
|
if (entry.type == FunctionDatabase.Type.Auto || entry.type == FunctionDatabase.Type.Fix) {
|
||||||
break;
|
needStub = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!needStub) {
|
||||||
|
script.println("Function exists for " + externalFunction.getName() + " - skipping generating stub");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!needStub)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String fileName = sanitizedExtFunctionName + ".cxx";
|
String fileName = sanitizedExtFunctionName + ".cxx";
|
||||||
File f4 = new File(RemanConfig.INSTANCE.dirDecompStub, fileName);
|
File f4 = new File(RemanConfig.INSTANCE.dirDecompStub, fileName);
|
||||||
|
@ -172,12 +176,10 @@ public class FunctionDumper {
|
||||||
String addrString = "0x" +
|
String addrString = "0x" +
|
||||||
externalFunction.getEntryPoint().toString().replace("0x", "");
|
externalFunction.getEntryPoint().toString().replace("0x", "");
|
||||||
if (returnType.equals("void")) {
|
if (returnType.equals("void")) {
|
||||||
writer2.println(" " + stubFunction + "<" + addrString + ", void>(" +
|
writer2.println(" " + stubFunction + "<" + addrString + ", void>(" + paramList.toString() + ");");
|
||||||
(paramList.length() > 0 ? ", " + paramList.toString() : "") + ");");
|
|
||||||
} else {
|
} else {
|
||||||
writer2.println(" return " + stubFunction + "<" + addrString + ", " + returnType + ">(" +
|
writer2.println(" return " + stubFunction + "<" + addrString + ", " + returnType + ">(" +
|
||||||
externalFunction.getEntryPoint().toString().replace("0x", "") +
|
paramList.toString() + ");");
|
||||||
(paramList.length() > 0 ? ", " + paramList.toString() : "") + ");");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writer2.println("}");
|
writer2.println("}");
|
||||||
|
@ -431,7 +433,7 @@ public class FunctionDumper {
|
||||||
|
|
||||||
// Possibly generate stubs for external functions
|
// Possibly generate stubs for external functions
|
||||||
for (Function externalFunction : externalFunctionCalls) {
|
for (Function externalFunction : externalFunctionCalls) {
|
||||||
dumpStubFunction(externalFunction);
|
dumpStubFunction(externalFunction, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue