赞
踩
- #include<windows.h>
- #include<stdio.h>
-
- void main()
- {
- //获取游戏窗口句柄
- HWND hd = FindWindow(L"MainWindow",L"植物大战僵尸中文版");
-
- DWORD pid;
-
- //通过窗口句柄获取进程ID
- GetWindowThreadProcessId(hd, &pid);
-
- //通过进程ID获取进程句柄
- HANDLE hprocess = OpenProcess(PROCESS_ALL_ACCESS,false,pid);
-
- DWORD address;
-
- //通过基址和偏移获取阳光的地址 (想得到这些数据需要学点CheatEngine简称CE)
- ReadProcessMemory(hprocess, (LPVOID)0x6a9ec0, &address, 4, NULL);
- ReadProcessMemory(hprocess, (LPVOID)(address+0x768), &address, 4, NULL);
- address += 0x5560;
-
- //printf("阳光地址:%x", address);
- int sun;
- scanf_s("%d",&sun);
-
- //改阳光数
- WriteProcessMemory(hprocess, (LPVOID)address, &sun, 4,NULL);
-
- }
- import win32gui,win32api,win32process,ctypes
-
- #载入kernal32.dll,Windows读写内存的函数在这个dll里面
- kernal32=ctypes.windll.LoadLibrary(r"C:\Windows\System32\kernel32.dll")
-
- #用于通过基址获取最终的地址
- def GetAddress(handle,BaseAddress,offset=[]):
- value=ctypes.c_long()
- kernal32.ReadProcessMemory(int(handle),BaseAddress,ctypes.byref(value),4,None)
- for i in range(len(offset)-1):
- kernal32.ReadProcessMemory(int(handle), value.value+offset[i], ctypes.byref(value), 4, None)
- return value.value+offset[len(offset)-1]
-
- #获取窗口句柄
- hwnd=win32gui.FindWindow("MainWindow","植物大战僵尸中文版")
-
- #通过窗口句柄获取进程ID,该函数返回一个列表,进程ID是在第二
- pid=win32process.GetWindowThreadProcessId(hwnd)[1]
-
- #通过进程ID获取句柄
- handle=win32api.OpenProcess(0x1F0FFF,False,pid)
-
- #ctypes.c_long()返回的是一个C语言long类型的变量
- showSun=ctypes.c_long()
- changeSun=ctypes.c_long()
-
- while 1:
- address = GetAddress(handle, 0x6a9ec0, offset=[0x768, 0x5560])
-
- #ctypes.byref(showSun)相当于取showSun的指针
- kernal32.ReadProcessMemory(int(handle),address,ctypes.byref(showSun),4,None)
- print("{}{}".format("当前阳光:",showSun.value))
-
- changeSun.value = int(input("要修改成多少:"))
- kernal32.WriteProcessMemory(int(handle), address, ctypes.byref(changeSun), 4, None)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。