系统相关
首页 > 系统相关> > 有没有用Python内置的好的和易于使用的模块来编辑内存?

有没有用Python内置的好的和易于使用的模块来编辑内存?

作者:互联网

有没有用Python内置的好的和易于使用的模块来编辑内存?或者有这样的模块吗?

我正在寻找的是一种附加到进程并从中读取/写入的方法.就像Cheat Engine的工作原理一样. Here’s a example of how it works in C++.

解决方法:

花了一些时间才找到这样做的方法,但这就是我想出来的!

from ctypes import *
from ctypes.wintypes import *

pid = 0 #the pid of the process, aquired earlier by hand

address = 0x0000 #where to read from while in the memory

OpenProcess = windll.kernel32.OpenProcess
ReadProcessMemory = windll.kernel32.ReadProcessMemory
CloseHandle = windll.kernel32.CloseHandle


PROCESS_ALL_ACCESS = 0x1F0FFF

datadummy = b'.'*200
buffer = c_char_p(datadummy)
bufferSize = len(buffer.value)
bytesRead = c_ulong(0)

processHandle = OpenProcess(PROCESS_ALL_ACCESS, False, int(PID))

ReadProcessMemory(processHandle, address, buffer, bufferSize, byref(bytesRead))

CloseHandle(processHandle)

写入内存我只需添加WriteProcessMemory = windll.kernel32.WriteProcessMemory然后调用它

标签:python,python-3-2,memory-editing
来源: https://codeday.me/bug/20190613/1232159.html