mirror of
https://github.com/CrazyRedMachine/popnhax.git
synced 2025-01-24 15:22:12 +01:00
cleanup placeholders
This commit is contained in:
parent
beca091d16
commit
95ead1e961
@ -305,13 +305,19 @@ void quickexit_option_screen_cleanup()
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t g_addr_icca;
|
||||
void (*real_option_screen)();
|
||||
void quickexit_option_screen()
|
||||
{
|
||||
quickexit_option_screen_cleanup();
|
||||
|
||||
__asm("push ebx\n");
|
||||
__asm("mov ebx, dword ptr [0x12345678]\n"); /* placeholder value, will be set to addr_icca afterwards */
|
||||
|
||||
__asm("push ecx\n");
|
||||
__asm("mov ecx, %0\n": :"m"(g_addr_icca));
|
||||
__asm("mov ebx, [ecx]\n");
|
||||
__asm("pop ecx\n");
|
||||
|
||||
__asm("add ebx, 0xAC\n");
|
||||
__asm("mov ebx, [ebx]\n");
|
||||
|
||||
@ -364,7 +370,12 @@ void (*real_game_loop)();
|
||||
void quickexit_game_loop()
|
||||
{
|
||||
__asm("push ebx\n");
|
||||
__asm("mov ebx, dword ptr [0x12345678]\n"); /* placeholder value, will be set to addr_icca afterwards */
|
||||
|
||||
__asm("push ecx\n");
|
||||
__asm("mov ecx, %0\n": :"m"(g_addr_icca));
|
||||
__asm("mov ebx, [ecx]\n");
|
||||
__asm("pop ecx\n");
|
||||
|
||||
__asm("add ebx, 0xAC\n");
|
||||
__asm("mov ebx, [ebx]\n");
|
||||
|
||||
@ -415,7 +426,11 @@ void (*real_result_loop)();
|
||||
void quickexit_result_loop()
|
||||
{
|
||||
//__asm("push ebx\n"); //handled by :"b"
|
||||
__asm("mov ebx, dword ptr [0x12345678]\n"); /* placeholder value, will be set to addr_icca afterwards */
|
||||
__asm("push ecx\n");
|
||||
__asm("mov ecx, %0\n": :"m"(g_addr_icca));
|
||||
__asm("mov ebx, [ecx]\n");
|
||||
__asm("pop ecx\n");
|
||||
|
||||
__asm("add ebx, 0xAC\n");
|
||||
__asm("mov ebx, [ebx]\n");
|
||||
__asm("shr ebx, 16\n");
|
||||
@ -1755,16 +1770,12 @@ static bool patch_quick_retire(bool pfree)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t addr_icca;
|
||||
if (!get_addr_icca(&addr_icca))
|
||||
if (!get_addr_icca(&g_addr_icca))
|
||||
{
|
||||
LOG("popnhax: cannot retrieve ICCA address for numpad hook\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t quickexitaddr = (int64_t)&quickexit_game_loop;
|
||||
patch_memory(quickexitaddr+3, (char *)&addr_icca, 4);
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)quickexit_game_loop,
|
||||
(void **)&real_game_loop);
|
||||
@ -1779,16 +1790,12 @@ static bool patch_quick_retire(bool pfree)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t addr_icca;
|
||||
if (!get_addr_icca(&addr_icca))
|
||||
if (!get_addr_icca(&g_addr_icca))
|
||||
{
|
||||
LOG("popnhax: cannot retrieve ICCA address for numpad hook\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t quickexitaddr = (int64_t)&quickexit_result_loop;
|
||||
patch_memory(quickexitaddr+4, (char *)&addr_icca, 4);// +3 -> +4
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x05;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)quickexit_result_loop,
|
||||
(void **)&real_result_loop);
|
||||
@ -1845,23 +1852,11 @@ static bool patch_quick_retire(bool pfree)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t addr_icca;
|
||||
if (!get_addr_icca(&addr_icca))
|
||||
if (!get_addr_icca(&g_addr_icca))
|
||||
{
|
||||
LOG("popnhax: quick retry: cannot retrieve ICCA address for numpad hook\n");
|
||||
return false;
|
||||
}
|
||||
int64_t quickexitaddr = (int64_t)&quickexit_option_screen;
|
||||
uint8_t *patch_str = (uint8_t*) quickexitaddr;
|
||||
|
||||
uint8_t placeholder_offset = 0;
|
||||
while (patch_str[placeholder_offset+0] != 0x78
|
||||
|| patch_str[placeholder_offset+1] != 0x56
|
||||
|| patch_str[placeholder_offset+2] != 0x34
|
||||
|| patch_str[placeholder_offset+3] != 0x12)
|
||||
placeholder_offset++;
|
||||
|
||||
patch_memory(quickexitaddr+placeholder_offset, (char *)&addr_icca, 4);
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset + 12 + 5 + 2;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)quickexit_option_screen,
|
||||
|
Loading…
x
Reference in New Issue
Block a user