forked from Popn_Tools/popnhax
Compare commits
No commits in common. "11ee17f48b76b25503604b10634a59b0a00e3797" and "c18656658cc466b27ac45cc41b675b758d537ce4" have entirely different histories.
11ee17f48b
...
c18656658c
6
dist/popnhax/popnhax.xml
vendored
6
dist/popnhax/popnhax.xml
vendored
@ -6,9 +6,9 @@
|
||||
<!-- Force unlock music, charts, characters, and deco parts when applicable -->
|
||||
<force_unlocks __type="bool">0</force_unlocks>
|
||||
<!-- Put customs into their own category (0: no, 1: simple category with all customs, 2: subcategories by folder name) -->
|
||||
<custom_categ __type="u8">2</custom_categ>
|
||||
<custom_categ __type="u8">0</custom_categ>
|
||||
<!-- Prevent customs from showing up in version folders -->
|
||||
<custom_exclude_from_version __type="bool">1</custom_exclude_from_version>
|
||||
<custom_exclude_from_version __type="bool">0</custom_exclude_from_version>
|
||||
<!-- Prevent customs from showing up in level folders -->
|
||||
<custom_exclude_from_level __type="bool">0</custom_exclude_from_level>
|
||||
|
||||
@ -140,8 +140,6 @@
|
||||
<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>
|
||||
<!-- Do not perform music limit checks for patch_xml_auto (not recommended) -->
|
||||
<ignore_music_limit __type="bool">0</ignore_music_limit>
|
||||
|
||||
<!-- Custom category options -->
|
||||
<!-- minimum songid for a song to be seen as "custom" -->
|
||||
|
@ -39,7 +39,6 @@ struct popnhax_config {
|
||||
bool disable_redirection;
|
||||
bool disable_multiboot;
|
||||
bool patch_xml_auto;
|
||||
bool ignore_music_limit;
|
||||
char patch_xml_filename[MAX_PATH];
|
||||
char force_datecode[11];
|
||||
bool network_datecode;
|
||||
|
@ -203,8 +203,6 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_STR, struct popnhax_config, custom_track_ti
|
||||
"/popnhax/custom_track_title_format")
|
||||
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, local_favorites,
|
||||
"/popnhax/local_favorites")
|
||||
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, ignore_music_limit,
|
||||
"/popnhax/ignore_music_limit")
|
||||
PSMAP_END
|
||||
|
||||
enum BufferIndexes {
|
||||
@ -1411,78 +1409,10 @@ static bool patch_purelong()
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool get_music_limit(uint32_t* limit) {
|
||||
DWORD dllSize = 0;
|
||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||
|
||||
{
|
||||
int64_t string_loc = search(data, dllSize, "Illegal music no %d", 19, 0);
|
||||
if (string_loc == -1) {
|
||||
LOG("popnhax: patch_db: could not retrieve music limit error string\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
string_loc += 0x10000000; //entrypoint
|
||||
char *as_hex = (char *) &string_loc;
|
||||
int64_t pattern_offset = search(data, dllSize, as_hex, 4, 0);
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: patch_db: could not retrieve music limit test function\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x1F;
|
||||
*limit = *(uint32_t*)patch_addr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
char *get_datecode_from_patches() {
|
||||
SearchFile s;
|
||||
char datecode[11] = {0};
|
||||
uint32_t music_limit = 0;
|
||||
if ( !get_music_limit(&music_limit) )
|
||||
{
|
||||
LOG("WARNING: could not retrieve music limit for datecode_auto\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s.search("data_mods", "xml", false);
|
||||
auto result = s.getResult();
|
||||
|
||||
for (uint16_t i=0; i<result.size(); i++) {
|
||||
uint32_t found_limit = 0;
|
||||
property *patch_xml = load_prop_file(result[i].c_str());
|
||||
READ_U32_OPT(patch_xml, property_search(patch_xml, NULL, "/patches/limits"), "music", found_limit)
|
||||
free(patch_xml);
|
||||
|
||||
if ( found_limit == music_limit )
|
||||
{
|
||||
memcpy(datecode, result[i].c_str()+10+8, 10);
|
||||
return strdup(datecode);
|
||||
}
|
||||
}
|
||||
|
||||
LOG("ERROR: datecode_auto: could not find matching patch file\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool patch_datecode(char *datecode) {
|
||||
DWORD dllSize = 0;
|
||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||
|
||||
if ( strcmp(datecode, "auto") == 0 )
|
||||
{
|
||||
if ( !config.patch_db )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
LOG("popnhax: find datecode based on patches_.xml file\n");
|
||||
g_datecode_override = get_datecode_from_patches();
|
||||
if ( g_datecode_override == NULL )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
g_datecode_override = strdup(datecode);
|
||||
g_datecode_override = strdup(datecode);
|
||||
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x8D\x44\x24\x10\x88\x4C\x24\x10\x88\x5C\x24\x11\x8D\x50\x01", 15, 0);
|
||||
@ -1527,6 +1457,21 @@ static bool patch_database() {
|
||||
DWORD dllSize = 0;
|
||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||
|
||||
patch_purelong();
|
||||
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x8D\x44\x24\x10\x88\x4C\x24\x10\x88\x5C\x24\x11\x8D\x50\x01", 15, 0);
|
||||
if (pattern_offset != -1) {
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)omnimix_patch_jbx,
|
||||
(void **)&real_omnimix_patch_jbx);
|
||||
|
||||
LOG("popnhax: Patched X rev for omnimix\n");
|
||||
} else {
|
||||
LOG("popnhax: Couldn't find rev patch\n");
|
||||
}
|
||||
}
|
||||
|
||||
char *target;
|
||||
|
||||
if (config.patch_xml_auto) {
|
||||
@ -1534,22 +1479,15 @@ static bool patch_database() {
|
||||
SearchFile s;
|
||||
uint8_t *datecode = NULL;
|
||||
bool found = false;
|
||||
uint32_t music_limit = 0;
|
||||
if ( !config.ignore_music_limit && !get_music_limit(&music_limit) )
|
||||
{
|
||||
LOG("WARNING: could not retrieve music limit\n");
|
||||
} else {
|
||||
LOG("popnhax: patch_db: music limit : %d\n", music_limit);
|
||||
}
|
||||
|
||||
if ( g_datecode_override != NULL )
|
||||
if (config.force_datecode[0] != '\0')
|
||||
{
|
||||
LOG("popnhax: auto detect patch file with datecode override %s\n", g_datecode_override);
|
||||
datecode = (uint8_t*) strdup(g_datecode_override);
|
||||
LOG("popnhax: auto detect patch file with datecode override %s\n",config.force_datecode);
|
||||
datecode = (uint8_t*) strdup(config.force_datecode);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("popnhax: auto detect patch file with datecode from ea3-config\n");
|
||||
LOG("popnhax: auto detect patch file from ea3-config\n");
|
||||
property *config_xml = load_prop_file("prop/ea3-config.xml");
|
||||
READ_STR_OPT(config_xml, property_search(config_xml, NULL, "/ea3/soft"), "ext", datecode)
|
||||
free(config_xml);
|
||||
@ -1567,58 +1505,26 @@ static bool patch_database() {
|
||||
|
||||
LOG("popnhax: patch_db: found %d xml files in data_mods\n",result.size());
|
||||
for (uint16_t i=0; i<result.size(); i++) {
|
||||
|
||||
filename = result[i].c_str()+10; // strip "data_mods\" since parsedb will prepend it...
|
||||
LOG("%d : %s\n",i,filename);
|
||||
bool datecode_match = (strstr(result[i].c_str(), (const char *)datecode) != NULL);
|
||||
bool limit_match = false;
|
||||
if ( music_limit != 0 )
|
||||
{
|
||||
uint32_t found_limit = 0;
|
||||
LOG(" check music limit... ");
|
||||
property *patch_xml = load_prop_file(result[i].c_str());
|
||||
READ_U32_OPT(patch_xml, property_search(patch_xml, NULL, "/patches/limits"), "music", found_limit)
|
||||
free(patch_xml);
|
||||
LOG("%d\n",found_limit);
|
||||
if ( found_limit == music_limit )
|
||||
{
|
||||
limit_match = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( limit_match )
|
||||
{
|
||||
LOG("popnhax: patch_db: found matching music limit, end search\n");
|
||||
if ( !datecode_match )
|
||||
{
|
||||
LOG("WARNING: datecode did NOT match, please update your %s\n", ( g_datecode_override != NULL ) ? "force_datecode value" : "ea3-config.xml");
|
||||
}
|
||||
if (strstr(result[i].c_str(), (const char *)datecode) != NULL) {
|
||||
found = true;
|
||||
LOG("popnhax: patch_db: found matching datecode, end search\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if ( datecode_match )
|
||||
{
|
||||
if ( music_limit == 0 )
|
||||
{
|
||||
found = true;
|
||||
LOG("popnhax: patch_db: found matching datecode (no music limit check), end search\n");
|
||||
break;
|
||||
}
|
||||
LOG("WARNING: found matching datecode but music limit doesn't check out, continue search\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
LOG("popnhax: patch_db: matching %s not found, please add the correct patch xml file in data_mods folder.\n", (music_limit == 0) ? "datecode" : "music limit");
|
||||
return false;
|
||||
LOG("popnhax: patch_db: matching datecode not found, defaulting to latest patch file.\n");
|
||||
}
|
||||
|
||||
LOG("popnhax: patch_db: using %s\n",filename);
|
||||
target = parse_patchdb(filename, data);
|
||||
|
||||
} else {
|
||||
|
||||
target = parse_patchdb(config.patch_xml_filename, data);
|
||||
|
||||
}
|
||||
|
||||
if (config.disable_redirection) {
|
||||
@ -1657,21 +1563,6 @@ static bool patch_database() {
|
||||
);
|
||||
limit_table[STYLE_TABLE_IDX] = new_limit_table[STYLE_TABLE_IDX];
|
||||
|
||||
patch_purelong();
|
||||
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x8D\x44\x24\x10\x88\x4C\x24\x10\x88\x5C\x24\x11\x8D\x50\x01", 15, 0);
|
||||
if (pattern_offset != -1) {
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset;
|
||||
MH_CreateHook((LPVOID)patch_addr, (LPVOID)omnimix_patch_jbx,
|
||||
(void **)&real_omnimix_patch_jbx);
|
||||
|
||||
LOG("popnhax: Patched X rev for omnimix\n");
|
||||
} else {
|
||||
LOG("popnhax: Couldn't find rev patch\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (config.disable_redirection) {
|
||||
LOG("Redirection-related code is disabled, buffer address, buffer size and related patches will not be applied");
|
||||
printf("Redirection-related code is disabled, buffer address, buffer size and related patches will not be applied");
|
||||
@ -5515,15 +5406,14 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
if (force_no_omni)
|
||||
config.patch_db = false;
|
||||
|
||||
bool datecode_auto = (strcmp(config.force_datecode, "auto") == 0);
|
||||
|
||||
if (!config.disable_multiboot)
|
||||
{
|
||||
/* automatically force datecode based on dll name when applicable (e.g. popn22_2022061300.dll and force_datecode is empty or "auto") */
|
||||
/* automatically force datecode based on dll name when applicable (e.g. popn22_2022061300.dll and no force_datecode) */
|
||||
if ( (strlen(g_game_dll_fn) == 21)
|
||||
&& ( datecode_auto || (config.force_datecode[0] == '\0') ) )
|
||||
&& (config.force_datecode[0] == '\0') )
|
||||
{
|
||||
LOG("popnhax: multiboot autotune activated (custom game dll, no force_datecode)\n");
|
||||
LOG("popnhax: multiboot autotune activated (custom game dll, force_datecode off)\n");
|
||||
memcpy(config.force_datecode, g_game_dll_fn+7, 10);
|
||||
LOG("popnhax: multiboot: auto set datecode to %s\n", config.force_datecode);
|
||||
if (config.score_challenge && ( config.game_version < 26 || strcmp(config.force_datecode,"2020092800") <= 0 ) )
|
||||
@ -5551,8 +5441,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
|
||||
if (config.force_datecode[0] != '\0')
|
||||
{
|
||||
if (!datecode_auto && strlen(config.force_datecode) != 10)
|
||||
LOG("popnhax: force_datecode: Invalid datecode %s, should be 10 digits (e.g. 2022061300) or \"auto\"\n", config.force_datecode);
|
||||
if (strlen(config.force_datecode) != 10)
|
||||
LOG("popnhax: force_datecode: Invalid datecode %s, should be 10 digits (e.g. 2022061300)\n", config.force_datecode);
|
||||
else
|
||||
patch_datecode(config.force_datecode);
|
||||
}
|
||||
@ -5729,15 +5619,13 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
}
|
||||
|
||||
if (config.patch_db) {
|
||||
/* must be called after force_datecode */
|
||||
LOG("popnhax: patching songdb\n");
|
||||
if ( patch_database() )
|
||||
{
|
||||
patch_db_power_points();
|
||||
patch_db_fix_cursor();
|
||||
if (config.custom_categ)
|
||||
patch_custom_categs(g_game_dll_fn, &config);
|
||||
}
|
||||
/* must be called after force_datecode */
|
||||
patch_db_power_points();
|
||||
patch_db_fix_cursor();
|
||||
if (config.custom_categ)
|
||||
patch_custom_categs(g_game_dll_fn, &config);
|
||||
patch_database();
|
||||
}
|
||||
|
||||
if (config.force_unlocks) {
|
||||
|
@ -1049,9 +1049,10 @@ void musichax_core_init(struct popnhax_config *config,
|
||||
|
||||
uint64_t chara_size, uint64_t *new_chara_size, char *orig_chara_data,
|
||||
uint8_t **new_chara_table) {
|
||||
bool force_unlocks = config->force_unlocks;
|
||||
bool is_expansion_allowed = !config->disable_expansions;
|
||||
bool is_redirection_allowed = !config->disable_redirection;
|
||||
|
||||
bool force_unlocks = config->force_unlocks;
|
||||
bool is_expansion_allowed = !config->disable_expansions;
|
||||
bool is_redirection_allowed = !config->disable_redirection;
|
||||
|
||||
if (style_size > fontstyle_table_size) {
|
||||
fontstyle_table_size = style_size;
|
||||
|
Loading…
Reference in New Issue
Block a user