I'm trying to get product name, vendor name and category from some VSTs. I have used this page of Teragon audio as a guide and ended up with this code:
Code: Select all
extern "C" {
VstIntPtr VSTCALLBACK hostCallback(AEffect *effect, VstInt32 opcode, VstInt32 index, VstInt32 value, void *ptr, float opt)
{
if (opcode == audioMasterVersion)
return 2400;
return 0;
}
}
Code: Select all
bool GetVSTInfo(string path, string &category, string &name, string &vendor)
{
AEffect *plugin = NULL;
HMODULE module = LoadLibrary(path.c_str());
if (module == NULL)
{
category = "Failed loading dll, " + to_string(GetLastError());
return false;
}
vstPluginFuncPtr mainEntryPoint = (vstPluginFuncPtr)GetProcAddress(module, "VSTPluginMain");
if (!mainEntryPoint)
mainEntryPoint = (vstPluginFuncPtr)GetProcAddress(module, "VstPluginMain()");
if (!mainEntryPoint)
mainEntryPoint = (vstPluginFuncPtr)GetProcAddress(module, "main");
if (!mainEntryPoint)
{
category = "No entry point";
FreeLibrary(module);
return false;
}
plugin = mainEntryPoint(hostCallback);
if (!plugin || plugin->magic != kEffectMagic)
{
category = "Bad plugin's magic number";
FreeLibrary(module);
return false;
}
dispatcherFuncPtr dispatcher = (dispatcherFuncPtr)(plugin->dispatcher);
dispatcher(plugin, effOpen, 0, 0, NULL, 0.0f);
category = "VST";
if (dispatcher(plugin, effGetPlugCategory, 0, 0, 0, 0.0f) == kPlugCategSynth)
category = "VSTi";
//char cname[kVstMaxProductStrLen] = "";
//dispatcher(plugin, effGetProductString, 0, 0, cname, 0.0f);
//name = cname;
char ceffname[kVstMaxEffectNameLen] = "";
dispatcher(plugin, effGetEffectName, 0, 0, ceffname, 0.0f);
name = ceffname;
char cvendor[kVstMaxVendorStrLen] = "";
dispatcher(plugin, effGetVendorString, 0, 0, cvendor, 0.0f);
vendor = cvendor;
dispatcher(plugin, effClose, 0, 0, NULL, 0.0f);
BOOL r = FreeLibrary(module);
return true;
}
The crashing plugins are Kuassa basiQ (it doesn't load other libraries), TDR Proximity (crashes when unloading GdiPlus.dll) and Softube Saturation Knob (crashes when unloading oleacc.dll).
- A note on GdiPlus.dll: the same file is loaded by Sonic Anomaly's SLAX.dll, but it doesn't crash when unloading. -
Do I need to support more initialization and host callback flags?
Thanks in advance.