+ -
当前位置:首页 → 问答吧 → vb写入不了内存啊!求帮忙,在线等

vb写入不了内存啊!求帮忙,在线等

时间:2011-12-16

来源:互联网

游戏是本地计算机上面的“扫雷”
下面是我写的源码:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject 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 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 Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim Process As Long
Dim PID As Long
Dim lhprocess As Long
Dim Time As Long
Process = FindWindow("扫雷", "扫雷")
If Process = 0 Then
Label1.Caption = "游戏没有运行..."
Else
Label1.Caption = "游戏已经运行"
End If
GetWindowThreadProcessId Process, PID
If PID = 0 Then
Label2.Caption = "没有找到PID的句柄"
Else
Label2.Caption = "PID句柄已经找到"
End If
lhprocess = OpenProcess(PROCESS_ALL_ACCESS, False, PID)
ReadProcessMemory lhprocess, ByVal &H100579C, Time, 4, 0&
CloseHandle hProcess
Label3.Caption = "当前时间:" & Time
End Sub
Private Sub Command1_Click()
lhprocess = OpenProcess(PROCESS_ALL_ACCESS, False, PID)
WriteProcessMemory lhprocess, ByVal &H100579C, 0, 4, 0&
End Sub

作者: VB_AL   发布时间: 2011-12-16

基址没有错,都可以读取了,就是修改不了啊,求解答

作者: VB_AL   发布时间: 2011-12-16