test new_is_custom (not good enough, will discard)

This commit is contained in:
CrazyRedMachine 2024-04-27 23:04:42 +02:00
parent a7bf74962b
commit 94b7eb014d

View File

@ -26,7 +26,7 @@ uint32_t g_max_id = 0;
const char *g_categname = "Customs";
const char *g_categicon = "cate_cc";
const char *g_categformat = "[ol:4][olc:d92f0d]%s";
const char *g_customformat = "※[rz:3][c:d92f0d]%s[/rz][/c]※";
const char *g_customformat = "<EFBFBD>¦ [rz:3][c:d92f0d]%s[/rz][/c]";
char *g_string_addr;
uint8_t idx = 0;
@ -430,6 +430,54 @@ void hook_artist_printf()
real_artist_printf();
}
const char* g_newicon = "new";
const char* g_nonewicon = "non";
void (*real_song_checkifnew)();
void hook_song_checkifnew()
{
__asm("push eax\n");
__asm("push ebx\n");
__asm("mov ebx, _g_nonewicon\n");
__asm("mov dword ptr ss:[esp+0x50], ebx\n");
__asm("mov eax, [esp+0x48]\n");
__asm("cmp eax, _g_min_id\n");
__asm("jb put_nonewicon\n");
__asm("cmp dword ptr _g_max_id, 0\n");
__asm("je put_newicon\n");
__asm("cmp eax, _g_max_id\n");
__asm("ja put_nonewicon\n");
__asm("put_newicon:\n");
__asm("mov ebx, _g_newicon\n");
__asm("mov dword ptr ss:[esp+0x50], ebx\n");
__asm("put_nonewicon:\n");
__asm("pop ebx\n");
__asm("pop eax\n");
real_song_checkifnew();
}
static bool patch_custom_is_new(const char *game_dll_fn) {
DWORD dllSize = 0;
char *data = getDllData(game_dll_fn, &dllSize);
//hook format string for song/genre name
{
int64_t pattern_offset = search(data, dllSize, "\x8B\x50\x5C\x51\x8B\xCB\xFF\xD2\xC7\x44\x24\x48", 12, 0);
if (pattern_offset == -1) {
LOG("popnhax: custom_is_new: cannot find \"song is new\" check function\n");
return false;
}
uint64_t patch_addr = (int64_t)data + pattern_offset + 0x1C;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)hook_song_checkifnew,
(void **)&real_song_checkifnew);
}
return true;
}
static bool patch_custom_highlight(const char *game_dll_fn) {
DWORD dllSize = 0;
char *data = getDllData(game_dll_fn, &dllSize);
@ -695,6 +743,7 @@ bool patch_custom_categs(const char *dllFilename, uint8_t mode, uint16_t min, ui
}
patch_custom_highlight(dllFilename);
patch_custom_is_new(dllFilename);
return patch_custom_categ(dllFilename);
}