Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Arkantos

Avatar / Picture

Registered:
Posts: 481
Reply with quote  #1 
So I've been working on trying to understand the payload for the packet the client sends when the game master clicks on a button. If you aren't familiar with the Artemis protocol, here's a brief explanation. Every packet comes with a 24-byte header, followed by a payload. Four of the bytes in the header are a number which identifies the packet type. Some packets also have a subtype, which will be the first thing in the payload.

So I loaded the script in this thread for setting up the buttons, and captured the packets so that I could look at them. I should be clear that the structure for the packets which the server sends to the game master client to tell it what buttons to create is already fully understood. It does not communicate any sort of ID for the button. In fact, except for buttons that have a particular position and size, the only thing transmitted in the payload is a value that says, "We're creating a button" and the label for that button. So I expected that the packet that tells the server that a button has been pressed would probably use the label itself as the identifier, especially considering that the scripts do the same thing.

It was pretty easy to see, by looking at the packets sent by the client when the game master clicked buttons, that the corresponding packet type in hex is 0x4c821d3c subtype 0x15. (This can be a little confusing because the bytes are in little-endian order, but most programming languages present numeric values big-endian. So the actual bytes transmitted for the type are 3c 1d 82 4c.)

So far, so good. Now it was just a matter of looking at the payload bytes to see how it communicates which button is clicked. But this is where it gets tricky. Here are the payloads for a couple of button clicks that I captured:

150000000d00000057ce9597 ("Teleport Selection")
150000000d0000009b4e92f7 ("Create Enemy/Small Standard")

There are twelve bytes, and it looks like there are three values of four bytes each in each packet payload. The first four bytes are pretty clearly the subtype value (0x15), since other known packets that use the 0x4c821d3c packet type have 4-byte subtype values. I don't know what the second value is, but for both it was 0x0d, so there's no distinguishing between buttons with that value.

So that leaves just four bytes for identifying which button was pressed. This throws out the idea of labels being used as the identifiers, since they'd be longer than four bytes. (Strings in the Artemis protocol are encoded in null-terminated UTF-16, so four bytes is only enough for one character and the terminating null.)

We have 57ce9597 for the first packet and 9b4e92f7 for the second one. They are clearly intended to tell me which button is being clicked, but I'm not sure how.

If we interpret the values as integers, we get -1751789993 and -141406565, neither of which makes sense as a value for identifying the button that was clicked. Integers in Artemis are signed, but let's pretend that for some reason these ones are unsigned. In that case, we have 2543177303 and 4153560731, not exactly meaningful.

As floats, they're -9.6809868e-25 and -5.9349191e+33, which makes no sense, either.

It's possible that they're a pair of 2-byte integral values (shorts). If that's the case, we get -12713 and -26731 for the first packet and 20123 and -2158 for the second, still not very meaningful. Suppose they're unsigned values? That would make them 52823, 38805, 20123 and 63378. None of these pop out at me as a way that these buttons might be identified.

At this point, I'm kind of at a loss to understand how the client is communicating which button was clicked. If any other geeks out there have an idea of what's going on here, I'm open to suggestions.
Xavier Wise

Registered:
Posts: 1,362
Reply with quote  #2 
Are they coordinates?
I have no idea on this by the way, so just a guess! Perhaps though it defines an area of the screen in which to detect a click. What would these look like plotted on the space map?

__________________
Fleet Captain Xavier Wise - TSN Sabre
Link to TSN RP Community Website

Want to follow development of the TSN Sandbox? Head here:
https://ko-fi.com/xavierwise
Arkantos

Avatar / Picture

Registered:
Posts: 481
Reply with quote  #3 
The buttons are plotted on screen coordinates, not game-space coordinates. The game master can zoom and pan the map, but the buttons don't move. None of the numbers make any sense as screen coordinates.
Xavier Wise

