• Welcome to Valhalla Legends Archive.
 

Optimal BNLS procedure?

Started by Don Cullen, February 04, 2007, 12:42 PM

Previous topic - Next topic

Barabajagal

BNLS has absolutely no packet order requirements. post a packet log of your send to bnls?

Mystical

Quote from: Kyro on February 10, 2007, 04:01 PM
Okay, I'm still getting stuck. I've re-coded it to be compatiable with BNLS, and yet it keeps failing. This is the console output:

This is my On BNLS Connect sub:

Private Sub sckBNLS_Connect()
    RaiseEvent DebugOutput("Connected to BNLS.")
    If m_VerByte = "" Then
        'missing verbyte
        BNLS_REQUESTVERSIONBYTE
    End If
End Sub




Just wondering why Verbyte is treated as a string and not a long?

Barabajagal

Quote from: Mystical on February 10, 2007, 09:04 PM
Quote from: Kyro on February 10, 2007, 04:01 PM
Okay, I'm still getting stuck. I've re-coded it to be compatiable with BNLS, and yet it keeps failing. This is the console output:

This is my On BNLS Connect sub:

Private Sub sckBNLS_Connect()
    RaiseEvent DebugOutput("Connected to BNLS.")
    If m_VerByte = "" Then
        'missing verbyte
        BNLS_REQUESTVERSIONBYTE
    End If
End Sub




Just wondering why Verbyte is treated as a string and not a long?

why would it be a long... it's a verBYTE. a byte value.

FrostWraith

Kinda stupid but what do your constants looks like?

Don Cullen

My bot allows the user to give a string value, which in turn will be converted into a long value. See below. It should answer your question.

Public Sub SID_AUTH_INFO() '0x50
    If Ready = False Then
        RaiseEvent sError("Error! Missing data!")
        RaiseEvent sError("Connection aborted locally.")
        Disconnect
    Else
        With PacketBuf
            .Clear
            .InsertDWORD &H0  'BNET Protocol ID (Currently zero.)
            .InsertDWORD CLng("&H" & Replace(StrToHex("IX86"), " ", vbNullString)) 'IX86
            .InsertDWORD CLng("&H" & Replace(StrToHex(m_GameCode), " ", vbNullString)) 'SEXP
            [b][i].InsertDWORD CLng("&H" & m_VerByte)   'Verbyte, changes with product upgrade.[/b][/i]
            .InsertDWORD CLng("&H" & Replace(StrToHex("enUS"), " ", vbNullString))  'Product Language
            .InsertDWORD CLng("&H" & Replace(StrToHex(IP2NBO(sckBNET.LocalIP)), " ", vbNullString))  'Local IP for NAT compatibility
            .InsertDWORD GetTimeZoneBias  'Time Zone bias
            .InsertDWORD GetUserDefaultLCID()  'Locale ID
            .InsertDWORD GetUserDefaultLangID  'Language ID
            .InsertNTString GetInfo(LOCALE_SABBREVCTRYNAME) 'Abbrev. of country
            .InsertNTString GetInfo(LOCALE_SENGCOUNTRY) 'Name of country
            .SendPacket sckBNET, &H50    'Send 0x50 packet
            .Clear
            .InsertDWORD &H0  '0ms ping.
            .SendPacket DMBot.BNET, &H25 'Send 0x25 packet
            .Clear
        End With
        RaiseEvent DebugOutput("0x50 SID_AUTH_INFO packet sent.")
    End If
End Sub


Edit:

As for the constants, here...

' PacketID Constants for Visual Basic
' Generated by BnetDocs on 10/02/07 02:13:14
' BnetDocs software written by Arta
' Content compiled by Arta & Skywing

' Visit us on Battle.net in channel Op [vL]

Public Const PRODUCT_STARCRAFT& = &H1
Public Const PRODUCT_BROODWAR& = &H2
Public Const PRODUCT_WAR2BNE& = &H3
Public Const PRODUCT_DIABLO2& = &H4
Public Const PRODUCT_LORDOFDESTRUCTION& = &H5
Public Const PRODUCT_JAPANSTARCRAFT& = &H6
Public Const PRODUCT_WARCRAFT3& = &H7
Public Const PRODUCT_FROZENTHRONE& = &H8
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

l2k-Shadow

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.

Don Cullen

