This commit is contained in:
CrazyRedMachine 2024-04-21 16:09:33 +02:00
parent 75ca8ba050
commit 5f2a9d7bc0

View File

@ -46,7 +46,7 @@ static bool subcateg_has_songid(uint32_t songid, subcategory_s* subcateg)
static void add_song_to_subcateg(uint32_t songid, subcategory_s* subcateg) static void add_song_to_subcateg(uint32_t songid, subcategory_s* subcateg)
{ {
if ( songid >= 4000 && !subcateg_has_songid(songid, subcateg) ) if ( songid >= 3000 && !subcateg_has_songid(songid, subcateg) )
{ {
subcateg->songlist = (uint32_t *) realloc(subcateg->songlist, sizeof(uint32_t)*(++subcateg->size)); subcateg->songlist = (uint32_t *) realloc(subcateg->songlist, sizeof(uint32_t)*(++subcateg->size));
subcateg->songlist[subcateg->size-1] = songid; subcateg->songlist[subcateg->size-1] = songid;
@ -94,13 +94,12 @@ void get_subcateg_size_impl()
{ {
__asm("push edx\n"); __asm("push edx\n");
__asm("mov _idx, eax\n"); __asm("mov _idx, eax\n");
tmp_size = subcategories[idx-2].size;
// tmp_categ_ptr = (uint32_t)&(subcategories[idx]); tmp_size = subcategories[idx].size;
// tmp_songlist_ptr = (uint32_t)&(subcategories[idx].songlist);
new_song_list = (struct songlist_struct_s*) songlist_struct_addr; new_song_list = (struct songlist_struct_s*) songlist_struct_addr;
// new_song_list = (struct songlist_struct_s*) calloc(1, sizeof(struct songlist_struct_s)); new_song_list->array_start = (uint32_t)&(subcategories[idx].songlist[0]);
new_song_list->array_start = (uint32_t)&(subcategories[idx-2].songlist[0]); new_song_list->array_end = (uint32_t)&(subcategories[idx].songlist[tmp_size]);
new_song_list->array_end = (uint32_t)&(subcategories[idx-2].songlist[tmp_size]);
__asm("mov eax, [_tmp_size]"); __asm("mov eax, [_tmp_size]");
__asm("mov ecx, _new_song_list"); __asm("mov ecx, _new_song_list");
__asm("pop edx\n"); __asm("pop edx\n");
@ -136,59 +135,12 @@ void hook_event_categ_generation()
real_event_categ_generation(); real_event_categ_generation();
} }
uint32_t tmp_array_begin;
uint32_t tmp_array_end;
uint32_t tmp_zone;
void get_subcateg_size_impl_new()
{
//on ecrit dans la zone d'où la fonction habituelle lit, p'tet ça marchera
__asm("push ebx\n");
__asm("push edx\n");
__asm("push eax\n");
__asm("push ecx\n");
__asm("mov _idx, eax\n");
__asm("lea eax, dword ptr [eax+eax*2]");
__asm("lea ecx, dword ptr [ecx+eax*8+0x1D8C]");
__asm("mov _tmp_zone, ecx");
__asm("pop ecx\n");
__asm("pop eax\n");
tmp_size = subcategories[idx-2].size;
// tmp_categ_ptr = (uint32_t)&(subcategories[idx]);
// tmp_songlist_ptr = (uint32_t)&(subcategories[idx].songlist);
new_song_list = (struct songlist_struct_s*) songlist_struct_addr;
// new_song_list = (struct songlist_struct_s*) calloc(1, sizeof(struct songlist_struct_s));
tmp_array_begin = (uint32_t)&(subcategories[idx-2].songlist[0]);
new_song_list->array_start = tmp_array_begin;
tmp_array_end = (uint32_t)&(subcategories[idx-2].songlist[tmp_size]);
new_song_list->array_end = tmp_array_end;
__asm("push ecx");
__asm("push edx");
__asm("mov ecx, _tmp_zone");
__asm("mov edx, _tmp_array_end");
__asm("mov dword ptr ds:[ecx+0x10], edx");
__asm("mov edx, _tmp_array_begin");
__asm("mov dword ptr ds:[ecx+0xC], edx");
__asm("pop edx");
__asm("pop ecx");
__asm("mov eax, [_tmp_size]");
__asm("mov ecx, _new_song_list");
__asm("pop edx\n");
__asm("pop ebx\n");
}
void get_subcateg_name_impl() void get_subcateg_name_impl()
{ {
__asm("push ecx\n"); __asm("push ecx\n");
__asm("push edx\n"); __asm("push edx\n");
__asm("mov _idx, eax\n"); __asm("mov _idx, eax\n");
g_string_addr = subcategories[idx-2].name; g_string_addr = subcategories[idx].name;
__asm("mov eax, _g_string_addr"); __asm("mov eax, _g_string_addr");
__asm("pop edx\n"); __asm("pop edx\n");
__asm("pop ecx\n"); __asm("pop ecx\n");
@ -228,7 +180,7 @@ void categ_inject_songlist_reimpl()
__asm("mov dword ptr fs:[0], eax\n"); __asm("mov dword ptr fs:[0], eax\n");
__asm("mov ebp, dword ptr [esp+0x34]\n"); __asm("mov ebp, dword ptr [esp+0x34]\n");
__asm("xor ebx, ebx\n"); __asm("xor ebx, ebx\n");
__asm("mov ebx, 2\n");
__asm("mov dword ptr ss:[esp+0x34], ebx\n"); __asm("mov dword ptr ss:[esp+0x34], ebx\n");
__asm("subcateg_loop:\n"); __asm("subcateg_loop:\n");
__asm("mov ecx, dword ptr ss:[ebp+0x08]\n"); __asm("mov ecx, dword ptr ss:[ebp+0x08]\n");
@ -308,14 +260,10 @@ __asm("mov ebx, 2\n");
__asm("next_iter:\n"); __asm("next_iter:\n");
__asm("inc ebx\n"); __asm("inc ebx\n");
__asm("mov dword ptr ss:[esp+0x34], ebx\n"); __asm("mov dword ptr ss:[esp+0x34], ebx\n");
__asm("push ecx"); __asm("cmp ebx, [_subcateg_count]\n");
__asm("mov ecx, [_subcateg_count]\n");
__asm("add ecx, 2\n");
__asm("cmp ebx, ecx\n");
__asm("pop ecx");
__asm("jb subcateg_loop\n"); __asm("jb subcateg_loop\n");
__asm("mov ecx, dword ptr ss:[esp+0x24]\n"); __asm("mov ecx, dword ptr ss:[esp+0x24]\n");
__asm("mov dword ptr fs:[0], ecx\n"); __asm("mov dword ptr fs:[0], ecx\n");
__asm("pop ecx\n"); __asm("pop ecx\n");