-
Notifications
You must be signed in to change notification settings - Fork 13
Legacy: PluginEntry routine
You are reading the documentation of YYToolkit Legacy (v2.x.x) - for documentation on current-gen YYTK, see the Homepage.
The PluginEntry routine is called exactly once after a plugin is loaded, and is responsible for initializing it.
For plugins located in the autoexec
folder, this routine is called prior to YYTK's Core hooks initializing.
For plugins loaded dynamically, the routine is called immediately.
DllExport YYTKStatus PluginEntry(
YYTKPlugin* PluginObject // A pointer to the dedicated plugin object
)
{
// Initialize the plugin, set callbacks inside the PluginObject.
// Set-up buffers.
return YYTK_OK; // Successful PluginEntry.
}
This is an example of a PluginEntry function.
YYTKStatus PluginEntry(
YYTKPlugin* PluginObject
);
The internal object representing a plugin entry. You may keep a pointer to this object, as it is always accessible throughout the lifetime of the plugin (ie. from the start of PluginEntry()
, up until the end of the optional PluginUnload
)
The function must return YYTK_OK
if initialization succeeds. Otherwise, it returns a matching YYTKStatus
to help with troubleshooting.
The PluginEntry
routine must always be exported, or else initialization fails - any other functions defined in the plugin module (DLL) can optionally be exported as well.
Due to this function being called synchronously before any other initialization is done in the core, the following is prohibited inside the routine:
- Infinite loops.
- Recursive functions with no break conditions.
- Calling
LoadPlugin
orUnloadPlugin
- this may load more plugins / unload the current one. - Synchronizing with other threads - this can cause a deadlock.
The following is 100% safe:
- Open, read from, and write to files.
- Allocate memory and initialize dynamic data structures.
- Set global pointers to
nullptr
, putting off the initialization of dynamic members. - Call API functions.
- Initializing callbacks.