Skip to content

Commit 3f192f4

Browse files
committed
Fix null item patch causing inconsistent access violations on debug builds
1 parent 59437cf commit 3f192f4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

repentogon/Patches/NullItemsAndCostumes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ void ASMPatchFixLoadingNullItemsFromXml() {
5454

5555
ASMPatch::SavedRegisters savedRegisters(ASMPatch::SavedRegisters::Registers::GP_REGISTERS_STACKLESS, true);
5656
ASMPatch patch;
57-
patch.AddBytes(ByteBuffer().AddAny((char*)addr, 0x5)) // Restore the commands we overwrote
58-
.PreserveRegisters(savedRegisters)
57+
patch.PreserveRegisters(savedRegisters)
5958
.Push(ASMPatch::Registers::EDI) // Push the newly created ItemConfig_Item
6059
.AddInternalCall(FixLoadingNullItemFromXml)
6160
.AddBytes("\x84\xC0") // test al, al
6261
.RestoreRegisters(savedRegisters)
63-
.AddConditionalRelativeJump(ASMPatcher::CondJumps::JE, (char*)addr + 0x5) // Jump for false (no new entry was added, continue as normal)
64-
.AddRelativeJump((char*)addr + 0x2B); // Jump for true (new entry was added, skip some internal code)
62+
.AddConditionalRelativeJump(ASMPatcher::CondJumps::JNZ, (char*)addr + 0x2B) // Jump for true (new entry was added, skip some internal code)
63+
.AddBytes(ByteBuffer().AddAny((char*)addr, 0x5)) // Restore the commands we overwrote
64+
.AddRelativeJump((char*)addr + 0x5); // Jump for false (no new entry was added, continue as normal)
6565
sASMPatcher.PatchAt(addr, &patch);
6666
}
6767

0 commit comments

Comments
 (0)