• Welcome to Valhalla Legends Archive.
 

Request for Research: The Starcraft Game Protocol

Started by Arta, July 06, 2005, 09:20 AM

Previous topic - Next topic

Arta

BnetDocs lacks any information whatsoever on this protocol, sometimes named CLS. If anybody is interested in researching this area, and possibly becoming the editor responsible for maintaining the information published on BnetDocs, they should get in touch.

Kp

I have no interest in contributing my information, but I can tell you why it's sometimes dubbed CLS.  Starcraft and Diablo both use Storm.dll for constructing and transmitting their messages, so notation developed in reversing Diablo is sometimes carried over to Starcraft.  Adron dubbed one of the fields in the storm header "class" for reasons I do not know.  That field differentiates among storm control messages, asynchronous events, and synchronous events.  Hence, a "class 2" refers to any message which has a 2 in the class field of the header, or any traffic which it would make sense to place in that slot.  Starcraft commands are mostly transferred in the synchronous stream, which accounts both for the delay between click and action, and the game's ability to remain synchronized even in highly lossy conditions.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Ringo

Thats a interesting descution, i was talking to archangle about it yesderday.

My old bot supports most of the protocol, and iv never needed to call storm functions..
Unless i missed somthing, could you please explain more?
(Or do you mean the UDP checksum fuinctions?)
Im kinda lost by what you mean.

MyndFyre

I believe he's talking about the Diablo I and Starcraft game protocols, not D2GS.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

UserLoser.

#4
Quote from: Ringo on July 06, 2005, 06:47 PM
Thats a interesting descution, i was talking to archangle about it yesderday.

My old bot supports most of the protocol, and iv never needed to call storm functions..
Unless i missed somthing, could you please explain more?
(Or do you mean the UDP checksum fuinctions?)
Im kinda lost by what you mean.


One point of writing a bot is to not use Blizzard's clients, therefore, like you said, you wouldn't be using Storm.dll for any message handling/building since you do it all your self.  I'm not sure what you mean exactly, but the UDP checksum function used in this protocol is somewhere in Storm.dll

Ringo

Ah, i get what he means now.
My mistake, thanks.


Archangel

#6
Skywing:

Quote
The header you are working with is specific to the Storm UDP protocol
and is ot ever assembled or viewed by the game protocol module itself.  Thus
only ontrol messages for the Storm UDP protocol use the command field.

The way this is laid out can be represented something like this:

-----------------
-- Storm Header--
-----------------
-- Data Payload -
-----------------

Storm.dll receives the data off the wire, and interprets class 0
control messages directly, instead of passing them on to the game (except
perhaps in the form of high level callbacks, such as a "player joined the game"
callback or event).

For non-class0 messages, the data payload is passed uninterpreted on to
the game protocol parser itself, whether that be in Diablo.exe,
Starcraft.exe,
etc:

-----------------
-- Data Payload -
-----------------

Since the main game module never sees the Storm header, command ids for
other than the internal control class can't be stored there.

Note that I am logically equating Storm.dll and the Storm network
service provider (SNP) as the same module.  In reality, the SNP is responsible
for sending and receiving the game data off of the wire, whether that be a
UDP socket or an IPX socket, or just an internal loopback (e.g. standard.snp).

Class 1 is used for messages that do not need to be synchronized with
the game state, such as chat commands.  Thus, class 1 commands can be sent
and received at any time.

Class 2 is used for messages that do need to be synchronized with the
game state, such as unit orders.  Thus, class 2 commands can only be sent
once each game turn (as a result they are typically queued internally inside
the game protocol module until the next turn is transmitted).

At this time I do not have a list of Starcraft game protocol commands
in other than source code form, which I am not prepared to distribute.
I'm not an Addict.

Archangel

Lets post the very 1st thing that is needed to know:
Packet Format:
   (DWORD) 0x00
   (WORD) Checksum
   (WORD) Length
   (WORD) Sent
   (WORD) Recved
   (BYTE) Command Class
   (BYTE) Command
   (BYTE) Sender ID
   (BYTE) Resend
   (VOID) Packet

[If i am wrong, i am looking for corrections]
I'm not an Addict.

Archangel

The UDP Checksum [Visual Basic]:


Private Function RShift(ByVal pnValue As Long, ByVal pnShift As Long) As Double
On Error Resume Next
    RShift = CDbl(pnValue \ (2 ^ pnShift))
End Function

