• Welcome to Valhalla Legends Archive.
 

BNCS 0x09! help please.

Started by brew, April 01, 2007, 06:43 AM

Previous topic - Next topic

warz

Quote from: [RealityRipple] on April 01, 2007, 10:47 PM
"" takes up memory, vbNullString doesn't.

Edit: http://forums.devx.com/showthread.php?t=70074 might clear some things up.

both take up memory. unicode strings just take up a lot more. 4 + (length_of_string * 2), in fact. so, the header of a unicode string would be why "" would not equate to a single null terminating byte.

Barabajagal

Did you even read the link?

UserLoser

#17
Brew, find your Starcraft CD and get to work.  There's plenty of information out there about this message and it has been covered numerous of times.

Quote from: [RealityRipple] on April 01, 2007, 09:55 PM
No, "" is not a null string in Visual Basic. We've already had this discussion.

Truth spoken

warz

No, I didn't read the forum link you gave, but I read this, more helpful, page - http://www.aivosto.com/vbtips/stringopt2.html#memorylayout

brew

Quote from: UserLoser on April 02, 2007, 12:40 PM
Brew, find your Starcraft CD and get to work.  There's plenty of information out there about this message and it has been covered numerous of times.

If there's plenty of information out there about this message, then how come I have to find my Starcraft CD and get to work? Shouldn't I just be able to use the search feature of this forum?

Also...

FF 09 75 04 'header
0A 00 'game type
00 00 'parameter
0A 00 01 00 'unknown
09 04 'address family
00 00 02 00 'address family?
C5 2C 'port?
A2 53 66 3F 'ip address
00 00 00 00 'sin_zero
00 00 00 00 'sin_zero
04 00 00 00 'game status
45 00 00 00 'elapsed time
31 32 30 30 30 20 68 79 64 72 61 73 21 21 20 44 4F 4E 54 20 53 55 43 00 'game name
00  'game password
2C 31 34 2C 31 37 2C 36 2C 2C 61 2C 2C 31 2C 62 66 37 39 33 33 61 61 2C 36 2C 2C 78 44 61 4E 0D 07 48 79 64 72 61 6C 69 73 6B 20 41 74 74 61 63 6B 20 31 32 2C 30 30 30 0D 00 'game statstring


According to bnet docs, half of the IP Address is really where the port would be, same with the address family.. etc, just doesn't make sense. Check for yourself. When really, I believe bnetdocs just might be wrong. I would have posted something about it there, but it doesn't allow the creation of new accounts.... go figure.... and someone PLEASE fix the documentation on the S > C 0x09.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Barabajagal

#20
Working on the Receive side now?

Here's my crappy way of doing it:
Private Sub SID_Recv_GETADVLISTEX()
Dim GameType()   As Long
Dim param()      As Long
Dim IP()         As String
Dim Status()     As Long
Dim Time()       As Long
Dim GameName()   As String
Dim Pass()       As String
Dim Statstring() As String
Dim GameCount    As Long
Dim I            As Long
Dim tmp          As Variant
Dim NewData      As String
Dim TmpPort      As Long
Dim TmpIP        As String
    On Error GoTo Erred
    GameCount = Packet.GetDWORD
    If GameCount = 0 Then
        Select Case Packet.GetDWORD
            Case 1
                RaiseEvent BNetError("Game Doesn't Exist")
            Case 2
                RaiseEvent BNetError("Incorrect Password")
            Case 3
                RaiseEvent BNetError("Game Full")
            Case 4
                RaiseEvent BNetError("Game Already Started")
            Case 6
                RaiseEvent BNetError("Too Many Server Requests")
            Case Else
                RaiseEvent BNetError("Unknown Game Error")
        End Select
    Else
        For I = 0 To GameCount - 1
            ReDim Preserve GameType(I) As Long
            ReDim Preserve param(I) As Long
            ReDim Preserve IP(I) As String
            ReDim Preserve Status(I) As Long
            ReDim Preserve Time(I) As Long
            ReDim Preserve GameName(I) As String
            ReDim Preserve Pass(I) As String
            ReDim Preserve Statstring(I) As String
            GameType(I) = Packet.GetWORD
            param(I) = Packet.GetWORD
            tmp = Packet.GetDWORD
            tmp = Packet.GetWORD
            TmpPort = htons(Packet.GetWORD)
            TmpIP = Packet.GetString(4)
            IP(I) = Asc(Mid$(TmpIP, 1, 1)) & "." & _
                    Asc(Mid$(TmpIP, 2, 1)) & "." & _
                    Asc(Mid$(TmpIP, 3, 1)) & "." & _
                    Asc(Mid$(TmpIP, 4, 1)) & ":" & TmpPort
            tmp = Packet.GetDWORD
            tmp = Packet.GetDWORD
            Status(I) = Packet.GetDWORD
            Time(I) = Packet.GetDWORD
            GameName(I) = Packet.GetNTString
            Pass(I) = Packet.GetNTString
            Statstring(I) = Packet.GetNTString
            If Config.Game = WAR3 Or Config.Game = W3XP Then
                DecodeMapData Mid$(Statstring(I), 2), NewData
                Statstring(I) = Mid$(NewData, 21)
            End If
        Next I
        RaiseEvent GameListing(GameType(), param(), IP(), Status(), Time(), GameName(), Pass(), Statstring())
    End If
