Find all our projects in development below.
All source code is GNU General Public License (GPL)
Browsing frmIPSpy.vb (54.57 KB)
Option Explicit On
Imports System.IO
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Text
Imports Be.Windows.Forms
Public Class frmIPSpy
Private _udpClient As clsUdpClient = Nothing
Private _udpServer As clsUdpServer = Nothing
Private _tcpClient As clsTcpClient = Nothing
Private _tcpServer As clsTcpServer = Nothing
Private _tcpServerClient As clsTcpClient = Nothing
Private _clientIn As DynamicByteProvider = Nothing
Private _clientOut As DynamicByteProvider = Nothing
Private _serverIn As DynamicByteProvider = Nothing
Private _serverOut As DynamicByteProvider = Nothing
Private srcHex As HexBox = Nothing
Private clientText As String = ""
Private clientBytes As Integer = 0
Private clientUpdate As DateTime = Nothing
Private serverText As String = ""
Private serverBytes As Integer = 0
Private serverUpdate As DateTime = Nothing
Private lastIconKey As String = ""
Public ClientDisplayText As String = ""
Public ClientBytesRecvCount As Double = 0
Public ClientPacketsRecvCount As Double = 0
Public ClientBytesSentCount As Double = 0
Public ClientPacketsSentCount As Double = 0
Public ServerDisplayText As String = ""
Public ServerBytesRecvCount As Double = 0
Public ServerPacketsRecvCount As Double = 0
Public ServerBytesSentCount As Double = 0
Public ServerPacketsSentCount As Double = 0
Private Const BytesPerLine As Integer = 8
Private Const UpdateExpires As Integer = 5 ' seconds
Private Const DefaultMaxClients As Integer = 1
Public Function UdpClientDataRecvByteCallback(ByVal byteData() As Byte) As Byte()
If Me.InvokeRequired Then
Return Me.Invoke(New clsUdpClient.UdpClientDataRecvByteFunc(AddressOf UdpClientDataRecvByteCallback), byteData)
Else
_clientIn.Bytes.AddRange(byteData)
hexClientIn.Refresh()
hexClientIn.VScrollBarVisible = False
hexClientIn.VScrollBarVisible = True
hexClientIn.SelectionStart = hexClientIn.ByteProvider.Length
hexClientIn.ScrollByteIntoView(hexClientIn.SelectionStart - 1)
clientBytes += byteData.Length
ClientBytesRecvCount += byteData.Length
ClientPacketsRecvCount += 1
lblClient.Text = "Client: Recv " + clientBytes.ToString + " byte(s)"
clientUpdate = Now()
UpdateIcon("data_recv")
Return Array.CreateInstance(GetType(Byte), 0)
End If
End Function
Public Function UdpServerDataRecvByteCallback(ByVal byteData() As Byte) As Byte()
If Me.InvokeRequired Then
Return Me.Invoke(New clsUdpServer.UdpServerDataRecvByteFunc(AddressOf UdpServerDataRecvByteCallback), byteData)
Else
_serverIn.Bytes.AddRange(byteData)
hexServerIn.Refresh()
hexServerIn.VScrollBarVisible = False
hexServerIn.VScrollBarVisible = True
hexServerIn.SelectionStart = hexServerIn.ByteProvider.Length
hexServerIn.ScrollByteIntoView(hexServerIn.SelectionStart - 1)
serverBytes += byteData.Length
ServerBytesRecvCount += byteData.Length
ServerPacketsRecvCount += 1
lblServer.Text = "Host: Recv " + serverBytes.ToString + " byte(s)"
serverUpdate = Now()
UpdateIcon("data_recv")
Return Array.CreateInstance(GetType(Byte), 0)
End If
End Function
Public Function TcpClientDataRecvByteCallback(ByVal byteData() As Byte) As Byte()
If Me.InvokeRequired Then
Return Me.Invoke(New clsTcpClient.TcpClientDataRecvByteFunc(AddressOf TcpClientDataRecvByteCallback), byteData)
Else
_clientIn.Bytes.AddRange(byteData)
hexClientIn.Refresh()
hexClientIn.VScrollBarVisible = False
hexClientIn.VScrollBarVisible = True
hexClientIn.SelectionStart = hexClientIn.ByteProvider.Length
hexClientIn.ScrollByteIntoView(hexClientIn.SelectionStart - 1)
clientBytes += byteData.Length
ClientBytesRecvCount += byteData.Length
ClientPacketsRecvCount += 1
lblClient.Text = "Client: Recv " + clientBytes.ToString + " byte(s)"
clientUpdate = Now()
UpdateIcon("data_recv")
Return Array.CreateInstance(GetType(Byte), 0)
End If
End Function
Public Function TcpServerDataRecvByteCallback(ByVal byteData() As Byte) As Byte()
If Me.InvokeRequired Then
Return Me.Invoke(New clsTcpClient.TcpClientDataRecvByteFunc(AddressOf TcpServerDataRecvByteCallback), byteData)
Else
_serverIn.Bytes.AddRange(byteData)
hexServerIn.Refresh()
hexServerIn.VScrollBarVisible = False
hexServerIn.VScrollBarVisible = True
hexServerIn.SelectionStart = hexServerIn.ByteProvider.Length
hexServerIn.ScrollByteIntoView(hexServerIn.SelectionStart - 1)
serverBytes += byteData.Length
ServerBytesRecvCount += byteData.Length
ServerPacketsRecvCount += 1
lblServer.Text = "Host: Recv " + serverBytes.ToString + " byte(s)"
serverUpdate = Now()
UpdateIcon("data_recv")
Return Array.CreateInstance(GetType(Byte), 0)
End If
End Function
Public Sub ServerNewClientCallback(ByVal newClient As clsTcpClient)
If Me.InvokeRequired Then
Me.Invoke(New clsTcpServer.TcpServerNewClientSub(AddressOf ServerNewClientCallback), newClient)
Else
_tcpServerClient = newClient
_tcpServerClient.StartListen(New clsTcpClient.TcpClientDataRecvByteFunc(AddressOf TcpServerDataRecvByteCallback))
ServerDisplayText = newClient.ToString
serverText = "Host: Connection from " + ServerDisplayText
lblServer.Text = serverText
serverUpdate = Now()
End If
End Sub
Public Sub ClientDisconnectCallback(ByVal thisClient As clsTcpClient)
If Me.InvokeRequired Then
Me.Invoke(New clsTcpClient.TcpClientDisconnectSub(AddressOf ClientDisconnectCallback), thisClient)
Else
clientText = "Client: Ready"
lblClient.Text = "Client: Disconnected from " + thisClient.ToString
clientUpdate = Now()
_tcpClient.Dispose()
_tcpClient = Nothing
If btnClientCmd.Tag Then btnClientCmd_Click(Nothing, Nothing)
End If
End Sub
Public Sub ServerClientDisconnectCallback(ByVal thisClient As clsTcpClient)
If Me.InvokeRequired Then
Me.Invoke(New clsTcpClient.TcpClientDisconnectSub(AddressOf ServerClientDisconnectCallback), thisClient)
Else
If _tcpServer.Clients.Count = 0 Then
serverText = "Host: Listening on port " + CStr(Val(txtServerPort.Text))
Else
serverText = "Host: " + _tcpServer.Clients.Count.ToString + " connected client(s)"
End If
ServerDisplayText = ""
lblServer.Text = "Host: Disconnect from " + thisClient.ToString
serverUpdate = Now()
_tcpServerClient.Dispose()
_tcpServerClient = Nothing
End If
End Sub
Private Function ChooseIPEntry(ByVal host As String) As IPAddress
Dim hostIP As IPAddress = Nothing
Dim hostIPs As IPHostEntry = Dns.GetHostEntry(host)
If hostIPs.AddressList.Length > 1 Then
' create the user selection request
Dim userRequest As New clsUserSelection(Me)
userRequest.AllowCancel = True
' add columns
userRequest.AddColumn("IP Address")
' enumerate each ip entry
For Each thisIP As IPAddress In hostIPs.AddressList
userRequest.AddRow(thisIP.ToString)
Next
' show the user selection dialog
userRequest.Show("Choose IP Address of Hostname")
' make sure user did not cancel
If userRequest.retIndex >= 0 Then
' get the query file chosen
hostIP = hostIPs.AddressList(userRequest.retIndex)
End If
Else
hostIP = hostIPs.AddressList(0)
End If
Return hostIP
End Function
Private Function LocationToClient(ByVal obj As Control) As Point
Dim offsetX As Integer = 0
Dim offsetY As Integer = 0
Do While Not (obj Is Nothing) AndAlso _
Not (obj.Equals(obj.TopLevelControl))
offsetX += obj.Left
offsetY += obj.Top
obj = obj.Parent
Loop
Return New Point(offsetX + 1, offsetY + 1)
End Function
Private Sub PrepareToolbar()
With srcHex
Try
btnCut.Enabled = .CanCut
Catch
btnCut.Enabled = False
End Try
Try
btnCopy.Enabled = .CanCopy
Catch
btnCopy.Enabled = False
End Try
Try
btnPaste.Enabled = .CanPaste
Catch
btnPaste.Enabled = False
End Try
btnDelete.Enabled = .SelectionLength > 0
btnSelectAll.Enabled = .ByteProvider.Length > 0 And _
.ByteProvider.Length <> .SelectionLength
btnFind.Enabled = .ByteProvider.Length > 0
End With
End Sub
Private Sub UpdateIcon(ByVal iconKey As String)
If iconKey <> lastIconKey And _
(lastIconKey = "data_recv" Or lastIconKey = "data_send") Then
lastIconKey = "data_both"
Else
lastIconKey = iconKey
End If
lblIcon.Image = GetResourceImage(lastIconKey)
timerIcon.Stop()
timerIcon.Start()
End Sub
Private Sub _showWaitCursor(ByVal bShow As Boolean)
' show/hide the hourglass
If bShow Then
Me.Cursor = Cursors.WaitCursor
Me.UseWaitCursor = True
Else
Me.UseWaitCursor = False
Me.Cursor = Cursors.Arrow
End If
End Sub
Private Sub frmIPSpy_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Try
If Not (_udpClient Is Nothing) Then _udpClient.Dispose()
If Not (_udpServer Is Nothing) Then _udpServer.Dispose()
If Not (_tcpClient Is Nothing) Then _tcpClient.Dispose()
If Not (_tcpServer Is Nothing) Then _tcpServer.Dispose()
Catch
End Try
End Sub
Private Sub frmIPSpy_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim _b() As Byte = {}
_clientIn = New DynamicByteProvider(_b)
hexClientIn.ByteProvider = _clientIn
_clientOut = New DynamicByteProvider(_b)
hexClientOut.ByteProvider = _clientOut
_serverIn = New DynamicByteProvider(_b)
hexServerIn.ByteProvider = _serverIn
_serverOut = New DynamicByteProvider(_b)
hexServerOut.ByteProvider = _serverOut
btnClientCmd.Tag = False
btnServerCmd.Tag = False
End Sub
Private Sub frmIPSpy_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
If Me.MinimumSize.Width > 0 Then
Dim cols As Integer = BytesPerLine + Math.Round( _
(Me.Size.Width - Me.MinimumSize.Width - _
SystemInformation.FrameBorderSize.Width) / 36)
hexClientOut.BytesPerLine = cols
hexClientIn.BytesPerLine = cols
hexServerIn.BytesPerLine = cols
hexServerOut.BytesPerLine = cols
End If
End Sub
Private Sub btnClientCmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClientCmd.Click
If radTCP.Checked Then
If Not btnClientCmd.Tag Then
Me.CancelButton = btnClientCmd
btnClientCmd.Tag = True
btnClientCmd.Text = "&Disconnect"
txtClientHost.Enabled = False
txtClientPort.Enabled = False
radTCP.Enabled = False
radUDP.Enabled = False
boxClientConfig.Text += " (TCP)"
_clientIn.Bytes.Clear()
hexClientIn.Refresh()
hexClientIn.VScrollBarVisible = False
hexClientIn.VScrollBarVisible = True
Try
Dim hostIP As IPAddress = Nothing
If txtClientHost.Text.Trim <> "" And Val(txtClientPort.Text) > 0 Then
If Not IPAddress.TryParse(txtClientHost.Text.Trim, hostIP) Then
' have user choose ip entry for host
hostIP = ChooseIPEntry(txtClientHost.Text.Trim)
End If
If Not (hostIP Is Nothing) Then
_tcpClient = New clsTcpClient(hostIP.ToString, Val(txtClientPort.Text), _
New clsTcpClient.TcpClientDisconnectSub(AddressOf ClientDisconnectCallback))
_tcpClient.StartListen(New clsTcpClient.TcpClientDataRecvByteFunc(AddressOf TcpClientDataRecvByteCallback))
ClientDisplayText = hostIP.ToString + ":" + CStr(Val(txtClientPort.Text))
clientText = "Client: Connected to " + ClientDisplayText
lblClient.Text = clientText
Else
txtClientHost.Focus()
Throw New Exception("No host to connect to.")
End If
Else
txtClientHost.Focus()
Throw New Exception("Please enter the host or port.")
End If
Catch ex As Exception
lblClient.Text = "Client: Ready"
clientText = ""
Me.CancelButton = Nothing
txtClientPort.Enabled = True
txtClientHost.Enabled = True
btnClientCmd.Tag = False
btnClientCmd.Text = "&Connect"
boxClientConfig.Text = "Spy as a Client"
If Not btnClientCmd.Tag And Not btnServerCmd.Tag Then
radTCP.Enabled = True
radUDP.Enabled = True
End If
If Not (_tcpClient Is Nothing) Then
_tcpClient.Dispose()
_tcpClient = Nothing
End If
If Not ex.Message.Contains("No host to connect to") Then
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Try
Else
If Not (_tcpClient Is Nothing) Then
lblClient.Text = "Client: Ready"
clientText = ""
End If
Me.CancelButton = Nothing
txtClientPort.Enabled = True
txtClientHost.Enabled = True
btnClientCmd.Tag = False
btnClientCmd.Text = "&Connect"
boxClientConfig.Text = "Spy as a Client"
If Not btnClientCmd.Tag And Not btnServerCmd.Tag Then
radTCP.Enabled = True
radUDP.Enabled = True
End If
If Not (_tcpClient Is Nothing) Then
_tcpClient.Dispose()
_tcpClient = Nothing
End If
ClientDisplayText = ""
ClientBytesRecvCount = 0
ClientPacketsRecvCount = 0
ClientBytesSentCount = 0
ClientPacketsSentCount = 0
End If
ElseIf radUDP.Checked Then
If Not btnClientCmd.Tag Then
Me.CancelButton = btnClientCmd
btnClientCmd.Tag = True
btnClientCmd.Text = "&Disconnect"
txtClientHost.Enabled = False
txtClientPort.Enabled = False
radTCP.Enabled = False
radUDP.Enabled = False
boxClientConfig.Text += " (UDP)"
_clientIn.Bytes.Clear()
hexClientIn.Refresh()
hexClientIn.VScrollBarVisible = False
hexClientIn.VScrollBarVisible = True
Try
Dim hostIP As IPAddress = Nothing
If txtClientHost.Text.Trim <> "" And Val(txtClientPort.Text) > 0 Then
If Not IPAddress.TryParse(txtClientHost.Text.Trim, hostIP) Then
' have user choose ip entry for host
hostIP = ChooseIPEntry(txtClientHost.Text.Trim)
End If
If Not (hostIP Is Nothing) Then
_udpClient = New clsUdpClient(hostIP.ToString, Val(txtClientPort.Text))
_udpClient.StartListen(New clsUdpClient.UdpClientDataRecvByteFunc(AddressOf UdpClientDataRecvByteCallback))
ClientDisplayText = hostIP.ToString + ":" + CStr(Val(txtClientPort.Text))
clientText = "Client: Connected to " + ClientDisplayText
lblClient.Text = clientText
Else
txtClientHost.Focus()
Throw New Exception("No host to connect to.")
End If
Else
txtClientHost.Focus()
Throw New Exception("Please enter the host or port.")
End If
Catch ex As Exception
lblClient.Text = "Client: Ready"
clientText = ""
Me.CancelButton = Nothing
txtClientPort.Enabled = True
txtClientHost.Enabled = True
btnClientCmd.Tag = False
btnClientCmd.Text = "&Connect"
boxClientConfig.Text = "Spy as a Client"
If Not btnClientCmd.Tag And Not btnServerCmd.Tag Then
radTCP.Enabled = True
radUDP.Enabled = True
End If
If Not (_udpClient Is Nothing) Then
_udpClient.Dispose()
_udpClient = Nothing
End If
If Not ex.Message.Contains("No host to connect to") Then
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Try
Else
If Not (_udpClient Is Nothing) Then
lblClient.Text = "Client: Ready"
clientText = ""
End If
Me.CancelButton = Nothing
txtClientPort.Enabled = True
txtClientHost.Enabled = True
btnClientCmd.Tag = False
btnClientCmd.Text = "&Connect"
boxClientConfig.Text = "Spy as a Client"
If Not btnClientCmd.Tag And Not btnServerCmd.Tag Then
radTCP.Enabled = True
radUDP.Enabled = True
End If
If Not (_udpClient Is Nothing) Then
_udpClient.Dispose()
_udpClient = Nothing
End If
ClientDisplayText = ""
ClientBytesRecvCount = 0
ClientPacketsRecvCount = 0
ClientBytesSentCount = 0
ClientPacketsSentCount = 0
End If
End If
End Sub
Private Sub btnClientSendData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClientSendData.Click
If radTCP.Checked Then
If Not (_tcpClient Is Nothing) Then
Try
Dim buff() As Byte = _clientOut.Bytes.GetBytes()
_tcpClient.Send(buff)
ClientBytesSentCount += buff.Length
ClientPacketsSentCount += 1
lblClient.Text = "Client: Sent " + buff.Length.ToString + " byte(s)"
clientUpdate = Now()
UpdateIcon("data_send")
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("Not connected.", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
ElseIf radUDP.Checked Then
If Not (_udpClient Is Nothing) Then
Try
Dim buff() As Byte = _clientOut.Bytes.GetBytes()
_udpClient.Send(buff)
ClientBytesSentCount += buff.Length
ClientPacketsSentCount += 1
lblClient.Text = "Client: Sent " + buff.Length.ToString + " byte(s)"
clientUpdate = Now()
UpdateIcon("data_send")
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("Not connected.", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End If
End Sub
Private Sub btnServerCmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnServerCmd.Click
If radTCP.Checked Then
If Not btnServerCmd.Tag Then
Me.CancelButton = btnServerCmd
btnServerCmd.Tag = True
btnServerCmd.Text = "&Disconnect"
txtServerHost.Enabled = False
txtServerPort.Enabled = False
radTCP.Enabled = False
radUDP.Enabled = False
boxServerConfig.Text += " (TCP)"
_serverIn.Bytes.Clear()
hexServerIn.Refresh()
hexServerIn.VScrollBarVisible = False
hexServerIn.VScrollBarVisible = True
Try
If Val(txtServerPort.Text) > 0 Then
If txtServerHost.Text.Trim <> "" Then
_tcpServer = New clsTcpServer(txtServerHost.Text.Trim, Val(txtServerPort.Text), DefaultMaxClients, _
New clsTcpServer.TcpServerClientDisconnectSub(AddressOf ServerClientDisconnectCallback))
Else
_tcpServer = New clsTcpServer(Nothing, Val(txtServerPort.Text), DefaultMaxClients, _
New clsTcpServer.TcpServerClientDisconnectSub(AddressOf ServerClientDisconnectCallback))
End If
_tcpServerClient = Nothing
_tcpServer.StartListener(New clsTcpServer.TcpServerNewClientSub(AddressOf ServerNewClientCallback))
serverText = "Host: Listening on port " + CStr(Val(txtServerPort.Text))
lblServer.Text = serverText
Else
txtServerPort.Focus()
Throw New Exception("Please enter the port.")
End If
Catch ex As Exception
lblServer.Text = "Host: Ready"
serverText = ""
Me.CancelButton = Nothing
txtServerPort.Enabled = True
txtServerHost.Enabled = True
btnServerCmd.Tag = False
btnServerCmd.Text = "&Listen"
boxServerConfig.Text = "Spy as a Host"
If Not btnClientCmd.Tag And Not btnServerCmd.Tag Then
radTCP.Enabled = True
radUDP.Enabled = True
End If
If Not (_tcpServer Is Nothing) Then
_tcpServer.Dispose()
_tcpServer = Nothing
End If
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
lblServer.Text = "Host: Ready"
serverText = ""
Me.CancelButton = Nothing
txtServerPort.Enabled = True
txtServerHost.Enabled = True
btnServerCmd.Tag = False
btnServerCmd.Text = "&Listen"
boxServerConfig.Text = "Spy as a Host"
If Not btnClientCmd.Tag And Not btnServerCmd.Tag Then
radTCP.Enabled = True
radUDP.Enabled = True
End If
If Not (_tcpServer Is Nothing) Then
_tcpServer.Dispose()
_tcpServer = Nothing
End If
ServerDisplayText = ""
ServerBytesRecvCount = 0
ServerPacketsRecvCount = 0
ServerBytesSentCount = 0
ServerPacketsSentCount = 0
End If
ElseIf radUDP.Checked Then
If Not btnServerCmd.Tag Then
Me.CancelButton = btnServerCmd
btnServerCmd.Tag = True
btnServerCmd.Text = "&Disconnect"
txtServerHost.Enabled = False
txtServerPort.Enabled = False
radTCP.Enabled = False
radUDP.Enabled = False
boxServerConfig.Text += " (UDP)"
_serverIn.Bytes.Clear()
hexServerIn.Refresh()
hexServerIn.VScrollBarVisible = False
hexServerIn.VScrollBarVisible = True
Try
If Val(txtServerPort.Text) > 0 Then
If txtServerHost.Text.Trim <> "" Then
_udpServer = New clsUdpServer(txtServerHost.Text.Trim, Val(txtServerPort.Text))
Else
_udpServer = New clsUdpServer(Nothing, Val(txtServerPort.Text))
End If
_udpServer.StartListen(New clsUdpServer.UdpServerDataRecvByteFunc(AddressOf UdpServerDataRecvByteCallback))
serverText = "Host: Binded to port " + CStr(Val(txtServerPort.Text))
lblServer.Text = serverText
Else
txtServerPort.Focus()
Throw New Exception("Please enter the port.")
End If
Catch ex As Exception
lblServer.Text = "Host: Ready"
serverText = ""
Me.CancelButton = Nothing
txtServerPort.Enabled = True
txtServerHost.Enabled = True
btnServerCmd.Tag = False
btnServerCmd.Text = "&Listen"
If Not btnClientCmd.Tag And Not btnServerCmd.Tag Then
radTCP.Enabled = True
radUDP.Enabled = True
End If
boxServerConfig.Text = "Spy as a Host"
If Not (_udpServer Is Nothing) Then
_udpServer.Dispose()
_udpServer = Nothing
End If
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
lblServer.Text = "Host: Ready"
serverText = ""
Me.CancelButton = Nothing
txtServerPort.Enabled = True
txtServerHost.Enabled = True
btnServerCmd.Tag = False
btnServerCmd.Text = "&Listen"
boxServerConfig.Text = "Spy as a Host"
If Not btnClientCmd.Tag And Not btnServerCmd.Tag Then
radTCP.Enabled = True
radUDP.Enabled = True
End If
If Not (_udpServer Is Nothing) Then
_udpServer.Dispose()
_udpServer = Nothing
End If
ServerDisplayText = ""
ServerBytesRecvCount = 0
ServerPacketsRecvCount = 0
ServerBytesSentCount = 0
ServerPacketsSentCount = 0
End If
End If
End Sub
Private Sub btnServerSendData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnServerSendData.Click
If radTCP.Checked Then
If Not (_tcpServer Is Nothing) Then
If Not (_tcpServerClient Is Nothing) Then
Try
Dim buff() As Byte = _serverOut.Bytes.GetBytes()
_tcpServerClient.Send(buff)
ServerBytesSentCount += buff.Length
ServerPacketsSentCount += 1
lblServer.Text = "Host: Sent " + buff.Length.ToString + " byte(s)"
serverUpdate = Now()
UpdateIcon("data_send")
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("No client connected.", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
Else
MessageBox.Show("Not connected.", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
ElseIf radUDP.Checked Then
If Not (_udpServer Is Nothing) Then
Try
Dim buff() As Byte = _serverOut.Bytes.GetBytes()
_udpServer.Send(buff)
ServerBytesSentCount += buff.Length
ServerPacketsSentCount += 1
lblServer.Text = "Host: Sent " + buff.Length.ToString + " byte(s)"
serverUpdate = Now()
UpdateIcon("data_send")
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("Not connected.", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End If
End Sub
Private Sub btnClientLoadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClientLoadFile.Click
Try
fileOpen.ShowDialog()
If fileOpen.FileName <> "" Then
_showWaitCursor(True)
_clientOut.Bytes.Clear()
_clientOut.Bytes.AddRange(File.ReadAllBytes(fileOpen.FileName))
hexClientOut.Refresh()
hexClientOut.VScrollBarVisible = False
hexClientOut.VScrollBarVisible = True
hexClientOut.SelectionStart = hexClientOut.ByteProvider.Length
hexClientOut.ScrollByteIntoView(hexClientOut.SelectionStart - 1)
_showWaitCursor(False)
End If
Catch
End Try
End Sub
Private Sub btnClientSaveFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClientSaveFile.Click
Try
fileSave.ShowDialog()
If fileSave.FileName <> "" Then
_showWaitCursor(True)
Try
File.WriteAllBytes(fileSave.FileName, _clientOut.Bytes.GetBytes())
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, _
Application.ProductName, MessageBoxButtons.OK, _
MessageBoxIcon.Error)
End Try
_showWaitCursor(False)
End If
Catch
End Try
End Sub
Private Sub btnServerLoadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnServerLoadFile.Click
Try
fileOpen.ShowDialog()
If fileOpen.FileName <> "" Then
_showWaitCursor(True)
_serverOut.Bytes.Clear()
_serverOut.Bytes.AddRange(File.ReadAllBytes(fileOpen.FileName))
hexServerOut.Refresh()
hexServerOut.VScrollBarVisible = False
hexServerOut.VScrollBarVisible = True
hexServerOut.SelectionStart = hexServerOut.ByteProvider.Length
hexServerOut.ScrollByteIntoView(hexServerOut.SelectionStart - 1)
_showWaitCursor(False)
End If
Catch
End Try
End Sub
Private Sub btnServerSaveFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnServerSaveFile.Click
Try
fileSave.ShowDialog()
If fileSave.FileName <> "" Then
_showWaitCursor(True)
Try
File.WriteAllBytes(fileSave.FileName, _serverOut.Bytes.GetBytes())
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, _
Application.ProductName, MessageBoxButtons.OK, _
MessageBoxIcon.Error)
End Try
_showWaitCursor(False)
End If
Catch
End Try
End Sub
Private Sub tabIPSpy_Selected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles tabIPSpy.Selected
pnlCmd.Visible = False
If tabIPSpy.SelectedTab.Equals(tabClient) And btnClientCmd.Tag Then
Me.CancelButton = btnClientCmd
ElseIf tabIPSpy.SelectedTab.Equals(tabHost) And btnServerCmd.Tag Then
Me.CancelButton = btnServerCmd
Else
Me.CancelButton = Nothing
End If
End Sub
Private Sub hexClientOut_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientOut.GotFocus
srcHex = hexClientOut
End Sub
Private Sub hexClientOut_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles hexClientOut.KeyDown
If e.Control And e.KeyCode = Keys.X Then ' cut
btnCut_Click(Nothing, Nothing)
e.Handled = True
ElseIf e.Control And e.KeyCode = Keys.C Then ' copy
btnCopy_Click(Nothing, Nothing)
e.Handled = True
ElseIf e.Control And e.KeyCode = Keys.V Then ' paste
btnPaste_Click(Nothing, Nothing)
e.Handled = True
End If
End Sub
Private Sub hexClientOut_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles hexClientOut.KeyUp
If e.KeyCode = Keys.F3 Then btnFind_Click(Nothing, Nothing)
End Sub
Private Sub hexClientOut_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientOut.MouseEnter
srcHex = hexClientOut
pnlCmd.Location = LocationToClient(srcHex)
PrepareToolbar()
pnlCmd.Visible = True
End Sub
Private Sub hexClientOut_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientOut.MouseLeave
Dim pnlRect As Rectangle = Me.RectangleToScreen( _
New Rectangle(pnlCmd.Left, pnlCmd.Top, _
pnlCmd.Width, pnlCmd.Height))
If Not pnlRect.Contains(Control.MousePosition) Then _
pnlCmd.Visible = False
End Sub
Private Sub hexClientOut_SelectionLengthChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientOut.SelectionLengthChanged
PrepareToolbar()
End Sub
Private Sub hexClientOut_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientOut.TextChanged
PrepareToolbar()
End Sub
Private Sub hexClientIn_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientIn.GotFocus
srcHex = hexClientIn
End Sub
Private Sub hexClientIn_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles hexClientIn.KeyDown
If e.Control And e.KeyCode = Keys.X Then ' cut
btnCut_Click(Nothing, Nothing)
e.Handled = True
ElseIf e.Control And e.KeyCode = Keys.C Then ' copy
btnCopy_Click(Nothing, Nothing)
e.Handled = True
ElseIf e.Control And e.KeyCode = Keys.V Then ' paste
btnPaste_Click(Nothing, Nothing)
e.Handled = True
End If
End Sub
Private Sub hexClientIn_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles hexClientIn.KeyUp
If e.KeyCode = Keys.F3 Then btnFind_Click(Nothing, Nothing)
End Sub
Private Sub hexClientIn_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientIn.MouseEnter
srcHex = hexClientIn
pnlCmd.Location = LocationToClient(srcHex)
PrepareToolbar()
pnlCmd.Visible = True
End Sub
Private Sub hexClientIn_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientIn.MouseLeave
Dim pnlRect As Rectangle = Me.RectangleToScreen( _
New Rectangle(pnlCmd.Left, pnlCmd.Top, _
pnlCmd.Width, pnlCmd.Height))
If Not pnlRect.Contains(Control.MousePosition) Then _
pnlCmd.Visible = False
End Sub
Private Sub hexClientIn_SelectionLengthChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientIn.SelectionLengthChanged
PrepareToolbar()
End Sub
Private Sub hexClientIn_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexClientIn.TextChanged
PrepareToolbar()
End Sub
Private Sub hexServerIn_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerIn.GotFocus
srcHex = hexServerIn
End Sub
Private Sub hexServerIn_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles hexServerIn.KeyDown
If e.Control And e.KeyCode = Keys.X Then ' cut
btnCut_Click(Nothing, Nothing)
e.Handled = True
ElseIf e.Control And e.KeyCode = Keys.C Then ' copy
btnCopy_Click(Nothing, Nothing)
e.Handled = True
ElseIf e.Control And e.KeyCode = Keys.V Then ' paste
btnPaste_Click(Nothing, Nothing)
e.Handled = True
End If
End Sub
Private Sub hexServerIn_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles hexServerIn.KeyUp
If e.KeyCode = Keys.F3 Then btnFind_Click(Nothing, Nothing)
End Sub
Private Sub hexServerIn_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerIn.MouseEnter
srcHex = hexServerIn
pnlCmd.Location = LocationToClient(srcHex)
PrepareToolbar()
pnlCmd.Visible = True
End Sub
Private Sub hexServerIn_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerIn.MouseLeave
Dim pnlRect As Rectangle = Me.RectangleToScreen( _
New Rectangle(pnlCmd.Left, pnlCmd.Top, _
pnlCmd.Width, pnlCmd.Height))
If Not pnlRect.Contains(Control.MousePosition) Then _
pnlCmd.Visible = False
End Sub
Private Sub hexServerIn_SelectionLengthChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerIn.SelectionLengthChanged
PrepareToolbar()
End Sub
Private Sub hexServerIn_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerIn.TextChanged
PrepareToolbar()
End Sub
Private Sub hexServerOut_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerOut.GotFocus
srcHex = hexServerOut
End Sub
Private Sub hexServerOut_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles hexServerOut.KeyDown
If e.Control And e.KeyCode = Keys.X Then ' cut
btnCut_Click(Nothing, Nothing)
e.Handled = True
ElseIf e.Control And e.KeyCode = Keys.C Then ' copy
btnCopy_Click(Nothing, Nothing)
e.Handled = True
ElseIf e.Control And e.KeyCode = Keys.V Then ' paste
btnPaste_Click(Nothing, Nothing)
e.Handled = True
End If
End Sub
Private Sub hexServerOut_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles hexServerOut.KeyUp
If e.KeyCode = Keys.F3 Then btnFind_Click(Nothing, Nothing)
End Sub
Private Sub hexServerOut_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerOut.MouseEnter
srcHex = hexServerOut
pnlCmd.Location = LocationToClient(srcHex)
PrepareToolbar()
pnlCmd.Visible = True
End Sub
Private Sub hexServerOut_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerOut.MouseLeave
Dim pnlRect As Rectangle = Me.RectangleToScreen( _
New Rectangle(pnlCmd.Left, pnlCmd.Top, _
pnlCmd.Width, pnlCmd.Height))
If Not pnlRect.Contains(Control.MousePosition) Then _
pnlCmd.Visible = False
End Sub
Private Sub hexServerOut_SelectionLengthChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerOut.SelectionLengthChanged
PrepareToolbar()
End Sub
Private Sub hexServerOut_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles hexServerOut.TextChanged
PrepareToolbar()
End Sub
Private Sub toolEdit_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles toolEdit.MouseEnter
PrepareToolbar()
End Sub
Private Sub toolEdit_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles toolEdit.MouseLeave
Dim hexRect As Rectangle = srcHex.Parent.RectangleToScreen( _
New Rectangle(srcHex.Left, srcHex.Top, _
srcHex.Width, srcHex.Height))
If Not hexRect.Contains(Control.MousePosition) Then _
pnlCmd.Visible = False
End Sub
Private Sub btnCut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCut.Click
If Not (srcHex Is Nothing) Then
Dim bCut As Boolean = False
Try
If srcHex.CanCut Then
srcHex.Cut()
bCut = True
End If
Catch
End Try
If bCut And srcHex.SelectionLength > 0 Then
Try
srcHex.ByteProvider.DeleteBytes( _
srcHex.SelectionStart, srcHex.SelectionLength)
Catch
End Try
srcHex.SelectionLength = 0
srcHex.Refresh()
End If
PrepareToolbar()
End If
End Sub
Private Sub btnCopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCopy.Click
If Not (srcHex Is Nothing) Then
Try
If srcHex.CanCopy Then srcHex.Copy()
Catch
End Try
PrepareToolbar()
End If
End Sub
Private Sub btnPaste_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPaste.Click
If Not (srcHex Is Nothing) Then
Try
If srcHex.CanPaste Then srcHex.Paste()
Catch
End Try
PrepareToolbar()
End If
End Sub
Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If Not (srcHex Is Nothing) Then
Try
srcHex.ByteProvider.DeleteBytes( _
srcHex.SelectionStart, srcHex.SelectionLength)
Catch
End Try
srcHex.SelectionLength = 0
srcHex.Refresh()
PrepareToolbar()
End If
End Sub
Private Sub btnSelectAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSelectAll.Click
If Not (srcHex Is Nothing) Then
Try
srcHex.SelectionStart = 0
srcHex.SelectionLength = srcHex.ByteProvider.Length
Catch
End Try
PrepareToolbar()
End If
End Sub
Private Sub btnFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFind.Click
If srcHex Is Nothing Then Exit Sub
Static lastFindText As String = ""
Dim findText As String = ""
If e Is Nothing And lastFindText <> "" Then
findText = lastFindText
Else
findText = InputBox("Enter the text to find:", Application.ProductName, lastFindText)
End If
If findText <> "" Then
_showWaitCursor(True)
Dim ret As Long = srcHex.Find(Encoding.ASCII.GetBytes( _
findText), srcHex.SelectionStart + IIf(srcHex.SelectionLength > 0, 1, 0))
_showWaitCursor(False)
If ret = -1 Then
MessageBox.Show("Cannot find """ + findText + """", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Information)
findText = ""
End If
End If
lastFindText = findText
End Sub
Private Sub txtClientHost_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtClientHost.KeyDown
If e.KeyCode = Keys.Enter Then _
btnClientCmd.PerformClick()
End Sub
Private Sub txtClientPort_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtClientPort.KeyDown
If e.KeyCode = Keys.Enter Then _
btnClientCmd.PerformClick()
End Sub
Private Sub txtServerHost_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtServerHost.KeyDown
If e.KeyCode = Keys.Enter Then _
btnServerCmd.PerformClick()
End Sub
Private Sub txtServerPort_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtServerPort.KeyDown
If e.KeyCode = Keys.Enter Then _
btnServerCmd.PerformClick()
End Sub
Private Sub lblIcon_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblIcon.DoubleClick
Static frmDetails As frmIPStats = Nothing
If Not (frmDetails Is Nothing) AndAlso Not frmDetails.IsDisposed Then
frmDetails.Focus()
Else
frmDetails = New frmIPStats(Me)
frmDetails.Show(Me)
End If
End Sub
Private Sub timerUpdate_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerUpdate.Tick
If clientText <> "" AndAlso clientText <> lblClient.Text Then
If Now.Subtract(clientUpdate).Seconds > UpdateExpires Then
lblClient.Text = clientText
clientBytes = 0
End If
End If
If serverText <> "" AndAlso serverText <> lblServer.Text Then
If Now.Subtract(serverUpdate).Seconds > UpdateExpires Then
lblServer.Text = serverText
serverBytes = 0
End If
End If
End Sub
Private Sub timerIcon_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerIcon.Tick
timerIcon.Stop()
lblIcon.Image = GetResourceImage("data_none")
lastIconKey = ""
End Sub
Private Sub btnDNSLookup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDNSLookup.Click
If txtDNSLookup_IP.Text.Trim = "" Then
MessageBox.Show("Please enter the IP address to lookup.", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtDNSLookup_IP.Focus()
Exit Sub
End If
_showWaitCursor(True)
txtDNSLookup_Host.Text = ""
Application.DoEvents()
Try
Dim host As IPHostEntry = Dns.GetHostEntry(txtDNSLookup_IP.Text)
txtDNSLookup_Host.Text = host.HostName
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
_showWaitCursor(False)
End Sub
Private Sub btnReverseDNSLookup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReverseDNSLookup.Click
If txtReverseDNSLookup_Host.Text.Trim = "" Then
MessageBox.Show("Please enter the hostname to lookup.", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtReverseDNSLookup_Host.Focus()
Exit Sub
End If
_showWaitCursor(True)
txtReverseDNSLookup_IPs.Text = ""
Application.DoEvents()
Try
Dim host As IPHostEntry = Dns.GetHostEntry(txtReverseDNSLookup_Host.Text)
For Each resolvedIP As IPAddress In host.AddressList
txtReverseDNSLookup_IPs.Text += resolvedIP.ToString() + vbCrLf
Next
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
_showWaitCursor(False)
End Sub
Private Sub btnPing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPing.Click
If txtPing_IP.Text.Trim = "" Then
MessageBox.Show("Please enter the ip or hostname to ping.", Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtPing_IP.Focus()
Exit Sub
End If
_showWaitCursor(True)
Dim _ping As New Ping
Dim _reply As PingReply = Nothing
Try
_reply = _ping.Send(txtPing_IP.Text)
MessageBox.Show("Ping Result: " + _reply.Status.ToString() + vbCrLf + _
"Ping Time: " + _reply.RoundtripTime.ToString() + " ms", _
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message, Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
_showWaitCursor(False)
End Sub
Private Sub btnTraceRoute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTraceRoute.Click
With New frmTraceRoute(txtTraceRoute_IP.Text)
.Show(Me)
End With
End Sub
Private Sub txtDNSLookup_IP_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDNSLookup_IP.GotFocus
Me.AcceptButton = btnDNSLookup
End Sub
Private Sub txtDNSLookup_IP_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDNSLookup_IP.LostFocus
Me.AcceptButton = Nothing
End Sub
Private Sub txtReverseDNSLookup_Host_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtReverseDNSLookup_Host.GotFocus
Me.AcceptButton = btnReverseDNSLookup
End Sub
Private Sub txtReverseDNSLookup_Host_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtReverseDNSLookup_Host.LostFocus
Me.AcceptButton = Nothing
End Sub
Private Sub txtPing_IP_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPing_IP.GotFocus
Me.AcceptButton = btnPing
End Sub
Private Sub txtPing_IP_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPing_IP.LostFocus
Me.AcceptButton = Nothing
End Sub
Private Sub txtTraceRoute_IP_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTraceRoute_IP.GotFocus
Me.AcceptButton = btnTraceRoute
End Sub
Private Sub txtTraceRoute_IP_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTraceRoute_IP.LostFocus
Me.AcceptButton = Nothing
End Sub
End Class