Managing 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.dllextension
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:
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.
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.
Mod-to-Mod Dependencies
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:
[
{
"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:
[
{
"name": "NitroBoost",
"version": "1.2.4"
}
]If one of the mod dependencies failed to load, the mod parser will report a failure for that mod.
Mod load priorities
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:
ImportantOptional
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.
override ModLoadPriority LoadPriority =>
ModLoadPriority.Optional;Mod Inter-communication
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
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