红色警戒2尤里的复仇(单人游戏加钱)修改器
没有事玩起了老游戏“红色警戒2尤里的复仇”
但是钱的问题让我没有办法~于是做了一个简单 程序,修改一下钱,哈哈~下面就是代码
了,也很简单~看下就知道了
Option Explicit
'寻找窗口列表中第一个符合指定条件的顶级窗口(在vb里使用:FindWindow最常见的一
个用途是获得ThunderRTMain类的隐藏窗口的句柄;该类是所有运行中vb执行程序的一部
分。获得句柄后,可用api函数GetWindowText取得这个窗口的名称;该名也是应用程序的
标题)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'得到窗体控件句柄的函数
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 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 Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long '读取进程内存的函数
Private Declare Function ReadProcessMemory Lib "kernel32.dll" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesWritten As Long) As Long
'参数决定了对进程的存储权限,使用完全控制
'在指定进程中写内存
Private Declare Function WriteProcessMemory Lib "kernel32" _
(ByVal hProcess As Long, _
lpBaseAddress As Any, _
lpBuffer As Any, _
ByVal nSize As Long, _
lpNumberOfBytesWritten As Long) As Long
Private Fr As Boolean
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const SYNCHRONIZE = &H100000
Private Const PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
Private 打开进程 As Boolean
Private hwd As Long
Private pid As Long
Private sb As Long, pb As Long, B As Long, s As Long
Private hProcess As Long '存放进程句柄
Private Sub Command1_Click()
If 打开进程 Then
On Error GoTo E
s = s + Val(Text1.Text)
WriteProcessMemory hProcess, ByVal (B + pb), s, 4, 0&
ReadProcessMemory hProcess, ByVal B + pb, s, 4, 0&
Label1.Caption = GetStrMony(s)
End If
Exit Sub
E:
On Error GoTo 0
CloseHandle hProcess
打开进程 = False
End Sub
Private Sub Form_Load()
sb = CLng("&H" & Text2.Text) pb = CLng("&H" & Text3.Text) Label3_Click
End Sub
Private Sub Form_Unload(Cancel As Integer)
CloseHandle hProcess
End Sub
Private Sub Label3_Click()
If Fr Then Me.Height = 3120 Else Me.Height = 1755
Fr = Not Fr
End Sub
Private Sub Text2_Change()
sb = CLng("&H" & Text2.Text): 打开进程 = False
End Sub
Private Sub Text3_Change()
pb = CLng("&H" & Text3.Text): 打开进程 = False
End Sub
Private Sub Text4_Change()
打开进程 = False
CloseHandle hProcess
End Sub
Private Sub Timer1_Timer()
If 打开进程 = False Then
hwd = FindWindow(vbNullString, Text4.Text)
If hwd <> 0 Then
GetWindowThreadProcessId hwd, pid
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
If hProcess Then
ReadProcessMemory hProcess, ByVal sb, B, 4, 0&
If B > 0 Then 打开进程 = True Else Label1.Caption = "读取基址错误~"
Else
Label1.Caption = "进程打开失败~"
End If
Else
Label1.Caption = "游戏没有运行~"
End If
End If
If 打开进程 Then
ReadProcessMemory hProcess, ByVal (B + pb), s, 4, 0&
Label1.Caption = GetStrMony(s)
End If
End Sub
Private Function GetStrMony(ByVal k As Long) As String Dim ts As String, cs As String
cs = CStr(k)
Do While Len(cs) - 3 > 0
ts = Right(cs, 3) & IIf(ts <> "", ",", "") & ts
cs = Left(cs, Len(cs) - 3)
Loop
GetStrMony = "RMB:" & IIf(cs <> "", cs & ",", "") & ts End Function
运行时如图~ 呵~不算麻烦