forked from Popn_Tools/popnhax
simple categ malloc
This commit is contained in:
parent
46ec71b83b
commit
2543d2632f
2
dist/popnhax/popnhax.xml
vendored
2
dist/popnhax/popnhax.xml
vendored
@ -134,7 +134,7 @@
|
||||
<disable_expansions __type="bool">0</disable_expansions>
|
||||
<!-- Copy the new table information over top the old tables (automatically enables disable_expansions) -->
|
||||
<disable_redirection __type="bool">0</disable_redirection>
|
||||
<!-- minimum songid for a song to be seen as "custom" (inclusive) -->
|
||||
<!-- minimum songid for a song to be seen as "custom" -->
|
||||
<custom_categ_min_songid __type="u16">4000</custom_categ_min_songid>
|
||||
<!-- maximum songid for a song to be seen as "custom" (0 = no limit) -->
|
||||
<custom_categ_max_songid __type="u16">0</custom_categ_max_songid>
|
||||
|
@ -19,9 +19,37 @@
|
||||
#include "minhook/hde32.h"
|
||||
#include "minhook/include/MinHook.h"
|
||||
|
||||
bool g_subcategmode = false;
|
||||
uint32_t g_min_id = 4000;
|
||||
uint32_t g_max_id = 0;
|
||||
|
||||
const char *g_categname = "Custom Tracks";
|
||||
const char *g_categicon = "cate_13";
|
||||
const char *g_categformat = "[ol:4][olc:d92f0d]%s";
|
||||
|
||||
char *g_string_addr;
|
||||
uint8_t idx = 0;
|
||||
uint32_t tmp_size = 0;
|
||||
uint32_t tmp_categ_ptr = 0;
|
||||
uint32_t tmp_songlist_ptr = 0;
|
||||
|
||||
#define SIMPLE_CATEG_ALLOC 1
|
||||
|
||||
#if SIMPLE_CATEG_ALLOC == 1
|
||||
uint32_t *songlist;
|
||||
#else
|
||||
uint32_t songlist[4096] = {0};
|
||||
#endif
|
||||
uint32_t songlist_addr = (uint32_t)&songlist;
|
||||
uint32_t songlist_count = 0;
|
||||
|
||||
struct songlist_struct_s {
|
||||
uint32_t dummy[3];
|
||||
uint32_t array_start;
|
||||
uint32_t array_end;
|
||||
} songlist_struct;
|
||||
uint32_t songlist_struct_addr = (uint32_t)&songlist_struct;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
uint32_t size;
|
||||
@ -65,28 +93,6 @@ static subcategory_s* get_subcateg(char *title)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool g_subcategmode = false;
|
||||
const char *g_categname = "Custom Tracks";
|
||||
const char *g_categicon = "cate_13";
|
||||
const char *g_categformat = "[ol:4][olc:d92f0d]%s";
|
||||
|
||||
char *g_string_addr;
|
||||
uint8_t idx = 0;
|
||||
uint32_t tmp_size = 0;
|
||||
uint32_t tmp_categ_ptr = 0;
|
||||
uint32_t tmp_songlist_ptr = 0;
|
||||
|
||||
uint32_t songlist[4096] = {0};
|
||||
uint32_t songlist_addr = (uint32_t)&songlist;
|
||||
uint32_t songlist_count = 0;
|
||||
|
||||
struct songlist_struct_s {
|
||||
uint32_t dummy[3];
|
||||
uint32_t array_start;
|
||||
uint32_t array_end;
|
||||
} songlist_struct;
|
||||
uint32_t songlist_struct_addr = (uint32_t)&songlist_struct;
|
||||
|
||||
void (*add_song_in_list)();
|
||||
void (*categ_inject_songlist)();
|
||||
|
||||
@ -279,10 +285,12 @@ void categ_inject_songlist_subcategs()
|
||||
//this replaces the category handling function ( add_song_in_list is a subroutine called by the game )
|
||||
void categ_inject_songlist_simple()
|
||||
{
|
||||
__asm("push ecx\n");
|
||||
__asm("push edx\n");
|
||||
songlist_struct.array_start = (uint32_t)&songlist;
|
||||
songlist_struct.array_start = (uint32_t)songlist;
|
||||
songlist_struct.array_end = (uint32_t)&(songlist[songlist_count]);
|
||||
__asm("pop edx\n");
|
||||
__asm("pop ecx\n");
|
||||
__asm("push ecx\n");
|
||||
__asm("push _songlist_struct_addr\n");
|
||||
__asm("lea eax, dword ptr [ecx+0x24]\n");
|
||||
@ -306,9 +314,20 @@ void hook_categ_build_songlist()
|
||||
__asm("je add_my_song\n");
|
||||
__asm("cmp eax, _g_max_id\n");
|
||||
__asm("ja categ_skip_add\n");
|
||||
|
||||
__asm("add_my_song:\n");
|
||||
__asm("push eax\n");
|
||||
__asm("push ebx\n");
|
||||
#if SIMPLE_CATEG_ALLOC == 1
|
||||
__asm("push ecx\n");
|
||||
__asm("push edx\n");
|
||||
__asm("sub esp, 0x08\n");
|
||||
songlist = (uint32_t*)realloc((void*)songlist, sizeof(uint32_t)*(songlist_count+1)); //TODO: only realloc when growing
|
||||
songlist_addr = (uint32_t)songlist;
|
||||
__asm("add esp, 0x08\n");
|
||||
__asm("pop edx\n");
|
||||
__asm("pop ecx\n");
|
||||
#endif
|
||||
__asm("mov eax, [_songlist_count]\n");
|
||||
__asm("sal eax, 2\n");
|
||||
__asm("add eax, _songlist_addr\n");
|
||||
|
Loading…
Reference in New Issue
Block a user