vsantiago113 / ReadWriteMemory

This module can read and write to the memory of any process on Windows.
MIT License
148 stars 36 forks source link

process.read() error, int too long to convert #4

Closed MonteyMontey closed 4 years ago

MonteyMontey commented 4 years ago

I used Cheat Engine to find the memory address for a 4 bytes value of a process on Windows. The address was 262F337041C but when I do process.get_pointer(0x262F337041C) I get: ctypes.ArgumentError: argument 2: <class 'OverflowError'>: int too long to convert. Any idea why this is happening?

vsantiago113 commented 4 years ago

Could you share a screenshot of Cheat Engine with that address on it? The address seem to be incorrect but I could be wrong.

MonteyMontey commented 4 years ago

That's how the addresses for my value look now:

cheatengine
vsantiago113 commented 4 years ago

What version of the game are you using? Can you send me the steam url of the game? I want to download the game to do some troubleshooting.

vsantiago113 commented 4 years ago

That game has a 32bit and a 64bit version? I ask to see if you are using the 64bit version and if you could try the 32bit version.

Or maybe change the "read_buffer = ctypes.c_uint()" to "read_buffer = ctypes.c_ulong()" in the function below and then give that a try.

    def read(self, lp_base_address: int) -> Any:
        """
        Read data from the process's memory.
        :param lp_base_address: The process's pointer
        :return: The data from the process's memory if succeed if not raises an exception.
        """
        try:
            read_buffer = ctypes.c_uint()
MonteyMontey commented 4 years ago

It's not on steam unfortunately but you can download it for free at Uplay . I'm trying to read the speed at the back of the car if that matters.

MonteyMontey commented 4 years ago

For this version of the game, there's only one version as far as I'm concerned and I tried your suggested change but now I get ctypes.ArgumentError: argument 5: <class 'TypeError'>: wrong type instead.

MillhioreBT commented 4 years ago

@MonteyMontey show exactly the part of the code you are using to help you, in case you have already solved it, please close the PR

I am also using this module for my BOT, however I had to make a modification to get the pointers correctly, this is how I fixed it:

    def get_pointer_modified(self, lp_base_address: hex, offsets: List[hex] = ()) -> int:
        """
        Get the pointer of a given address.

        :param lp_base_address: The address from where you want to get the pointer.
        :param offsets: a list of offets.

        :return: The pointer of a give address.
        """
        if not offsets:
            return lp_base_address
        else:
            for offset in offsets:
                lp_base_address = self.read(lp_base_address) + int(offset)
            return lp_base_address

You can take a look at my fork if you need to read / write text strings to memory.

MonteyMontey commented 4 years ago

Thanks, I used Pymem instead, so I didn't try it any further. I closed the issue.