diff --git a/mem_edit/VERSION b/mem_edit/VERSION index bd73f47..be58634 100644 --- a/mem_edit/VERSION +++ b/mem_edit/VERSION @@ -1 +1 @@ -0.4 +0.3 diff --git a/mem_edit/windows.py b/mem_edit/windows.py index cdaf657..038c58a 100644 --- a/mem_edit/windows.py +++ b/mem_edit/windows.py @@ -67,51 +67,19 @@ mem_types = { 'MEM_PRIVATE': 0x20000, } + # C struct for VirtualQueryEx -class MEMORY_BASIC_INFORMATION32(ctypes.Structure): +class MEMORY_BASIC_INFORMATION(ctypes.Structure): _fields_ = [ - ('BaseAddress', ctypes.wintypes.DWORD), - ('AllocationBase', ctypes.wintypes.DWORD), + ('BaseAddress', ctypes.c_void_p), + ('AllocationBase', ctypes.c_void_p), ('AllocationProtect', ctypes.wintypes.DWORD), - ('RegionSize', ctypes.wintypes.DWORD), + ('RegionSize', ctypes.wintypes.UINT), ('State', ctypes.wintypes.DWORD), ('Protect', ctypes.wintypes.DWORD), ('Type', ctypes.wintypes.DWORD), ] -class MEMORY_BASIC_INFORMATION64(ctypes.Structure): - _fields_ = [ - ('BaseAddress', ctypes.c_ulonglong), - ('AllocationBase', ctypes.c_ulonglong), - ('AllocationProtect', ctypes.wintypes.DWORD), - ('__alignment1', ctypes.wintypes.DWORD), - ('RegionSize', ctypes.c_ulonglong), - ('State', ctypes.wintypes.DWORD), - ('Protect', ctypes.wintypes.DWORD), - ('Type', ctypes.wintypes.DWORD), - ('__alignment2', ctypes.wintypes.DWORD), - ] - -PTR_SIZE = ctypes.sizeof(ctypes.c_void_p) -if PTR_SIZE == 8: # 64-bit python - MEMORY_BASIC_INFORMATION = MEMORY_BASIC_INFORMATION64 -elif PTR_SIZE == 4: # 32-bit python - MEMORY_BASIC_INFORMATION = MEMORY_BASIC_INFORMATION32 - -ctypes.windll.kernel32.VirtualQueryEx.argtypes = [ctypes.wintypes.HANDLE, - ctypes.wintypes.LPCVOID, - ctypes.c_void_p, - ctypes.c_size_t] -ctypes.windll.kernel32.ReadProcessMemory.argtypes = [ctypes.wintypes.HANDLE, - ctypes.wintypes.LPCVOID, - ctypes.c_void_p, - ctypes.c_size_t, - ctypes.c_void_p] -ctypes.windll.kernel32.WriteProcessMemory.argtypes = [ctypes.wintypes.HANDLE, - ctypes.wintypes.LPCVOID, - ctypes.c_void_p, - ctypes.c_size_t, - ctypes.c_void_p] # C struct for GetSystemInfo class SYSTEM_INFO(ctypes.Structure): @@ -121,7 +89,7 @@ class SYSTEM_INFO(ctypes.Structure): ('dwPageSize', ctypes.wintypes.DWORD), ('lpMinimumApplicationAddress', ctypes.c_void_p), ('lpMaximumApplicationAddress', ctypes.c_void_p), - ('dwActiveProcessorMask', ctypes.c_void_p), + ('dwActiveProcessorMask', ctypes.wintypes.DWORD), ('dwNumberOfProcessors', ctypes.wintypes.DWORD), ('dwProcessorType', ctypes.wintypes.DWORD), ('dwAllocationGranularity', ctypes.wintypes.DWORD), @@ -237,8 +205,6 @@ class Process(AbstractProcess): return pid except ValueError: pass - except MemEditError as err: - logger.info(repr(err)) logger.info('Found no process with name {}'.format(target_name)) return None