WEB开发网
开发学院软件开发VB VB从零开始编外挂(六) 阅读

VB从零开始编外挂(六)

 2006-02-27 21:11:18 来源:WEB开发网   
核心提示:应用实战需要VBAPI函数:FindWindowGetWindowThreadPRocessIdOpenProcessReadProcessMemoryCloseHandle相关API声明:FindWindow↓PrivateDeclareFunctionFindWindowLib"user32"A

--------------------------------------------------------------------------------------------------------------------------------------------------------
应用实战
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要VBAPI函数:
FindWindow
GetWindowThreadPRocessId
OpenProcess
ReadProcessMemory
CloseHandle
--------------------------------------------------------------------------------------------------------------------------------------------------------
相关API声明:
FindWindow

PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,ByVallpWindowNameAsString)AsLong

GetWindowThreadProcessId

PrivateDeclareFunctionGetWindowThreadProcessIdLib"user32"(ByValhwndAsLong,lpdwProcessIdAsLong)
AsLong

OpenProcess

PrivateDeclareFunctionOpenProcessLib"kernel32"(ByValdwDesiredaccessAsLong,ByValbInheritHandleAsLong,ByValdwProcessIdAsLong)AsLong

ReadProcessMemory

PrivateDeclareFunctionReadProcessMemoryLib"kernel32"(ByValhProcessAsLong,ByVallpBaseAddressAsAny,ByVallpBufferAsAny,ByValnSizeAsLong,lpNumberOfBytesWrittenAsLong)AsLong

CloseHandle

PrivateDeclareFunctionCloseHandleLib"kernel32"(ByValhObjectAsLong)AsLong

GetCurrentProcess

PrivateDeclareFunctionGetCurrentProcessLib"kernel32"()AsLong
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要的控件:Label、Timer(interval不为空)、Text
--------------------------------------------------------------------------------------------------------------------------------------------------------
定义函数:
DimSetHpAsInteger'定义设定的体力值
DimSetMpAsInteger'定义设定的魔法值
DimNowHpAsLong'定义目前的体力值
DimNowMpAsLong'定义目前的魔法值
DimMaxHpAsLong'定义角色的最高体力值
DimMaxMpAsLong'定义角色的最高魔法值
DimDiZhiAsLong'定义内存地址函数
DimhwndAsLong'储存FindWindow函数返回的句柄
--------------------------------------------------------------------------------------------------------------------------------------------------------
代码:
PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,ByVallpWindowNameAsString)AsLong
PrivateDeclareFunctionGetWindowThreadProcessIdLib"user32"(ByValhwndAsLong,lpdwProcessIdAsLong)
AsLong
PrivateDeclareFunctionOpenProcessLib"kernel32"(ByValdwDesiredAccessAsLong,ByValbInheritHandleAsLong,ByValdwProcessIdAsLong)AsLong
PrivateDeclareFunctionReadProcessMemoryLib"kernel32"(ByValhProcessAsLong,ByVallpBaseAddressAsAny,ByVallpBufferAsAny,ByValnSizeAsLong,lpNumberOfBytesWrittenAsLong)AsLong
PrivateDeclareFunctionCloseHandleLib"kernel32"(ByValhObjectAsLong)AsLong
PrivateDeclareFunctionGetCurrentProcessLib"kernel32"()AsLong
DimSetHpAsInteger'定义设定的体力值
DimSetMpAsInteger'定义设定的魔法值
DimNowHpAsLong'定义目前的体力值
DimNowMpAsLong'定义目前的魔法值
DimMaxHpAsLong'定义角色的最高体力值
DimMaxMpAsLong'定义角色的最高魔法值
DimDiZhiAsLong'定义内存地址函数

PrivateFunctionncnr(lpADDressAsLong)AsInteger
'声明一些需要的变量
DimhwndAsLong'储存FindWindow函数返回的句柄
DimpidAsLong'储存进程标识符(ProcessId)
DimpHandleAsLong'储存进程句柄
hwnd=FindWindow(vbNullString,"封神榜·网络版")
'取得进程标识符
GetWindowThreadProcessIdhwnd,pid
'使用进程标识符取得进程句柄
pHandle=OpenProcess(PROCESS_ALL_ACCESS,False,pid)
'在内存地址中读取数据
ReadProcessMemorypHandle,lpADDress,ByValVarPtr(ncnr),4,0&
'关闭进程句柄
CloseHandlehProcess
EndFunction
ConstSTANDARD_RIGHTS_REQUIRED=&HF0000
ConstSYNCHRONIZE=&H100000
ConstSPECIFIC_RIGHTS_ALL=&HFFFF
ConstSTANDARD_RIGHTS_ALL=&H1F0000
ConstPROCESS_ALL_ACCESS=STANDARD_RIGHTS_REQUIREDOrSYNCHRONIZEOr&HFFF
ConstPROCESS_VM_OperaTION=&H8&
ConstPROCESS_VM_READ=&H10&
ConstPROCESS_VM_WRITE=&H20&

PrivateSubForm_Load()
'体力:07F68F3这里替换你所搜索到的地址魔法:07F6860同前
DiZhi=&H07F68F3
Timer1.Enabled=True
Timer2.Enabled=False
Timer3.Enabled=False
EndSub

PrivateSubTimer1_Timer()
DimhwndAsLong
hwnd=FindWindow(vbNullString,"封神榜·网络版")

Ifhwnd=0Then
Label12.Caption="游戏未加载"
Timer1.Enabled=True
Timer2.Enabled=False
Timer3.Enabled=False
ExitSub
EndIf

Label12.Caption="游戏已加载"
SetHp=Text1.Text'获取设定的体力值
SetMp=Text2.Text'获取设定的魔法值
NowHp=ncnr(DiZhi)'获取当前的体力值
NowMp=ncnr(DiZhi 12)'获取当前的魔法值
MaxHp=ncnr(DiZhi 4)'获取角色的最高体力值
MaxMp=ncnr(DiZhi 16)'获取角色的最高魔法值
Label3.Caption=Str(NowHp) "/" Str(MaxHp)'显示角色体力值状态
Label4.Caption=Str(NowMp) "/" Str(MaxMp)'显示角色魔法值状态

IfCheck1.ValueThen
Timer2.Enabled=True
Else
Timer2.Enabled=False
EndIf
IfCheck2.ValueThen
Timer3.Enabled=True
Else
Timer3.Enabled=False
EndIf
EndSub

PrivateSubTimer2_Timer()
'体力值小于设定值按下数字键1
If(NowHp)<SetHpThen
SendKeys"1"
EndIf
EndSub

PrivateSubTimer3_Timer()
'魔法值小于设定值按下数字键2
If(NowMp)<SetMpThen
SendKeys"2"
EndIf
EndSub
--------------------------------------------------------------------------------------------------------------------------------------------------------

->

Tags:VB 开始 外挂

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接