Skip to content

Commit

Permalink
Update and Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Apr 9, 2020
1 parent 96b4bf1 commit e8180ec
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 68 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
build/
Test/build/
develop-eggs/
dist/
downloads/
Expand Down Expand Up @@ -100,5 +100,5 @@ ENV/
# mypy
.mypy_cache/

#PyCharm
.idea/
# PyCharm
.idea/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Victor Santiago

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
108 changes: 99 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ReadWriteMemory

### Description
This ReadWriteMemory Module is made on Python for reading and writing to the memory of any process. This module does not required any extra modules only uses standard Python lib’s like ctypes.
The ReadWriteMemory Class is made on Python for reading and writing to the memory of any process. This Class does not depend any extra modules only uses standard Python lib’s like ctypes.

---

Expand All @@ -23,26 +23,116 @@ OS: Windows 7, 8 and 10<br />

---

### Usage

### Import Class ReadWriteMemory()
## Usage

### Import the Class
```python
from ReadWriteMemory import ReadWriteMemory
```

### Instantiate the Class
```python
rwm = ReadWriteMemory()
```

---
### Get a Process by name
```python
process = rwm.get_process_by_name('ac_client.exe')
```

### Get a Process by ID
```python
process = rwm.get_process_by_name(1337)
```

### Print the Process information
```python
print(process.__dict__)
```

### Print the Process HELP docs
```python
help(process)
```

### Open the Process
To be able to read or write to the process's memory first you need to call the open() method.
```python
process.open()
```

### Set the pointers for example: to get health, ammo and grenades
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
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])
```

### Read the values for the health, ammo and grenades from the Process's memory
```python
health = process.read(health_pointer)
ammo = process.read(ammo_pointer)
grenade = process.read(grenade_pointer)
```

### Print the health, ammo and grenade values
```python
print({'Health': health, 'Ammo': ammo, 'Grenade': grenade})
```

### Write some random values for health, ammo and grenade to the Process's memory
```python
process.write(health_pointer, randint(1, 100))
process.write(ammo_pointer, randint(1, 20))
process.write(grenade_pointer, randint(1, 5))
```

### Get the process PID by the process name - ReadWriMemory.get_process_id_by_name(process_name: str)
### Close the Process's handle when you are done using it.
```python
process.close()
```

### Examples
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](https://github.com/assaultcube/AC/releases/tag/v1.1.0.4)<br />
For more examples check out the AssaultCube game trainer:
[https://github.com/vsantiago113/ACTrainer](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()

pid = rwm.get_process_id_by_name('ac_client.exe')
```
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()

### How to open the process - ReadWriMemory.open()
```
Loading

0 comments on commit e8180ec

Please sign in to comment.