Skip to content

Legacy: PluginEntry routine

Archie_UwU edited this page Nov 19, 2023 · 1 revision

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.

Example

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.

Syntax

YYTKStatus PluginEntry(
    YYTKPlugin* PluginObject
);

Parameters

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)

Return Value

The function must return YYTK_OK if initialization succeeds. Otherwise, it returns a matching YYTKStatus to help with troubleshooting.

Remarks

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 or UnloadPlugin - 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.

Quick Access

Documentation

Writeups

Clone this wiki locally