Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
VST3::Hosting::anonymous_namespace{module_win32.cpp}::Win32Module Class Reference
Inheritance diagram for VST3::Hosting::anonymous_namespace{module_win32.cpp}::Win32Module:
[legend]
Collaboration diagram for VST3::Hosting::anonymous_namespace{module_win32.cpp}::Win32Module:
[legend]

Public Member Functions

template<typename T >
getFunctionPointer (const char *name)
 
 ~Win32Module () override
 
bool load (const std::string &inPath, std::string &errorDescription) override
 
- Public Member Functions inherited from Module
 Module (const FilePath &name)
 
virtual ~Module ()
 
void ShowLoadFailureError (const wxString &Error)
 
bool Load (wxString &deferredErrorMessage)
 
void Unload ()
 
bool HasDispatch ()
 
int Dispatch (ModuleDispatchTypes type)
 
void * GetSymbol (const wxString &name)
 
const FilePathGetName () const
 

Public Attributes

HINSTANCE mModule {nullptr}
 

Detailed Description

Definition at line 125 of file module_win32.cpp.

Constructor & Destructor Documentation

◆ ~Win32Module()

VST3::Hosting::anonymous_namespace{module_win32.cpp}::Win32Module::~Win32Module ( )
inlineoverride

Definition at line 134 of file module_win32.cpp.

135 {
136 factory = PluginFactory (nullptr);
137
138 if (mModule)
139 {
140 // ExitDll is optional
141 if (auto dllExit = getFunctionPointer<ExitModuleFunc> ("ExitDll"))
142 dllExit ();
143
144 FreeLibrary ((HMODULE)mModule);
145 }
146 }
static RegisteredToolbarFactory factory

References cloud::factory.

Member Function Documentation

◆ getFunctionPointer()

template<typename T >
T VST3::Hosting::anonymous_namespace{module_win32.cpp}::Win32Module::getFunctionPointer ( const char *  name)
inline

Definition at line 129 of file module_win32.cpp.

130 {
131 return reinterpret_cast<T> (GetProcAddress (mModule, name));
132 }
const TranslatableString name
Definition: Distortion.cpp:76

References name.

◆ load()

bool VST3::Hosting::anonymous_namespace{module_win32.cpp}::Win32Module::load ( const std::string &  inPath,
std::string &  errorDescription 
)
inlineoverride

Definition at line 148 of file module_win32.cpp.

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

References VST3::Hosting::anonymous_namespace{module_win32.cpp}::architectureString, and cloud::factory.

Member Data Documentation

◆ mModule

HINSTANCE VST3::Hosting::anonymous_namespace{module_win32.cpp}::Win32Module::mModule {nullptr}

Definition at line 197 of file module_win32.cpp.


The documentation for this class was generated from the following file: