VST scan

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi all. I'm doing some experiments on vst scanning using SWS extension in Reaper as a base.
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;
}
but with some plugins the function GetVSTInfo() crashes when returning with error STATUS_STACK_BUFFER_OVERRUN.
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.

Post

Nobody?

Post

Have you used the debugger to see what calls with what parameters lead to the crashes?

Also, best to get used to the idea that the largest amount of work in a VST host is going to be working around bugs and quirks in the plugins. (For all intents and purposes you will be implementing a host even if it's just for scanning some basic plugin infos...)

Post

Hi thanks for the answer. I have used this utility to get all messages between the host and the plugins. I checked the crashing plugins and some other and I found out that the same calls are always made. I have added some flags in the host callback, but nothing changed.
I will add some more debugging log.

I don't get why Proximity (for example) crashes while SLAX doesn't even if they load the same dll, so I thought the problem can be in the messages I send to the plug. The same can apply to the other plugs.

I have also searched for STATUS_STACK_BUFFER_OVERRUN and it seems it can be caused by different calling convention, but in the code I am always using VSTCALLBACK, which is __cdecl.

Post

The joys of vst scanning.... you will need to support a few more calls in addition to audioMasterVersion:

- audioMasterGetTime (just return a fixed data structure with a valid tempo)
- audioMasterGetSampleRate (return a fixed 44100 rate)
- audioMasterGetBlockSize (return 512 or something like that)
- audioMasterGetVendorString and audioMasterGetProductString

You will also need specific code for shell plugins, if you want to support these.

Post

Big Tick wrote:
You will also need specific code for shell plugins, if you want to support these.
Just a general inquiry: are shell plugins a bad idea, or are they just misunderstood?. I haven't dealt with them except for trying to get Waves plugins recognized. They are of thee devil! :evil:
I started on Logic 5 with a PowerBook G4 550Mhz. I now have a MacBook Air M1 and it's ~165x faster! So, why is my music not proportionally better? :(

Post

To me they are a curiosity. I never understood the need for them, but because of Waves you typically will need to support them if you are writing a VST host.

Post Reply

Return to “DSP and Plugin Development”