3

So I've studied some reverse engineering lately and I'd really like to have a more better idea about how things like sa-mp and mafia 2 multiplayer are actually made. When I connect to a server in sa-mp and it starts the game. Does it inject a dll or something at this point to control the flow of the game and remove all the npcs from the cities etc? I am not really asking anything really specific but just the idea. I looked at the source codes of a few similar projects but didn't really get how it all starts. I would appreciate that someone who has knowledge about these things could enlighten me.

This is really something that has interested me since I discovered these mods so I look forward to hearing from you.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Samuli Lehtonen
  • 3,840
  • 5
  • 39
  • 49
  • 1
    Sounds like you're asking for help in breaking EULAs. Am I right? – Lightness Races in Orbit Apr 03 '13 at 17:21
  • 3
    @LightnessRacesinOrbit Who cares? This isn't asking [how to send 100k emails](http://stackoverflow.com/questions/3905734/how-to-send-100-000-emails-weekly). This one looks fine for me. – Mysticial Apr 03 '13 at 17:24
  • 2
    Maybe the owner of the app might care, (and their lawyers). – Martin James Apr 03 '13 at 17:30
  • I am just interested in how these mods function. I am not asking any code for how to do it, just the idea how it works as I said. SA-MP has also existed for many years without it being taken down, so I think the game company is quite content with it. – Samuli Lehtonen Apr 03 '13 at 17:32
  • 1
    @SamuliLehtonen: Movie-sharing newsgroups have existed on Usenet for decades without being [successfully] taken down, so it must be legally acceptable to pirate movies. – Lightness Races in Orbit Apr 03 '13 at 17:38
  • I don't really think that you can compare those two. As far as I know rockstars haven't even tried to take down the sa-mp. If we think further, why would they even want to? That mod keeps the game alive and brings new customers(you need the game before you can play the mod) It just wouldn't make sense for them to bring it down. – Samuli Lehtonen Apr 03 '13 at 18:10
  • Since when has sanity mattered to lawyers? I consider it somewhat insulting that anyone should ask questions of dubious legality on SO, whether they can justify in some way or not. Nobody is gonna come after me and take my house. – Martin James Apr 04 '13 at 00:13
  • 1
    Well since this isn't getting anywhere, I'll answer this question myself once I find it out to help others if they're looking for the same things. Also as I stated in the OP, I am not actually looking for help on some particular game(I just used those as examples) so you can't really make an assumption that every game's EULAs don't allow these things. I will find this out one way or another, whether it be from here or from somewhere else. I consider it pretty insulting that once I ask something that differs from the "ordinary type of questions", I get attacked immediately. – Samuli Lehtonen Apr 04 '13 at 12:43

1 Answers1

1

A big part of the work that needs to be done when developing such software is reverse-engineering.

This includes figuring out how the game client works and how you will be able to perform tasks with it. Things to generally look for may include:

  • the data structure / container that holds all entities of the game
  • the structure of important classes from which you will need to read information (positions, health, ammunition... )
  • ways to control the client. This starts with simple stuff like emulating key presses to calling controlling functions of the game or to directly manipulate the network traffic.

After that the preferred way to interact with the target process is to write a dynamic library (DLL). This has the main advantage that you have shared virtual memory with the target and therefore are able to dereference pointers like you would own all the data. You can directly read and write memory, call functions, detour functions etc.

If you have enough understanding of the client you can modify it up to the limits of you imagination.

It seems to me that the mod you linked also created its own server. The server will just be a regular game server (built with the information you gathered) which you have full control over. The client side needs to be implemented inside the DLL.

typ1232
  • 5,535
  • 6
  • 35
  • 51