forked from Popn_Tools/popnhax
wip, folder names
This commit is contained in:
parent
298842bd61
commit
d0ea7fcc00
@ -19,7 +19,50 @@
|
||||
#include "minhook/hde32.h"
|
||||
#include "minhook/include/MinHook.h"
|
||||
|
||||
uint8_t g_subcateg_count = 5;
|
||||
uint8_t g_subcateg_count = 3;
|
||||
uint32_t **subcategs;
|
||||
char **subcateg_names;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
uint32_t size;
|
||||
uint32_t *songlist;
|
||||
} subcategory_s;
|
||||
|
||||
subcategory_s* subcategories;
|
||||
uint32_t subcateg_count = 0;
|
||||
|
||||
struct property *load_prop_file(const char *filename);
|
||||
|
||||
static bool subcateg_has_songid(uint32_t songid, subcategory_s* subcateg)
|
||||
{
|
||||
for ( uint32_t i = 0; i < subcateg->size; i++ )
|
||||
{
|
||||
if ( subcateg->songlist[i] == songid )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void add_song_to_subcateg(uint32_t songid, subcategory_s* subcateg)
|
||||
{
|
||||
if ( songid >= 3000 && !subcateg_has_songid(songid, subcateg) )
|
||||
{
|
||||
subcateg->songlist = (uint32_t *) realloc(subcateg->songlist, sizeof(uint32_t)*(++subcateg->size));
|
||||
subcateg->songlist[subcateg->size-1] = songid;
|
||||
LOG("%s : %d (subcateg size %d)\n", subcateg->name, songid, subcateg->size);
|
||||
}
|
||||
}
|
||||
|
||||
static subcategory_s* get_subcateg(char *title)
|
||||
{
|
||||
for (uint32_t i = 0; i < subcateg_count; i++)
|
||||
{
|
||||
if (strcmp(title, subcategories[i].name) == 0)
|
||||
return &(subcategories[i]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool g_subcategmode = false;
|
||||
const char *g_categname = "Custom Tracks";
|
||||
@ -47,16 +90,23 @@ void get_subcateg_size_impl()
|
||||
__asm("mov eax, 0");
|
||||
}
|
||||
|
||||
char g_test_string[9] = "TOTOMCDO";
|
||||
char *g_string_addr;
|
||||
uint8_t idx = 0;
|
||||
void get_subcateg_name_impl()
|
||||
{
|
||||
__asm("mov eax, _g_test_string");
|
||||
__asm("push ecx\n");
|
||||
__asm("push edx\n");
|
||||
__asm("mov _idx, eax\n");
|
||||
g_string_addr = subcategories[idx].name;
|
||||
__asm("mov eax, _g_string_addr");
|
||||
__asm("pop edx\n");
|
||||
__asm("pop ecx\n");
|
||||
}
|
||||
|
||||
uint32_t reimpl_value_1;
|
||||
uint32_t reimpl_value_2;
|
||||
void (*get_subcateg_size)();// = &get_subcateg_size_impl;
|
||||
void (*get_subcateg_name)();// = &get_subcateg_name_impl;
|
||||
void (*get_subcateg_name)() = &get_subcateg_name_impl;
|
||||
void (*reimpl_func_1)();
|
||||
void (*reimpl_func_2)();
|
||||
void (*reimpl_func_3)();
|
||||
@ -166,7 +216,7 @@ void categ_inject_songlist_reimpl()
|
||||
__asm("next_iter:\n");
|
||||
__asm("inc ebx\n");
|
||||
__asm("mov dword ptr ss:[esp+0x34], ebx\n");
|
||||
__asm("cmp ebx, [_g_subcateg_count]\n");
|
||||
__asm("cmp ebx, [_subcateg_count]\n");
|
||||
__asm("jb subcateg_loop\n");
|
||||
__asm("mov ecx, dword ptr ss:[esp+0x24]\n");
|
||||
__asm("mov dword ptr fs:[0], ecx\n");
|
||||
@ -290,7 +340,7 @@ static bool patch_custom_categ_simple(const char *game_dll_fn) {
|
||||
reimpl_func_4 = (void (*)())( *((uint32_t*)(function_addr +0xD1)) + (uint32_t)(function_addr +0x04 +0xD1) );
|
||||
|
||||
get_subcateg_size = (void (*)())( *((uint32_t*)(function_addr +0x37)) + (uint32_t)(function_addr +0x04 +0x37) );
|
||||
get_subcateg_name = (void (*)())( *((uint32_t*)(function_addr +0x63)) + (uint32_t)(function_addr +0x04 +0x63) );
|
||||
//get_subcateg_name = (void (*)())( *((uint32_t*)(function_addr +0x63)) + (uint32_t)(function_addr +0x04 +0x63) );
|
||||
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)hook_categ_listing,
|
||||
(void **)&real_categ_listing);
|
||||
@ -395,50 +445,6 @@ static bool patch_custom_categ_simple(const char *game_dll_fn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t **subcategs;
|
||||
char **subcateg_names;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
uint32_t size;
|
||||
uint32_t *songlist;
|
||||
} subcategory_s;
|
||||
|
||||
subcategory_s* subcategories;
|
||||
uint32_t subcateg_count = 0;
|
||||
|
||||
struct property *load_prop_file(const char *filename);
|
||||
|
||||
static bool subcateg_has_songid(uint32_t songid, subcategory_s* subcateg)
|
||||
{
|
||||
for ( uint32_t i = 0; i < subcateg->size; i++ )
|
||||
{
|
||||
if ( subcateg->songlist[i] == songid )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void add_song_to_subcateg(uint32_t songid, subcategory_s* subcateg)
|
||||
{
|
||||
if ( songid >= 3000 && !subcateg_has_songid(songid, subcateg) )
|
||||
{
|
||||
subcateg->songlist = (uint32_t *) realloc(subcateg->songlist, sizeof(uint32_t)*(++subcateg->size));
|
||||
subcateg->songlist[subcateg->size-1] = songid;
|
||||
LOG("%s : %d (subcateg size %d)\n", subcateg->name, songid, subcateg->size);
|
||||
}
|
||||
}
|
||||
|
||||
static subcategory_s* get_subcateg(char *title)
|
||||
{
|
||||
for (uint32_t i = 0; i < subcateg_count; i++)
|
||||
{
|
||||
if (strcmp(title, subcategories[i].name) == 0)
|
||||
return &(subcategories[i]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//extract folder name (cut "data_mods")
|
||||
static char *get_folder_name(const char* path) {
|
||||
size_t len = (size_t)(strchr(path+10, '\\')-(path+10));
|
||||
@ -495,6 +501,8 @@ bool patch_custom_categs(const char *dllFilename, uint8_t mode)
|
||||
if (mode == 1)
|
||||
{
|
||||
g_subcategmode = true;
|
||||
subcateg_count = 0;
|
||||
load_databases();
|
||||
return patch_custom_categ_simple(dllFilename);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user