Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Guides & Templates
You last visited: Today at 13:54

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Visual Basic 2006 : A Simple Winsock Connection

Discussion on Visual Basic 2006 : A Simple Winsock Connection within the SRO Guides & Templates forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Nov 2007
Posts: 236
Received Thanks: 17
Visual Basic 2006 : A Simple Winsock Connection

I made a little tut for a simple winsock connection
This tut can be usefull for creating a bot that workes with nuconnector
In visual basic 2006 !
So here it comes


Start with opening vb6


Now open Standard EXE


Now look at the right and right mouse click there
And Choose Compoments


Now Scroll down till Microsoft Winsock Control 6.0
And Check it !


And click ok

Now Add 2 off those Winsock things !



Ok Now the fun part starts

Now rename the first one to "WsCon" ( Without the ")
Now rename the second one to "WsServ" ( Without the ")




Now change the port of wsServ to 1566


Now Double Click the form1
And type : wsServ.lisen


Now Let's make a textbox
Dont need pic for that
Make the multiline to True
And remove the text

Now create 2 Command Buttons
the first one with "Connect"
And the second on with "DisConnect"
Now double click the connect button and type
wscon.connect "127.0.0.1", 1566
Now double click the wsCon
And Right Above u'll see Error now go to connect.
Then delete the line below it !
Now type in wsCon_Connect()
txt1.text = text1.text & "Succesfully Connected" &Vbcrlf

Now Close that code
now double click disconnect and type in
wsCon.close
thats all for that now
Now close that code and double click wsServ
U'll see right above error again
Now go to Connection Requested and delete the line below
Type in the Connection Requested now :
If wsServ.state <> sckclosed then
wsServ.close
wsServ.accept requestiD
End if

So now thats done

Now double click the Dissconnect button and type there :
txt1.text = text1.text & "Succesfully DisConnected" &Vbcrlf
This must below to the Wscon.close

Now Start Program and test
GL yaáll !


EDIT:

Added source code..
Would be so mutch easyer for some users
Attached Files
File Type: rar Source Code.rar (5.9 KB, 54 views)
daniellook is offline  
Old 04/12/2009, 21:08   #2
 
IRever's Avatar
 
elite*gold: 0
Join Date: Nov 2007
Posts: 575
Received Thanks: 73
Add the images in [IMG][/IMG] Bracets then they'll show right up on to the forum, also this belongs to the coders tutorial section
IRever is offline  
Old 04/13/2009, 01:05   #3
 
elite*gold: 0
Join Date: May 2006
Posts: 23
Received Thanks: 18
may want to mention this is vb6, not 2006

you only need to put one winsock control on the main form,the winsock control on the form is named wSock .
form loads then asks port number to connect(22580 is what nuconnector uses i believe)
Code:
Private Sub Form_Load()
Dim Port As Integer
Port = InputBox("Port Number", "Connect To Port", "22580")
wSock.Connect "127.0.0.1", Port
End Sub
End Sub
gets packet opcode, data ect
Code:
Private Sub wSock_DataArrival(ByVal bytesTotal As Long)
Dim sData As String
Dim iLenght As Integer
    If chkPause.Value = 0 Then
        Do
            iLenght = peekLength()
            sData = peekData(iLenght)
            If Len(sData) = iLenght Then
                sData = GetData(iLenght)
                If sData <> "" Then
                    PacketReceived sData
                End If
            End If
            DoEvents
        Loop Until iLenght = 0
    End If
End Sub

Private Function peekLength() As Integer
On Error GoTo ErrorHere
Dim sData As String
    wSock.peekData sData, , 4
    peekLength = CLng(Asc(Mid(sData, 2, 1))) * 256# + CLng(Asc(Mid(sData, 1, 1)))
    peekLength = peekLength + 6
    Exit Function
ErrorHere:
    peekLength = 0
End Function

Private Function peekData(iLenght As Integer) As String
On Error GoTo ErrorHere
    wSock.peekData peekData, , iLenght
    Exit Function
ErrorHere:
    peekData = ""
End Function

Private Function GetData(iLenght As Integer) As String
On Error GoTo ErrorHere
    wSock.GetData GetData, , iLenght
    Exit Function
ErrorHere:
    GetData = ""
End Function

Private Sub PacketReceived(sData As String)
Dim sHexVal As String
Dim JoymaxToClient As Boolean
Dim sOpCode As String
    'Convert packet into HEX format
    sHexVal = StringToHex(sData)
    
    'Remove Header
    If Mid(sHexVal, 10, 1) = "1" Then
        JoymaxToClient = False
    Else
        JoymaxToClient = True
    End If
    sOpCode = Mid(sHexVal, 7, 2) & Mid(sHexVal, 5, 2)
    sHexVal = Right(sHexVal, Len(sHexVal) - 12)
    Call PacketData(sOpCode, sHexVal, JoymaxToClient)
End Sub
now this is your packet parser, depending on the opcode of the packet you can call different functions.
Code:
Private Sub PacketData(sOpCode As String, sData As String, JoymaxToClient As Boolean)

Select Case sOpCode
Case Is = "600D"
'this is where you would call the function
End Select
End Sub
just add another Case Is = "" with another opcode to support more packets


you will need conversion functions as well(HexToDec(), WordFromInt(), HexToString(), ect)

good luck on everyones packet bots,apps ect
salter is offline  
Old 04/13/2009, 01:41   #4
 
elite*gold: 0
Join Date: Nov 2007
Posts: 236
Received Thanks: 17
Quote:
Originally Posted by salter View Post
may want to mention this is vb6, not 2006

you only need to put one winsock control on the main form,the winsock control on the form is named wSock .
form loads then asks port number to connect(22580 is what nuconnector uses i believe)
Code:
Private Sub Form_Load()
Dim Port As Integer
Port = InputBox("Port Number", "Connect To Port", "22580")
wSock.Connect "127.0.0.1", Port
End Sub
End Sub
gets packet opcode, data ect
Code:
Private Sub wSock_DataArrival(ByVal bytesTotal As Long)
Dim sData As String
Dim iLenght As Integer
    If chkPause.Value = 0 Then
        Do
            iLenght = peekLength()
            sData = peekData(iLenght)
            If Len(sData) = iLenght Then
                sData = GetData(iLenght)
                If sData <> "" Then
                    PacketReceived sData
                End If
            End If
            DoEvents
        Loop Until iLenght = 0
    End If
End Sub

Private Function peekLength() As Integer
On Error GoTo ErrorHere
Dim sData As String
    wSock.peekData sData, , 4
    peekLength = CLng(Asc(Mid(sData, 2, 1))) * 256# + CLng(Asc(Mid(sData, 1, 1)))
    peekLength = peekLength + 6
    Exit Function
ErrorHere:
    peekLength = 0
End Function

Private Function peekData(iLenght As Integer) As String
On Error GoTo ErrorHere
    wSock.peekData peekData, , iLenght
    Exit Function
ErrorHere:
    peekData = ""
End Function

Private Function GetData(iLenght As Integer) As String
On Error GoTo ErrorHere
    wSock.GetData GetData, , iLenght
    Exit Function
ErrorHere:
    GetData = ""
End Function

Private Sub PacketReceived(sData As String)
Dim sHexVal As String
Dim JoymaxToClient As Boolean
Dim sOpCode As String
    'Convert packet into HEX format
    sHexVal = StringToHex(sData)
    
    'Remove Header
    If Mid(sHexVal, 10, 1) = "1" Then
        JoymaxToClient = False
    Else
        JoymaxToClient = True
    End If
    sOpCode = Mid(sHexVal, 7, 2) & Mid(sHexVal, 5, 2)
    sHexVal = Right(sHexVal, Len(sHexVal) - 12)
    Call PacketData(sOpCode, sHexVal, JoymaxToClient)
End Sub
now this is your packet parser, depending on the opcode of the packet you can call different functions.
Code:
Private Sub PacketData(sOpCode As String, sData As String, JoymaxToClient As Boolean)

Select Case sOpCode
Case Is = "600D"
'this is where you would call the function
End Select
End Sub
just add another Case Is = "" with another opcode to support more packets


you will need conversion functions as well(HexToDec(), WordFromInt(), HexToString(), ect)

good luck on everyones packet bots,apps ect

Nice one man
daniellook is offline  
Reply


Similar Threads Similar Threads
Visual C++ (C++), Visual Basic, oder AutoIT?
06/24/2010 - .NET Languages - 11 Replies
Hallo Zusammen Ich würde gerne mit dem Programmieren anfangen. Meine Vorstellungen: Es müsste möglich sein, eigene Programme zu schreiben wie z. B. MSN, Emule oder ähnliches. Natürlich nie in dieser Grösse nur als Beispiel. Als weiteres sollte mit der gleichen Programmiersprache auch die Möglichkeit bestehen einen WoW Bot zu schreiben. Habe gehört die meisten Bots sind in Auto IT geschrieben. Gibt es unterschiede wegen des Warden schutzes oder kommt es nicht darauf an?
Vb6 : A Simple Winsock Connection !
04/12/2009 - .NET Languages - 0 Replies
I made a little tut for a simple winsock connection In visual basic 2006 ! So here it comes Start with opening vb6 http://img412.imageshack.us/img412/9527/54328939. jpg Now open Standard EXE http://img258.imageshack.us/img258/5764/73925545. jpg



All times are GMT +1. The time now is 13:58.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.