# HG changeset patch # User Chris Cannam # Date 1528713107 -3600 # Node ID 4b619c5871eeded4de7532890f3e0c44586194aa # Parent 54277cb679ffd1fd2dd439cb5a6a3eadf8f2263a Use VAMP_PATH_32 environment variable instead of VAMP_PATH, when running in a 32-bit process within 64-bit Windows (WoW64) diff -r 54277cb679ff -r 4b619c5871ee src/vamp-hostsdk/Files.cpp --- a/src/vamp-hostsdk/Files.cpp Fri Jun 08 11:25:19 2018 +0100 +++ b/src/vamp-hostsdk/Files.cpp Mon Jun 11 11:31:47 2018 +0100 @@ -324,6 +324,48 @@ } bool +Files::isNonNative32Bit() +{ + // Return true if we are running on a system for which we should + // use the VAMP_PATH_32 variable instead of VAMP_PATH. This will + // be the case if we are a 32-bit executable but the OS is + // natively 64-bit. + // + // This currently works only on Windows; other operating systems + // will use VAMP_PATH always. + + if (sizeof(void *) == 8) { + return false; + } + +#ifdef _WIN32 + BOOL wow64 = FALSE; + BOOL (WINAPI *fnIsWow64Process)(HANDLE, PBOOL) = + (BOOL (WINAPI *)(HANDLE, PBOOL)) GetProcAddress + (GetModuleHandle(TEXT("kernel32")), "IsWow64Process"); + if (fnIsWow64Process) { + if (fnIsWow64Process(GetCurrentProcess(), &wow64)) { + if (wow64) { + return true; + } else { + return false; + } + } else { + cerr << "Vamp::HostExt: Unable to query process architecture" + << endl; + return false; + } + } else { + cerr << "Vamp::HostExt: Unable to query process architecture: " + << "Function not available" << endl; + return false; + } +#endif + + return false; +} + +bool Files::getEnvUtf8(std::string variable, std::string &value) { value = ""; diff -r 54277cb679ff -r 4b619c5871ee src/vamp-hostsdk/Files.h --- a/src/vamp-hostsdk/Files.h Fri Jun 08 11:25:19 2018 +0100 +++ b/src/vamp-hostsdk/Files.h Mon Jun 11 11:31:47 2018 +0100 @@ -63,6 +63,7 @@ static std::string splicePath(std::string a, std::string b); static std::vector listFiles(std::string dir, std::string ext); + static bool isNonNative32Bit(); static bool getEnvUtf8(std::string variable, std::string &value); }; diff -r 54277cb679ff -r 4b619c5871ee src/vamp-hostsdk/PluginHostAdapter.cpp --- a/src/vamp-hostsdk/PluginHostAdapter.cpp Fri Jun 08 11:25:19 2018 +0100 +++ b/src/vamp-hostsdk/PluginHostAdapter.cpp Mon Jun 11 11:31:47 2018 +0100 @@ -72,7 +72,11 @@ std::vector path; std::string envPath; - (void)Files::getEnvUtf8("VAMP_PATH", envPath); + if (Files::isNonNative32Bit()) { + (void)Files::getEnvUtf8("VAMP_PATH_32", envPath); + } else { + (void)Files::getEnvUtf8("VAMP_PATH", envPath); + } #ifdef _WIN32 #define PATH_SEPARATOR ';'