Hi,
I'm trying to load a plugin, which is not located in the plugin-paths of After Effects from another plugin. It seems to load the aex(dll) and execute the main function fine, but afterwards it crashes immediately and I have no idea why.
This is how my pluginLoader-PlugIn looks like:
1. I created a commandHook to be able to trigger the pluginLoad from the Edit Menu
2. for the actual load of the dll I use the following commands:
AEGP_SuiteHandler suites(basic_suite); std::string dllName = "C:/PATH/TO/plugin.aex"; // defining type and order of the arguments of the entry function typedef A_Err (*args_type)(SPBasicSuite *pica_basicP, A_long major_versionL, A_long minor_versionL, A_long aegp_plugin_id, AEGP_GlobalRefcon *global_refconP); args_type pluginEntryMethod = NULL; // loading the dll(aex) and the entry function # ifdef _WIN32 HMODULE hDLL = LoadLibrary(dllName.c_str()); if (hDLL != NULL) { pluginEntryMethod = (args_type) GetProcAddress(hDLL, "EntryPointFunc"); } else { return err; } # else void *pLib = ::dlopen(szMyLib, RTLD_LAZY); if (pLib != NULL) { pluginEntryMethod = (args_type)::dlsym(pLib, "EntryPointFunc"); } else { return err; } # endif if (pluginEntryMethod != NULL) { // hardcoding the plugin version A_long mavL = 0L; A_long mivL = 1L; AEGP_PluginID plId; // to get a valid plugin-id I use this command suites.UtilitySuite3()->AEGP_RegisterWithAEGP(*globalRefcon, "nameOfPlugin", &plId); // I create copy of the refcon and the suite AEGP_GlobalRefcon newRefcon(*globalRefcon); SPBasicSuite newSuite(*basic_suite); pluginEntryMethod(&newSuite, mavL, mivL, plId, &newRefcon); } # ifdef _WIN32 FreeLibrary(hDLL); # else dlclose(pLib); # endif
If I run After Effects with the debugger, the EntryFunction of the new plugin runs through without errors. But Then it crashes and stops at random positions: sometimes in the IdleHook of the newly loaded Plugin, sometimes in the MenuHook.
Does anyone have an idea, what I am doing wrong?
btw: when I copy the second plugin in the default Afx-Plugin-Folder it loads fine and seems to work correct.
Thanks for your help!
Martin