2010-10-22 61 views
0

我一直在嘗試在vb.net中構建一個遊戲機器人。其中一個主要問題是訪問遊戲在屏幕上打印的文本,所以我一直在嘗試將遊戲調用掛接到windows api drawtext和textout函數。我一直在尋找如何在vb.net中設置一個很長時間沒有任何運氣的鉤子的例子。我發現不可能翻譯舊學校vb,C++和C#中的例子。爲了方便起見,我想使用免費的deviare和/或easyhook庫。誰能幫忙?掛鉤另一個程序的調用vb.net中的winapi函數

+0

遊戲機器人......爲這遊戲? – 2011-06-20 00:02:52

+0

在這種情況下,它是一個撲克機器人。 – mazoula 2013-09-06 10:22:11

回答

0

easyhook庫

嘗試使用the EasyHook library

+0

我發現沒有使用easyhook和vb.net的工作示例 – mazoula 2010-10-23 04:19:46

+0

@mazoula將它用作任何其他.NET庫 – Abyx 2010-10-23 11:25:17

+0

當時我無法使EasyHook正常工作 – mazoula 2013-09-06 10:25:25

2

我發現基於埋在deviare論壇deviare掛鉤的dll工作vb.net代碼。

請記住在安裝deviare後添加在Visual Studio的添加引用頁面的com選項卡下找到的所有6個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 
1

我正在將Easyhook c#代碼轉換爲vb.net。此刻,我收到錯誤代碼5消息,並且掛鉤的應用程序正在被Windows關閉,例如幫助保護您的計算機等。如果有人能夠幫助解決此問題,我將不勝感激。我有什麼到目前爲止...

Imports EasyHook 
Imports System 
Imports System.Diagnostics 
Imports System.Runtime.Remoting 
Imports System.Windows.Forms 
Imports System.Security 
Imports System.Security.Principal 

Namespace FileMon 
Friend Class Program 
    ' Methods 
    Public Shared Sub Main(ByVal args As String()) 

     Dim result As Integer = 0 
     If ((args.Length <> 1) OrElse Not Integer.TryParse(args(0), result)) Then 
      Console.WriteLine() 
      Console.WriteLine("Usage: FileMon %PID%") 
      Console.WriteLine() 
     Else 
      Try 
       Try 
        Console.WriteLine("Registering Application") 
        Console.WriteLine() 
        Config.Register("A FileMon like demo application.", "FileMon.exe", "FileMonInject.dll") 

       Catch exception1 As ApplicationException 
        Console.WriteLine("This is an administrative task! " & exception1.ToString) 
        Console.WriteLine() 
        Process.GetCurrentProcess.Kill() 
       End Try 

       Console.WriteLine("Creating IPC Server") 
       Console.WriteLine() 
       RemoteHooking.IpcCreateServer(Of FileMonInterface)(Program.ChannelName, WellKnownObjectMode.SingleCall) 
       RemoteHooking.Inject(result, "FileMonInject.dll", "FileMonInject.dll", New Object() {Program.ChannelName}) 
       Console.WriteLine("Injected") 
       Console.WriteLine() 
       Console.ReadLine() 

      Catch exception As Exception 
       Console.WriteLine("There was an error while connecting to target:" & exception.ToString) 
      End Try 
     End If 
    End Sub 

    ' Fields 
    Private Shared ChannelName As String 
End Class 
End Namespace 

Imports System 

Namespace FileMon 
Public Class FileMonInterface 
    Inherits MarshalByRefObject 
    ' Methods 
    Public Sub IsInstalled(ByVal InClientPID As Integer) 
     Console.WriteLine("FileMon has been installed in target " & InClientPID) 
    End Sub 

    Public Sub OnCreateFile(ByVal InClientPID As Integer, ByVal InFileNames As String()) 
     Dim i As Integer 
     For i = 0 To InFileNames.Length - 1 
      Console.WriteLine(InFileNames(i)) 
     Next i 
    End Sub 

    Public Sub Ping() 
    End Sub 

    Public Sub ReportException(ByVal InInfo As Exception) 
     Console.WriteLine(("The target process has reported an error:" & InInfo.ToString)) 
    End Sub 

End Class 
End Namespace