forked from jan/mem_edit
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
898c4eba78 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,5 +4,4 @@ __pycache__
|
|||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
build/
|
|
||||||
dist/
|
dist/
|
||||||
|
@ -38,7 +38,7 @@ pip3 install git+https://mpxd.net/code/jan/mem_edit.git@release
|
|||||||
|
|
||||||
Most functions and classes are documented inline.
|
Most functions and classes are documented inline.
|
||||||
To read the inline help,
|
To read the inline help,
|
||||||
```python3
|
```python
|
||||||
import mem_edit
|
import mem_edit
|
||||||
help(mem_edit.Process)
|
help(mem_edit.Process)
|
||||||
```
|
```
|
||||||
@ -46,7 +46,7 @@ help(mem_edit.Process)
|
|||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
Increment a magic number (unsigned long 1234567890) found in 'magic.exe':
|
Increment a magic number (unsigned long 1234567890) found in 'magic.exe':
|
||||||
```python3
|
```python
|
||||||
import ctypes
|
import ctypes
|
||||||
from mem_edit import Process
|
from mem_edit import Process
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ Increment a magic number (unsigned long 1234567890) found in 'magic.exe':
|
|||||||
```
|
```
|
||||||
|
|
||||||
Narrow down a search after a value changes:
|
Narrow down a search after a value changes:
|
||||||
```python3
|
```python
|
||||||
import ctypes
|
import ctypes
|
||||||
from mem_edit import Process
|
from mem_edit import Process
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ Narrow down a search after a value changes:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Read and alter a structure:
|
Read and alter a structure:
|
||||||
```python3
|
```python
|
||||||
import ctypes
|
import ctypes
|
||||||
from mem_edit import Process
|
from mem_edit import Process
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ def ptrace(command: int, pid: int = 0, arg1: int = 0, arg2: int = 0) -> int:
|
|||||||
"""
|
"""
|
||||||
Call ptrace() with the provided pid and arguments. See the ```man ptrace```.
|
Call ptrace() with the provided pid and arguments. See the ```man ptrace```.
|
||||||
"""
|
"""
|
||||||
logger.debug('ptrace({}, {}, {}, {})'.format(command, pid, arg1, arg2))
|
logger.debug('ptrace({}, {}, {}, {})'.format(command, pid, arg1, arg2))
|
||||||
result = _ptrace(command, pid, arg1, arg2)
|
result = _ptrace(command, pid, arg1, arg2)
|
||||||
if result == -1:
|
if result == -1:
|
||||||
err_no = ctypes.get_errno()
|
err_no = ctypes.get_errno()
|
||||||
@ -58,7 +58,7 @@ class Process(AbstractProcess):
|
|||||||
self.pid = process_id
|
self.pid = process_id
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
os.kill(self.pid, signal.SIGSTOP)
|
os.kill(self.pid, signal.SIGSTOP)
|
||||||
ptrace(ptrace_commands['PTRACE_DETACH'], self.pid, 0, 0)
|
ptrace(ptrace_commands['PTRACE_DETACH'], self.pid, 0, 0)
|
||||||
self.pid = None
|
self.pid = None
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class Process(AbstractProcess):
|
|||||||
with open('/proc/{}/cmdline', 'rb') as f:
|
with open('/proc/{}/cmdline', 'rb') as f:
|
||||||
return f.read().decode().split('\x00')[0]
|
return f.read().decode().split('\x00')[0]
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_available_pids() -> List[int]:
|
def list_available_pids() -> List[int]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user