forked from jan/mem_edit
Style fixes
This commit is contained in:
parent
e962137950
commit
b50b37c1c4
@ -11,14 +11,14 @@ To get started, try:
|
|||||||
help(Process)
|
help(Process)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
__author__ = 'Jan Petykiewicz'
|
|
||||||
|
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
from .utils import MemEditError
|
from .utils import MemEditError
|
||||||
|
|
||||||
|
|
||||||
|
__author__ = 'Jan Petykiewicz'
|
||||||
|
|
||||||
|
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
if system == 'Windows':
|
if system == 'Windows':
|
||||||
from .windows import Process
|
from .windows import Process
|
||||||
|
@ -235,9 +235,9 @@ class Process(metaclass=ABCMeta):
|
|||||||
:param targets: List of (offset, read_buffer) pairs which will be read from the struct.
|
:param targets: List of (offset, read_buffer) pairs which will be read from the struct.
|
||||||
:return: List of read values corresponding to the provided targets.
|
:return: List of read values corresponding to the provided targets.
|
||||||
"""
|
"""
|
||||||
base = self.read_memory(base_address, ctypes.c_void_p())
|
base = self.read_memory(base_address, ctypes.c_void_p()).value
|
||||||
vals = [self.read_memory(base + offset, buffer) for offset, buffer in targets]
|
values = [self.read_memory(base + offset, buffer) for offset, buffer in targets]
|
||||||
return vals
|
return values
|
||||||
|
|
||||||
def search_addresses(self, addresses: List[int], needle_buffer: ctypes_buffer_t) -> List[int]:
|
def search_addresses(self, addresses: List[int], needle_buffer: ctypes_buffer_t) -> List[int]:
|
||||||
"""
|
"""
|
||||||
@ -253,10 +253,10 @@ class Process(metaclass=ABCMeta):
|
|||||||
found = []
|
found = []
|
||||||
read_buffer = copy.copy(needle_buffer)
|
read_buffer = copy.copy(needle_buffer)
|
||||||
|
|
||||||
for addr in addresses:
|
for address in addresses:
|
||||||
read = self.read_memory(addr, read_buffer)
|
read = self.read_memory(address, read_buffer)
|
||||||
if ctypes_equal(needle_buffer, read):
|
if ctypes_equal(needle_buffer, read):
|
||||||
found.append(addr)
|
found.append(address)
|
||||||
return found
|
return found
|
||||||
|
|
||||||
def search_all_memory(self, needle_buffer, writeable_only=True) -> List[int]:
|
def search_all_memory(self, needle_buffer, writeable_only=True) -> List[int]:
|
||||||
|
@ -43,10 +43,10 @@ def ptrace(command: int, pid: int = 0, arg1: int = 0, arg2: int = 0) -> int:
|
|||||||
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:
|
||||||
errno = ctypes.get_errno()
|
err_no = ctypes.get_errno()
|
||||||
if errno:
|
if err_no:
|
||||||
raise MemEditError('ptrace({}, {}, {}, {})'.format(command, pid, arg1, arg2) +
|
raise MemEditError('ptrace({}, {}, {}, {})'.format(command, pid, arg1, arg2) +
|
||||||
' failed with error {}: {}'.format(errno, strerror(errno)))
|
' failed with error {}: {}'.format(err_no, strerror(err_no)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@ -75,8 +75,8 @@ class Process(AbstractProcess):
|
|||||||
|
|
||||||
def get_path(self) -> str:
|
def get_path(self) -> str:
|
||||||
try:
|
try:
|
||||||
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 ''
|
||||||
|
|
||||||
|
@ -211,12 +211,12 @@ class Process(AbstractProcess):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def list_mapped_regions(self, writeable_only: bool = True) -> List[Tuple[int, int]]:
|
def list_mapped_regions(self, writeable_only: bool = True) -> List[Tuple[int, int]]:
|
||||||
sysinfo = SYSTEM_INFO()
|
sys_info = SYSTEM_INFO()
|
||||||
sysinfo_ptr = ctypes.byref(sysinfo)
|
sys_info_ptr = ctypes.byref(sys_info)
|
||||||
ctypes.windll.kernel32.GetSystemInfo(sysinfo_ptr)
|
ctypes.windll.kernel32.GetSystemInfo(sys_info_ptr)
|
||||||
|
|
||||||
start = sysinfo.lpMinimumApplicationAddress
|
start = sys_info.lpMinimumApplicationAddress
|
||||||
stop = sysinfo.lpMaximumApplicationAddress
|
stop = sys_info.lpMaximumApplicationAddress
|
||||||
|
|
||||||
def get_mem_info(address):
|
def get_mem_info(address):
|
||||||
"""
|
"""
|
||||||
@ -236,7 +236,7 @@ class Process(AbstractProcess):
|
|||||||
if success != mbi_size:
|
if success != mbi_size:
|
||||||
if success == 0:
|
if success == 0:
|
||||||
raise MemEditError('Failed VirtualQueryEx with handle ' +
|
raise MemEditError('Failed VirtualQueryEx with handle ' +
|
||||||
'{}: {}'.format(self.process_handle, self._get_last_error()))
|
'{}: {}'.format(self.process_handle, self._get_last_error()))
|
||||||
else:
|
else:
|
||||||
raise MemEditError('VirtualQueryEx output too short!')
|
raise MemEditError('VirtualQueryEx output too short!')
|
||||||
|
|
||||||
|
4
setup.py
4
setup.py
@ -8,7 +8,7 @@ setup(name='mem_edit',
|
|||||||
author='Jan Petykiewicz',
|
author='Jan Petykiewicz',
|
||||||
author_email='anewusername@gmail.com',
|
author_email='anewusername@gmail.com',
|
||||||
url='https://mpxd.net/gogs/jan/mem_edit',
|
url='https://mpxd.net/gogs/jan/mem_edit',
|
||||||
keywords = [
|
keywords=[
|
||||||
'memory',
|
'memory',
|
||||||
'edit',
|
'edit',
|
||||||
'editing',
|
'editing',
|
||||||
@ -25,7 +25,7 @@ setup(name='mem_edit',
|
|||||||
'cheat',
|
'cheat',
|
||||||
'trainer',
|
'trainer',
|
||||||
],
|
],
|
||||||
classifiers = [
|
classifiers=[
|
||||||
'Programming Language :: Python',
|
'Programming Language :: Python',
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 4 - Beta',
|
||||||
|
Loading…
Reference in New Issue
Block a user