141 {
142 auto wideStr = StringConvert::convert (inPath);
143 mModule = LoadLibraryW (
reinterpret_cast<LPCWSTR
> (wideStr.data ()));
145 {
146 filesystem::path p (inPath);
147 auto filename = p.filename ();
148 p /= "Contents";
150 p /= filename;
151 wideStr = StringConvert::convert (p.string ());
152 mModule = LoadLibraryW (
reinterpret_cast<LPCWSTR
> (wideStr.data ()));
154 {
155 auto lastError = GetLastError ();
156 LPVOID lpMessageBuffer;
157 FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
158 nullptr, lastError, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
159 (LPSTR)&lpMessageBuffer, 0, nullptr);
160 errorDescription = "LoadLibray failed: " + std::string ((char*)lpMessageBuffer);
161 LocalFree (lpMessageBuffer);
162
163 return false;
164 }
165 }
166 auto factoryProc = getFunctionPointer<GetFactoryProc> ("GetPluginFactory");
167 if (!factoryProc)
168 {
169 errorDescription = "The dll does not export the required 'GetPluginFactory' function";
170 return false;
171 }
172
173 auto dllEntry = getFunctionPointer<InitModuleFunc> ("InitDll");
174 if (dllEntry && !dllEntry ())
175 {
176 errorDescription = "Calling 'InitDll' failed";
177 return false;
178 }
179 auto f = Steinberg::FUnknownPtr<Steinberg::IPluginFactory> (owned (factoryProc ()));
180 if (!f)
181 {
182 errorDescription = "Calling 'GetPluginFactory' returned nullptr";
183 return false;
184 }
186 return true;
187 }
constexpr auto architectureString