Good to hear bro.
Printable View
I am confused. I can't seem to get what the little-endian is or looks like. is it part of the int byte or what? anyone know?
I figured out everything else except that. the wiki didn't help much either.
Ah, well yeah its a little confusing...
A Integer byte is 4 bytes long, for example 4 is [04] [00] [00] [00] ....
Now because its under the max for 1 byte (FF) nothing needs tobe done to it, but if you have something like [FF] [01] [00] [00]
After little endianing it it changes to [01] [FF] [00] [00] ..
Its really just swaping it around..
Examples:
[01] [00] [00] [00] -----> [01] [00] [00] [00]
[01] [02] [00] [00] -----> [02] [01] [00] [00]
[01] [02] [03] [00] -----> [03] [02] [01] [00]
[01] [02] [03] [04] -----> [04] [05] [02] [01]
I think thats how it works, I'm not 100% sure, I googled a Java function for it and I just use that and it seems to work fine ^_^
ok about little and big endian:
First of all the endianness describes the byte order of integers.
You already know that a byte consists of 8 bit wich represents the numbers from 0 to 255 (unsigned) or -128 to +127 (signed). For details about the representation of numbers in memory take a look at Two's complement at http://en.wikipedia.org/wiki/Signed_...epresentations
Now to the problem of endianness, historically there were two main formats little and big endian, one is easier for the cpu developer to handle (little) the other is more readable for the human user (big).
Now how do they look a like
Bigendian is like we are used to reading numbers meaning the number 5 is represented as:
uint8 = [05]
uint16 = [00][05]
uint32 = [00][00][00][05]
Littleendian the bytes are swaped meaning the number 5 is represented as:
uint8 = [05]
uint16 = [05][00]
uint32 = [05][00][00][00]
for a longer example big = [12][34][56][78] - [78][56][34][12] = little
Hope this helps
KumaT
//EDIT
I did forget to mention that a byte is the smalles element current computers handle, meaning for calculations at least a byte is used even if you only operate on one of its bits.
//EDIT2
changed BYTE,short,long -> uint8,uint16,uint32
because long/long long is the currently most irritating datatype defention, i know of (If you like read about it, its related with 32 and 64 bit processors)
by sending this packet (in C#), i can get a blank server list window:
0x5E, 0x08, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x00, 0x00, 0x6D, 0x00, 0x00, 0x00
after that anything else I put on the packet does nothing and crashes my login server.
the username would be test and the server name is Test, and the ip is of course 127.0.0.1.
I try to put those in along with the int-length and nothing happens. what am I doing wrong?
Oh I was wrong, read this ^^.. That clears it up for me... I was a bit confused about how it worked xD
Not sure what the 6D is for o.O...
Anyway, after that you need to put [04] [00] [00] [00] [t] [e] [s] [t] [0B] [00] [00] [00] [FF] [FF] [FF] [FF] [01] [00] [00] [00]
[04] [00] [00] [00] [t] [e] [s] [t] [09] [00] [00] [00] [IP ... ?] [00] [00] [00] [00] [00] [00] [00] [00] [01] [00] [00] [00] [00] [00] [00] [00] [01] [00] [00] [00] [01] [00] [00] [00] [INT-Length] [Channel Name] [00] [00] [00] [00] [00] [00] [00] [00] [INT-Online Players] [01] [00] [00] [00] [INT-Channel Capacity]
Fill in the "test" bytes, not sure on the values, and the IP, channel name, channel name length, online players and capacity..
Hopefully some-what helpful o.O
i'm gonna try this out now. Thanks for your help ανєяηιкαѕ and KumaT. You broke it down into what I can understand.
---Edit----
this is the whole packet for the server list.
0x5E, 0x09, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x00, 0x00, 0x48, 0x6E, 0x17, 0x19, 0x01, 0x04, 0x00, 0x00, 0x00, 0x74, 0x64, 0x73, 0x25, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x4B, 0x65, 0x72, 0x6E, 0x09, 0x00, 0x00, 0x00, 0x31, 0x32, 0x37, 0x2E, 0x30, 0x2E, 0x30, 0x2E, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x2D, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x4C, 0x04, 0x00, 0x00
I cannot figure out why the server hangs when I use the FF FF FF FF part of the packet which crashes my server.
If I change them to all 0x00 I get no errors, but nothing comes up but a blank screen.
If you use Windows, open up your calculator, hit 1100, then (if your in scientific mode) click "Hex", then look at the number in the box...
Dont forget to flip it.
Your problem is here.
After 0x5E, there are four bytes which tell the client how big the packet is. Calculate the packet's size and add it where x9 x0 x0 x0 take place. The packet size should be the size of the whole thing -5. (5e and the size int don't count)Code:0x5E, 0x09, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x00, 0x00, 0x48, ...
x5E, 0x7B, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x00, 0x00, 0x48, 0x6E, 0x17, 0x19, 0x01, 0x04, 0x00, 0x00, 0x00, 0x64, 0x61, 0x72, 0x6B, 0x73, 0x61, 0x6D, 0x75, 0x73, 0x38, 0x32, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x44, 0x65, 0x6D, 0x69, 0x61, 0x6E, 0x28, 0x50, 0x4B, 0x29, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x36, 0x34, 0x2E, 0x31, 0x32, 0x37, 0x2E, 0x31, 0x30, 0x33, 0x2E, 0x32, 0x35, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x37, 0x2D, 0x31, 0x28, 0x50, 0x4B, 0x29, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5D, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x4C, 0x04, 0x00, 0x00
corrected the packet size minue 5e and packet length. works but still no server name showing up. can't figure it out. anyone got a clue?
Change the 0x04 to username's length.Code:x5E, 0x7B, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x00, 0x00, 0x48, 0x6E, 0x17, 0x19, 0x01, 0x04, 0x00, 0x00, 0x00, 0x64, 0x61, 0x72, 0x6B, 0x73, 0x61 ...
If nothing works, heres how I did mine:
1. Added int FD
2. Added bytes xE6, xA8, x3E, x7B, x01
3. Added length of username (int, 4 bytes)
4. Added username string
5. Added int x25
6. Started looping through each cluster found in database:
6a. Added xFF xFF xFF xFF
6b. Added cluster ID (int)
6c. Added length of cluster name (int, 4 bytes..)
6d. Added cluster name string
6e. Added length of cluster's IP (once again, int, 4 bytes)
6f. Added cluster's IP string
6g. Added 8 times x00
6h. Added byte x01
6i. Added 7 times x00
6j. Started looping through each server of the current cluster:
6ja. Added cluster ID (int)
6jb. Added an increasing int (increases by 1 after each server, resets when starting with another cluster, probably the int being sent from the client which tells the cluster server which server the user has picked up. not sure..)
6jc. Added length of server's name (int, 4 bytes)
6jd. Added server's name string
6je. Added 8 times x00
6jf. Added online players count (int)
6jg. Added int 1 (01 00 00 00)
6jh. Added server's max capacity (int)
End of server loop. If you want to add another server for the cluster, repeat step 6ja. Otherwise, you can do two things from there:
- Continue adding clusters (repeat step 6a)
- Continue to the rest of the packet, when there are no more clusters left to add.
So, when theres no more clusters to add, you just calculate the size of the whole thing you've made in here, add it as a little endian int to the beginning of the packet (after x5E) and send it to the client.
Hope it helped.
it seems like i added to many bytes. like instead of byte [25] I put [25] [00] [00] [00]. I'm going to rewrite the packet in the format you provided. It's not that I don't understand the packet structure, it's just not working for me. but i won't give up.
Wait.. my bad. That x25 SHOULD be an int. I accidently read it as byte. :\
oops.ok then I'll make it a byte. thanks for the heads up.