用VB6.0修改内存中的数据

来源:百度知道 编辑:UC知道 时间:2024/06/08 22:25:13
我想用VB6.0编写一个可以修改指定程序指定内存地址数据的程序。

比如说,已知有一123.exe的程序正在运行,我想按一下Command按钮就能修改其中0456A3内存中的数据为FF,请问如何实现(包括如何获取PID,写入内存数据等等)。

回答者请给出源代码,以及所有的声明(代码中就按上述举例来设置参数)。要求是:我直接拷贝到VB里就能使用。如果满足要求,分数不是问题。

'这些写道bas中
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

'这些写道form里
Private Sub Timer1_Timer()