forked from Popn_Tools/popnhax
wip exclude from level
This commit is contained in:
parent
0b88b1253d
commit
d1c1d8a13f
@ -629,10 +629,13 @@ static bool patch_custom_track_format(const char *game_dll_fn) {
|
||||
//hook format string for song/genre name
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x83\xC4\x08\x8B\x44\x24\x50\x50\x68", 9, 0);
|
||||
if (pattern_offset == -1) {
|
||||
pattern_offset = search(data, dllSize, "\x83\xC4\x08\x8B\x44\x24\x4C\x50\x68", 9, 0); //usaneko
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: custom_track_format: cannot find song/genre print function\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x07;
|
||||
|
||||
@ -966,40 +969,24 @@ static void load_databases() {
|
||||
LOG("\n");
|
||||
}
|
||||
|
||||
void (*real_getversion)();
|
||||
void hook_getversion()
|
||||
void (*real_after_getlevel)();
|
||||
void hook_after_getlevel()
|
||||
{
|
||||
__asm("cmp eax, _g_min_id\n");
|
||||
__asm("jb real_version\n");
|
||||
__asm("push ebx\n");
|
||||
__asm("mov ebx, dword ptr [esp+0x04]\n");
|
||||
__asm("cmp ebx, _g_min_id\n");
|
||||
__asm("jb real_level\n");
|
||||
__asm("cmp dword ptr _g_max_id, 0\n");
|
||||
__asm("je force_version_0\n");
|
||||
__asm("cmp eax, _g_max_id\n");
|
||||
__asm("ja real_version\n");
|
||||
__asm("je force_level_0\n");
|
||||
__asm("cmp ebx, _g_max_id\n");
|
||||
__asm("ja real_level\n");
|
||||
|
||||
__asm("force_version_0:\n");
|
||||
__asm("force_level_0:\n");
|
||||
__asm("mov eax, 0x00\n");
|
||||
__asm("ret\n");
|
||||
|
||||
__asm("real_version:\n");
|
||||
real_getversion();
|
||||
}
|
||||
|
||||
void (*real_getcsversion)();
|
||||
void hook_getcsversion()
|
||||
{
|
||||
__asm("cmp eax, _g_min_id\n");
|
||||
__asm("jb real_csversion\n");
|
||||
__asm("cmp dword ptr _g_max_id, 0\n");
|
||||
__asm("je force_csversion_0\n");
|
||||
__asm("cmp eax, _g_max_id\n");
|
||||
__asm("ja real_csversion\n");
|
||||
|
||||
__asm("force_csversion_0:\n");
|
||||
__asm("mov eax, 0x00\n");
|
||||
__asm("ret\n");
|
||||
|
||||
__asm("real_csversion:\n");
|
||||
real_getcsversion();
|
||||
__asm("real_level:\n");
|
||||
__asm("pop ebx\n");
|
||||
real_after_getlevel();
|
||||
}
|
||||
|
||||
bool patch_exclude(const char *game_dll_fn)
|
||||
@ -1009,37 +996,19 @@ bool patch_exclude(const char *game_dll_fn)
|
||||
char *data = getDllData(game_dll_fn, &dllSize);
|
||||
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x00\x8B\x56\x04\x0F\xB7\x02\xE8", 8, 0);
|
||||
int64_t pattern_offset = search(data, dllSize, "\x8B\xF8\x83\xC4\x08\x85\xFF\x7E\x42", 9, 0);
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: exclude_customs: cannot find songlist processing table\n");
|
||||
LOG("popnhax: custom_exclude_from_level: cannot find songlist processing table\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t function_call_addr = (int64_t)(data + pattern_offset + 0x07);
|
||||
uint32_t function_offset = *((uint32_t*)(function_call_addr +0x01));
|
||||
uint64_t function_addr = function_call_addr+5+function_offset;
|
||||
uint64_t patch_addr = (int64_t)(data + pattern_offset);
|
||||
|
||||
MH_CreateHook((LPVOID)function_addr, (LPVOID)hook_getversion,
|
||||
(void **)&real_getversion);
|
||||
}
|
||||
/*
|
||||
//exclude from CS version category too
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\xB8\x13\x05\x00\x00\x66\x3B\xF0", 8, 0);
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: exclude_customs: cannot find getCSVersion calling function\n");
|
||||
return false;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)hook_after_getlevel,
|
||||
(void **)&real_after_getlevel);
|
||||
}
|
||||
|
||||
uint64_t function_call_addr = (int64_t)(data + pattern_offset + 0x0C);
|
||||
uint32_t function_offset = *((uint32_t*)(function_call_addr +0x01));
|
||||
uint64_t function_addr = function_call_addr+5+function_offset;
|
||||
|
||||
MH_CreateHook((LPVOID)function_addr, (LPVOID)hook_getcsversion,
|
||||
(void **)&real_getcsversion);
|
||||
}*/
|
||||
|
||||
LOG("popnhax: exclude_customs: Custom songs excluded from version listings\n");
|
||||
LOG("popnhax: custom_exclude_from_level: Custom songs excluded from level listings\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1073,6 +1042,9 @@ LOG("custom title format is %s\n", g_customformat);
|
||||
patch_custom_track_format(dllFilename);
|
||||
}
|
||||
|
||||
if (config->custom_exclude_from_level)
|
||||
patch_exclude(dllFilename);
|
||||
|
||||
return patch_custom_categ(dllFilename);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user