forked from Popn_Tools/popnhax
Compare commits
4 Commits
083d572007
...
2535fba8d6
Author | SHA1 | Date | |
---|---|---|---|
2535fba8d6 | |||
ccf3a4c8f8 | |||
c3e8eb5f13 | |||
783dafbe97 |
8
Makefile
8
Makefile
@ -232,8 +232,8 @@ $$(dll_$1_$2_$3) $$(implib_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) \
|
||||
$(ccache) $$(toolchain_$1)gcc -shared $$(srcdir_$3)/$3.def \
|
||||
-o $$(dll_$1_$2_$3) -Wl,--out-implib,$$(implib_$1_$2_$3) \
|
||||
$$^ $$(ldflags_$3) $(optflags_$1)
|
||||
strip -s $$(dll_$1_$2_$3)
|
||||
ranlib $$(implib_$1_$2_$3)
|
||||
$$(toolchain_$1)strip -s $$(dll_$1_$2_$3)
|
||||
$$(toolchain_$1)ranlib $$(implib_$1_$2_$3)
|
||||
|
||||
endef
|
||||
|
||||
@ -248,7 +248,7 @@ exe_$1_$2_$3 := $$(bindir_$1_$2)/$3.exe
|
||||
$$(exe_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) $$(absdpl_$1_$2_$3) \
|
||||
| $$(bindir_$1_$2)
|
||||
$(ccache) $$(toolchain_$1)gcc -o $$@ $$^ $$(ldflags_$3) $(optflags_$1)
|
||||
strip -s $$@
|
||||
$$(toolchain_$1)strip -s $$@
|
||||
|
||||
endef
|
||||
|
||||
@ -259,7 +259,7 @@ define t_import
|
||||
impdef_$1_$2_$3 ?= imports/import_$1_$2_$3.def
|
||||
|
||||
$$(bindir_$1_$2)/lib$3.a: $$(impdef_$1_$2_$3) | $$(bindir_$1_$2)
|
||||
dlltool -l $$@ -d $$<
|
||||
$$(toolchain_$1)dlltool -l $$@ -d $$<
|
||||
|
||||
endef
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
#include "SearchFile.h"
|
||||
|
||||
#define PROGRAM_VERSION "1.9c_rc1"
|
||||
|
||||
const char *g_game_dll_fn = NULL;
|
||||
const char *g_config_fn = NULL;
|
||||
FILE *g_log_fp = NULL;
|
||||
@ -2319,8 +2321,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 +2340,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);
|
||||
}
|
||||
@ -2340,13 +2348,19 @@ static bool patch_quick_retire(bool pfree)
|
||||
/* no need to press red button when numpad 8 or 9 is pressed on result screen */
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x84\xC0\x75\x0F\x8B\x8D\x1C\x0A\x00\x00\xE8", 11, 0);
|
||||
int adjust = 0;
|
||||
|
||||
if (pattern_offset == -1) {
|
||||
/* fallback */
|
||||
pattern_offset = search(data, dllSize, "\x09\x00\x84\xC0\x75\x0F\x8B\x8D", 8, 0);
|
||||
adjust = 2;
|
||||
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;
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset + 0x1A + adjust;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)quickexit_result_button_loop,
|
||||
(void **)&real_result_button_loop);
|
||||
|
||||
@ -2356,7 +2370,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 +2410,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 +2423,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);
|
||||
}
|
||||
@ -2418,41 +2432,53 @@ static bool patch_quick_retire(bool pfree)
|
||||
{
|
||||
/* go back to song select with numpad 9 on song option screen (before pressing yellow) */
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x8B\x85\x0C\x0A\x00\x00\x83\x78\x34\x00\x75", 11, 0);
|
||||
int64_t pattern_offset = search(data, dllSize, "\x0A\x00\x00\x83\x78\x34\x00\x75\x3D\xB8", 10, 0); //unilab
|
||||
uint8_t adjust = 3;
|
||||
if (pattern_offset == -1) {
|
||||
/* fallback */
|
||||
pattern_offset = search(data, dllSize, "\x8B\x85\x0C\x0A\x00\x00\x83\x78\x34\x00\x75", 11, 0);
|
||||
adjust = 0;
|
||||
}
|
||||
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: back to song select: cannot retrieve option screen loop function\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset;
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset - adjust;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)backtosongselect_option_screen,
|
||||
(void **)&real_option_screen_later);
|
||||
}
|
||||
/* automatically leave option screen after numpad 9 press */
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x84\xC0\x75\x63\x8B\x85\x10\x0A\x00\x00\x83\xC0\x04\xBF\x0C\x00\x00\x00", 18, 0);
|
||||
int64_t pattern_offset = search(data, dllSize, "\x0A\x00\x00\x83\xC0\x04\xBF\x0C\x00\x00\x00\xE8", 12, 0);
|
||||
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: back to song select: cannot retrieve option screen loop function\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset;
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x07;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)backtosongselect_option_screen_auto_leave,
|
||||
(void **)&real_backtosongselect_option_screen_auto_leave);
|
||||
}
|
||||
|
||||
/* go back to song select with numpad 9 on song option screen (after pressing yellow) */
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x8B\x85\x0C\x0A\x00\x00\x83\x78\x38\x00\x75", 11, 0);
|
||||
int64_t pattern_offset = search(data, dllSize, "\x0A\x00\x00\x83\x78\x38\x00\x75\x3D\x68", 10, 0); //unilab
|
||||
uint8_t adjust = 3;
|
||||
if (pattern_offset == -1) {
|
||||
/* fallback */
|
||||
pattern_offset = search(data, dllSize, "\x8B\x85\x0C\x0A\x00\x00\x83\x78\x38\x00\x75", 11, 0);
|
||||
adjust = 0;
|
||||
}
|
||||
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: quick retry: cannot retrieve option screen loop function\n");
|
||||
LOG("popnhax: quick retry: cannot retrieve yellow option screen loop function\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset;
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset - adjust;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)backtosongselect_option_yellow,
|
||||
(void **)&real_option_screen_yellow);
|
||||
}
|
||||
@ -4066,7 +4092,7 @@ if (use_sp_flg){
|
||||
__asm("add esp, 0x0C\n");
|
||||
}
|
||||
|
||||
if (config.enhanced_polling_stats)
|
||||
if (config.enhanced_polling && config.enhanced_polling_stats)
|
||||
enhanced_polling_stats_disp_sub();
|
||||
|
||||
real_aging_loop();
|
||||
@ -4079,7 +4105,7 @@ static bool patch_practice_mode()
|
||||
|
||||
/* AGING MODE to Practice Mode */
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x83\xEC\x40\x53\x56\x57", 6, 0);
|
||||
int64_t pattern_offset = search(data, dllSize-0x100000, "\x83\xEC\x40\x53\x56\x57", 6, 0x100000);
|
||||
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: cannot retrieve aging loop\n");
|
||||
@ -4249,7 +4275,7 @@ static bool patch_enhanced_polling_stats()
|
||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x83\xEC\x40\x53\x56\x57", 6, 0);
|
||||
int64_t pattern_offset = search(data, dllSize-0x100000, "\x83\xEC\x40\x53\x56\x57", 6, 0x100000);
|
||||
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: enhanced_polling_stats: cannot retrieve aging loop\n");
|
||||
@ -4285,6 +4311,7 @@ uint16_t *g_base_bpm_ptr = 0; //will point to g_low_bpm or g_hi_bpm according to
|
||||
uint16_t g_low_bpm = 0;
|
||||
uint16_t g_hi_bpm = 0;
|
||||
uint16_t g_longest_bpm = 0;
|
||||
uint16_t g_low_bpm_ebp_offset = 0;
|
||||
unsigned char *g_chart_addr = 0;
|
||||
|
||||
typedef struct chart_chunk_s {
|
||||
@ -4427,9 +4454,14 @@ void hook_read_hispeed()
|
||||
__asm("push ecx\n");
|
||||
__asm("push edx\n");
|
||||
|
||||
__asm("mov %0, word ptr [ebp+0xA1A]\n":"=a"(g_low_bpm): :);
|
||||
__asm("mov %0, word ptr [ebp+0xA1C]\n":"=a"(g_hi_bpm): :);
|
||||
__asm("mov %0, byte ptr [ebp+0xA1E]\n":"=a"(g_mystery_bpm): :);
|
||||
__asm("mov ecx, ebp\n");
|
||||
__asm("add cx, word ptr [%0]\n"::"a"(&g_low_bpm_ebp_offset));
|
||||
|
||||
__asm __volatile__("mov %0, word ptr [ecx]\n":"=a"(g_low_bpm): :);
|
||||
__asm("add cx, 2\n");
|
||||
__asm __volatile__("mov %0, word ptr [ecx]\n":"=a"(g_hi_bpm): :);
|
||||
__asm("add cx, 2\n");
|
||||
__asm __volatile__("mov %0, byte ptr [ecx]\n":"=a"(g_mystery_bpm): :);
|
||||
|
||||
if ( g_bypass_hispeed || g_target_bpm == 0 ) //bypass for mystery BPM and soflan songs (to avoid hi-speed being locked since target won't change)
|
||||
{
|
||||
@ -4564,13 +4596,28 @@ 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);
|
||||
/* improve compatibility with newer games */
|
||||
int64_t pattern_offset = search(data, dllSize, "\xEB\x57\x8B\xBC\x24\x50\x01\x00\x00\x66\x8B\x85", 12, 0);
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: auto hi-speed: cannot find chart BPM address offset\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset + 0x1C;
|
||||
g_low_bpm_ebp_offset = *((uint16_t *)(patch_addr));
|
||||
|
||||
if (g_low_bpm_ebp_offset != 0x0A1A && g_low_bpm_ebp_offset != 0x0A1E)
|
||||
{
|
||||
LOG("popnhax: auto hi-speed: WARNING: unexpected BPM address offset (%hu), might not work\n", g_low_bpm_ebp_offset);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x07;
|
||||
patch_addr = (int64_t)data + pattern_offset - 0x07;
|
||||
|
||||
MH_CreateHook((LPVOID)(patch_addr), (LPVOID)hook_read_hispeed,
|
||||
(void **)&real_read_hispeed);
|
||||
@ -5134,6 +5181,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
{
|
||||
LOG("cannot open popnhax.log for write, output to stderr only\n");
|
||||
}
|
||||
LOG("== popnhax version " PROGRAM_VERSION " ==\n");
|
||||
LOG("popnhax: Initializing\n");
|
||||
if (MH_Initialize() != MH_OK) {
|
||||
LOG("Failed to initialize minhook\n");
|
||||
|
Loading…
Reference in New Issue
Block a user