请教vb.net下 readprocessmemory一些问题 里有代码

wudi009 2008-09-06 07:57:23
vb6代码
如下:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesRead As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten 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 GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF



Dim jcm As Long
Dim jcpid As Long
Dim dujc As Long

jcm = FindWindow(vbNullString, "游戏名")
If jcm = 0 Then
Form1.Caption = "游戏未启动,请开启在试"
Else
Form1.Caption = "游戏启动成功"
End If
GetWindowThreadProcessId jcm, jcpid
dujc = OpenProcess(PROCESS_ALL_ACCESS, False, jcpid)


ReadProcessMemory dujc, ByVal dizhi, dxue, 4, 0&
dxue = &H8FC4 + &H314 + dxue
ReadProcessMemory dujc, ByVal dxue, dxue, 4, 0&

label1.caption=dxue
显示成功



vb.net 下代码如下:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function OpenProcess Lib "kernel32.dll" Alias "OpenProcess" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" Alias "GetWindowThreadProcessId" (ByVal hwnd As Integer, ByRef lpdwProcessId As Integer) As Integer
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As Integer, ByVal dwSize As Integer, ByRef lpNumberOfBytesRead As Integer) As Boolean

Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF


Dim jcm As Integer
Dim jcpid As Integer
Dim dujc As Integer
Dim dxue As Integer


jcm = FindWindow(vbNullString,"游戏名" )

If jcm > 0 Then
Me.Text = "启动成功"


GetWindowThreadProcessId(jcm, jcpid)
If jcpid > 0 Then

dujc = OpenProcess(PROCESS_ALL_ACCESS, 0, jcpid)
If dujc = 0 Then

Else
ReadProcessMemory(dujc, &H99D8B8, dxue, 4, 0&)
dxue=dxue + (&H8FC4 + &H314)
ReadProcessMemory(dujc, dxue,dxue, 4, 0&)


label1.Text = CInt(dxue)


End If

End If

End If

无法显示 显示为0 读不内存

忘高手指教下!!!!
...全文
68 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wudi009 2008-09-08
  • 打赏
  • 举报
回复
没人指点吗 高手来啊
wudi009 2008-09-07
  • 打赏
  • 举报
回复
高手帮忙指点下啊!!!!
wudi009 2008-09-06
  • 打赏
  • 举报
回复
ReadProcessMemory(dujc, &H99D8B8, dxue, 4, 0&) 跟踪这里 dxue 根本读不到数据 奇怪了!!

16,718

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