-
-
Notifications
You must be signed in to change notification settings - Fork 0
API Loader
3cxc edited this page Sep 13, 2026
·
2 revisions
Plugin loading and lifecycle management.
public unsafe class PluginLoader
{
public PluginLoader(Action<string> logAction,
HostApiTable apiTable,
Version apiVersion);
public HostApiTable Api { get; }
public Action<string> LogWriter { get; }
public Version CurrentApiVersion { get; }
public bool LoadPlugin(string dllPath);
public void LoadPluginsFromDirectory(string directoryPath);
public void UnloadAll();
}Loads a single plugin DLL/SO/DYLIB.
Steps performed:
-
LoadLibrary(Windows) ordlopen(Unix). - Read
GetPluginInfo→PluginInfo. - Reject if the plugin requests an incompatible API version.
- Read
OnInitand invoke it with a pointer to theHostApiTable. - Record the handle for later
UnloadAll.
The module handle is kept alive for the host's lifetime.
Enumerates *.dll / *.so / *.dylib (based on the compile-time platform) and calls LoadPlugin for each. Silently returns if the directory does not exist.
Iterates every loaded plugin:
- Calls the exported
OnStopif present. -
FreeLibrary/dlclose.
After UnloadAll, the plugin loader is empty and can be reused.