|
50 | 50 | #include "ASMPatches/ASMCamera.h" |
51 | 51 |
|
52 | 52 | #include "ASMPatcher.hpp" |
| 53 | +#include "ASMDefinition.h" |
53 | 54 |
|
54 | 55 | /* This patch hooks KAGE_LogMessage by hand. LibZHL can't properly hook functions with varargs, and we need varargs to properly get log messages. |
55 | 56 | * So, we'll just do it manually, not a big deal. |
@@ -131,36 +132,33 @@ void ModSavesReReoute() { |
131 | 132 | } |
132 | 133 |
|
133 | 134 | void ASMPatchModReRoute() { |
134 | | - SigScan scanner("83c4446a0068????????ffd7"); |
135 | | - scanner.Scan(); |
136 | | - void* addr = scanner.GetAddress(); |
| 135 | + void* addr = sASMDefinitionHolder->GetDefinition(&AsmDefinitions::SetupSaveDirectoryModFolder); |
137 | 136 |
|
138 | | - printf("[REPENTOGON] Patching Mod Dir::Point to original mods dir %p\n", addr); |
| 137 | + printf("[REPENTOGON] Patching SetupSaveDirectory to redirect to original 'mods/' dir %p\n", addr); |
139 | 138 |
|
140 | | - ASMPatch::SavedRegisters savedRegisters(ASMPatch::SavedRegisters::GP_REGISTERS, true); |
| 139 | + ASMPatch::SavedRegisters savedRegisters(ASMPatch::SavedRegisters::GP_REGISTERS_STACKLESS, true); |
141 | 140 | ASMPatch patch; |
142 | 141 | patch.PreserveRegisters(savedRegisters) |
143 | 142 | .AddInternalCall(ModReReoute) |
144 | | - .RestoreRegisters(savedRegisters); |
145 | | - sASMPatcher.FlatPatch(addr, &patch); |
146 | | - |
147 | | - //Mod save data |
| 143 | + .RestoreRegisters(savedRegisters) |
| 144 | + .AddBytes(ByteBuffer().AddAny((char*)addr, 0x5)) // Restore overwritten bytes |
| 145 | + .AddRelativeJump((char*)addr + 0x5); |
| 146 | + sASMPatcher.PatchAt(addr, &patch); |
| 147 | +} |
148 | 148 |
|
149 | | - SigScan scanner2("83c4246a0068????????ffd7803d????????00"); |
150 | | - scanner2.Scan(); |
151 | | - void* addr2 = scanner2.GetAddress(); |
| 149 | +void ASMPatchModDataReRoute() { |
| 150 | + void* addr = sASMDefinitionHolder->GetDefinition(&AsmDefinitions::SetupSaveDirectoryModSaveDataFolder); |
152 | 151 |
|
153 | | - printf("[REPENTOGON] Patching Mod SaveData Dir::Point to original data dir %p\n", addr); |
| 152 | + printf("[REPENTOGON] Patching SetupSaveDirectory to redirect to original mod 'data/' dir %p\n", addr); |
154 | 153 |
|
155 | | - ASMPatch::SavedRegisters savedRegisters2(ASMPatch::SavedRegisters::GP_REGISTERS, true); |
156 | | - ASMPatch patch2; |
157 | | - patch2.PreserveRegisters(savedRegisters2) |
| 154 | + ASMPatch::SavedRegisters savedRegisters2(ASMPatch::SavedRegisters::GP_REGISTERS_STACKLESS, true); |
| 155 | + ASMPatch patch; |
| 156 | + patch.PreserveRegisters(savedRegisters2) |
158 | 157 | .AddInternalCall(ModSavesReReoute) |
159 | | - .RestoreRegisters(savedRegisters2); |
160 | | - sASMPatcher.FlatPatch(addr2, &patch2); |
161 | | - printf("%s \n", &g_ModSaveDataPath); |
162 | | - |
163 | | - |
| 158 | + .RestoreRegisters(savedRegisters2) |
| 159 | + .AddBytes(ByteBuffer().AddAny((char*)addr, 0x5)) // Restore overwritten bytes |
| 160 | + .AddRelativeJump((char*)addr + 0x5); |
| 161 | + sASMPatcher.PatchAt(addr, &patch); |
164 | 162 | } |
165 | 163 |
|
166 | 164 | void PerformASMPatches() { |
@@ -304,6 +302,7 @@ void PerformASMPatches() { |
304 | 302 |
|
305 | 303 | //Mod folder redirect |
306 | 304 | ASMPatchModReRoute(); |
| 305 | + ASMPatchModDataReRoute(); |
307 | 306 |
|
308 | 307 | // Tweaks (bug crashes) |
309 | 308 | if (!ASMPatches::FixGodheadEntityPartition()) { |
|
0 commit comments