 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
ulysse31 Master Cheater
Reputation: 2
Joined: 19 Mar 2015 Posts: 324 Location: Paris
|
Posted: Tue Nov 10, 2015 11:38 am Post subject: [c++] Case sorting and Variable name printing problem |
|
|
Hi, I am coding a packet program for an online game.
After decryption, I analyze the decrypted packets and the program takes action accordingly, I do this with a switch..case.
Simply put, I injected a dll into the game that retrieved me all the packet names and their corresponding hexa number, they are defined as follow in my c++:
Quote: | const int S_PLAYER_CHANGE_PROF = 0xbb32;
const int C_CREST_APPLY_LIST = 0xbb79;
const int C_ADMIN_LOBBY = 0xbbce;
const int S_MOUNT_VEHICLE = 0xbbf1; |
The way i filter packets that matter is this one :
Quote: | void ProcessUndecryptedPacketData(boost::asio::ip::tcp::socket &socket, uint16_t& size, uint16_t& title, std::vector <unsigned char> &vectArgument, int &length)
{
switch (title)
{
case S_PLAYER_CHANGE_PROF:
//do something..
break;
case S_MOUNT_VEHICLE
//Do somth
break;
}
} |
There are over 2000 packets, a switch case code cannot go over 128 possible cases or else i get a compiler limit error.
Each time a packet is processed, I log its entirety with its hexa number.
First problem :
I know there is a way better way to do this, can someone point me in the right direction ? (switch case like i did is simply bad)
I need to log the title of the packet ie S_MOUNT_VEHICLE and not only its hexa value, I came across a macro code but it prints the variable name and here the variable name is title (because switch(title)) and what i want is to print the name of the variable to which the value of title equals the hexas..I need to log the S_MOUNT_VEHICLE string and i don't see how to do this, I've thought of a function returning a string but then i'd have too many nested cases in the function.
Any help would be greatly appreciated
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
Back to top |
|
 |
ulysse31 Master Cheater
Reputation: 2
Joined: 19 Mar 2015 Posts: 324 Location: Paris
|
Posted: Wed Nov 11, 2015 3:35 pm Post subject: |
|
|
Thanks, I haven't had the chance to come across those c ++ tools till now, it looks pretty good.
edit : Made it work, turns out to be just perfect
Last edited by ulysse31 on Wed Nov 11, 2015 7:33 pm; edited 1 time in total |
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|