Skip to content

Commit

Permalink
Implemented changes per @ArmYof0n3 in issue #100
Browse files Browse the repository at this point in the history
  • Loading branch information
hollow87 committed Mar 20, 2021
1 parent 883ad2b commit 8913698
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Memory/memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,6 @@ public UIntPtr CreateCodeCave(string code, byte[] newBytes, int replaceCount, in
{
jmpBytes[i] = 0x90;
}
WriteBytes(address, jmpBytes);

byte[] caveBytes = new byte[5 + newBytes.Length];
offset = (int)(((long)address + jmpBytes.Length) - ((long)caveAddress + newBytes.Length) - 5);
Expand All @@ -1639,6 +1638,7 @@ public UIntPtr CreateCodeCave(string code, byte[] newBytes, int replaceCount, in
BitConverter.GetBytes(offset).CopyTo(caveBytes, newBytes.Length + 1);

WriteBytes(caveAddress, caveBytes);
WriteBytes(address, jmpBytes);

return caveAddress;
}
Expand Down Expand Up @@ -1739,10 +1739,10 @@ private UIntPtr FindFreeBlockForRegion(UIntPtr baseAddress, uint size)
previous = current;
current = UIntPtr.Add(mbi.BaseAddress, (int)mbi.RegionSize);

if ((long)current > (long)maxAddress)
if ((long)current >= (long)maxAddress)
return ret;

if ((long)previous > (long)current)
if ((long)previous >= (long)current)
return ret; // Overflow
}

Expand Down

0 comments on commit 8913698

Please sign in to comment.