Index: mptrack/Vstplug.cpp =================================================================== --- mptrack/Vstplug.cpp (revision 14002) +++ mptrack/Vstplug.cpp (working copy) @@ -94,7 +94,7 @@ } -AEffect *CVstPlugin::LoadPlugin(bool maskCrashes, VSTPluginLib &plugin, HMODULE &library, bool forceBridge) +AEffect *CVstPlugin::LoadPlugin(bool maskCrashes, VSTPluginLib &plugin, HMODULE &library, bool forceBridge, bool forceLegacy) { const mpt::PathString &pluginPath = plugin.dllPath; @@ -106,7 +106,7 @@ { try { - effect = BridgeWrapper::Create(plugin); + effect = BridgeWrapper::Create(plugin, forceLegacy); if(effect != nullptr) { return effect; Index: mptrack/Vstplug.h =================================================================== --- mptrack/Vstplug.h (revision 14002) +++ mptrack/Vstplug.h (working copy) @@ -77,7 +77,7 @@ CVstPlugin(bool maskCrashes, HMODULE hLibrary, VSTPluginLib &factory, SNDMIXPLUGIN &mixPlugin, Vst::AEffect &effect, CSoundFile &sndFile); ~CVstPlugin(); - static Vst::AEffect *LoadPlugin(bool maskCrashes, VSTPluginLib &plugin, HMODULE &library, bool forceBridge); + static Vst::AEffect *LoadPlugin(bool maskCrashes, VSTPluginLib &plugin, HMODULE &library, bool forceBridge, bool forceLegacy); protected: void Initialize(); Index: pluginBridge/BridgeWrapper.cpp =================================================================== --- pluginBridge/BridgeWrapper.cpp (revision 14002) +++ pluginBridge/BridgeWrapper.cpp (working copy) @@ -257,11 +257,11 @@ // Create a plugin bridge object -AEffect *BridgeWrapper::Create(const VSTPluginLib &plugin) +AEffect *BridgeWrapper::Create(const VSTPluginLib &plugin, bool forceLegacy) { BridgeWrapper *wrapper = new(std::nothrow) BridgeWrapper(); BridgeWrapper *sharedInstance = nullptr; - const Generation wantedGeneration = plugin.modernBridge ? Generation::Modern : Generation::Legacy; + const Generation wantedGeneration = (plugin.modernBridge && !forceLegacy) ? Generation::Modern : Generation::Legacy; // Should we share instances? if(plugin.shareBridgeInstance) Index: pluginBridge/BridgeWrapper.h =================================================================== --- pluginBridge/BridgeWrapper.h (revision 14002) +++ pluginBridge/BridgeWrapper.h (working copy) @@ -200,7 +200,7 @@ static bool IsPluginNative(const mpt::PathString &pluginPath) { return GetPluginBinaryType(pluginPath) == GetNativePluginBinaryType(); } static uint64 GetFileVersion(const WCHAR *exePath); - static Vst::AEffect *Create(const VSTPluginLib &plugin); + static Vst::AEffect *Create(const VSTPluginLib &plugin, bool forceLegacy); protected: BridgeWrapper(); Index: soundlib/plugins/PluginManager.cpp =================================================================== --- soundlib/plugins/PluginManager.cpp (revision 14002) +++ soundlib/plugins/PluginManager.cpp (working copy) @@ -533,6 +533,7 @@ } #ifndef NO_VST + bool requiresLegacyBridge = false; unsigned long exception = 0; // Always scan plugins in a separate process HINSTANCE hLib = NULL; @@ -542,7 +543,9 @@ ExceptionHandler::ContextSetter ectxguard{&ectx}; #endif // MODPLUG_TRACKER - Vst::AEffect *pEffect = CVstPlugin::LoadPlugin(maskCrashes, *plug, hLib, true); + Vst::AEffect *pEffect = nullptr; + + pEffect = CVstPlugin::LoadPlugin(maskCrashes, *plug, hLib, true, false); if(pEffect != nullptr && pEffect->magic == Vst::kEffectMagic && pEffect->dispatcher != nullptr) { @@ -568,6 +571,42 @@ validPlug = true; } + if(!validPlug || (exception != 0)) + { + validPlug = false; + exception = 0; + pEffect = nullptr; + + requiresLegacyBridge = true; + + pEffect = CVstPlugin::LoadPlugin(maskCrashes, *plug, hLib, true, true); + + if(pEffect != nullptr && pEffect->magic == Vst::kEffectMagic && pEffect->dispatcher != nullptr) + { + CVstPlugin::DispatchSEH(maskCrashes, pEffect, Vst::effOpen, 0, 0, 0, 0, exception); + + plug->pluginId1 = pEffect->magic; + plug->pluginId2 = pEffect->uniqueID; + + GetPluginInformation(maskCrashes, pEffect, *plug); + +#ifdef VST_LOG + intptr_t nver = CVstPlugin::DispatchSEH(maskCrashes, pEffect, Vst::effGetVstVersion, 0,0, nullptr, 0, exception); + if (!nver) nver = pEffect->version; + MPT_LOG(LogDebug, "VST", MPT_UFORMAT("{}: v{}.0, {} in, {} out, {} programs, {} params, flags=0x{} realQ={} offQ={}")( + plug->libraryName, nver, + pEffect->numInputs, pEffect->numOutputs, + mpt::ufmt::dec0<2>(pEffect->numPrograms), mpt::ufmt::dec0<2>(pEffect->numParams), + mpt::ufmt::HEX0<4>(static_cast(pEffect->flags)), pEffect->realQualities, pEffect->offQualities)); +#endif // VST_LOG + + CVstPlugin::DispatchSEH(maskCrashes, pEffect, Vst::effClose, 0, 0, 0, 0, exception); + + validPlug = true; + } + + } + } FreeLibrary(hLib); if(exception != 0) @@ -574,6 +613,13 @@ { CVstPluginManager::ReportPlugException(MPT_UFORMAT("Exception {} while trying to load plugin \"{}\"!\n")(mpt::ufmt::HEX0<8>(exception), plug->libraryName)); } + + if(requiresLegacyBridge) + { + plug->useBridge = true; + plug->modernBridge = false; + } + #endif // NO_VST // Now it should be safe to assume that this plugin loaded properly. :) @@ -720,7 +766,7 @@ HINSTANCE hLibrary = nullptr; bool validPlugin = false; - pEffect = CVstPlugin::LoadPlugin(maskCrashes, *pFound, hLibrary, TrackerSettings::Instance().bridgeAllPlugins); + pEffect = CVstPlugin::LoadPlugin(maskCrashes, *pFound, hLibrary, TrackerSettings::Instance().bridgeAllPlugins, false); if(pEffect != nullptr && pEffect->dispatcher != nullptr && pEffect->magic == Vst::kEffectMagic) {