Modding Wiki
  • 🏠Home
  • 🫂How to contribute
  • Playing with Mods
    • Discovering Mods
    • Installing Mods
      • On Game Clients
      • For Multiplayer
      • On Dedicated Servers
      • No Console Support
    • Troubleshooting
    • Reporting Bugs
    • Uninstalling Mods
  • Creating Mods
    • Getting Started Modding
      • Setting Up the Modding SDK
      • Testing the Example Mods
      • Viewing Console Logs
    • Modding Limitations
    • Inspecting Other Mods' Code
    • Modding Tools
      • Scripting IDE
      • Unity Explorer
      • Asset Ripper
      • NG Tools Missing Script Recovery
      • DnSpy
      • Attaching a Debugger
    • Common Concepts
      • Unique Names and IDs
    • Modding Libraries
      • CoreLib
    • Modding Examples
      • Items
        • Weapons and Tools
        • Armor
        • Food
      • Obtaining items
        • Adding Crafting Recipe
        • Adding your items to crafters
        • Adding items to Enemy loot
      • Placeables
        • Tiles
      • NPCs and Enemies
      • UI and Interactions
      • Client-Server communications
    • Inspecting Base Game Content
      • Importing Ripped Assets to your Editor
      • Inspecting Assets In-Game
      • Inspecting Game Code
    • Updating your Modding SDK
    • Releasing Mods
      • Create a mod.io Page
      • Mod Files Upload
  • Concepts
    • Important Folder Paths
    • Technologies and Tools
    • Elevated Access
  • Archive
    • General Reference
    • Outdated Unity Setup Guide
    • Outdated IL2CPP Guides
      • Getting started with modding
      • How to view game source code
      • How to setup your Unity project
      • How to install Core Keeper mono version
Powered by GitBook
On this page
  • Using Cpp2IL
  • Guide Deprecated
  • Using Ghidra / IDA
  • Guide Deprecated

Was this helpful?

Edit on GitHub
Export as PDF
  1. Archive
  2. Outdated IL2CPP Guides

How to view game source code

PreviousGetting started with moddingNextHow to setup your Unity project

Last updated 8 months ago

Was this helpful?

You can use DnSpy to view game code. To set this up follow these steps:

  1. Using DnSpy navigate to the game's asseblies, which can be found in <game path>/CoreKeeper_Data/Managed folder

Using Cpp2IL

Guide Deprecated

This guide was made for IL2CPP version of Core Keeper and no longer applies. Please refer to:

can generate .NET assemblies which can be open with DnSpy.

To generate these assemblies you need to use the tool in the command line with following options: .\Cpp2IL.exe --game-path "<path to your core keeper installation>" --just-give-me-dlls-asap-dammit

Note that the source code is divided into three assemblies (Pug.Core, Pug.Other and PugWorldGen) and to let Cpp2Il know you want to analyze them you need to use one of these:

  • --run-analysis-for-assembly <assembly name>. When using it you will need to run the tool three times and combine the output.

  • --analyze-all. This option will analyze all the assemblies, but it will take much longer.

After running the tool you will see new folder cpp2il_out. You can now use DnSpy to read the source code.

Using Ghidra / IDA

Guide Deprecated

Using a binary reverse engineering tool we can get more precise output. You can use both Ghidra and IDA for this, but since Ghidra is free this guide will be focused on it.

Il2CppDumper.exe <executable-file> <global-metadata>

GameAssembly.dll is the executable file you need, and you will find global metadata file in Core Keeper\CoreKeeper_Data\il2cpp_data\Metadata\.

After the tool is done executing you should see il2cpp.h, dump.cs and script.json files. These files contain metadata information we need. To import it into Ghidra first open the GameAssembly.dll with ghidra.

NOTE: For best results, choose No when Ghidra asks if you would like to perform auto-analysis when the binary is first loaded. If you receive a Conflicting data exists at address error when running the script below, re-load the binary into the project and choose No at the auto-analysis prompt.

NOTE: To significantly speed up analysis for ELF files, set the image base to zero (0x00000000) in the load options for the binary.

To import metadata into an existing Ghidra project:

  1. From the Code Browser, choose File -> Parse C Source...

  2. Create a new profile and add the generated C++ type header file. This is il2cpp.h.

  3. Ensure the Parse Options are set exactly as follows:

    -D_GHIDRA_

  4. Click Parse to Program and accept any warnings. This may take a long time to complete.

  5. Open the Script Manager and add the output folder of the Il2CppDumper.

  6. Click Refresh to make the script appear in Script Manager.

  7. Right-click the script and choose Run. The script is going to ask for script.json file, which you can find in the Il2CppDumper output folder. This may take a while to complete.

This guide was made for IL2CPP version of Core Keeper and no longer applies. Please refer to:

Unfortunately using these tools alone would also provide bad results. We need to add Il2Cpp metadata (Which contains information about all types, methods and fields) to the Ghidra. To do so we will use , in your command line type:

https://mod.io/g/corekeeper/r/core-keeper-mod-sdk-introduction
Cpp2Il
https://mod.io/g/corekeeper/r/core-keeper-mod-sdk-introduction
Il2CppDumper