@@ -161,6 +161,71 @@ def __init__(self) -> None:
161
161
helper_addr = guard_write_addr + 0x33b , helper_code_len = 13 ,
162
162
code_addr = code_addr , injected_code = injected_code )
163
163
164
+ # NOTE: damage multiplier
165
+ """
166
+ 48 ** ** ** 8B ** 89 ** ** ** 00 00 85 C0 7F
167
+ """
168
+ bytes_pattern = b"\x48 ...\x8b .\x89 ...\x00 \x00 \x85 \xc0 \x7f "
169
+ damage_write_addr = pymem .pattern .pattern_scan_module (
170
+ self .pm .process_handle , module_game , bytes_pattern )
171
+ if damage_write_addr is None :
172
+ logging .critical ("damage_write_addr scan failed" )
173
+ raise RuntimeError ()
174
+ """[code injection]
175
+ push rcx
176
+ push rbx
177
+ push rdx
178
+ mov rdx, damage2boss_multiplier
179
+ mov rcx, agent_mem_ptr
180
+ cmp [rcx], rbx
181
+ jne calc
182
+ mov rdx, damage2agent_multiplier
183
+ lea rdx, [rdx]
184
+
185
+ calc:
186
+ test eax, eax
187
+ jz done
188
+ lea rbx, [rbx+130]
189
+ cmp [rbx], eax
190
+ jle done
191
+ mov ecx, [rbx]
192
+ sub ecx, eax
193
+ push rcx
194
+ fild dword ptr [rsp]
195
+ fmul dword ptr [rdx]
196
+ fistp dword ptr [rsp]
197
+ pop rcx
198
+ mov eax, [rbx]
199
+ sub eax, ecx
200
+ jns done
201
+ xor eax, eax
202
+
203
+ done:
204
+ pop rdx
205
+ pop rbx
206
+ pop rcx
207
+ """
208
+ code_addr = self .pm .allocate (256 )
209
+ damage2boss_multiplier = self .pm .allocate (4 ) # 4 bytes
210
+ self .pm .write_float (damage2boss_multiplier , 2.0 )
211
+ damage2agent_multiplier = self .pm .allocate (4 )
212
+ self .pm .write_float (damage2agent_multiplier , 0.2 )
213
+ injected_code = b"\x51 \x53 \x52 " + \
214
+ b"\x48 \xba " + damage2boss_multiplier .to_bytes (8 , "little" ) + \
215
+ b"\x48 \xb9 " + self .agent_mem_ptr .to_bytes (8 , "little" ) + \
216
+ b"\x48 \x39 \x19 " + b"\x0f \x85 \x0d \x00 \x00 \x00 " + \
217
+ b"\x48 \xba " + damage2agent_multiplier .to_bytes (8 , "little" ) + b"\x48 \x8d \x12 " + \
218
+ b"\x85 \xc0 " + b"\x0f \x84 \x29 \x00 \x00 \x00 " + \
219
+ b"\x48 \x8d \x9b \x30 \x01 \x00 \x00 " + b"\x39 \x03 " + \
220
+ b"\x0f \x8e \x1a \x00 \x00 \x00 " + b"\x8b \x0b " + b"\x29 \xc1 " + \
221
+ b"\x51 " + b"\xdb \x04 \x24 \xd8 \x0a \xdb \x1c \x24 " + b"\x59 " + \
222
+ b"\x8b \x03 " + b"\x29 \xc8 " + b"\x0f \x89 \x02 \x00 \x00 \x00 " + b"\x31 \xc0 " + \
223
+ b"\x5A \x5B \x59 "
224
+ self .damage_code_injection = CodeInjection (
225
+ self .pm , original_addr = damage_write_addr + 6 , original_code_len = 6 ,
226
+ helper_addr = damage_write_addr + 0x1a59 , helper_code_len = 13 ,
227
+ code_addr = code_addr , injected_code = injected_code )
228
+
164
229
self .agent_mem_ptr = partial (
165
230
self .pm .read_ulonglong , self .agent_mem_ptr )
166
231
self .boss_mem_ptr = partial (
@@ -175,6 +240,7 @@ def __init__(self) -> None:
175
240
def restoreMemory (self ) -> None :
176
241
self .agent_code_injection .restoreMemory ()
177
242
self .boss_code_injection .restoreMemory ()
243
+ self .damage_code_injection .restoreMemory ()
178
244
179
245
def resetEndurance (self ) -> None :
180
246
try :
0 commit comments