The ReadWriteMemory Class is made on Python for reading and writing to the memory of any process. This Class does not depend on any extra modules and only uses standard Python libraries like ctypes.
Python 3.4+
OS: Windows 7, 8 and 10
EnumProcesses
GetProcessImageFileName
OpenProcess
Process Security and Access Rights
CloseHandle
GetLastError
ReadProcessMemory
WriteProcessMemory
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory() ```
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') ```
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_id(1337) ```
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
processes_ids = rwm.enumerate_processes() ```
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') print(process.dict) ```
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') help(process) ```
````python from ReadWriteMemory import ReadWriteMemory from ReadWriteMemory import ReadWriteMemoryError
rwm = ReadWriteMemory() try: process = rwm.get_process_by_name('ac_client.exe') except ReadWriteMemoryError as error: print(error) ````
To be able to read or write to the process's memory first you need to call the open() method. ```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') process.open() ```
The offsets must be a list in the correct order, if the address does not have any offsets then just pass the address. You need to pass two arguments, first the process address as hex and a list of offsets as hex. ```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') process.open()
health_pointer = process.get_pointer(0x004e4dbc, offsets=[0xf4]) ammo_pointer = process.get_pointer(0x004df73c, offsets=[0x378, 0x14, 0x0]) grenade_pointer = process.get_pointer(0x004df73c, offsets=[0x35c, 0x14, 0x0]) ```
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') process.open()
health_pointer = process.get_pointer(0x004e4dbc, offsets=[0xf4]) ammo_pointer = process.get_pointer(0x004df73c, offsets=[0x378, 0x14, 0x0]) grenade_pointer = process.get_pointer(0x004df73c, offsets=[0x35c, 0x14, 0x0])
health = process.read(health_pointer) ammo = process.read(ammo_pointer) grenade = process.read(grenade_pointer) ```
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') process.open()
health_pointer = process.get_pointer(0x004e4dbc, offsets=[0xf4]) ammo_pointer = process.get_pointer(0x004df73c, offsets=[0x378, 0x14, 0x0]) grenade_pointer = process.get_pointer(0x004df73c, offsets=[0x35c, 0x14, 0x0])
health = process.read(health_pointer) ammo = process.read(ammo_pointer) grenade = process.read(grenade_pointer)
print({'Health': health, 'Ammo': ammo, 'Grenade': grenade}) ```
```python from ReadWriteMemory import ReadWriteMemory from random import randint
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') process.open()
health_pointer = process.get_pointer(0x004e4dbc, offsets=[0xf4]) ammo_pointer = process.get_pointer(0x004df73c, offsets=[0x378, 0x14, 0x0]) grenade_pointer = process.get_pointer(0x004df73c, offsets=[0x35c, 0x14, 0x0])
process.write(health_pointer, randint(1, 100)) process.write(ammo_pointer, randint(1, 20)) process.write(grenade_pointer, randint(1, 5)) ```
```python from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name('ac_client.exe') process.open()
process.close() ```
Check out the code inside the Test folder on the python file named testing_script.py.
The AssaultCube game used for this test is version v1.1.0.4 If you use a different version then you will have to use CheatEngine to find the memory addresses.
https://github.com/assaultcube/AC/releases/tag/v1.1.0.4
For more examples check out the AssaultCube game trainer:
https://github.com/vsantiago113/ACTrainer
```python
from ReadWriteMemory import ReadWriteMemory
from random import randint
rwm = ReadWriteMemory() process = rwm.get_process_by_name('ac_client.exe') process.open()
print('\nPrint the Process information.') print(process.dict)
health_pointer = process.get_pointer(0x004e4dbc, offsets=[0xf4]) ammo_pointer = process.get_pointer(0x004df73c, offsets=[0x378, 0x14, 0x0]) grenade_pointer = process.get_pointer(0x004df73c, offsets=[0x35c, 0x14, 0x0]) print(health_pointer)
health = process.read(health_pointer) ammo = process.read(ammo_pointer) grenade = process.read(grenade_pointer)
print('\nPrinting the current values.') print({'Health': health, 'Ammo': ammo, 'Grenade': grenade})
process.write(health_pointer, randint(1, 100)) process.write(ammo_pointer, randint(1, 20)) process.write(grenade_pointer, randint(1, 5))
health = process.read(health_pointer) ammo = process.read(ammo_pointer) grenade = process.read(grenade_pointer)
print('\nPrinting the new modified random values.') print({'Health': health, 'Ammo': ammo, 'Grenade': grenade})
process.close()
```
My code is as follows. I am attempting to read a pointer location using offsets and than write to them. issue is when process.get_pointer() is called. you get the collowing error
ctypes.windll.kernel32.ReadProcessMemory(self.handle, lp_base_address, lp_buffer, ctypes.ArgumentError: argument 2: OverflowError: int too long to convert
`from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
points_pointer_address = 0x19BC7D60160+0x00497DE0
process = rwm.get_process_by_name("PieceByPiece.exe")
process.open()
points_pointer = process.get_pointer(points_pointer_address, offsets=[0xB8, 0x2F8, 0x18, 0x70, 0x20, 0x10, 0x60]) process.write(points_pointer, 500)
#value = process.read(points_pointer)
#print(value)`
Originally posted by @evanwheelrr in https://github.com/pypi/warehouse/issues/13128
Hi, I have the same problem of others people with the get_pointer
function who can't find the address because it needs the base address.
So I tried
base_address = process.get_modules()[0]
process.get_pointer(process.get_modules()[0] + address, offsets=offsets)
as said @MillhioreBT in issue #12, but I have this error AttributeError: 'Process' object has no attribute 'get_modules'
.
I'm it with Python 3.10, and the module version is 0.1.5. Thx!
After the merged PR #21 We can now obtain the base address of the process very easily: get_modules()[0]
but to make it intuitive and easy to understand for everyone it is better to have a method for it: get_base_address()
I found something .
if be " "(space) in name of app show this error
Example
csgo.exe --> ok
Minecraft 1.16.4.exe --> Process "" not found!
Is there some way i can retrieve all the memory addresses on the process?
Hey there, I'm having some problem while trying to read a string from another program. Somehow my output is this:{'name': 'Deezer.exe', 'pid': 1100, 'handle': 456, 'error_code': None} {'Titel': ''}
This is my code ``` from ReadWriteMemory import ReadWriteMemory
rwm = ReadWriteMemory()
process = rwm.get_process_by_name("Deezer.exe") print(process.dict)
process.open()
title_pointer = process.get_pointer(0x04D21E1C, offsets=[0x10C, 0x44, 0x4, 0x30, 0x0])
titel = process.readString(title_pointer, 20)
print({'Titel': titel})
process.close() ```
And this is what i got with CE
I hope someone can help me with this.
This is the latest version and it has been updated with some bug fixes.
This version has been updated from the one I used on the YouTube Video. This version handles pointers too.
IT consultant with over ten years of experience in the industry. Skilled in designing and implementing automated solutions for various industries.
GitHub Repository