Valhalla Legends Forums Archive | C/C++ Programming | starcraft in-game protocol

AuthorMessageTime
aton
hi!
(sorry if this is the wrong place for what i am posting.. i am coding c only thats why i post here)

i am looking for information about the starcraft in-game protocol, like packets that move units, packets that make buildings, packets that change mineral count etc.

if anyone has any information, i'd greatly appreciate that.
(i have been sniffing a long time now, and its getting on my nerves)

thanks in advance,

aton
May 1, 2005, 10:47 AM
aton
what i have so far is at http://aton.skillzenmasse.de/packet.txt
it might be wrong, i will update it constantly. please tell me if you have any idea/data thats more correct than mine.
May 1, 2005, 3:12 PM
UserLoser.
[quote]
                  player string        '\0'
                  |                    |
0030  00 00 00 00 55 72 7A 61 68 69 6C 00 50 58 45 53    ....Urzahil.PXES

      |- these are probably version info etc.
0040  20 30 20 30 20 31 20 30 20 30 20 30 20 30 20 30     0 0 1 0 0 0 0 0
         "SEXP" starcraft expansion
          |            '\0'
          |              |
0050  20 50 58 45 53 00                                   PXES.

[/quote]

That's just their battle.net account name and their statstring.  Statstring contains what product they're using, wins, rating, rank, high rank, rating, high rating, spawn, icon etc.

Edit: eww at bnetd stuff at bottom
May 1, 2005, 9:23 PM
aton
do you know what field means what exactly? i think i can find out the wins/losses but not the icon for example
May 1, 2005, 9:28 PM
UserLoser.
[quote author=aton link=topic=11443.msg110704#msg110704 date=1114982931]
do you know what field means what exactly? i think i can find out the wins/losses but not the icon for example

[/quote]

Icon is last part, in this case, 'SEXP'.

Document on user statstrings
May 1, 2005, 9:32 PM
aton
thanks, i updated the file.

you dont have any information on "click" packets (or do i better call them "movement" packets?), have you?

as i understand only the player actions are transmitted over the net, i.e. when a player moves a unit, or builds a building, correct?

edit: btw has anyone got an outline of how the udp checksum is created? i am into linux and cannot really debug in windows very well...  just a description of the algorithm would be sufficient, i'd write my own routine...
May 1, 2005, 9:38 PM
dRAgoN
your first ?.?.? in the statstring = the persons ladder rank it will only show up if they are ranked on the list eg. #1 - #1000.
May 2, 2005, 12:36 AM
Adron
Only player actions are transmitted yes. Say, when a player queues up a building or unit to be built.

The udp checksum is something like a loop summing the packet. The data in the packet is summed into one accumulator, and that accumulator is summed into another one.
May 2, 2005, 2:31 AM
aton
so each byte is summed together? i.e. longer packets -> bigger checksum? sounds too easy for my taste  ;)
do you have the assembly routine for it?
May 2, 2005, 3:47 PM
R.a.B.B.i.T
I've got the VB6 code here, which I ported from C++ with Pianka (that code I can't find, but is on the forums somewhere).  It should be easy enough to port it back if you can't find the original code.

[code]
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (ByRef Destination As Any, ByRef Source As Any, ByVal numBytes As Long)

Private Function UDPChecksum(ByRef bufa As String) As Single
    Dim subsum As Double
    Dim A As Double
    Dim B As Single
    Dim buf As Long
   
    buf = MakeLong(bufa)
   
    subsum = SubChecksum(buf + 2, buf - 1)

    A = &HFF - ((subsum And &HFF) + (subsum Xor 8)) Mod &HFF
    B = CSng(((&HFF - (A + (ShiftRight(subsum, 8))) Mod &HFF) And &HFF) Or (ShiftLeft(A, 8)))
   
    UDPChecksum = B
End Function

Private Function SubChecksum(ByRef buf As Long, length As Long) As Currency
    Dim sum1 As Double
    Dim sum2 As Double
    Dim p As Long
   
    sum1 = sum2 = 0
   
    p = buf And (length - 1)
    While length - 1 > 0
        sum2 = sum2 + p
        p = p - 1
        If sum2 > &HFF Then sum2 = sum2 - &HFF
        sum1 = sum1 + sum2
        length = length - 1
    Wend
   
    SubChecksum = ((sum2 And &HFF) Xor 8) Or ((sum1 Mod &HFF) And &HFF)
End Function

Private Sub Form_Load()
    Debug.Print UDPChecksum(1234)
End Sub

Public Function ShiftRight(ByVal A As Long, ByVal L As Long) As Double
    ShiftRight = CDbl(A / (2 ^ L))
End Function

Public Function ShiftLeft(ByVal A As Long, ByVal L As Long) As Double
    ShiftLeft = CDbl(A * (2 ^ L))
End Function

Private Function MakeLong(str As String) As Long
    CopyMemory MakeLong, ByVal str, Len(str)
End Function[/code]
May 2, 2005, 4:52 PM
Adron
Does your VB6 code work?
May 2, 2005, 5:20 PM
LoRd
[quote author=Adron link=topic=11443.msg110805#msg110805 date=1115054421]
Does your VB6 code work?
[/quote]

It looks as if it was just ported from your NBBot :p
May 2, 2005, 7:39 PM
R.a.B.B.i.T
It was ported from some C++ code that someone asked about (if there was an equivolent of in VB6).  Nobody knew about any so that's why Pianka and I ported it.  Where ever the original code came from, I don't know, is where it was ported from.  So, maybe.
May 2, 2005, 9:01 PM
aton
cool thanks, i will port that back to c, i think i gotta fresh up my vb a bit, has been quite a while...
May 3, 2005, 12:17 AM
St0rm.iD
I think I was able to get into the pregame room, but that was it.
May 3, 2005, 12:55 AM
Adron
[quote author=LoRd[nK] link=topic=11443.msg110822#msg110822 date=1115062753]
[quote author=Adron link=topic=11443.msg110805#msg110805 date=1115054421]
Does your VB6 code work?
[/quote]

It looks as if it was just ported from your NBBot :p
[/quote]

The reason I asked was it looked like an inaccurate nonworking port from NBBot :p
May 3, 2005, 1:31 AM
aton
ok i will begin with writing a bot to login and get game listings etc. there should be enough info for that on the bnet docs
after that i will do some more years of sniffing ;)
May 3, 2005, 1:47 AM
aton
btw i heard iago is doing some linux stuff... so iago how do you logon to b.net? have you written the hashing functions yourself or have you managed to use a .dll somehow? i cannot think of any way that could be done..
May 5, 2005, 4:21 AM
KkBlazekK
Was he using Java?
May 5, 2005, 12:10 PM
Ban
it is more than possible to log onto battle.net with linux...

http://newds.zefga.net <- *poke*
http://www.javaop.com <- *poke*

Just avoid languages that are platform specific (Visual Basic, Basic, etc) and avoid any portions of the language, such as API calls, that would restrict it to a single operating system. Both of the above links are links to open source bots, so if you are interested in how to connect to battle.net using *nix, take a look if it suits you.
May 5, 2005, 2:42 PM
aton
ok solved it, thanks
May 8, 2005, 7:41 PM
aton
now the problem is the udp checksum. does anyone have it in c/c++ ?
May 9, 2005, 10:39 AM
Ban
Please stop double posting.
May 9, 2005, 2:40 PM
warz
This is his thread. Get out of his thread.
May 9, 2005, 4:43 PM
aton
ah nevermind, he is right, i probably double posted, i am somewhat dizzy during the last days.
anyways i converted the vb functions to c, they work perfectly, thanks.
May 9, 2005, 5:26 PM

Search