level 5
痛苦地微笑
楼主
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
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 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 CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, ByVal cb As Long, ByRef cbNeeded As Long) As Long
Private Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, ByRef lphModule As Long, ByVal cb As Long, ByRef lpcbNeeded As Long) As Long
Private Declare Function GetModuleFileNameEx Lib "psapi.dll" Alias "GetModuleFileNameExA" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long
Private Declare Function GetProcessImageFileName Lib "psapi.dll" Alias "GetProcessImageFileNameA" (ByVal hProcess As Long, ByVal lpImageFileName As String, ByVal nSize As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId 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 Const MEM_COMMIT = &H1000
Private Const MEM_RESERVE = &H2000
Private Const MEM_RELEASE = &H8000
Private Const PAGE_READWRITE = &H4
Private Const PROCESS_VM_OPERATION = (&H8)
Private Const PROCESS_VM_READ = (&H10)
Private Const PROCESS_VM_WRITE = (&H20)
Private Const PROCESS_QUERY_INFORMATION = &H400 '进程信息
Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF '所有权限
Private addr(1) As Long
Private mValue(1) As Long
Private Sub Command1_Click()
Dim hGame As Long
If pidtxt.Text = 0 Then
MsgBox "游戏未运行!", 0, "警告"
Exit Sub
End If
hGame = OpenProcess(PROCESS_ALL_ACCESS, False, CLng(pidtxt.Text))
'MsgBox hGame
ReadProcessMemory hGame, ByVal addr(0), mValue(0), Len(mValue(0)), 0&
ReadProcessMemory hGame, ByVal addr(1), mValue(1), Len(mValue(1)), 0&
Text1.Text = mValue(0)
Text2.Text = mValue(1)
CloseHandle hGame
End Sub
Private Sub Command2_Click()
Dim hGame As Long
hGame = OpenProcess(PROCESS_ALL_ACCESS, False, CLng(pidtxt))
If pidtxt.Text = 0 Then
MsgBox "游戏未运行!", 0, "警告"
Exit Sub
End If
WriteProcessMemory hGame, ByVal addr(0), CLng(Text1.Text), Len(mValue(0)), 0&
WriteProcessMemory hGame, ByVal addr(1), CLng(Text2.Text), Len(mValue(1)), 0&
'Text1.Text = mValue
CloseHandle hGame
End Sub
Private Sub Text3_Change()
End Sub
Private Sub Form_Load()
Dim mpid() As Long
mpid = FindProcessByWindowCaption("北京浮生记")
pidtxt.Text = mpid(0)
addr(0) = &H12F52C
addr(1) = &H12F530
End Sub
2010年07月10日 07点07分
1
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
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 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 CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, ByVal cb As Long, ByRef cbNeeded As Long) As Long
Private Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, ByRef lphModule As Long, ByVal cb As Long, ByRef lpcbNeeded As Long) As Long
Private Declare Function GetModuleFileNameEx Lib "psapi.dll" Alias "GetModuleFileNameExA" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long
Private Declare Function GetProcessImageFileName Lib "psapi.dll" Alias "GetProcessImageFileNameA" (ByVal hProcess As Long, ByVal lpImageFileName As String, ByVal nSize As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId 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 Const MEM_COMMIT = &H1000
Private Const MEM_RESERVE = &H2000
Private Const MEM_RELEASE = &H8000
Private Const PAGE_READWRITE = &H4
Private Const PROCESS_VM_OPERATION = (&H8)
Private Const PROCESS_VM_READ = (&H10)
Private Const PROCESS_VM_WRITE = (&H20)
Private Const PROCESS_QUERY_INFORMATION = &H400 '进程信息
Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF '所有权限
Private addr(1) As Long
Private mValue(1) As Long
Private Sub Command1_Click()
Dim hGame As Long
If pidtxt.Text = 0 Then
MsgBox "游戏未运行!", 0, "警告"
Exit Sub
End If
hGame = OpenProcess(PROCESS_ALL_ACCESS, False, CLng(pidtxt.Text))
'MsgBox hGame
ReadProcessMemory hGame, ByVal addr(0), mValue(0), Len(mValue(0)), 0&
ReadProcessMemory hGame, ByVal addr(1), mValue(1), Len(mValue(1)), 0&
Text1.Text = mValue(0)
Text2.Text = mValue(1)
CloseHandle hGame
End Sub
Private Sub Command2_Click()
Dim hGame As Long
hGame = OpenProcess(PROCESS_ALL_ACCESS, False, CLng(pidtxt))
If pidtxt.Text = 0 Then
MsgBox "游戏未运行!", 0, "警告"
Exit Sub
End If
WriteProcessMemory hGame, ByVal addr(0), CLng(Text1.Text), Len(mValue(0)), 0&
WriteProcessMemory hGame, ByVal addr(1), CLng(Text2.Text), Len(mValue(1)), 0&
'Text1.Text = mValue
CloseHandle hGame
End Sub
Private Sub Text3_Change()
End Sub
Private Sub Form_Load()
Dim mpid() As Long
mpid = FindProcessByWindowCaption("北京浮生记")
pidtxt.Text = mpid(0)
addr(0) = &H12F52C
addr(1) = &H12F530
End Sub