Skip to content

v2 changes

devilExE edited this page Jan 5, 2024 · 3 revisions

Preface

It's been a long time since i worked on this project and I decided to re-write the whole injection process because the old one wasn't very reliable. It suddenly stopped working, so a fix was needed.

Here I explain the architecture differences from v1 to v2, and the whole injection process.

Main change

Loadson now uses UnityDoorstop instead of MInject to load the Kernel

Also instead of launching from the Bootstrapper (Loadson.exe), you now need to start Karlson directly.

UnityDoorstop automatically injects the Kernel (now renamed _Loadson.dll) into the game

Kernel activity (_Loadson.dll)

When injected and executed by UnityDoorstop (UD for short), the kernel launches the UpdateChecker.exe which checks and updates all the files needed for Loadson.

This is needed because TLS 1.2 is not natively supported by the Mono engine that runs Karlson, and the way UD executes the Kernel is a bit dodgy.

UpdateChecker has the same code as the Bootstrapper, just checking the filetree and hashmap (from deployment branch) and comparing to local files

After UpdateChecker is done, the new Launcher.exe gets executed as a child process

This is more or less the same as the old one, just fewer options, and communicates with the Kernel via the exit code.

Depending on what exit code the Launcher returns, the Kernel does the following:

  • case 0: close the whole process tree (aka do nothing, abort starting the game), because the user pressed X (or closed the window)
  • case 1: run the game without loading Loadson, because the user pressed Run Karlson Vanilla
  • case 2: inject the main Loadson module

The injection process is just a bit complicated, because we need to wait for the user to go past the configuration screen

(also, configuration screen is now back, in v1 Windows Messages were used to send VK_RETURN as soon as the window popped up, so MInject would work properly)

Other than that it's just normal C# Reflection.

Launch Flags

The kernel looks for the following flags: (which can be passed by creating a shortcut, or running from CMD like Karlson.exe -vanilla)

  • -vanilla: This simply exits the Kernel immediately and Karlson resumes running normally (vanilla)
  • -silent: This flags tells the Kernel to jump directly to injecting, skipping the Launcher.exe
  • -debug: This tells the Kernel not to Update Check, because you (or me) are running custom files.

Kernel Auto-update

The kernel now auto-updates, because this functionality is needed. (Kernel update isn't skipped by the -debug flag)

With the old structure, the Bootstrapper would take care of everything, but now the Kernel is kind of the Bootstrapper

The main Loadson module simply checks for the _Loadson.md5 file on the deployment branch and compares it locally.

If an update is needed, the user is asked, and it auto-updates and restarts Loadson.

Install process / Auto update from v1 to v2

The new Launcher.exe accounts for two cases:

running on the old architecture (the Bootstrapper did its job, updating all files, and running Launcher.exe)

in this case the user is asked to install 'additional files' to the game directory

this simply downloads the files found in the Karlson directory on the deployment branch to your current Karlson directory

running on v2

the launcher works as expected



If you are just installing Loadson, the same process happens, initially running on v1 architecture

The only difference is that you are asked to select your Karlson directory (clean install)

Small changes to Loadson

A few functions were moved from the original Start method to the first Harmony Hooked method (because of Unity modules BS)

The in-game mod disable button was removed. This is because I think not a lot of people used it (mainly me for testing it LOL)

You can still enable/disable mods from the Launcher screen.

Also brand new feature, Loadson now allows natively running UnityExplorer. If you want to do so check the wiki page for it

Why did I make this article?

Because I wanted to be more transparent to the community, which probably don't have the time to look into the code and understand the whole process that happens behind the scenes for Loadson.

Final words

I hope that v2 won't be as buggy as v1

Also if you have any questions, don't hesitate to ping me ( @devilexe3 ) on the modding channel and ask me.

Clone this wiki locally