Private Function LShift(ByVal pnValue As Long, ByVal pnShift As Long) As Double
On Error Resume Next
    LShift = CDbl(pnValue * (2 ^ pnShift))
End Function

Private Function SubCheckSum(ByVal buf As String, ByVal length As Integer) As Long
    Dim sum1, sum2
    Dim i As Integer, iY As Integer
        For iY = 0 To length - 1
            i = length - iY
            sum2 = sum2 + Asc(Mid(buf, i, 1))
            If sum2 > &HFF Then
                sum2 = sum2 - &HFF
            End If
            sum1 = sum1 + sum2
        Next iY
        SubCheckSum = (LShift((sum2 And &HFF), 8)) Or ((sum1 Mod &HFF) And &HFF)
End Function

Private Function UDPCheckSum(buf As String) As Integer
    Dim subsum As Long, length As Integer
    Dim a As Long, b As Long, Ret As Integer
        CopyMemory length, ByVal Mid$(buf, 3, 2), 2
        length = length - 2
        subsum = SubCheckSum(Mid$(buf, 3), length)
        a = &HFF - ((subsum And &HFF) + (RShift(subsum, 8))) Mod &HFF
        b = CLng((((&HFF - (a + RShift(subsum, 8)) Mod &HFF) And &HFF) Or LShift(a, 8)))
        CopyMemory Ret, b, 2
        UDPCheckSum = Ret
End Function
I'm not an Addict.

pianka

Quote from: Archangel on July 07, 2005, 08:28 PM
Lets post the very 1st thing that is needed to know:
Packet Format:
   (DWORD) 0x00
   (WORD) Checksum
   (WORD) Length
   (WORD) Sent
   (WORD) Recved
   (BYTE) Command Class
   (BYTE) Command
   (BYTE) Sender ID
   (BYTE) Resend
   (VOID) Packet

[If i am wrong, i am looking for corrections]

Ahem, we discussed if you were to release anything that we'd done, my name was to be on it as well and you might as well post the rest of the research.

Warrior

He didn't put his name on it, as it was a contribution by him and him being a co-author I don't see the problem is. You want your name on a structure battle.net wrote, amazing.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

UserLoser.

Quote from: PiaNKA on July 20, 2005, 04:25 PM
Quote from: Archangel on July 07, 2005, 08:28 PM
Lets post the very 1st thing that is needed to know:
Packet Format:
   (DWORD) 0x00
   (WORD) Checksum
   (WORD) Length
   (WORD) Sent
   (WORD) Recved
   (BYTE) Command Class
   (BYTE) Command
   (BYTE) Sender ID
   (BYTE) Resend
   (VOID) Packet

[If i am wrong, i am looking for corrections]

Ahem, we discussed if you were to release anything that we'd done, my name was to be on it as well and you might as well post the rest of the research.

I thought Adron came up with the names to each part, then released it publically?

[If I am wrong, I am looking for a correction]

Archangel

Quote from: PiaNKA on July 20, 2005, 04:25 PM
Quote from: Archangel on July 07, 2005, 08:28 PM
Lets post the very 1st thing that is needed to know:
Packet Format:
   (DWORD) 0x00
   (WORD) Checksum
   (WORD) Length
   (WORD) Sent
   (WORD) Recved
   (BYTE) Command Class
   (BYTE) Command
   (BYTE) Sender ID
   (BYTE) Resend
   (VOID) Packet

[If i am wrong, i am looking for corrections]

Ahem, we discussed if you were to release anything that we'd done, my name was to be on it as well and you might as well post the rest of the research.

The reseach got your name in it, i wont go posting your name in every post i make lol.
But you are right.
That info is on Piankas & ArchAngel research. sorry ^^

UserLoser? Why dont you post usefull stuff?
I'm not an Addict.

shout

#13
Quote from: Archangel on July 20, 2005, 11:26 PM
UserLoser? Why dont you post usefull stuff?

Because UserLoser is a god, he needs not go out of his way for mere mortals.

I have packetlogged quite a few packets using WPEPro that do not follow this format at all, could it be something about WPEPro? The ones I captured seemed to have something like this:


(WORD) Length
(WORD) 0x00
(DWORD) Unknown, ID?
(VOID) Packet


By the way I was using a LAN game to capture them, not Battle.net.

pianka

#14
Sorry, wasn't trying to be bitchy, I just figured you'd put the rest of the stuff up there.

UL: Not that I had ever come across :-\