3

I was always curious about how some single-player games are turned into multiplayer ones. Some samples are SA-MP and MTA, that turn Grand Theft Auto: San Andreas into a multiplayer game.

In an infrastructure perspective, I know you might have a server that receives packets from a client and makes sure all the other clients receive these packets as well.

For example, whenever a player moves, the client sends a message to the server. The server then redirects the messages to each connected client. Each connected client updates the player's position.

However, how the engineers can "inject a code" into the game to make it send a network packet to a server whenever a player moves? How can they "inject a code" into the game, so it listens to a network packet to react over it?

The "inject a code" term is between quotes because I don't even know if a code is really injected into the game. That's exactly what I'm curious about. Which techniques are used? How can this be possible?

Do they hook into specific events to execute a custom code that performs networking communication? If so, could you guys elaborate that a bit further?

I'm not planning to do so, and I have no prior experience with Reverse Engineering. I couldn't find anything on the Internet. Due to that, feel free to explain any "basic concept" as well. :) I'd like to understand as much as possible about it, and different opinions and perspectives are more than welcome.

  • 1
    Well you can inject any kind of code you want, create new threads etc. Usually it's done via https://en.m.wikipedia.org/wiki/DLL_injection techniques. The hard part is finding all the game state in memory and all the functions involved with updating it. – Trass3r Jun 07 '20 at 13:02
  • Thanks, @Trass3r! From what I understood by quickly reading about DLL Injection, you then create a small executable lib file that overrides the original process' functions. By overriding it, you're allowed to run your own code and then call the original process' function again. That said, I would need to find out WHICH functions are called whenever the - let's say - W key is pressed (in theory, it moves the player), intercept it, send a packet to a server, and then call the original process' function again, so the player is really moved. Is this reasoning right? – Stanley Sathler Jun 09 '20 at 14:45
  • Yep it's called function hooking. – Trass3r Jun 10 '20 at 16:53

0 Answers0