mirror of
https://github.com/CrazyRedMachine/popnhax.git
synced 2024-11-27 23:40:50 +01:00
--no-omni, cleanup
This commit is contained in:
parent
2127e8c928
commit
5ede5a3692
6
dist/popnhax/popnhax.xml
vendored
6
dist/popnhax/popnhax.xml
vendored
@ -79,9 +79,9 @@
|
|||||||
<disable_redirection __type="bool">0</disable_redirection>
|
<disable_redirection __type="bool">0</disable_redirection>
|
||||||
|
|
||||||
<!-- Translation -->
|
<!-- Translation -->
|
||||||
<!-- Disable string replacements from .dict file -->
|
<!-- Disable .dict string replacements and .ips patches -->
|
||||||
<disable_translation __type="bool">0</disable_translation>
|
<disable_translation __type="bool">0</disable_translation>
|
||||||
<!-- Dump applied translations in dict_applied.txt (requires translation) -->
|
<!-- Dump applied translations and dll runtime data to help debug translation -->
|
||||||
<dump_dict __type="bool">0</dump_dict>
|
<translation_debug __type="bool">0</translation_debug>
|
||||||
|
|
||||||
</popnhax>
|
</popnhax>
|
||||||
|
@ -111,7 +111,8 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, audio_source_f
|
|||||||
"/popnhax/audio_source_fix")
|
"/popnhax/audio_source_fix")
|
||||||
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, unset_volume,
|
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, unset_volume,
|
||||||
"/popnhax/unset_volume")
|
"/popnhax/unset_volume")
|
||||||
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, event_mode, "/popnhax/event_mode")
|
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, event_mode,
|
||||||
|
"/popnhax/event_mode")
|
||||||
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, remove_timer,
|
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, remove_timer,
|
||||||
"/popnhax/remove_timer")
|
"/popnhax/remove_timer")
|
||||||
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, freeze_timer,
|
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, freeze_timer,
|
||||||
@ -1106,9 +1107,9 @@ static bool patch_unset_volume() {
|
|||||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||||
|
|
||||||
int64_t first_loc = search(data, dllSize, "\x04\x00\x81\xC4\x00\x01\x00\x00\xC3\xCC", 10, 0);
|
int64_t first_loc = search(data, dllSize, "\x04\x00\x81\xC4\x00\x01\x00\x00\xC3\xCC", 10, 0);
|
||||||
if (first_loc == -1) {
|
if (first_loc == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t pattern_offset = search(data, 0x10, "\x83", 1, first_loc);
|
int64_t pattern_offset = search(data, 0x10, "\x83", 1, first_loc);
|
||||||
if (pattern_offset == -1) {
|
if (pattern_offset == -1) {
|
||||||
@ -1172,7 +1173,7 @@ static bool patch_skip_tutorials() {
|
|||||||
DWORD dllSize = 0;
|
DWORD dllSize = 0;
|
||||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||||
|
|
||||||
{
|
{
|
||||||
int64_t first_loc = search(data, dllSize, "\xFD\xFF\x5E\xC2\x04\x00\xE8", 7, 0);
|
int64_t first_loc = search(data, dllSize, "\xFD\xFF\x5E\xC2\x04\x00\xE8", 7, 0);
|
||||||
if (first_loc == -1) {
|
if (first_loc == -1) {
|
||||||
return false;
|
return false;
|
||||||
@ -1231,7 +1232,7 @@ bool force_unlock_songs() {
|
|||||||
int music_unlocks = 0, chart_unlocks = 0;
|
int music_unlocks = 0, chart_unlocks = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
// 0xac here is the size of music_entry. May change in the future
|
// 0xac here is the size of music_entry. May change in the future
|
||||||
int64_t pattern_offset = search(data, dllSize, "\x69\xC0\xAC\x00\x00\x00\x8B\x80", 8, 0);
|
int64_t pattern_offset = search(data, dllSize, "\x69\xC0\xAC\x00\x00\x00\x8B\x80", 8, 0);
|
||||||
if (pattern_offset == -1) {
|
if (pattern_offset == -1) {
|
||||||
LOG("popnhax: couldn't unlock songs and charts\n");
|
LOG("popnhax: couldn't unlock songs and charts\n");
|
||||||
@ -1281,7 +1282,7 @@ bool force_unlock_charas() {
|
|||||||
int chara_unlocks = 0;
|
int chara_unlocks = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
// 0x4c here is the size of character_entry. May change in the future
|
// 0x4c here is the size of character_entry. May change in the future
|
||||||
int64_t pattern_offset = search(data, dllSize, "\x98\x6B\xC0\x4C\x8B\x80", 6, 0);
|
int64_t pattern_offset = search(data, dllSize, "\x98\x6B\xC0\x4C\x8B\x80", 6, 0);
|
||||||
if (pattern_offset == -1) {
|
if (pattern_offset == -1) {
|
||||||
LOG("popnhax: couldn't unlock characters\n");
|
LOG("popnhax: couldn't unlock characters\n");
|
||||||
@ -1527,7 +1528,7 @@ static bool patch_hidden_is_offset()
|
|||||||
patch_memory(hiddencommitoptionaddr+placeholder_offset+1, eax_to_offset, 5);
|
patch_memory(hiddencommitoptionaddr+placeholder_offset+1, eax_to_offset, 5);
|
||||||
|
|
||||||
/* find option commit function (unilab) */
|
/* find option commit function (unilab) */
|
||||||
uint8_t shift = 6;
|
uint8_t shift = 6;
|
||||||
int64_t pattern_offset = search(data, dllSize, "\x03\xC7\x8D\x44\x01\x2A\x89\x10", 8, 0);
|
int64_t pattern_offset = search(data, dllSize, "\x03\xC7\x8D\x44\x01\x2A\x89\x10", 8, 0);
|
||||||
if (pattern_offset == -1) {
|
if (pattern_offset == -1) {
|
||||||
/* wasn't found, look for older function */
|
/* wasn't found, look for older function */
|
||||||
@ -1578,8 +1579,8 @@ static bool patch_show_hidden_adjust_result_screen() {
|
|||||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||||
|
|
||||||
int64_t first_loc = search(data, dllSize, "\x6A\x00\x0F\xBE\xCB", 5, 0);
|
int64_t first_loc = search(data, dllSize, "\x6A\x00\x0F\xBE\xCB", 5, 0);
|
||||||
if (first_loc == -1)
|
if (first_loc == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
int64_t pattern_offset = search(data, 0x200, "\x80\xBC\x24", 3, first_loc);
|
int64_t pattern_offset = search(data, 0x200, "\x80\xBC\x24", 3, first_loc);
|
||||||
@ -2074,7 +2075,7 @@ static bool patch_score_challenge()
|
|||||||
/* Part1: retrieve course id and song id, useful and will simplify a little */
|
/* Part1: retrieve course id and song id, useful and will simplify a little */
|
||||||
{
|
{
|
||||||
|
|
||||||
int64_t pattern_offset = search(data, dllSize, "\x81\xC6\xCC\x08\x00\x00\xC7\x44\x24", 9, 0);
|
int64_t pattern_offset = search(data, dllSize, "\x81\xC6\xCC\x08\x00\x00\xC7\x44\x24", 9, 0);
|
||||||
if (pattern_offset == -1) {
|
if (pattern_offset == -1) {
|
||||||
LOG("popnhax: score challenge: cannot find course/song address\n");
|
LOG("popnhax: score challenge: cannot find course/song address\n");
|
||||||
return false;
|
return false;
|
||||||
@ -2493,7 +2494,7 @@ static bool get_rendaddr()
|
|||||||
DWORD dllSize = 0;
|
DWORD dllSize = 0;
|
||||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||||
|
|
||||||
{
|
{
|
||||||
int64_t pattern_offset = search(data, dllSize, "\x3b\xC3\x74\x13\xC7\x00\x02\x00\x00\x00\x89\x58\x04\x89\x58\x08", 16, 0);
|
int64_t pattern_offset = search(data, dllSize, "\x3b\xC3\x74\x13\xC7\x00\x02\x00\x00\x00\x89\x58\x04\x89\x58\x08", 16, 0);
|
||||||
if (pattern_offset == -1) {
|
if (pattern_offset == -1) {
|
||||||
return false;
|
return false;
|
||||||
@ -2911,16 +2912,13 @@ static bool patch_practice_mode()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||||
switch (ul_reason_for_call) {
|
switch (ul_reason_for_call) {
|
||||||
case DLL_PROCESS_ATTACH: {
|
case DLL_PROCESS_ATTACH: {
|
||||||
g_log_fp = fopen("popnhax.log", "w");
|
g_log_fp = fopen("popnhax.log", "w");
|
||||||
if (g_log_fp == NULL)
|
if (g_log_fp == NULL)
|
||||||
{
|
{
|
||||||
g_log_fp = stderr;
|
LOG("cannot open popnhax.log for write, output to stderr only\n");
|
||||||
LOG("cannot open popnhax.log for write, output to stderr\n");
|
|
||||||
}
|
}
|
||||||
LOG("popnhax: Initializing\n");
|
LOG("popnhax: Initializing\n");
|
||||||
if (MH_Initialize() != MH_OK) {
|
if (MH_Initialize() != MH_OK) {
|
||||||
@ -2929,7 +2927,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool force_trans_debug = false;
|
bool force_trans_debug = false;
|
||||||
|
bool force_no_omni = false;
|
||||||
|
|
||||||
LPWSTR *szArglist;
|
LPWSTR *szArglist;
|
||||||
int nArgs;
|
int nArgs;
|
||||||
@ -2957,9 +2956,14 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
}
|
}
|
||||||
else if ( wcscmp(szArglist[i], L"--translation-debug") == 0 )
|
else if ( wcscmp(szArglist[i], L"--translation-debug") == 0 )
|
||||||
{
|
{
|
||||||
LOG("--translation-debug: turning on translation-related dumps\n");
|
LOG("--translation-debug: turning on translation-related dumps\n");
|
||||||
force_trans_debug = true;
|
force_trans_debug = true;
|
||||||
}
|
}
|
||||||
|
else if ( wcscmp(szArglist[i], L"--no-omni") == 0 )
|
||||||
|
{
|
||||||
|
LOG("--no-omni: force disable patch_db\n");
|
||||||
|
force_no_omni = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LocalFree(szArglist);
|
LocalFree(szArglist);
|
||||||
|
|
||||||
@ -2983,8 +2987,11 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
|
|
||||||
_load_config(g_config_fn, &config, config_psmap);
|
_load_config(g_config_fn, &config, config_psmap);
|
||||||
|
|
||||||
if (force_trans_debug)
|
if (force_trans_debug)
|
||||||
config.translation_debug = true;
|
config.translation_debug = true;
|
||||||
|
|
||||||
|
if (force_no_omni)
|
||||||
|
config.patch_db = false;
|
||||||
|
|
||||||
if (!config.disable_multiboot)
|
if (!config.disable_multiboot)
|
||||||
{
|
{
|
||||||
@ -2992,7 +2999,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
if ( (strlen(g_game_dll_fn) == 21)
|
if ( (strlen(g_game_dll_fn) == 21)
|
||||||
&& (config.force_datecode[0] == '\0') )
|
&& (config.force_datecode[0] == '\0') )
|
||||||
{
|
{
|
||||||
LOG("popnhax: multiboot autotune activated (custom game dll, default xml, force_datecode off)\n");
|
LOG("popnhax: multiboot autotune activated (custom game dll, force_datecode off)\n");
|
||||||
memcpy(config.force_datecode, g_game_dll_fn+7, 10);
|
memcpy(config.force_datecode, g_game_dll_fn+7, 10);
|
||||||
LOG("popnhax: multiboot: auto set datecode to %s\n", config.force_datecode);
|
LOG("popnhax: multiboot: auto set datecode to %s\n", config.force_datecode);
|
||||||
if (config.force_unlock_deco && ( strcmp(config.force_datecode, "2022061300") > 0) )
|
if (config.force_unlock_deco && ( strcmp(config.force_datecode, "2022061300") > 0) )
|
||||||
@ -3032,37 +3039,37 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
{
|
{
|
||||||
|
|
||||||
sprintf(translation_folder, "_%s%s", config.force_datecode, "_tr");
|
sprintf(translation_folder, "_%s%s", config.force_datecode, "_tr");
|
||||||
sprintf(translation_path, "%s%s", "data_mods\\", translation_folder);
|
sprintf(translation_path, "%s%s", "data_mods\\", translation_folder);
|
||||||
if (access(translation_path, F_OK) != 0)
|
if (access(translation_path, F_OK) != 0)
|
||||||
{
|
{
|
||||||
translation_folder[0] = '\0';
|
translation_folder[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (translation_folder[0] == '\0')
|
if (translation_folder[0] == '\0')
|
||||||
{
|
{
|
||||||
sprintf(translation_folder, "%s", "_translation");
|
sprintf(translation_folder, "%s", "_translation");
|
||||||
sprintf(translation_path, "%s%s", "data_mods\\", translation_folder);
|
sprintf(translation_path, "%s%s", "data_mods\\", translation_folder);
|
||||||
if (access(translation_path, F_OK) != 0)
|
if (access(translation_path, F_OK) != 0)
|
||||||
{
|
{
|
||||||
translation_folder[0] = '\0';
|
translation_folder[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (translation_folder[0] != '\0')
|
if (translation_folder[0] != '\0')
|
||||||
{
|
{
|
||||||
LOG("popnhax: translation: using folder \"%s\"\n", translation_folder);
|
LOG("popnhax: translation: using folder \"%s\"\n", translation_folder);
|
||||||
patch_translate(g_game_dll_fn, translation_folder, config.translation_debug);
|
patch_translate(g_game_dll_fn, translation_folder, config.translation_debug);
|
||||||
|
}
|
||||||
|
else if ( config.translation_debug )
|
||||||
|
{
|
||||||
|
DWORD dllSize = 0;
|
||||||
|
char *data = getDllData(g_game_dll_fn, &dllSize);
|
||||||
|
LOG("popnhax: translation debug: no translation applied, dump prepatched dll\n");
|
||||||
|
FILE* dllrtp = fopen("dllruntime_prepatched.dll", "wb");
|
||||||
|
fwrite(data, 1, dllSize, dllrtp);
|
||||||
|
fclose(dllrtp);
|
||||||
}
|
}
|
||||||
else if ( config.translation_debug )
|
|
||||||
{
|
|
||||||
DWORD dllSize = 0;
|
|
||||||
char *data = getDllData(g_game_dll_fn, &dllSize);
|
|
||||||
LOG("popnhax: translation debug: no translation applied, dump prepatched dll\n");
|
|
||||||
FILE* dllrtp = fopen("dllruntime_prepatched.dll", "wb");
|
|
||||||
fwrite(data, 1, dllSize, dllrtp);
|
|
||||||
fclose(dllrtp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.practice_mode) {
|
if (config.practice_mode) {
|
||||||
|
@ -81,23 +81,6 @@ bool patch_sjis(const char *dllFilename, const char *find, uint8_t find_size, in
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* _translation_open_dict(char *foldername, bool *ips)
|
|
||||||
{
|
|
||||||
*ips = true;
|
|
||||||
char dict_filepath[64];
|
|
||||||
sprintf(dict_filepath, "%s%s%s", "data_mods\\", foldername, "\\popn22.ips");
|
|
||||||
FILE *file = fopen(dict_filepath, "rb");
|
|
||||||
if (file != NULL)
|
|
||||||
{
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ips = false;
|
|
||||||
sprintf(dict_filepath, "%s%s%s", "data_mods\\", foldername, "\\popn22.dict");
|
|
||||||
file = fopen(dict_filepath, "rb");
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RELOC_HIGHLOW 0x3
|
#define RELOC_HIGHLOW 0x3
|
||||||
static void perform_reloc(char *data, int32_t delta, uint32_t ext_base, uint32_t ext_delta)
|
static void perform_reloc(char *data, int32_t delta, uint32_t ext_base, uint32_t ext_delta)
|
||||||
{
|
{
|
||||||
@ -450,11 +433,6 @@ static bool patch_translation_dict(const char *dllFilename, const char *folderna
|
|||||||
#undef STATE_TRANSLATION
|
#undef STATE_TRANSLATION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool patch_translate(const char *dllFilename, const char *folder, bool debug)
|
bool patch_translate(const char *dllFilename, const char *folder, bool debug)
|
||||||
{
|
{
|
||||||
bool ips_done = false;
|
bool ips_done = false;
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
FILE* _translation_open_dict(char *foldername, bool *ips);
|
|
||||||
|
|
||||||
bool patch_translate(const char *dllFilename, const char *folder, bool debug);
|
bool patch_translate(const char *dllFilename, const char *folder, bool debug);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
extern FILE *g_log_fp;
|
extern FILE *g_log_fp;
|
||||||
|
|
||||||
#define LOG(...) do { \
|
#define LOG(...) do { \
|
||||||
if (g_log_fp != stderr) { \
|
if (g_log_fp != NULL) { \
|
||||||
fprintf(g_log_fp, __VA_ARGS__); \
|
fprintf(g_log_fp, __VA_ARGS__); \
|
||||||
fflush(g_log_fp);\
|
fflush(g_log_fp);\
|
||||||
}\
|
}\
|
||||||
|
@ -36,43 +36,40 @@ int _search(unsigned char *haystack, size_t haystack_size, const unsigned char *
|
|||||||
int j = needle_size - 1;
|
int j = needle_size - 1;
|
||||||
if (debug == 2)
|
if (debug == 2)
|
||||||
{
|
{
|
||||||
LOG("--------------------------------\n");
|
LOG("--------------------------------\n");
|
||||||
LOG("txt...");
|
LOG("txt...");
|
||||||
for (size_t i = 0; i < needle_size; i++)
|
for (size_t i = 0; i < needle_size; i++)
|
||||||
{
|
{
|
||||||
LOG("%02x ", haystack[orig_offset+s+i]);
|
LOG("%02x ", haystack[orig_offset+s+i]);
|
||||||
}
|
}
|
||||||
LOG("\n");
|
LOG("\n");
|
||||||
LOG("pat...");
|
LOG("pat...");
|
||||||
for (size_t i = 0; i < needle_size; i++)
|
for (size_t i = 0; i < needle_size; i++)
|
||||||
{
|
{
|
||||||
LOG("%02x ", needle[i]);
|
LOG("%02x ", needle[i]);
|
||||||
}
|
}
|
||||||
LOG("\n");
|
LOG("\n");
|
||||||
}
|
}
|
||||||
while (j >= 0 && needle[j] == haystack[orig_offset + s + j])
|
while (j >= 0 && needle[j] == haystack[orig_offset + s + j])
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
if (j < 0) {
|
if (j < 0) {
|
||||||
//printf("\n pattern occurs at shift = %d", s);
|
if (debug)
|
||||||
//s += (s + needle_size < haystack_size) ? needle_size - badchar[txt[s + needle_size]] : 1;
|
LOG("found string at offset %llx!\n", orig_offset +s);
|
||||||
if (debug)
|
return orig_offset + s;
|
||||||
LOG("found string at offset %llx!\n", orig_offset +s);
|
|
||||||
return orig_offset + s;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s += max(1, j - badchar[(int)haystack[orig_offset + s + j]]);
|
s += max(1, j - badchar[(int)haystack[orig_offset + s + j]]);
|
||||||
if (debug)
|
if (debug)
|
||||||
LOG("mismatch at pos %d, new offset %llx\n\n", j, orig_offset+s);
|
LOG("mismatch at pos %d, new offset %llx\n\n", j, orig_offset+s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int search(char *haystack, size_t haystack_size, const char *needle, size_t needle_size, size_t orig_offset) {
|
int search(char *haystack, size_t haystack_size, const char *needle, size_t needle_size, size_t orig_offset) {
|
||||||
int res = _search((unsigned char*) haystack, haystack_size, (const unsigned char *)needle, needle_size, orig_offset, 0);
|
int res = _search((unsigned char*) haystack, haystack_size, (const unsigned char *)needle, needle_size, orig_offset, 0);
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user