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
下面是我写的源码:
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
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28