VB 从零开始编外挂(六)
2008-02-23 06:50:24来源:互联网 阅读 ()
--------------------------------------------------------------------------------------------------------------------------------------------------------
应用实战
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要VB API函数:
FindWindow
GetWindowThreadProcessId
OpenProcess
ReadProcessMemory
CloseHandle
--------------------------------------------------------------------------------------------------------------------------------------------------------
相关API声明:
FindWindow
↓
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( ByVal lpClassName As String , ByVal lpWindowName As String ) As Long
GetWindowThreadProcessId
↓
Private Declare Function GetWindowThreadProcessId Lib "user32" ( ByVal hwnd As Long , lpdwProcessId As Long )
As Long
OpenProcess
↓
Private Declare Function OpenProcess Lib "kernel32" ( ByVal dwDesiredAccess As Long , ByVal bInheritHandle As Long , ByVal dwProcessId As Long ) As Long
ReadProcessMemory
↓
Private 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
CloseHandle
↓
Private Declare Function CloseHandle Lib "kernel32" ( ByVal hObject As Long ) As Long
GetCurrentProcess
↓
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要的控件: Label 、 Timer(interval不为空)、Text
--------------------------------------------------------------------------------------------------------------------------------------------------------
定义函数:
Dim SetHp As Integer ' 定义设定的体力值
Dim SetMp As Integer ' 定义设定的魔法值
Dim NowHp As Long ' 定义目前的体力值
Dim NowMp As Long ' 定义目前的魔法值
Dim MaxHp As Long ' 定义角色的最高体力值
Dim MaxMp As Long ' 定义角色的最高魔法值
Dim DiZhi As Long '定义内存地址函数
Dim hwnd As Long ' 储存 FindWindow 函数返回的句柄
--------------------------------------------------------------------------------------------------------------------------------------------------------
代码:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( ByVal lpClassName As String , ByVal lpWindowName As String ) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" ( ByVal hwnd As Long , lpdwProcessId 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 ReadProcessMemory Lib "kernel32" ( ByVal hProcess As Long , ByVal lpBaseAddress As Any , ByVal 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 GetCurrentProcess Lib "kernel32" () As Long
Dim SetHp As Integer ' 定义设定的体力值
Dim SetMp As Integer ' 定义设定的魔法值
Dim NowHp As Long ' 定义目前的体力值
Dim NowMp As Long ' 定义目前的魔法值
Dim MaxHp As Long ' 定义角色的最高体力值
Dim MaxMp As Long ' 定义角色的最高魔法值
Dim DiZhi As Long '定义内存地址函数
Private Function ncnr(lpADDress As Long ) As Integer
' 声明一些需要的变量
Dim hwnd As Long ' 储存 FindWindow 函数返回的句柄
Dim pid As Long ' 储存进程标识符( Process Id )
Dim pHandle As Long ' 储存进程句柄
hwnd = FindWindow(vbNullString, "封神榜·网络版")
' 取得进程标识符
GetWindowThreadProcessId hwnd, pid
' 使用进程标识符取得进程句柄
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
' 在内存地址中读取数据
ReadProcessMemory pHandle, lpADDress, ByVal VarPtr(ncnr), 4, 0&
' 关闭进程句柄
CloseHandle hProcess
End Function
Const STANDARD_RIGHTS_REQUIRED = &HF0000
Const SYNCHRONIZE = &H100000
Const SPECIFIC_RIGHTS_ALL = &HFFFF
Const STANDARD_RIGHTS_ALL = &H1F0000
Const PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF
Const PROCESS_VM_OPERATION = &H8&
Const PROCESS_VM_READ = &H10&
Const PROCESS_VM_WRITE = &H20&
Private Sub Form_Load()
' 体力:07F68F3 这里替换你所搜索到的地址 魔法:07F6860 同前
DiZhi = &H 07F68F3
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim hwnd As Long
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash