gitlabEdit

wrenchManaging your Mod

This page describes how to manage your kernel mods

Kernel modification files are stored in the following directories that are found under the kernel configuration directory:

  • KSMods: Stores all the modifications under the .dll extension


Mod finalization

The mod finalization phase gets executed as soon as the mod parser sees the file as a mod (a .dll assembly that implements IMod from Nitrocid.Kernel.Extensions), with a call to the FinalizeMods() function. Here's what it does:

1

Verifies the script

If it sees the script as an instance of IMod, it fires the ModParsed event

2

Adds the path to the assembly lookup path list

Adds mod dependency path to the assembly lookup path (KSMods/Deps/Mod-FileVersion/)

3

Checks the API version

Checks the expected mod API minimum version with the kernel API version to see if there is a mismatch.

  • If the checker found that the mod needs a higher API version, the mod parsing fails with the appropriate message.

  • If the checker couldn't determine the minimum API version required by the kernel mod, it goes ahead, but with a warning that the mod may fail to start.

4

Checks some more properties

Mod parsing fails if:

  • the mod has no name.

  • the version is not a SemVer 2.0 compliant version, or if the version is empty.

5

Satisfies the mod dependencies

Satisfies the mod dependencies by loading them as appropriate.

6

Runs the startup function

Calls the script.StartMod() function in your script

7

Adds the mod

Adds the mod to the mod manager

circle-info

The mod system will automatically unload the target mod's directory for assembly lookup. If, for some reason, this fails, you can manually unload their paths from the lookup using the below function:

RemovePathFromAssemblySearchPath(Path);

Some useful tools

You can make use of some of the useful tools when dealing with mods.

chevron-rightMod-to-Mod Dependencieshashtag

If you want mods to depend on other mods, you can create a JSON file, called the dependency list file, that holds information about the mod name and the required mod version. The format for the dependency list file should be:

Mod-moddeps.json
[
    {
        "name": "Mod2",
        "version": "1.0.0"
    }
]

The dependencies list file should be saved as the name which satisfies this format: ModName-moddeps.json. For example, if your mod, called ProjectVision, depends on another mod, called NitroBoost, you must create that file called ProjectVision-moddeps.json that contains the following contents:

ProjectVision-moddeps.json
[
    {
        "name": "NitroBoost",
        "version": "1.2.4"
    }
]
triangle-exclamation
chevron-rightMod load prioritieshashtag

Important mods, including those that load splashes on boot, get loaded after the configuration files load, so people who use custom splashes in their kernel configuration will actually see their custom splashes when the kernel starts up.

However, for optional mods, they get loaded late so they can load properly. This loading is done by scanning the KSMods directory and querying every .DLL file with ParseMod().

Controlling the priority

You can control when your mod loads (early or late) by overriding the AddonType enumeration to point to one of the correct mod priorities, depending on your mod:

  • Important

  • Optional

Important mods get loaded before the kernel configuration loads, while the optional ones get loaded after the hardware gets parsed before the system verification stage.

Your mod code
override ModLoadPriority LoadPriority =>
    ModLoadPriority.Optional;
chevron-rightMod Inter-communicationhashtag

In addition to the above mod management tools, Nitrocid KS provides you with tools that allow you to communicate with either the other mods or the other addons that implement their public static functions, fields, or properties.

To get started, follow the two pages below, depending on the type of the communication, to get started:

Inter-Mod CommunicationInter-Addon Communication

circle-info

Mod management classes require that you use the inter-addon communication being done against the Nitrocid.Extras.Mods addon.

For example, to manage blacklisted mods, do this:

Last updated