srounet / Pymem

A python library for windows, providing the needed functions to start working on your own with memory editing.
MIT License
307 stars 44 forks source link

`scan_pattern_page` not finding all matches? #68

Closed jmctune closed 3 years ago

jmctune commented 3 years ago

Describe the bug

Unsure if this is a bug or intended, but I am executing scan_pattern_page with a specific byte pattern and getting mixed results back. Here's an example of the code I'm running:

import pymem

indexPattern = bytes.fromhex("49 4E 44 58 10 00 00 00")

def process_scan(handle: int, pattern: bytes, end_address: int = 0x7fffffff):
  next_region = 0
  while next_region < end_address:
    next_region, found = pymem.pattern.scan_pattern_page(handle, next_region, pattern)
    if found:
      print(hex(found))

  return found

pm = pymem.Pymem('DQXGame.exe')
handle = pm.process_handle

process_scan(handle, indexPattern)

This returns 19 results every time, but I'm expecting 110~ results from this query.

Output:

0x306f79b0
0x313721f0
...
0x48ab50b0
0x49696da0

Searching for the same in Cheat Engine:

image

Your Environment

Expected behavior

Expecting to have every matching pattern of "49 4E 44 58 10 00 00 00", but am getting less than 20% of the results back.

Traceback

N/A

Additional context

N/A

Thanks for any help you can provide.

StarrFox commented 3 years ago

This is intended behavior, scan_pattern_page only returns the first result it finds.

There is a pr to allow returning multiple results here: https://github.com/srounet/Pymem/pull/59

srounet commented 3 years ago

I have just released pymem (1.8.5) with the changes proposed by @StarrFox. @jmctune could you get the last pymem release and tell us if everything is going the way you need it ?

jmctune commented 3 years ago

Hey @srounet - the new changes are working great. Thanks!

srounet commented 3 years ago

Nice, you can thanks @StarrFox he made it happen.