From b50b37c1c47f00aaa6d31b3eac0a3569cdb8ffb8 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Wed, 21 Jun 2017 01:44:57 -0700 Subject: [PATCH] Style fixes --- mem_edit/__init__.py | 6 +++--- mem_edit/abstract.py | 12 ++++++------ mem_edit/linux.py | 10 +++++----- mem_edit/windows.py | 12 ++++++------ setup.py | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/mem_edit/__init__.py b/mem_edit/__init__.py index 43afed5..9f3fbf9 100644 --- a/mem_edit/__init__.py +++ b/mem_edit/__init__.py @@ -11,14 +11,14 @@ To get started, try: help(Process) """ -__author__ = 'Jan Petykiewicz' - - import platform from .utils import MemEditError +__author__ = 'Jan Petykiewicz' + + system = platform.system() if system == 'Windows': from .windows import Process diff --git a/mem_edit/abstract.py b/mem_edit/abstract.py index ad8df31..8ec4355 100644 --- a/mem_edit/abstract.py +++ b/mem_edit/abstract.py @@ -235,9 +235,9 @@ class Process(metaclass=ABCMeta): :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. """ - base = self.read_memory(base_address, ctypes.c_void_p()) - vals = [self.read_memory(base + offset, buffer) for offset, buffer in targets] - return vals + base = self.read_memory(base_address, ctypes.c_void_p()).value + values = [self.read_memory(base + offset, buffer) for offset, buffer in targets] + return values def search_addresses(self, addresses: List[int], needle_buffer: ctypes_buffer_t) -> List[int]: """ @@ -253,10 +253,10 @@ class Process(metaclass=ABCMeta): found = [] read_buffer = copy.copy(needle_buffer) - for addr in addresses: - read = self.read_memory(addr, read_buffer) + for address in addresses: + read = self.read_memory(address, read_buffer) if ctypes_equal(needle_buffer, read): - found.append(addr) + found.append(address) return found def search_all_memory(self, needle_buffer, writeable_only=True) -> List[int]: diff --git a/mem_edit/linux.py b/mem_edit/linux.py index acf2998..459c191 100644 --- a/mem_edit/linux.py +++ b/mem_edit/linux.py @@ -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)) result = _ptrace(command, pid, arg1, arg2) if result == -1: - errno = ctypes.get_errno() - if errno: + err_no = ctypes.get_errno() + if err_no: 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 @@ -75,8 +75,8 @@ class Process(AbstractProcess): def get_path(self) -> str: try: - with open('/proc/{}/cmdline', 'rb') as f: - return f.read().decode().split('\x00')[0] + with open('/proc/{}/cmdline', 'rb') as f: + return f.read().decode().split('\x00')[0] except FileNotFoundError: return '' diff --git a/mem_edit/windows.py b/mem_edit/windows.py index 4117d33..3f79b2d 100644 --- a/mem_edit/windows.py +++ b/mem_edit/windows.py @@ -211,12 +211,12 @@ class Process(AbstractProcess): return None def list_mapped_regions(self, writeable_only: bool = True) -> List[Tuple[int, int]]: - sysinfo = SYSTEM_INFO() - sysinfo_ptr = ctypes.byref(sysinfo) - ctypes.windll.kernel32.GetSystemInfo(sysinfo_ptr) + sys_info = SYSTEM_INFO() + sys_info_ptr = ctypes.byref(sys_info) + ctypes.windll.kernel32.GetSystemInfo(sys_info_ptr) - start = sysinfo.lpMinimumApplicationAddress - stop = sysinfo.lpMaximumApplicationAddress + start = sys_info.lpMinimumApplicationAddress + stop = sys_info.lpMaximumApplicationAddress def get_mem_info(address): """ @@ -236,7 +236,7 @@ class Process(AbstractProcess): if success != mbi_size: if success == 0: raise MemEditError('Failed VirtualQueryEx with handle ' + - '{}: {}'.format(self.process_handle, self._get_last_error())) + '{}: {}'.format(self.process_handle, self._get_last_error())) else: raise MemEditError('VirtualQueryEx output too short!') diff --git a/setup.py b/setup.py index 58f4541..d64d0d6 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup(name='mem_edit', author='Jan Petykiewicz', author_email='anewusername@gmail.com', url='https://mpxd.net/gogs/jan/mem_edit', - keywords = [ + keywords=[ 'memory', 'edit', 'editing', @@ -25,7 +25,7 @@ setup(name='mem_edit', 'cheat', 'trainer', ], - classifiers = [ + classifiers=[ 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Development Status :: 4 - Beta',