rewrite patch pattern for quick retire, auto hispeed

This commit is contained in:
CrazyRedMachine 2023-10-20 00:01:02 +02:00
parent dabfc4aa94
commit cff44b2712

View File

@ -2319,8 +2319,14 @@ static bool patch_quick_retire(bool pfree)
/* instant exit with numpad 9 on result screen */
{
int64_t pattern_offset = search(data, dllSize, "\xF8\x53\x55\x56\x57\x8B\xE9\x8B\x75\x00\x8B\x85", 12, 0);
int64_t first_loc = search(data, dllSize, "\xBF\x03\x00\x00\x00\x81\xC6", 7, 0);
if (first_loc == -1) {
LOG("popnhax: cannot retrieve result screen loop first loc\n");
return false;
}
int64_t pattern_offset = search(data, 0x50, "\x55\x8B\xEC\x83\xE4", 5, first_loc-0x50);
if (pattern_offset == -1) {
LOG("popnhax: cannot retrieve result screen loop\n");
return false;
@ -2332,7 +2338,7 @@ static bool patch_quick_retire(bool pfree)
return false;
}
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x05;
uint64_t patch_addr = (int64_t)data + pattern_offset;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)quickexit_result_loop,
(void **)&real_result_loop);
}
@ -2342,8 +2348,12 @@ static bool patch_quick_retire(bool pfree)
int64_t pattern_offset = search(data, dllSize, "\x84\xC0\x75\x0F\x8B\x8D\x1C\x0A\x00\x00\xE8", 11, 0);
if (pattern_offset == -1) {
LOG("popnhax: cannot retrieve result screen button check\n");
return false;
/* fallback */
pattern_offset = search(data, dllSize, "\x84\xC0\x75\x0F\x8B\x8D\x98\x1C\x00\x00\xE8", 11, 0);
if (pattern_offset == -1) {
LOG("popnhax: cannot retrieve result screen button check\n");
return false;
}
}
uint64_t patch_addr = (int64_t)data + pattern_offset + 0x1A;
@ -2356,7 +2366,7 @@ static bool patch_quick_retire(bool pfree)
/* retrieve songstart function pointer for quick retry */
{
int64_t pattern_offset = search(data, dllSize, "\xE9\x0C\x01\x00\x00\x8B\x85\x10\x0A\x00\x00", 11, 0);
int64_t pattern_offset = search(data, dllSize, "\xE9\x0C\x01\x00\x00\x8B\x85", 7, 0);
if (pattern_offset == -1) {
LOG("popnhax: quick retry: cannot retrieve song start function\n");
@ -2396,7 +2406,7 @@ static bool patch_quick_retire(bool pfree)
/* instant launch song with numpad 8 on option select (hold 8 during song for quick retry) */
{
int64_t pattern_offset = search(data, dllSize, "\x51\x50\x8B\x83\x0C\x0A\x00\x00\xEB\x09\x33\xD2", 12, 0);
int64_t pattern_offset = search(data, dllSize, "\x8B\xF0\x83\x7E\x0C\x00\x0F\x84", 8, 0);
if (pattern_offset == -1) {
LOG("popnhax: quick retry: cannot retrieve option screen loop\n");
@ -2409,7 +2419,7 @@ static bool patch_quick_retire(bool pfree)
return false;
}
uint64_t patch_addr = (int64_t)data + pattern_offset + 12 + 5 + 2;
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x0F;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)quickexit_option_screen,
(void **)&real_option_screen);
}
@ -4564,7 +4574,7 @@ bool patch_hispeed_auto(uint8_t mode, uint16_t default_bpm)
}
/* write new hispeed according to target bpm */
{
int64_t pattern_offset = search(data, dllSize, "\x98\x50\x66\x8B\x85\x1A\x0A\x00\x00\x8B\xCF", 11, 0);
int64_t pattern_offset = search(data, dllSize, "\x98\x50\x66\x8B\x85", 5, 0);
if (pattern_offset == -1) {
LOG("popnhax: auto hi-speed: cannot find hi-speed apply address\n");
return false;