Registered:
Posts: 1,362
Reply with quote  #4 
Ah, sorry. Thought it was worth a mention anyway.
__________________
Fleet Captain Xavier Wise - TSN Sabre
Link to TSN RP Community Website

Want to follow development of the TSN Sandbox? Head here:
https://ko-fi.com/xavierwise
Arkantos

Avatar / Picture

Registered:
Posts: 481
Reply with quote  #5 
No problem. I'm looking for any and all thoughts on the matter. Even if it's wrong, it may trigger inspiration that leads to the right answer. I'm going to try and capture some more packets tonight and see if I can see any patterns that I'm not seeing now.
Arkantos

Avatar / Picture

Registered:
Posts: 481
Reply with quote  #6 
Here's a list of the values for all the buttons in the script. I'm wondering if the values are some sort of hash of the label. Will experiment.

9b4e92f7 Create Enemy/Small Standard
1c83750d Create Enemy/Medium Standard
78ecbcf9 Create Enemy/Large Standard
3d009c0a Create Enemy/Small Skaraan
23e46ce2 Create Enemy/Medium Skaraan
35d1b6ff Create Enemy/Large Skaraan
e8f4610d Delete\Selected ship
82191cbd Delete\non-ships near
544548e9 Create Enemy/Extras/Minefield arc
70f04ba1 Create Enemy/Extras/Nebulas
d5c9096b Create Enemy/Extras/Asteroids
96f9864f Create Transport/going north
815f8f9d Create Transport/going east
1a589737 Create Transport/alien going east
57ce9597 Teleport Selection (40,210 200x30)
e3481f40 Enemy Brain/chase stations
7a2a86e8 Enemy Brain/chase player

Arkantos

Avatar / Picture

Registered:
Posts: 481
Reply with quote  #7 
It is a hash! I changed the labels of some of the buttons and their values changed, while the buttons whose labels remained unchanged had the same values. That's the good news. The bad news is that I don't know how the hashes are computed.
Arkantos

Avatar / Picture

Registered:
Posts: 481
Reply with quote  #8 
Artemis is written in Microsoft Visual C++ 2008. I'm guessing that if we can determine how string hashes are computed in that language, we'll have the solution.
Anagram

Registered:
Posts: 34
Reply with quote  #9 
I'm not sure that this is really helpful, but I came up pretty dry with a couple of your known values and a powershell script to try out a whole bunch of the "out-of-the-box" .net hash options. The script is available at:  https://gist.github.com/jrwarwick/44c1b13bc28410828f0f618dafda9df2
Arkantos

Avatar / Picture

Registered:
Posts: 481
Reply with quote  #10 
I appreciate the effort. I know pretty much zero about .NET stuff, as I've never coded anything on that framework. Not solving this isn't the end of the world, but it does mean that it would be impossible to create a fully-functional custom game master client, since you wouldn't be able to transmit button clicks to the server without it. So I appreciate whatever help can be lent by anyone to solve this mystery.
chrivers

Registered:
Posts: 1
Reply with quote  #11 

Well, you didn't make this super easy ;-)

Half the captured packets are wrong - here are the correct hashes:

70f04ba1 Delete\Selected ship
d5c9096b Delete\non-ships near
e8f4610d Create Enemy/Extras/Minefield arc
82191cbd Create Enemy/Extras/Nebulas
544548e9 Create Enemy/Extras/Asteroids
57ce9597 Teleport Selection


The hash function used is JamCrc, which is a pretty run-of-the-mill CRC32 variant, with 0x04c11db7 as the polynomial, and 0xffffffff as the init vector. The slightly weird thing, is that the JamCrc value is not run on the utf16 bytes, but on the ascii byte stream of the string(!). This is somewhat crazy, and seems completely unnecessary, but it's what's in use here.

Also, the hashes shown here, are byte swapped compared to the actual result. It's probably an artefact of capturing the data straight from the network, and not parsing it as a proper little-endian u32.

The protocol docs should be updated relatively soon with this new info.

Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.