mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Reduced the number of trailing NOPs for MakeCall/Jump
* when the trailing length is longer than 4 bytes, it will use a mix of 5-byte long NOPs and single-byte NOPs.
This commit is contained in:
@@ -555,8 +555,7 @@ static void DebugModePatch() {
|
||||
|
||||
// Fix to prevent crashes when there is a '%' character in the printed message
|
||||
if (dbgMode > 1) {
|
||||
MakeCall(0x4C703F, debug_log_hack);
|
||||
BlockCall(0x4C7044); // just nop code
|
||||
MakeCall(0x4C703F, debug_log_hack, 5);
|
||||
}
|
||||
// replace calling debug_printf_ with _debug_func, to avoid buffer overflow with messages longer than 260 bytes
|
||||
MakeCall(0x45540F, op_display_msg_hack);
|
||||
|
||||
+9
-2
@@ -22,9 +22,16 @@ static __declspec(noinline) void __stdcall SafeWriteFunc(BYTE code, DWORD addr,
|
||||
*((BYTE*)addr) = code;
|
||||
*((DWORD*)(addr + 1)) = data;
|
||||
|
||||
do {
|
||||
while (len >= 5) {
|
||||
*((DWORD*)addrMem) = 0x00441F0F; // 5-byte long NOP (0F1F4400-XX)
|
||||
addrMem += 5;
|
||||
len -= 5;
|
||||
}
|
||||
// Fill the remaining bytes (1-4 bytes) with single-byte NOPs
|
||||
while (len > 0) {
|
||||
*((BYTE*)addrMem++) = CodeType::Nop;
|
||||
} while (--len);
|
||||
len--;
|
||||
}
|
||||
VirtualProtect((void*)addr, protectLen, oldProtect, &oldProtect);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user