• Welcome to Valhalla Legends Archive.
 

[VB] Proxy Support Help

Started by Spilled, September 10, 2005, 11:46 PM

Previous topic - Next topic

l2k-Shadow


Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long)
Private Declare Function htons Lib "ws2_32" (ByVal hostshort As Long) As Integer

Public Function GetPortString(Port As Long) As String
Dim tmpPort As Integer, Output As String * 2
    tmpPort = htons(Port)
    CopyMemory ByVal Output, tmpPort, 2
    GetPortString = Output
End Function


Hope that helps.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

Spilled

Ok guys got it work thanks for all your help.

       Dim Send As String, Port As String * 2
       Dim IP As String * 4, Splt() As String
           Send = Chr(&H4)
           Send = Send & Chr(&H1)
           CopyMemory ByVal Port, htons(6112), 2
           Send = Send & Port  'Next two bytes, the port
           Splt() = Split(GetIPFromHostName(strServer), ".")
           IP = Chr(CInt(Splt(0))) & Chr(CInt(Splt(1))) & Chr(CInt(Splt(2))) & Chr(CInt(Splt(3)))
           Send = Send & IP
           Send = Send & Chr(&H0)
           wSock.SendData Send


Working code if anyone would like!
Thanks again

l2k-Shadow

#17
For future reference, if you wish not to use API to get the port (don't know why but yeah some people prefer that), the function would look something like this:


Public Function GetPortString(Port As Long) As String
Dim s As String
    s = Hex(Port)
    Select Case Len(s)
        Case 1, 2
            GetPortString = Chr$(0) & Chr$(CLng("&H" & s))
        Case 3
            GetPortString = Chr$(CLng("&H" & Left$(s, 1))) & Chr$(CLng("&H" & Mid$(s, 2, 2)))
        Case 4
            GetPortString = Chr$(CLng("&H" & Left$(s, 2))) & Chr$(CLng("&H" & Mid$(s, 3, 2)))
        Case Else
            MsgBox "Port value is too high. The maximum value for a Port is the maximum value of a 16-bit integer (65535)."
    End Select
End Function


EDIT: @UserLoser: good point :)
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

UserLoser.

Quote from: l2k-Shadow on September 14, 2005, 07:50 PM
For future reference, if you wish not to use API to get the port (don't know why but yeah some people prefer that), the function would look something like this:


Public Function GetPortString(Port As Long) As String
Dim s As String
    s = Hex(Port)
    Select Case Len(s)
        Case 1, 2
            GetPortString = Chr$(0) & Chr$(CLng("&H" & s))
        Case 3
            GetPortString = Chr$(CLng("&H" & Left$(s, 1))) & Chr$(CLng("&H" & Mid$(s, 2, 2)))
        Case 4
            GetPortString = Chr$(CLng("&H" & Left$(s, 2))) & Chr$(CLng("&H" & Mid$(s, 3, 2)))
        Case Else
            MsgBox "Port value is too high. The maximum value for a Port is the maximum value of a WORD (65535)."
    End Select
End Function


Some might argue that the maximum value of a WORD isn't necessarly 65535, so you might want to edit that to say 16-bit integer :P

rabbit

He's right.  A WORD's maximum value is 65535






















on a 16-bit system.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Spilled

Thanks for the tip Shadow and thanks for the help again UserLoser