Style fixes

This commit is contained in:
Jan Petykiewicz 2017-06-21 01:44:57 -07:00
parent e962137950
commit b50b37c1c4
5 changed files with 22 additions and 22 deletions

View File

@ -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

View File

@ -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]:

View File

@ -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

View File

@ -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):
"""