Skip to content

Commit

Permalink
Enhance pointer finder
Browse files Browse the repository at this point in the history
  • Loading branch information
hurrican6 committed Apr 1, 2018
1 parent 6138033 commit 7c7dffc
Show file tree
Hide file tree
Showing 9 changed files with 433 additions and 250 deletions.
24 changes: 24 additions & 0 deletions PS4_Cheater/HexEditor.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions PS4_Cheater/HexEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,13 @@ private void refresh_btn_Click(object sender, EventArgs e)
column = 0;
update_ui(page, line);
}

private void find_Click(object sender, EventArgs e)
{
FindOptions findOptions = new FindOptions();
findOptions.Type = FindType.Hex;
findOptions.Hex = MemoryHelper.string_to_hex_bytes(input_box.Text);
hexBox.Find(findOptions);
}
}
}
42 changes: 4 additions & 38 deletions PS4_Cheater/MemoryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static byte[] string_to_byte(string value)
{
return BitConverter.GetBytes(Byte.Parse(value));
}
static byte[] string_to_hex_bytes(string hexString)
public static byte[] string_to_hex_bytes(string hexString)
{
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
Expand Down Expand Up @@ -352,50 +352,16 @@ public void CompareWithMemoryBufferNewScanner(byte[] default_value_0, byte[] def
}
}
}
public static int BinarySearch(List<MappedSection> sections, int low, int high, ulong address)
{
int mid = (low + high) / 2;
if (low > high)
return -1;
else
{
if ((sections[mid].Start <= address) && (sections[mid].Start + (ulong)(sections[mid].Length)>= address))
return mid;
else if (sections[mid].Start > address)
return BinarySearch(sections, low, mid - 1, address);
else
return BinarySearch(sections, mid + 1, high, address);
}
}

private int IsInSection(List<MappedSection> sections, ulong address)
{
ulong start = 0;
ulong end = 0;

if (sections.Count > 0)
{
start = sections[0].Start;
end = sections[sections.Count - 1].Start + (ulong)sections[sections.Count - 1].Length;
}

if (start > address || end < address)
{
return -1;
}

return BinarySearch(sections, 0, sections.Count - 1, address);
}

public void CompareWithMemoryBufferPointerScanner(List<MappedSection> sections, byte[] buffer,
public void CompareWithMemoryBufferPointerScanner(ProcessManager processManager, byte[] buffer,
PointerList pointerList, ulong base_address)
{
Byte[] address_buf = new byte[8];
for (int i = 0; i + 8 < buffer.LongLength; i += 4)
for (int i = 0; i + 8 < buffer.LongLength; i += 8)
{
Buffer.BlockCopy(buffer, i, address_buf, 0, 8);
ulong address = BitConverter.ToUInt64(address_buf, 0);
int sectionID = IsInSection(sections, address);
int sectionID = processManager.GetMappedSectionID(address);
if (sectionID != -1)
{
Pointer pointer = new Pointer(base_address + (ulong)i, address);
Expand Down
155 changes: 87 additions & 68 deletions PS4_Cheater/PointerFinder.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7c7dffc

Please sign in to comment.