Search code examples
c#connectionudphexpacket

How to add 'ff ff ff ff' (HEX) before the data of an byte[] array?


I am currently programming an emulator for a multiplayer game.
The client sends this to the server: ÿÿÿÿ2joinParty 61586 110000140b9f842 1 1 0 -1 1 pw 1.
My program sends joinParty 61586 110000140b9f842 1 1 0 0 1 pw 1 to the server.
Now when I make it send the ÿÿÿÿ's with it, it sends instead of ff ff ff ff, 3f 3f 3f 3f. Almost all packets require that ff ff ff ff, or else the server rejects the connections.

How can I add them?


Solution

  • byte[] firstArray = new byte[] {0xFF,0xFF,0xFF,0xFF}; 
    byte[] secondArray = [your data here]
    byte[] result = firstArray.Concat(secondArray).ToArray();