Can anyone give me example of Visual Basic ?

Home Forums Discussions Support Can anyone give me example of Visual Basic ?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4818
    wat
    Participant

      Can anyone give me example of Visual Basic Code for using “NT Kernel Resources Local Host Monitor API” in order to capture raw data of every packet?

      Thank you for advance.

      #5431
      Anton
      Participant

        This will help, I hope


        Option Strict On
        Imports LHMONAPILib
        Module Module1

        Sub Main()
        Dim Lhmon As LhmonApi = New LhmonApi

        If Not Lhmon.IsDriverLoaded Then
        MsgBox("Delay value should be greater or equal to 0", MsgBoxStyle.Critical)
        Return
        End If

        Dim FilterInfo As _FILTER_INFO = New _FILTER_INFO

        Lhmon.Capture = False
        Lhmon.PurgeLog()

        FilterInfo.m_Address.m_Ip = Convert.ToUInt32(0)
        FilterInfo.m_Address.m_Mask = Convert.ToUInt32(0)
        FilterInfo.m_PortRange.m_StartRange = Convert.ToUInt16(0)
        FilterInfo.m_PortRange.m_EndRange = Convert.ToUInt16(65535)
        FilterInfo.m_LocalPortRange.m_StartRange = Convert.ToUInt16(0)
        FilterInfo.m_LocalPortRange.m_EndRange = Convert.ToUInt16(65535)
        FilterInfo.m_Protocol = _PROTOCOL.TCP
        Lhmon.AddFilter(FilterInfo)

        FilterInfo.m_Address.m_Ip = Convert.ToUInt32(0)
        FilterInfo.m_Address.m_Mask = Convert.ToUInt32(0)
        FilterInfo.m_PortRange.m_StartRange = Convert.ToUInt16(0)
        FilterInfo.m_PortRange.m_EndRange = Convert.ToUInt16(65535)
        FilterInfo.m_LocalPortRange.m_StartRange = Convert.ToUInt16(0)
        FilterInfo.m_LocalPortRange.m_EndRange = Convert.ToUInt16(65535)
        FilterInfo.m_Protocol = _PROTOCOL.UDP
        Lhmon.AddFilter(FilterInfo)

        Lhmon.Capture = True

        Dim LogInfo As _LOG_INFO = New LHMONAPILib._LOG_INFO
        Dim fbSuccess As Boolean
        fbSuccess = True
        While True

        Do
        fbSuccess = Lhmon.ReadLog(LogInfo)
        If fbSuccess And Not LogInfo.m_Offset.Equals(0) Then
        Console.WriteLine("Record" + LogInfo.m_ID.ToString())
        Console.WriteLine("LogInfo.m_LocalAddress.m_Ip = " + LogInfo.m_LocalAddress.m_Ip.ToString())
        Console.WriteLine("LogInfo.m_LocalAddress.m_Port = " + LogInfo.m_LocalAddress.m_Port.ToString())
        Console.WriteLine("LogInfo.m_RemoteAddress.m_Ip = " + LogInfo.m_RemoteAddress.m_Ip.ToString())
        Console.WriteLine("LogInfo.m_RemoteAddress.m_Port = " + LogInfo.m_RemoteAddress.m_Port.ToString())
        Console.WriteLine("LogInfo.m_Protocol = " + LogInfo.m_Protocol.ToString())
        Console.WriteLine("LogInfo.m_Offset = " + LogInfo.m_Offset.ToString())
        Console.WriteLine("LogInfo.m_Flags = " + LogInfo.m_Flags.ToString())
        Console.WriteLine("LogInfo.m_DataLength = " + LogInfo.m_DataLength.ToString())
        Console.WriteLine("LogInfo.m_ProcessID = " + LogInfo.m_ProcessID.ToString())
        Console.WriteLine("")

        End If
        Loop Until Not fbSuccess
        System.Threading.Thread.Sleep(100)
        End While

        End Sub

        End Module
      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.