Skip to content

Commit

Permalink
Merge pull request #105 from hollow87/master
Browse files Browse the repository at this point in the history
Implemented changes per @ArmYof0n3 in issue #100
  • Loading branch information
erfg12 authored Mar 24, 2021
2 parents 883ad2b + 8913698 commit 16baad7
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 16baad7

Please sign in to comment.