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 117 of file module_win32.cpp.

Constructor & Destructor Documentation

◆ ~Win32Module()

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

Definition at line 126 of file module_win32.cpp.

127 {
128 factory = PluginFactory (nullptr);
129
130 if (mModule)
131 {
132 // ExitDll is optional
133 if (auto dllExit = getFunctionPointer<ExitModuleFunc> ("ExitDll"))
134 dllExit ();
135
136 FreeLibrary ((HMODULE)mModule);
137 }
138 }
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 121 of file module_win32.cpp.

122 {
123 return reinterpret_cast<T> (GetProcAddress (mModule, name));
124 }
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 140 of file module_win32.cpp.

141 {
142 auto wideStr = StringConvert::convert (inPath);
143 mModule = LoadLibraryW (reinterpret_cast<LPCWSTR> (wideStr.data ()));
144 if (!mModule)
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 ()));
153 if (!mModule)
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 // InitDll is optional
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 }
185 factory = PluginFactory (f);
186 return true;
187 }

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 189 of file module_win32.cpp.


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