问题描述
我一直试图在vb.net中构建一个游戏机器人.主要问题之一是无法访问游戏在屏幕上打印的文本,因此我一直试图将对Windows api drawtext和textout函数的游戏调用挂起.我一直在寻找如何在vb.net上设置钩子的例子,很长时间没有任何运气.我发现不可能在老式的vb,C ++和C#中翻译示例.为了方便起见,我想使用免费提供的deviare和/或easyhook库.有人可以帮忙吗?
I have been trying to build a game bot in vb.net. One of the main problems is getting access to the text the game prints on the screen so I have been trying to hook the games calls to the windows api drawtext and textout functions. I have been hunting for examples of how to set up a hook in vb.net for a long time without any luck. I have found it impossible to translate examples in old school vb, C++, and C#. For convenience's sake I would like to use the freely available deviare and/or easyhook libraries. Can anyone help?
推荐答案
我发现基于在deviare论坛中埋藏的deviare钩子dll的有效vb.net代码.
I found working vb.net code based on the deviare hooking dlls buried in the deviare forums.
请记住在安装deviare之后,添加在Visual Studio的添加引用页面的com选项卡下找到的所有6个deviare引用.
please remember to add all 6 deviare references found under the com tab of the add references page of visual studio after installing deviare.
Public Class Form1
'To print to a textbox in the gui you will have to call textbox.invoke
Private _mgr As Deviare.SpyMgr
Private WithEvents _hook As Deviare.Hook
Private _proc As DeviareTools.IProcess
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
_mgr = New Deviare.SpyMgr()
_hook = _mgr.CreateHook("user32.dll!ShowWindow")
_hook.Attach(_mgr.Processes)
_hook.AddProcessFilter(0, "notepad", 1)
_hook.Hook()
Private Sub OnFunctionCalled(ByVal proc As DeviareTools.IProcess, ByVal callInfo As DeviareParams.ICallInfo, ByVal rCall As Deviare.IRemoteCall) Handles _hook.OnFunctionCalled
Debug.Print("Caught function call in " & proc.Name) 'view in imediate window
End Sub
end class
这篇关于在vb.net中将另一个程序的调用挂接到winapi函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!