Exit Sub
Erred:
    RaiseEvent CritError(Err.Description, Err.Number, Err.Source, "SID_Recv_GETADVLISTEX")
End Sub


A few notes: htons is an API call ( Private Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Long ), anything that says tmp=something means the value isn't important (I set it to a variable to make debug.print easier and see what they are). DecodeMapData is a function I found on here (I think it was in Java and I had to port it to VB).

Edit: Some more notes I forgot to mention: The first unknown (DWORD) is the Language ID (Like 1033 (0x409) for enUS). The second unknown (WORD) is usually 2. The last two (DWORDS) are usually 0's.

UserLoser

Quote from: brew on April 02, 2007, 05:17 PM
According to bnet docs, half of the IP Address is really where the port would be, same with the address family.. etc, just doesn't make sense. Check for yourself. When really, I believe bnetdocs just might be wrong. I would have posted something about it there, but it doesn't allow the creation of new accounts.... go figure.... and someone PLEASE fix the documentation on the S > C 0x09.

Last time I checked there was nothing wrong with the documentation on S->C 0x09.  What does BnetDocs say as opposed to that log you just posted?  I can't view BnetDocs at the moment.  That log you posted with comments next to it look ok, are those comments lining up with the formatting BnetDocs has?

Barabajagal

http://www.aznsoulja.com/bnetdocs/content8e9c.html?Section=m&Code=10

Except, the third field (Unknown) is the language ID of the game creator.

brew

#23
Quote from: UserLoser on April 02, 2007, 08:36 PM
Last time I checked there was nothing wrong with the documentation on S->C 0x09.  What does BnetDocs say as opposed to that log you just posted?  I can't view BnetDocs at the moment.  That log you posted with comments next to it look ok, are those comments lining up with the formatting BnetDocs has?

No, They are not. According to bnet docs, this would how the data would be parsed:


For each list item:
(WORD) Game Type
(WORD) Parameter
(DWORD) Unknown
(WORD) Address Family (Always AF_INET)
(WORD) Port
(DWORD) Host's IP
(DWORD) sin_zero (0)
(DWORD) sin_zero (0)
(DWORD) Game Status
(DWORD) Elapsed time (in seconds)
(STRING) Game name
(STRING) Game password
(STRING) Game statstring

FF 09 75 04 'header
0A 00 'game type
00 00 'parameter
0A 00 01 00 'unknown
09 04 'address family
00 00 'port <---this is where i knew it had to be wrong, the port just can't be 0.
02 00 C5 2C 'hosts ip
A2 53 66 3F 'sin_zero
00 00 00 00 'sin_zero
00 00 00 00 'game status
04 00 00 00 'elapsed time
45 00 00 00 31 32 30 30 30 20 68 79 64 72 61 73 21 21 20 44 4F 4E 54 20 53 55 43 00 'game name
00 'game password
2C 31 34 2C 31 37 2C 36 2C 2C 61 2C 2C 31 2C 62 66 37 39 33 33 61 61 2C 36 2C 2C 78 44 61 4E 0D 07 48 79 64 72 61 6C 69 73 6B 20 41 74 74 61 63 6B 20 31 32 2C 30 30 30 0D 00 'game statstring


As you can obviously see, this is an entire 4 bytes off! very misleading.

And btw, thank you Reality for the help with parsing it.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Barabajagal

Brew... you're reading the documentation wrong. The header is followed by a DWORD with the number of games listed.

UserLoser

Quote from: [RealityRipple] on April 02, 2007, 09:04 PM
Brew... you're reading the documentation wrong. The header is followed by a DWORD with the number of games listed.

lol  ::)

brew

oops......  ::) Then I assume the game type would be.... the first part of the "unknown". okay thank you lol :( i feel like a moron (which i should)
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P