• Welcome to Valhalla Legends Archive.
 

SC In Game Packets??

Started by ChR0NiC, July 08, 2004, 02:25 PM

Previous topic - Next topic

ChR0NiC

Can anybody tell me the structure of an SC in game packet?

They seem to start out with the Size but I am not sure where the packet ID is.

Blaze

Why not do a packet log and find it yourself?
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

iago

SC in-game packets are very complicated.  I would suggest looking at the storm functions that handle them (they're the small 100's, like storm_100 to storm_130 or so).  These are the SNet functions, in case you care.

I'm not 100% sure that this is correct, but one place might be to start is storm_122:
int __stdcall SNetReceiveTurns(void **,int,int,int,int)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


ChR0NiC

Quote from: Kk)Blaze(kK [Anti-yL] on July 09, 2004, 02:36 PM
Why not do a packet log and find it yourself?

They are very complicated

Quote from: iago on July 09, 2004, 02:52 PM
SC in-game packets are very complicated.  I would suggest looking at the storm functions that handle them (they're the small 100's, like storm_100 to storm_130 or so).  These are the SNet functions, in case you care.

I'm not 100% sure that this is correct, but one place might be to start is storm_122:
int __stdcall SNetReceiveTurns(void **,int,int,int,int)

Thanks for the suggestions, I really appreciate it. No sarcasm

Adron

They aren't that complicated at all. Post some samples here for parsing? Pick a set of sequential short packets from a two-player game, including a talk message and some other known message?

Adron

Quote
Quote from: Adron on July 10, 2004, 04:27 AM
They aren't that complicated at all. Post some samples here for parsing? Pick a set of sequential short packets from a two-player game, including a talk message and some other known message?

This will be a bit of guesswork, but I do remember some parts... Need more data to tell you more. Try to find packets that have different values in the unknown parts.


Quote
2 Player Game (Not host):

Send:  00 00 00 00 EB 34 16 00 98 01 A3 01 01 00 01 00 00 20 69 27 6D 20 6E 65 77 00
Text:  i'm new

Breakdown:

00 00 00 00
Header of 00's

EB 34
No idea

16 00
Packet length

98
Current packet sent (Keeps track of the amount of packets sent in-game)

01 A3 01 01 00 01 00 00
Not sure what every byte is for but I'll assume your playerID is one of these bytes. What are the others for?

20
PacketID (Space)?

69 27 6D 20 6E 65 77 00
Message


00 00 00 00 : zero bytes
EB 34 : checksum 34EB
16 00 : packet length 16
98 01 : sequence number 198
A3 01 : acknowledge for 1A3
01 01 00 01 00 00 : unknown for now
20 69 27 6D 20 6E 65 77 00 : <packet data, using another "standard" format>



Quote
More messages...

Send:  00 00 00 00 16 65 15 00 99 01 A3 01 01 00 01 00 00 20 61 72 65 20 75 3F 00
Text:  are u?

Send:  00 00 00 00 2D 2F 10 00 9A 01 A3 01 01 00 01 00 00 20 31 00            
Text:  1

Send:  00 00 00 00 3D 1D 10 00 9B 01 A3 01 01 00 01 00 00 20 32 00  
Text:  2

Send:  00 00 00 00 4D 0B 10 00 9C 01 A3 01 01 00 01 00 00 20 33 00
Text:  3

Send:  00 00 00 00 5D F8 10 00 9D 01 A3 01 01 00 01 00 00 20 34 00  
Text:  4


Here are some seq. keepalives too:

SEND-> 00 00 00 00 F7 D8 13 00 EE 00 EF 00 02 00 01 00 37 D2 0C D0 40 00 13
SEND-> 00 00 00 00 D5 7B 13 00 EF 00 F0 00 02 00 01 00 37 E1 F4 56 40 00 13
SEND-> 00 00 00 00 AC D2 13 00 F0 00 F1 00 02 00 01 00 37 F2 61 A8 40 00 13

No idea what this is:

SEND-> 00 00 00 00 5D F8 10 00 9D 01 A3 01 01 00 01 00 00 20 34 00

If you could break the packets down better that would be groovy.


00 00 00 00 16 65 15 00 99 01 A3 01 01 00 01 00 00 20 61 72 65 20 75 3F 00
00 00 00 00 2D 2F 10 00 9A 01 A3 01 01 00 01 00 00 20 31 00            
00 00 00 00 3D 1D 10 00 9B 01 A3 01 01 00 01 00 00 20 32 00  
00 00 00 00 4D 0B 10 00 9C 01 A3 01 01 00 01 00 00 20 33 00
00 00 00 00 5D F8 10 00 9D 01 A3 01 01 00 01 00 00 20 34 00  
00 00 00 00 F7 D8 13 00 EE 00 EF 00 02 00 01 00 37 D2 0C D0 40 00 13
00 00 00 00 D5 7B 13 00 EF 00 F0 00 02 00 01 00 37 E1 F4 56 40 00 13
00 00 00 00 AC D2 13 00 F0 00 F1 00 02 00 01 00 37 F2 61 A8 40 00 13
00 00 00 00 5D F8 10 00 9D 01 A3 01 01 00 01 00 00 20 34 00

AA AA AA AA BB BB CC CC DD DD EE EE FF GG HH II .. .. .. ..


A: zero bytes
B: checksum
C: length
D: sequence number (notice how it increases for each message sent)
E: acknowledge number (will increase if the other guy sends a message)
F: packet class (sequence / acknowledge numbers increase separately for each class)
G, H, I: need more data, one of them should be source or destination player, another should contain flags (try to find a packet that is being resent because of packet loss, good time to capture this should be when the game is lagging), another should be something I called command and is mostly used for class 0 packets sent while joining a game (capture some of those!)
.. : actual data - parse this differently depending on the class / command values found in the packet header.


Some of the packets sent when selecting units and ordering them around would be good to see too. If you can do more than one thing really quick, you'll also see how multiple actions are put into the same packet. Try for example selecting different unit groups quickly, or clicking out different orders. Label these packets with what you've been doing too. You should find that they are all of class 2.

Class 1 is used for messages and asynchronous stuff. Class 0 while joining a game. The class that causes the lag window to appear is class 2. Some class 1 packets can be lost for a long time and delivered much later, causing a lot of typed messages to appear at once on a laggy connection.


Paul

#6
The class information does actually help a lot. I never thought of or saw that after reviewing my logs. Presently I'm still continuing to document packet-building functions in the starcraft.exe before everything is passed through the battle.snp. And if you or anyone else cared I'm only doing this out of extreme boredom. I have no plans to write a game bot or anything entertaining; just a public doc/ref of my half-assed efforts.

To re-clarify a few things, there are only 3 classes of in-game packets (00, 01 and 02) and each class contains a variety of packet types for different actions? This would be how I would weed out the annoying keepalives by filtering them on class 02. Off the top of your head Adron, do game actions (Like moving units) also fall under class 02? That may cause a headache in my parsing if they are also under the same class as keepalives.

Edit:
Just read the bottom of your post. I guess unit movement and such does fall under class 02. Ho hum! Oh well!

Adron

Only three classes.

Class 02 runs the game, one of these is received from each player on each game tick. The data consists of a number of "subpackets", each starting with a byte that indicates the type of subpacket. The length of the subpacket is mostly fixed, and the game knows the length for each type of subpacket.

You may want to find this table of subpacket lengths inside the game. You could also just do various actions and assume that in most cases you'll have a 37 subpacket + that one action you just did in the packet.

Class 00 is used when joining a game, I'd say "for administrative purposes". The packet data contains different things depending on the command byte in the packet header. It doesn't have the same subpacket structure.

Class 01 is used for non-synchronous data such as talks.

When I originally did this, I noticed the increasing sequence numbers, and that they increased in different ranges. Then I looked for what was common to all packets counting up in a specific range and found the class byte.



hismajesty

#8
Many of the values are unknown. I think they depend on other things such as game type/speed/etc.

Here's what one of my friends gave me, I haven't looked into it myself:


(DWORD) Unknown (Protocol?/ID?)
(WORD) Checksum result
(WORD) Packet length, including this header
(WORD) Unknown
(WORD) Unknown
(WORD) Unknown
(WORD) Unknown
(VOID) Packet Data

Kp

Quote from: Adron on July 20, 2004, 01:23 PMOnly three classes.

Actually, if I recall correctly, there is a fourth class supported in Storm.  However, to the best of my knowledge, it's never used.  I haven't seen it in either Diablo or Starcraft game logs.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

iago

I have an old breakdown written by Adron, which I will post here with his permission.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Adron

Quote from: Kp on July 21, 2004, 01:59 PM
Actually, if I recall correctly, there is a fourth class supported in Storm.  However, to the best of my knowledge, it's never used.  I haven't seen it in either Diablo or Starcraft game logs.

That's possible. I recall seeing room for another seq/ack counter somewhere, but I assumed it was a case of aligning - I never saw the fourth class used.

Adron

Quote from: hismajesty[yL] on July 20, 2004, 07:22 PM
Many of the values are unknown. I think they depend on other things such as game type/speed/etc.

Did you look at my post? :P

I actually specified what your friend gave you and more, and it all came from memories awakened by looking at that packet log he posted.

Either way, I'm sure given some more samples, we, the great visitors to this forum, could figure out the rest. Unless iago posts that summary which I don't remember writing, but ... If he feels it should be posted, it's OK with me.

iago

I'm pretty sure this was originally from you:

struct message {
unsigned long udptype;
unsigned short checksum;
unsigned short len;
unsigned short pos1;
unsigned short pos2;
unsigned char cls;
unsigned char cmd;
unsigned char sender;
unsigned char resend;
char data[];
};
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


UserLoser.

Quote from: Adron on July 21, 2004, 04:38 PM

Did you look at my post? :P

I actually specified what your friend gave you and more, and it all came from memories awakened by looking at that packet log he posted.

Either way, I'm sure given some more samples, we, the great visitors to this forum, could figure out the rest. Unless iago posts that summary which I don't remember writing, but ... If he feels it should be posted, it's OK with me.

I'm sure I would be able to figure out a great deal of the rest once I first get my client joining the games :)