|
31 | 31 |
|
32 | 32 | #include "SearchFile.h" |
33 | 33 |
|
34 | | -#define PROGRAM_VERSION "1.10.dev" |
| 34 | +#define PROGRAM_VERSION "1.10" |
35 | 35 |
|
36 | 36 | const char *g_game_dll_fn = NULL; |
37 | 37 | const char *g_config_fn = NULL; |
@@ -2677,13 +2677,6 @@ static bool patch_pfree() { |
2677 | 2677 | MH_CreateHook((LPVOID)patch_addr, (LPVOID)hook_pfree_pplist_inject, |
2678 | 2678 | (void **)&real_pfree_pplist_inject); |
2679 | 2679 | } |
2680 | | - /* prevent crash when playing only customs in a credit */ |
2681 | | - { |
2682 | | - if (!find_and_patch_hex(g_game_dll_fn, "\x0F\x8E\x5C\xFF\xFF\xFF\xEB\x04", 8, 6, "\x90\x90", 2)) |
2683 | | - { |
2684 | | - LOG("popnhax: pfree: cannot patch end list pointer\n"); |
2685 | | - } |
2686 | | - } |
2687 | 2680 |
|
2688 | 2681 | /* restore pp_list pointer so that it is freed at end of credit */ |
2689 | 2682 | { |
@@ -5116,6 +5109,33 @@ static bool patch_db_fix_cursor(){ |
5116 | 5109 | return true; |
5117 | 5110 | } |
5118 | 5111 |
|
| 5112 | +void (*real_pp_mean_compute)(); |
| 5113 | +void hook_pp_mean_compute() |
| 5114 | +{ |
| 5115 | + __asm("test ecx, ecx\n"); |
| 5116 | + __asm("jnz divide_list\n"); |
| 5117 | + __asm("mov eax, 0\n"); |
| 5118 | + __asm("jmp skip_divide\n"); |
| 5119 | + __asm("divide_list:\n"); |
| 5120 | + __asm("div ecx\n"); |
| 5121 | + __asm("skip_divide:\n"); |
| 5122 | + real_pp_mean_compute(); |
| 5123 | +} |
| 5124 | + |
| 5125 | +void (*real_pp_convergence_loop)(); |
| 5126 | +void hook_pp_convergence_loop() |
| 5127 | +{ |
| 5128 | + __asm("movzx eax, word ptr[ebx]\n"); |
| 5129 | + __asm("cmp eax, 0xBB8\n"); |
| 5130 | + __asm("jl conv_loop_rearm\n"); |
| 5131 | + __asm("mov al, 0\n"); |
| 5132 | + __asm("jmp conv_loop_leave\n"); |
| 5133 | + __asm("conv_loop_rearm:\n"); |
| 5134 | + __asm("mov al, 1\n"); |
| 5135 | + __asm("conv_loop_leave:\n"); |
| 5136 | + real_pp_convergence_loop(); |
| 5137 | +} |
| 5138 | + |
5119 | 5139 | bool patch_db_power_points() |
5120 | 5140 | { |
5121 | 5141 | DWORD dllSize = 0; |
@@ -5145,7 +5165,20 @@ bool patch_db_power_points() |
5145 | 5165 | g_pfree_song_offset = *(uint8_t *) ((int64_t)data + pattern_offset + 0x03); |
5146 | 5166 | } |
5147 | 5167 |
|
5148 | | - /* Adapt convergence value computation (skip cs_omni and customs) */ |
| 5168 | + /* skip cs_omni and customs in power point convergence value */ |
| 5169 | + { |
| 5170 | + int64_t pattern_offset = search(data, dllSize, "\x8B\x6C\x24\x30\x8B\x4C\x24\x2C", 8, 0); |
| 5171 | + if (pattern_offset == -1) { |
| 5172 | + LOG("popnhax: patch_db: cannot find power point convergence value computation loop\n"); |
| 5173 | + return false; |
| 5174 | + } |
| 5175 | + |
| 5176 | + uint64_t patch_addr = (int64_t)data + pattern_offset - 0x08; |
| 5177 | + MH_CreateHook((LPVOID)(patch_addr), (LPVOID)hook_pp_convergence_loop, |
| 5178 | + (void **)&real_pp_convergence_loop); |
| 5179 | + } |
| 5180 | + |
| 5181 | + /* make sure they cannot count (sanity check) */ |
5149 | 5182 | { |
5150 | 5183 | int64_t pattern_offset = search(data, dllSize, "\x84\xC0\x75\x11\x8D\x44\x24\x38", 8, 0); |
5151 | 5184 | if (pattern_offset == -1) { |
@@ -5179,9 +5212,33 @@ bool patch_db_power_points() |
5179 | 5212 | return false; |
5180 | 5213 | } |
5181 | 5214 | skip_pp_list_elem = (void(*)()) ((int64_t)data + jump_addr_offset); |
| 5215 | + } |
| 5216 | + |
| 5217 | + /* prevent crash when playing only customs in a credit */ |
| 5218 | + { |
| 5219 | + if (!find_and_patch_hex(g_game_dll_fn, "\x0F\x8E\x5C\xFF\xFF\xFF\xEB\x04", 8, 6, "\x90\x90", 2)) |
| 5220 | + { |
| 5221 | + LOG("popnhax: patch_db: cannot patch end list pointer\n"); |
| 5222 | + } |
| 5223 | + } |
| 5224 | + |
| 5225 | + /* prevent another crash when playing only customs in a credit (sanity check) */ |
| 5226 | + { |
| 5227 | + int64_t pattern_offset = search(data, dllSize, "\xC1\xF9\x02\x33\xD2\xF7\xF1\x8B\xC8", 9, 0); |
| 5228 | + if (pattern_offset == -1) { |
| 5229 | + LOG("popnhax: patch_db: cannot find power point mean computation\n"); |
| 5230 | + return false; |
| 5231 | + } |
| 5232 | + |
| 5233 | + uint64_t patch_addr = (int64_t)data + pattern_offset + 0x05; |
| 5234 | + patch_memory(patch_addr, (char*)"\x90\x90", 2); // erase original div ecx (is taken care of in hook_pp_mean_compute) |
5182 | 5235 |
|
| 5236 | + /* fix possible divide by zero error */ |
| 5237 | + MH_CreateHook((LPVOID)patch_addr, (LPVOID)hook_pp_mean_compute, |
| 5238 | + (void **)&real_pp_mean_compute); |
5183 | 5239 | } |
5184 | 5240 |
|
| 5241 | + LOG("popnhax: patch_db: power point computation fixed\n"); |
5185 | 5242 | return true; |
5186 | 5243 | } |
5187 | 5244 |
|
|
0 commit comments