exclude from versions,CS + default fav rework

This commit is contained in:
CrazyRedMachine 2024-04-29 14:51:46 +02:00
parent 5e57926b58
commit d6ca83d076

View File

@ -84,14 +84,9 @@ void prepare_favorite_list(){
favorites_count = 0;
if ( file == NULL )
{
file = fopen("data_mods\\default.fav", "rb");
if (file == NULL)
{
return;
}
}
char line[32];
@ -213,6 +208,10 @@ void categ_inject_favorites()
__asm("cmp ecx, 0\n");
__asm("jne skip_fake_login\n");
__asm("mov dword ptr [edx], 0xFF000001\n");
__asm("sub edx, 0x19D\n"); //back to popn friendid offset
__asm("mov dword ptr [edx], 0x61666564\n"); // "defa"
__asm("add edx, 0x04\n");
__asm("mov dword ptr [edx], 0x00746C75\n"); // "ult"
__asm("skip_fake_login:\n");
//retrieve songlist according to friend id
@ -986,6 +985,84 @@ bool load_favorites(){
return true;
}
void (*real_getversion)();
void hook_getversion()
{
__asm("cmp eax, _g_min_id\n");
__asm("jb real_version\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("force_version_0:\n");
__asm("mov eax, 0x00\n");
//__asm("mov ecx, 0x138E\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("mov ecx, 0x138E\n");
__asm("ret\n");
__asm("real_csversion:\n");
real_getcsversion();
}
bool patch_exclude(const char *game_dll_fn)
{
DWORD dllSize = 0;
char *data = getDllData(game_dll_fn, &dllSize);
{
int64_t pattern_offset = search(data, dllSize, "\x00\x8B\x56\x04\x0F\xB7\x02\xE8", 8, 0);
if (pattern_offset == -1) {
LOG("popnhax: exclude_customs: 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;
MH_CreateHook((LPVOID)function_addr, (LPVOID)hook_getversion,
(void **)&real_getversion);
}
{
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;
}
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");
return true;
}
bool patch_custom_categs(const char *dllFilename, uint8_t mode, uint16_t min, uint16_t max)
{
g_min_id = min;
@ -999,6 +1076,8 @@ bool patch_custom_categs(const char *dllFilename, uint8_t mode, uint16_t min, ui
load_databases();
}
patch_exclude(dllFilename);
patch_custom_highlight(dllFilename);
load_favorites();