Files
SonicForgeStudio/native_bridge/include/VstDllSearch.h
T
3dtours 1acb6f23f1 fix(bridge): 0x7E iZotope — append core DLL dirs (Program Files/iZotope/*/Cores) vao PATH truoc Module::create
iZotope VST3 single-file (Ozone 11.vst3) reference core DLL
(iZOzone11Core.dll) dat rieng o C:\Program Files\iZotope\<Product>\Cores,
khong canh .vst3. SetDllDirectoryW chi phu dir canh plugin -> LoadLibraryW
fail ERROR_MOD_NOT_FOUND (0x7E) -> Windows dialog khi app load plugin.
VstDllSearch.h quet cac dir Cores co dinh + append vao PATH (process-global,
bridge load 1 plugin 1 luc). Ap dung ca RenderFxJob (FX chain + scan) va
Vst3Instrument (VSTi).
2026-09-01 18:08:10 +07:00

72 lines
2.6 KiB
C++

// native_bridge/include/VstDllSearch.h
// iZotope VST3 (Ozone 11, Nectar, Neutron...) là single-file .vst3 — core
// DLL (vd iZOzone11Core.dll) nằm RIÊNG ở
// C:\Program Files\iZotope\<Product>\Cores
// KHÔNG cạnh plugin → LoadLibraryW của VST3 SDK fail ERROR_MOD_NOT_FOUND
// (0x7E) dù setPluginSearchPath đã trỏ dir cạnh plugin. Helper này quét các
// dir Cores cố định và thêm vào PATH (process-global — bridge load 1 plugin
// 1 lúc, giống SetDllDirectoryW hiện có).
#ifndef VST_DLL_SEARCH_H
#define VST_DLL_SEARCH_H
#include <string>
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef _WIN32
inline std::string vstDllSearchExtras() {
std::string extras;
const char* bases[] = {
"C:\\Program Files\\iZotope",
"C:\\Program Files\\Common Files\\iZotope",
};
for (const char* base : bases) {
std::string pat = std::string(base) + "\\*";
WIN32_FIND_DATAA fd;
HANDLE h = FindFirstFileA(pat.c_str(), &fd);
if (h == INVALID_HANDLE_VALUE) continue;
do {
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) continue;
if (fd.cFileName[0] == '.') continue;
std::string cores = std::string(base) + "\\" + fd.cFileName + "\\Cores";
if (GetFileAttributesA(cores.c_str()) != INVALID_FILE_ATTRIBUTES) {
if (!extras.empty()) extras += ";";
extras += cores;
}
} while (FindNextFileA(h, &fd));
FindClose(h);
}
return extras;
}
// Append extras vào PATH (bỏ dir đã có). Gọi TRƯỚC Module::create.
inline void vstAddDllSearchPath(const std::string& extras) {
if (extras.empty()) return;
char buf[32768];
DWORD n = GetEnvironmentVariableA("PATH", buf, sizeof(buf));
std::string path = n ? std::string(buf) : "";
std::string toAdd;
size_t start = 0;
while (start <= extras.size()) {
size_t end = extras.find(';', start);
std::string dir = extras.substr(start, end == std::string::npos ? std::string::npos : end - start);
if (!dir.empty() && path.find(dir) == std::string::npos) {
if (!toAdd.empty()) toAdd += ";";
toAdd += dir;
}
if (end == std::string::npos) break;
start = end + 1;
}
if (toAdd.empty()) return;
if (!path.empty()) path += ";";
path += toAdd;
SetEnvironmentVariableA("PATH", path.c_str());
}
#else
inline std::string vstDllSearchExtras() { return std::string(); }
inline void vstAddDllSearchPath(const std::string&) {}
#endif
#endif // VST_DLL_SEARCH_H