forked from jan/mem_edit
Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0632b205ab | |||
|
|
5c75da31d5 | ||
|
|
bd6c22ca1d |
2 changed files with 41 additions and 7 deletions
|
|
@ -1 +1 @@
|
||||||
0.3
|
0.4
|
||||||
|
|
|
||||||
|
|
@ -67,19 +67,51 @@ mem_types = {
|
||||||
'MEM_PRIVATE': 0x20000,
|
'MEM_PRIVATE': 0x20000,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# C struct for VirtualQueryEx
|
# C struct for VirtualQueryEx
|
||||||
class MEMORY_BASIC_INFORMATION(ctypes.Structure):
|
class MEMORY_BASIC_INFORMATION32(ctypes.Structure):
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
('BaseAddress', ctypes.c_void_p),
|
('BaseAddress', ctypes.wintypes.DWORD),
|
||||||
('AllocationBase', ctypes.c_void_p),
|
('AllocationBase', ctypes.wintypes.DWORD),
|
||||||
('AllocationProtect', ctypes.wintypes.DWORD),
|
('AllocationProtect', ctypes.wintypes.DWORD),
|
||||||
('RegionSize', ctypes.wintypes.UINT),
|
('RegionSize', ctypes.wintypes.DWORD),
|
||||||
('State', ctypes.wintypes.DWORD),
|
('State', ctypes.wintypes.DWORD),
|
||||||
('Protect', ctypes.wintypes.DWORD),
|
('Protect', ctypes.wintypes.DWORD),
|
||||||
('Type', 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
|
# C struct for GetSystemInfo
|
||||||
class SYSTEM_INFO(ctypes.Structure):
|
class SYSTEM_INFO(ctypes.Structure):
|
||||||
|
|
@ -89,7 +121,7 @@ class SYSTEM_INFO(ctypes.Structure):
|
||||||
('dwPageSize', ctypes.wintypes.DWORD),
|
('dwPageSize', ctypes.wintypes.DWORD),
|
||||||
('lpMinimumApplicationAddress', ctypes.c_void_p),
|
('lpMinimumApplicationAddress', ctypes.c_void_p),
|
||||||
('lpMaximumApplicationAddress', ctypes.c_void_p),
|
('lpMaximumApplicationAddress', ctypes.c_void_p),
|
||||||
('dwActiveProcessorMask', ctypes.wintypes.DWORD),
|
('dwActiveProcessorMask', ctypes.c_void_p),
|
||||||
('dwNumberOfProcessors', ctypes.wintypes.DWORD),
|
('dwNumberOfProcessors', ctypes.wintypes.DWORD),
|
||||||
('dwProcessorType', ctypes.wintypes.DWORD),
|
('dwProcessorType', ctypes.wintypes.DWORD),
|
||||||
('dwAllocationGranularity', ctypes.wintypes.DWORD),
|
('dwAllocationGranularity', ctypes.wintypes.DWORD),
|
||||||
|
|
@ -205,6 +237,8 @@ class Process(AbstractProcess):
|
||||||
return pid
|
return pid
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
except MemEditError as err:
|
||||||
|
logger.info(repr(err))
|
||||||
|
|
||||||
logger.info('Found no process with name {}'.format(target_name))
|
logger.info('Found no process with name {}'.format(target_name))
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue