作者iloveqqp (kenny)
看板Visual_Basic
标题[VB6 ] 写植物大战殭屍修改器
时间Fri Feb 12 11:20:21 2010
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Declare Function WriteProcessMemory Lib "kernel32.dll" ( _
ByVal hProcess As Long, _
ByVal lpBaseAddress As Long, _
ByRef lpBuffer As Long, _
ByVal nSize As Long, _
ByRef lpNumberOfBytesWritten As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32.dll" ( _
ByVal hProcess As Long, _
ByVal lpBaseAddress As Long, _
ByRef lpBuffer As Long, _
ByVal nSize As Long, _
ByRef lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Dim o1 As Long, o2 As Long, o3 As Long, GG As Long, a As Long
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Me.Caption = "修改器" '定义标题
Timer2.Enabled = False
End Sub
Private Sub Timer1_Timer()
o1 = FindWindow(vbNullString, "Plants vs. Zombies") '游戏名称 最重要
If o1 <> 0 Then
Label1.Caption = "成功读取游戏!!"
Else
Label1.Caption = "读取游戏失败!!"
End If
Call GetWindowThreadProcessId(o1, o2)
If o2 <> 0 Then
Label2.Caption = "成功读取PID值!!"
Else
Label2.Caption = "读取PID值失败!!"
End If
o3 = OpenProcess(PROCESS_ALL_ACCESS, False, o2)
If o3 <> 0 Then
Label3.Caption = "成功取得程式控制权!!"
Else
Label3.Caption = "取得程式控制权失败!!"
End If
Call ReadProcessMemory(o3, ByVal &HF97DC8 + &H768, GG, 4, 0&) '第一层偏移量
Call ReadProcessMemory(o3, ByVal GG + &H160, GG, 4, 0&)
Call ReadProcessMemory(o3, ByVal GG + &H4, GG, 4, 0&)
Call ReadProcessMemory(o3, ByVal GG + &H5560, GG, 4, 0&)
Label4.Caption = GG
Dim AA As Long
Call WriteProcessMemory(o3, AA, GG, 4, 0&)
' 目前我用CE找好阳光的偏移量
' 读取游戏和阳光数值都没问题
' 用CE可以但是用VB就是无法写入....是我语法有错误还是游戏本身的问题呢??
' 希望大家帮我看看 谢谢:D
Label5.Caption = AA
Call CloseHandle(o3)
End Sub
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 219.81.192.13