applied patch #1912699 - "Pinned" / always loaded plugins support
this patch also adds plugin_api_version to exec_flags so your plug-in can now tell if features it needs are available more plug-ins that need this will be converted once the patch to make both the stubs and the plug-ins use the same header file is in place git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5809 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
9ac4ab0891
commit
4c30821aa5
10 changed files with 173 additions and 7 deletions
81
Source/exehead/plugin.c
Normal file
81
Source/exehead/plugin.c
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "plugin.h"
|
||||
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
|
||||
typedef struct _loaded_plugin
|
||||
{
|
||||
struct _loaded_plugin* next;
|
||||
NSISPLUGINCALLBACK proc;
|
||||
HMODULE dll;
|
||||
}
|
||||
loaded_plugin;
|
||||
|
||||
static loaded_plugin* g_plugins = 0; // not thread safe!
|
||||
|
||||
void NSISCALL Plugins_SendMsgToAllPlugins(int msg)
|
||||
{
|
||||
loaded_plugin* p;
|
||||
|
||||
for (p = g_plugins; p; p = p->next)
|
||||
{
|
||||
p->proc(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void NSISCALL Plugins_UnloadAll()
|
||||
{
|
||||
loaded_plugin* p = g_plugins;
|
||||
|
||||
Plugins_SendMsgToAllPlugins(NSPIM_UNLOAD);
|
||||
|
||||
while (p)
|
||||
{
|
||||
loaded_plugin* oldp = p;
|
||||
p = oldp->next;
|
||||
FreeLibrary(oldp->dll);
|
||||
GlobalFree(oldp);
|
||||
}
|
||||
|
||||
g_plugins = NULL;
|
||||
}
|
||||
|
||||
BOOL NSISCALL Plugins_CanUnload(HANDLE pluginHandle)
|
||||
{
|
||||
loaded_plugin* p;
|
||||
|
||||
for (p = g_plugins; p; p = p->next)
|
||||
{
|
||||
if (p->dll == pluginHandle)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NSISCALL RegisterPluginCallback(HMODULE pluginHandle, NSISPLUGINCALLBACK proc)
|
||||
{
|
||||
loaded_plugin* p;
|
||||
|
||||
if (!Plugins_CanUnload(pluginHandle))
|
||||
{
|
||||
// already registered
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
p = (loaded_plugin*) GlobalAlloc(LPTR, sizeof(loaded_plugin));
|
||||
if (p)
|
||||
{
|
||||
p->proc = proc;
|
||||
p->dll = pluginHandle;
|
||||
p->next = g_plugins;
|
||||
|
||||
g_plugins = p;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* #ifdef NSIS_CONFIG_PLUGIN_SUPPORT */
|
Loading…
Add table
Add a link
Reference in a new issue