python 植物大戰殭屍外掛輔助工具

MTQ_python發表於2020-03-22
import  win32process#程式模組
from  win32con import PROCESS_ALL_ACCESS #Opencress 許可權
import  win32api#呼叫系統模組
import ctypes#C語言型別
from win32gui import FindWindow#介面
import  time

def GetProcssID(address,bufflength):
    pid = ctypes.c_ulong()
    kernel32 = ctypes.windll.LoadLibrary("kernel32.dll")
    hwnd = FindWindow(None,u"植物大戰殭屍中文版")
    ReadProcessMemory = kernel32.ReadProcessMemory
    hpid, pid = win32process.GetWindowThreadProcessId(hwnd)
    hProcess = win32api.OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    addr = ctypes.c_ulong()
    ReadProcessMemory(int(hProcess), address, ctypes.byref(addr), bufflength, None)
    win32api.CloseHandle(hProcess)
    return addr.value

def SetProcssID(address,bufflength):
    pid = ctypes.c_ulong()
    kernel32 = ctypes.windll.LoadLibrary("kernel32.dll")
    hwnd = FindWindow(None,u"植物大戰殭屍中文版")
    WriteProcessMemory = kernel32.WriteProcessMemory
    hpid, pid = win32process.GetWindowThreadProcessId(hwnd)
    hProcess = win32api.OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    newdata = ctypes.c_long(5000)
    WriteProcessMemory(int(hProcess),address,ctypes.byref(newdata),bufflength,None)   #修改記憶體地址
    win32api.CloseHandle(hProcess)

def main():
    while(True):
        SetProcssID(GetProcssID(GetProcssID(0x006A9EC0, 4)+0x768, 4)+0x5560, 4)
        print("正在執行...")
        time.sleep(5)
    #sun = GetProcssID(GetProcssID(GetProcssID(0x006A9EC0, 4) + 0x768, 4) + 0x5560, 4)
    #print ("陽光的數量:%d" % sun)

if __name__ == '__main__':
    main()
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章