Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 17:10

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Tutorial] Inter-Process Communications in Conquer Online [Packets] [C#]

Discussion on [Tutorial] Inter-Process Communications in Conquer Online [Packets] [C#] within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
[Tutorial] Inter-Process Communications in Conquer Online [Packets] [C#]

Requirements for this Tutorial:
Before you continue, you must have a background in data types (signed and unsigned bytes, shorts, ints, longs, etc) and understand the amount of space they take up in a byte array. A background in byte arrays would be highly recommended before continuing this tutorial. You can find more information about byte arrays on MSDN. You must know how to make a new chat command in your source.

The Concept:
In Microsoft's Visual C# language, data is a collection of bytes that forms information in sequence. Sequence is very important when dealing with data because computers read instructions in sequence. On your computer, data is stored and accessed separately within each program; however, internet applications need to rely on data from elsewhere - sometimes from across the world. For an internet application (the client) to work on your computer, it must connect to the data provider (the server). Once the client establishes a connection with the server, the server tells the client to begin accepting data transactions. These data transactions form a line that connects the two computers together (each computer being an endpoint on this line). The endpoints contain a listener and system to handle data transactions. Like a radio antenna, the listener listens for incoming transmissions from the data source (our server). This system of listening for, handling, receiving, and sending data is called a Socket system. The two socket systems on each endpoint create an inter-process communication flow (in other words, a sequential flow of data). The data groups being sent across the flow (or stream) are formatted using common structures known by both the server and client. These groups of structured data being sent across the stream are called packets. Take this time to watch this video about packets:
In addition to a network wrapping, the structure of the packet body should tell the client and server how to handle it. In Conquer Online, each packet contains the packet length and type of packet. This way, when a movement packet (1005 / 10005) is sent to the server, the server can handle it as a movement packet, not a message packet or guild window packet. Take this time to become familiar with packet identities (don't open the structures yet): .

Like everything else relating to data structures in Computer Science, packets are constructed in sequence. This means that as you construct packets, you must add data in order (like structuring a house). This would mean completely reconstructing packets as variables (our building materials) change. Although packets must be sent in sequence, we can avoid reconstructing them every time a variable in the packet changes by using Object Oriented Programming (OOP). Visual C# is an OOP language, thus we can create an array of bytes at any time as an object. Visual C# uses byte arrays to send packets to and receive packets from the stream.

Packet Structures:
Like a blueprint for a house, packets have blueprints called packet structures. Each step of the structure relates to a position in the byte array. For example, in the first four bytes of every packet in Conquer Online, the client and server write a common header containing the length (the first 2 bytes / first unsigned short) and the packet identity (the second 2 bytes / unsigned short). Positionally, that would mean that at index 0 of the array, the client or server would write the packet length. At index 2, the packet identity. Here's a picture representation of positions in arrays: . These storage index numbers / positions in the array are called offsets. Take this time to review the structure of some of the packets on the or review the few I have on my . I suggest you review . It's the one we'll be using as an example.

If you review , you'll notice that elements being written to the array aren't byte sized. They exceed the size of a byte. Using a packet writer (found in Impulse's sources) or pointers, you can write large numbers as multiple bytes to an array. Strings may also be easily written to a byte array by writing each ASCII character as a byte in the array. Values can be read from arrays using BitConverter, which combines bytes in a byte array to form larger numbers, or Encoding.ASCII.GetString, which reads bytes as ASCII characters to create a string. The computer doesn't know what values are at what offsets, thus without packet structures, packet bodies would be meaningless. That's where you come in. Let's make a packet using a packet structure as an example.

Example:
Let's create a packet to send to the Conquer Online client. Make a new command called "packettest". In this command, we're going to make a skill adding packet (that adds a skill to the client's interface). I chose this packet because the structure has never changed and it's simple. The only expectation is that this packet will display the skill in the interface. Handlers come later. Don't cheat by looking at the skill packet's constructor in your source. Let's start by making the byte array. We'll define it to be of length 20: 4 bytes for the body's header (the length and identity of the packet), 8 bytes for the body's data (the experience, skill id, and skill level), and another 8 bytes for the "TQServer" ASCII character stamp (which I'll talk about in a minute). To write values to the offsets in the array, we're going to use Impulse's packet writer class. If requested, I'll explain how that works in another tutorial. To start, we're going to look at the packet structure: . You'll notice two things: the static id is at offset 8, and the length is 12. The length written to the packet does not include the length of the "TQServer" stamp that is written to the end of the packet. The static ids for skills can be found on my and . Using Impulse's packet writer is fairly simple. To write an unsigned short, we're going to use WriteUInt16; unsigned int, WriteUInt32. To use the packet writer, we assign the following parameters: Value, Offset, Array. Here's an example of writing the packet using the packet writer: . To send the constructed packet to yourself, you're going to use the client's send method which encrypts and sends the packet to the client. In Impulse's send method, he writes "TQServer" to the end of the packet. In patch 5018, TQ introduced this addition with Blowfish. If your source is below patch 5018, then your array length is the packet body length.

Practice:
Ok, now that you have the weapon skill working, erase it. Practice your new background in Conquer Online packet structures to write this packet structure to an array: . This packet updates the experience of a weapon skill. Good luck!

The Assumptions Made in this Tutorial:
This tutorial assumes that the inter-process communication flow is using the TCP/IP protocol. The video provided assumes that the internet is linear when it's really a web or net (thus why the internet is called the World Wide Web).

My Approach:
The main problem (to my understanding and from my experience) is the concept behind packets. I remember having difficulty with the concept; but once I got it, packets were easy. There's a lot of documentation on packet structures, but none on C# inter-process communications in Conquer Online private servers, specifically packets and how they interact with the server. Anyways, that's why I chose this approach. Hopefully this helps a few people get started.
Spirited is offline  
Thanks
4 Users
Old 06/07/2012, 19:07   #2
 
elite*gold: 0
Join Date: Sep 2008
Posts: 490
Received Thanks: 595
Nice I'm sure there are a lot of people that can really use this to get a better understanding. You get my thanks for the effort put in, I would be way too lazy to write something that long.
_fobos_ is offline  
Old 06/07/2012, 20:13   #3
 
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,199
I don't really get it... where exactly is the tutorial?
IAmHawtness is offline  
Thanks
3 Users
Old 06/07/2012, 20:28   #4
 
elite*gold: 0
Join Date: Sep 2008
Posts: 490
Received Thanks: 595
Quote:
Originally Posted by IAmHawtness View Post
I don't really get it... where exactly is the tutorial?
My guess it's more an easy to follow explanation instead of a tutorial.
_fobos_ is offline  
Old 06/07/2012, 20:36   #5
 
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,199
Quote:
Originally Posted by _fobos_ View Post
My guess it's more an easy to follow explanation instead of a tutorial.
Yeah, I can see how it could classify as an explanation more than a tutorial. Although, when I saw the inter-process communication part, I hoped to see some mention of shared memory and pipes
IAmHawtness is offline  
Thanks
1 User
Old 06/07/2012, 20:50   #6
 
elite*gold: 0
Join Date: Sep 2008
Posts: 490
Received Thanks: 595
Quote:
Originally Posted by IAmHawtness View Post
Yeah, I can see how it could classify as an explanation more than a tutorial. Although, when I saw the inter-process communication part, I hoped to see some mention of shared memory and pipes
My thoughts exactly when I opened this thread! However I mean all in all it isn't a bad explanation for people that have no good understanding of packets.
I'll let my gf read this and see if she understands will get back to you on that one haha.
_fobos_ is offline  
Old 06/07/2012, 20:56   #7
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by IAmHawtness View Post
Yeah, I can see how it could classify as an explanation more than a tutorial. Although, when I saw the inter-process communication part, I hoped to see some mention of shared memory and pipes
There are people who don't understand the basic concept of packets in C#. I didn't write this tutorial for people like you. If you'd like me to write a more advanced tutorial, I might have time next week, but I doubt you'd need a tutorial on advanced inter-process communications in C# for Conquer Online. At that level, you should be able to implement concepts from different articles and programming languages.
Spirited is offline  
Old 06/07/2012, 21:55   #8
 
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,199
Quote:
Originally Posted by Fаng View Post
There are people who don't understand the basic concept of packets in C#. I didn't write this tutorial for people like you. If you'd like me to write a more advanced tutorial, I might have time next week, but I doubt you'd need a tutorial on advanced inter-process communications in C# for Conquer Online. At that level, you should be able to implement concepts from different articles and programming languages.
Yeah, I see that now. It's a nice explanation, I just don't really see what it has to do with inter-process communication
IAmHawtness is offline  
Old 06/07/2012, 22:33   #9
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by IAmHawtness View Post
Yeah, I see that now. It's a nice explanation, I just don't really see what it has to do with inter-process communication
In this tutorial, I took packets and approached them by explaining their use in inter-process network communications, in specific, IPC network streams managed by C#. I don't want to over-complicate things, so I simply stated the name of the stream and the basic process that C# manages. The main purpose of doing that was for development in the concept. Inter-process communications in networks are important in Conquer Online. Hopefully by introducing them in this tutorial using a common term they some what know, they'll be able to get a grasp on the term.

Edit: For example... flat-files in the database, pipes, packet queues.. they all relate to inter-process communications in Conquer Online. This thread (as I said) is just a basic introduction to get their feet wet.
Spirited is offline  
Old 06/07/2012, 23:19   #10
 
elite*gold: 0
Join Date: Sep 2008
Posts: 490
Received Thanks: 595
Quote:
Originally Posted by Fаng View Post
In this tutorial, I took packets and approached them by explaining their use in inter-process network communications, in specific, IPC network streams managed by C#. I don't want to over-complicate things, so I simply stated the name of the stream and the basic process that C# manages. The main purpose of doing that was for development in the concept. Inter-process communications in networks are important in Conquer Online. Hopefully by introducing them in this tutorial using a common term they some what know, they'll be able to get a grasp on the term.

Edit: For example... flat-files in the database, pipes, packet queues.. they all relate to inter-process communications in Conquer Online. This thread (as I said) is just a basic introduction to get their feet wet.
I wouldn't help 'beginners' use languages as C#, who likes C# !
I dislike it haha, but we all got our own taste!
_fobos_ is offline  
Old 06/08/2012, 01:16   #11
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by _fobos_ View Post
I wouldn't help 'beginners' use languages as C#, who likes C# !
I dislike it haha, but we all got our own taste!
I would recommend Java for beginners if I could; however, most applications and sources here are made with C#. Since this guide is for Conquer Online sources here... you get the picture. Any OOP, managed, reputable language is a good start for beginners.
Spirited is offline  
Reply


Similar Threads Similar Threads
[Small Tutorial] Packets in Conquer Online
11/18/2017 - CO2 PServer Guides & Releases - 24 Replies
Replaced with https://www.elitepvpers.com/forum/co2-programming/ 4387789-tutorial-introduction-packets.html
Software that lets you sniff, modify and inject packets into a process
08/14/2008 - General Coding - 3 Replies
It has been around 5 years since I last did any packet hacking. I used to have a program that attached itself into a process. It then shows all network packets sent and received by the program. You can then create filters that will, for example, automatically send a packet once it sees a specific packet / pattern. It was using this software that I was able to crack a bunch of games and software. I was the one who discovered that Starcraft sent private data to Blizzard every time you logged into...



All times are GMT +1. The time now is 17:10.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.