请各大高手帮我将VB6上修改内存数据的代码转成在VB.net可用的

声明:DeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,By... 声明:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

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 Sub Timer1_Timer()
Dim hWnd As Long

Const STANDARD_RIGHTS_REQUIRED = &HF0000
Const SYNCHRONIZE = &H100000
Const PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
hWnd = FindWindow(vbNullString, "游戏窗口1")
If hWnd = 0 Then
Label1.Caption = " 提示:游戏窗口1未运行"
Label2.Caption = " 未开启任何功能"
Check1.Enabled = False
Check2.Enabled = False
Check3.Enabled = False
Check4.Enabled = False
Else
GetWindowThreadProcessId hWnd, pid
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
Check1.Enabled = True
Check2.Enabled = True
Check3.Enabled = True
Check4.Enabled = True
Label1.Caption = " 提示:游戏窗口1正在运行"
End If

If Check1.Enabled = True Then
Check1.Value = 1
End If

If Check2.Enabled = True Then
Check2.Value = 1
End If

If Check3.Enabled = True Then
Check3.Value = 1
End If

If Check1.Value = 1 Then
WriteProcessMemory pHandle, ByVal &H76998C, &H44, 1, 0&
WriteProcessMemory pHandle, ByVal &H7699A0, &H42, 1, 0&

Else
WriteProcessMemory pHandle, ByVal &H76998C, &H42, 1, 0&
WriteProcessMemory pHandle, ByVal &H7699A0, &H44, 1, 0&

End If

If Check3.Value = 1 Then
WriteProcessMemory pHandle, ByVal &H51AEC0, &HC2, 1, 0&
WriteProcessMemory pHandle, ByVal &H51AEC1, &HC, 1, 0&
WriteProcessMemory pHandle, ByVal &H51AEC2, &H0, 1, 0&

WriteProcessMemory pHandle, ByVal &H51AEE0, &HC2, 1, 0&
WriteProcessMemory pHandle, ByVal &H51AEE1, &H14, 1, 0&
WriteProcessMemory pHandle, ByVal &H51AEE2, &H0, 1, 0&

Else
WriteProcessMemory pHandle, ByVal &H51AEC0, &H55, 1, 0&
WriteProcessMemory pHandle, ByVal &H51AEC1, &H8B, 1, 0&
WriteProcessMemory pHandle, ByVal &H51AEC2, &HEC, 1, 0&

WriteProcessMemory pHandle, ByVal &H51AEE0, &H55, 1, 0&
WriteProcessMemory pHandle, ByVal &H51AEE1, &H8B, 1, 0&
WriteProcessMemory pHandle, ByVal &H51AEE2, &HEC, 1, 0&
End If

CloseHandle pHandle

If Check1.Value = 1 Then
Label2.Caption = " Cheat1 开启 Cheat2 开启 Cheat3 开启 "
End If
End Sub

在下才识浅陋 因初步接触VB.net 寻找了许多方法仍然毫无头绪,仍然无法解决… 以致寝室难安… 所以在此向各大侠请教之。望给予在下帮助… 不胜感激!
展开
 我来答
zhaobuping
2011-04-01 · TA获得超过340个赞
知道小有建树答主
回答量:195
采纳率:0%
帮助的人:268万
展开全部
Imports System.Runtime.InteropServices
Public Class Form1
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Integer, ByRef lpdwProcessId As Integer) As Integer
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As IntPtr, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer() As Byte, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Declare Function WriteProcessMemory Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As IntPtr, ByVal nSize As Integer, ByVal lpNumberOfBytesWritten As Integer) As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim hWnd As Integer
Dim pHandle As Integer
Dim pid As Integer
Const STANDARD_RIGHTS_REQUIRED = &HF0000
Const SYNCHRONIZE = &H100000
Const PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
hWnd = FindWindow(vbNullString, "游戏窗口1")
If hWnd = 0 Then
Label1.Text = " 提示:游戏窗口1未运行"
Label2.Text = " 未开启任何功能"
CheckBox1.Enabled = False
CheckBox2.Enabled = False
CheckBox3.Enabled = False
CheckBox4.Enabled = False
Else
GetWindowThreadProcessId(hWnd, pid)
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
CheckBox1.Enabled = True
CheckBox2.Enabled = True
CheckBox3.Enabled = True
CheckBox4.Enabled = True
Label1.Text = " 提示:游戏窗口1正在运行"
End If
If CheckBox1.Enabled = True Then
CheckBox1.Checked = True
End If
If CheckBox2.Enabled = True Then
CheckBox2.Checked = True
End If
If CheckBox3.Enabled = True Then
CheckBox3.Checked = True
End If
If CheckBox1.Checked = True Then
WriteProcessMemory(pHandle, &H76998C, &H44, 1, 0&)
WriteProcessMemory(pHandle, &H7699A0, &H42, 1, 0&)
Else
WriteProcessMemory(pHandle, &H76998C, &H42, 1, 0&)
WriteProcessMemory(pHandle, &H7699A0, &H44, 1, 0&)
End If
If CheckBox3.Checked = True Then
WriteProcessMemory(pHandle, &H51AEC0, &HC2, 1, 0&)
WriteProcessMemory(pHandle, &H51AEC1, &HC, 1, 0&)
WriteProcessMemory(pHandle, &H51AEC2, &H0, 1, 0&)
WriteProcessMemory(pHandle, &H51AEE0, &HC2, 1, 0&)
WriteProcessMemory(pHandle, &H51AEE1, &H14, 1, 0&)
WriteProcessMemory(pHandle, &H51AEE2, &H0, 1, 0&)
Else
WriteProcessMemory(pHandle, &H51AEC0, &H55, 1, 0&)
WriteProcessMemory(pHandle, &H51AEC1, &H8B, 1, 0&)
WriteProcessMemory(pHandle, &H51AEC2, &HEC, 1, 0&)
WriteProcessMemory(pHandle, &H51AEE0, &H55, 1, 0&)
WriteProcessMemory(pHandle, &H51AEE1, &H8B, 1, 0&)
WriteProcessMemory(pHandle, &H51AEE2, &HEC, 1, 0&)
End If
CloseHandle(pHandle)
If CheckBox1.Checked = True Then
Label2.Text = " Cheat1 开启 Cheat2 开启 Cheat3 开启 "
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Timer1.Start()
End Sub
End Class
更多追问追答
追问
不好意思 还要再麻烦你一下 本来写在VB上的模块的声明 在VB.net直接写在窗体上就可以了吗
然后 我能无错运行了 可是还不能修改到内存数据 请问这是什么回事吗
麻烦大侠再帮我调试下 拜托你啦! 我会好好加悬赏的
追答
你看 hWnd = FindWindow(vbNullString, "游戏窗口1")中的hWnd是否等于0,若等于0就表示窗口没找对。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式