I will as soon as I can figure out how to get WireShark to packet log. I'm a newbie to packet logging. I just installed it, and haven't the foggest idea as to how to configure it to only display BNLS and BNET packets...

Tried searching for a tutorial for specificially BNLS/BNET packet logging pertaining to WireShark/Etheral, no such luck...
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Barabajagal

#22
why not just use WPE...? it makes quick things like that a lot easier...

linky if ya need it (note that some anti-viruses think the dll is a trojan, since it sniffs packets... it's not a trojan, nor really a false positive, since it does sniff packets. you just happen to be the one that sees the packets.)

Don Cullen

#23
Hrmmmm... I'm having the same problems as Etheral/Wireshark, and Commview.

Which is: it seems to be logging nothing. Let me compile it as an exe, and try again.

Hmm... That's strange, nothing.

So that seems to imply there is nothing being sent... wtf... I'm going to look at my code and see why this innate drivel isn't working.

--------

Edit:

I just looked at my code. This is the 0x10 sub:

Public Sub BNLS_REQUESTVERSIONBYTE() '0x10

    Dim ProductID As Long
   
    Select Case UCase(GameCode)
        Case "SEXP"
            ProductID = PRODUCT_BROODWAR&
        Case "STAR"
            ProductID = PRODUCT_STARCRAFT&
        Case "D2DV"
            ProductID = PRODUCT_DIABLO2&
        Case "D2XP"
            ProductID = PRODUCT_LORDOFDESTRUCTION&
        Case "WAR3"
            ProductID = PRODUCT_WARCRAFT3&
        Case "W3XP"
            ProductID = PRODUCT_FROZENTHRONE&
        Case Else
            RaiseEvent sError("Unsupported game type.")
            Disconnect
            Exit Sub
    End Select
   
    With PacketBuf
        .Clear
        .InsertDWORD ProductID  'Product ID
        .SendBNLSPacket sckBNET, &H10    'Send 0x10 packet
        .Clear
    End With
    RaiseEvent DebugOutput("0x10 BNLS_REQUESTVERSIONBYTE packet sent.")
End Sub


And this is the SendBNLSPacket sub in the PacketBuffer class:

Public Function SendBNLSPacket(sck As Winsock, Optional PacketID As Long) As Boolean
    If sck.State = sckConnected Then
        sck.SendData MakeWORD(Len(Buffer) + 4) & Chr(PacketID) & Buffer
    End If
    Clear
End Function


And the name of the socket for BNLS is sckBNLS...
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Barabajagal

erm... the length is +3, not +4. A word is 2 bytes, plus 1 byte for the ID.

Don Cullen

Oops, thanks for pointing that out. Corrected that one.

But that still doesn't solve the fact the program isn't transmitting data. I mean, consider:

In order for BNLS to be sending me data, it must first recieve data. I've been able to confirm that the program successfully connects to BNLS, but beyond that, the program seems to fail in transmitting data to BNLS. I don't understand why it's not sending -- all of the code seems intact...
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Barabajagal

second problem
.SendBNLSPacket sckBNET, &H10    'Send 0x10 packet

shouldn't you be using sckBNLS? you really need to keep track of things like this better.

Don Cullen

Finally. It works. Thanks RealityRipple, and everyone else who helped. I appreciate it.

Jeez. I'm blind. I could've swore I typed BNLS, not BNET. You're right, I really need to pay attention to what I'm typing and where it goes...

Any idea how I can take a byte variable and display it as a string? For instance, if I get 0x10 from BNLS, it comes in vb as &H10. Is there a way I can take this hex and convert it directly into a string ("0x10")?

I tried this:

RaiseEvent DebugOutput("Identified as: " & CStr(PacketID))

But it came out as 16, not 10. Any tips?
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Barabajagal

"Identified as 0x" & Hex$(PacketID)

Don Cullen

Ah, simple. Works like a charm:

QuoteReady.
Username set.
Password set.
GameCode set to SEXP.
CDKey set.
Missing VerByte, now accquiring new VerByte.
Connecting to BNLS...
Connected to BNLS.
0x10 BNLS_REQUESTVERSIONBYTE packet sent.
Receiving incoming data...
Parsing BNLS packet...
Identified as 0x10
Recieved new VerByte from BNLS.
VerByte set: CF
Sockets closed.
Disconnected.

Many thanks. :-)
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

|