欢迎光临
我们一直在努力

vb从零开始编外挂(六)_visualbasic教程

建站超值云服务器,限时71元/月

——————————————————————————————————————————————————–
应用实战
——————————————————————————————————————————————————–
需要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
——————————————————————————————————————————————————–

->

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » vb从零开始编外挂(六)_visualbasic教程
分享到: 更多 (0)