Reverse engineering is taking apart an object to see how it works in order to duplicate or enhance the object. So in our case we will be taking apart the game source to create mods for it. Here you can read how to do this properly and efficient. There are of course other methods then the ones described here but this method will work fine for most. If you only want to work with the API you don’t really need any of these things.
The method described below also applies to other mods. This means you can read the source code of other mods and learn from it. It can also be used to check for malicious code.
The game source¶
It is possible to browse through the source code of the game. This means you can read how the game is build, what all methods do, what classes there are and so on. We have to thanks Pardox/CO for not obfuscating the code else this wouldn’t be as easy as it is now. Mods can still obfuscate their code but it’s really not recommended to do so. People will most likely report your mods as it can’t really be trusted. Even with obfuscation it’s possible to read the code but it makes it a lot harder and a lot easier to put in malicious code.
To decompile the assembly and browse through it, you will need a
There are many programs that can do this but for this guide we will be using ILSpy.
Some other good alternatives are DotPeek, JustDecompile or built in options in your IDE.
- Download ILSpy here (Download binaries)
- Extract the ZIP somwhere on your hard drive (It doesn’t have an installer)
- Open The program. (
- Load in the needed assemblies (.dll)
You can now browse through all the classes in the assembly. And when you click on any of the classes they will open up and you can see all the code. Remember that you can search!
Using the ModTools mod¶
Thanks to nlight we now have a mod that can help with reverse engineering. This mod has a scene explorer which allows you to examine all objects in the scene. It doesn’t just list the objects it also shows all the components, fields, properties and methods. This will help you a lot with understanding how the game works and find the parts of the code you need. It also has some other useful features like logging exceptions in the console so make sure to check it out! ModTools by nlight.