Python 修改植物大战僵尸阳光

具体也没啥,就是调用了win32的api而已,不过不同版本的基址和偏移量不一样,所以不能通用

import win32process
import win32con
import win32api
import win32gui
import ctypes
#PROCESS_ALL_ACCESS =(0x000F0000 | 0x00100000 | 0xFFF)
window_handle = win32gui.FindWindow("MainWindow","Plants vs. Zombies")
print(window_handle)
process_id= win32process.GetWindowThreadProcessId(window_handle)[1]
print(process_id)
process_handle = win32api.OpenProcess(0x1F0FFF,False,process_id)
print(process_handle)
kernel32 = ctypes.windll.LoadLibrary(r"C:\windows\System32\kernel32.dll")
print(kernel32)
data1 = ctypes.c_long()
kernel32.ReadProcessMemory(int(process_handle),0x00755E0c,ctypes.byref(data1),4,None)
print(hex(data1.value))
data2 = ctypes.c_long()
kernel32.ReadProcessMemory(int(process_handle),data1.value+0x868,ctypes.byref(data2),4,None)
print(hex(data2.value))
data3 = ctypes.c_long()
kernel32.ReadProcessMemory(int(process_handle),data2.value+0x5578,ctypes.byref(data3),4,None)
print(hex(data3.value))
#sun = ctypes.c_long(500)
kernel32.WriteProcessMemory(int(process_handle),data2.value+0x5578,ctypes.byref(ctypes.c_long(500)),4,None)

你可能感兴趣的:(Python 修改植物大战僵尸阳光)