qb-0 / PyMeow-

Python Game Hacking Library
MIT License
158 stars 21 forks source link

Pointer chain not working? #26

Closed Rykarix closed 2 years ago

Rykarix commented 2 years ago

Tried to use pointer_chain but this doesn't appear to be working.

qb-0 commented 2 years ago

I'm not able to help without any provided information.

Please show some example code. Your output and your expected output. If you're using cheat engine maybe a screenshot. 64bit or 32bit binary?

Rykarix commented 2 years ago

Let's say this is the address I want to point to: image

import pymeow as pm
import constants as c

mem = pm.process_by_name(c.Strings.PROCESS_NAME)
base = mem["modules"][c.Strings.MODULE_NAME]["baseaddr"] + c.Offsets.il2cpp_get_root_domain
array = [0x5C, 0x8, 0x0]

# ptr = pm.pointer_chain(mem, base, array)
# print(str(hex(ptr)))

"""
This produces the following error:

ptr = pm.pointer_chain(mem, base, array)
    nimpy.AccessViolationDefect: Unexpected error encountered: Read failed [Address: 0x2000FB1B35907424] [Error: 998]
"""

# I have to use my own function:
def pointer_chain2(mem, base, array):
    if c.Strings.PROCESS_BIT_TYPE == "32":
        correction = pm.read_int(mem, base)
        current_pointer = correction
        for i in array[:-1]:
            current_pointer = pm.read_int(mem, current_pointer + i)
        return current_pointer + array[-1]

    elif c.Strings.PROCESS_BIT_TYPE == "64":
        correction = pm.read_int64(mem, base)
        current_pointer = correction
        for i in array[:-1]:
            current_pointer = pm.read_int64(mem, current_pointer + i)
        return current_pointer + array[-1]
    else:
        raise Exception("Application bit type, 32/64, not defined.")

ptr = pointer_chain2(mem, base, array)
print(str(hex(ptr)))
qb-0 commented 2 years ago

Issue was on 32bit processes with using pointer chains. Solved with https://github.com/qb-0/PyMeow/commit/2e5063c2d146574e5bbf729b8357e4ed8274860f