MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / load

Method load

Suscan/Plugin.cpp:229–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229bool
230Plugin::load(void)
231{
232 PluginEntryFunc pluginEntry = nullptr;
233
234 if (this->m_loaded)
235 return true;
236
237 // Default plugin
238 if (this->m_handle == nullptr) {
239 pluginEntry = SigDigger::DefaultPluginEntry;
240 } else {
241 pluginEntry =
242 reinterpret_cast<PluginEntryFunc>(this->resolveSym(SIGDIGGER_PLUGIN_MANGLED_ENTRY));
243 const uint32_t *pPluginVer =
244 SCAST(const uint32_t *, this->resolveSym("plugin_ver"));
245 const uint32_t *pAPIVer =
246 SCAST(const uint32_t *, this->resolveSym("api_ver"));
247
248 if (pPluginVer == nullptr || pAPIVer == nullptr || pluginEntry == nullptr)
249 return false;
250
251 this->m_version = QString::asprintf(
252 "%d.%d.%d",
253 0xff & (*pPluginVer >> 16),
254 0xff & (*pPluginVer >> 8),
255 0xff & (*pPluginVer >> 0)).toStdString();
256
257 if (*pAPIVer > SIGDIGGER_API_VERSION) {
258 SU_ERROR(
259 "%s: this plugin is not compatible with the current SigDigger version\n",
260 this->m_path.c_str());
261 return false;
262 }
263 }
264
265 this->m_loaded = (pluginEntry) (this);
266
267 // Load okay, perform registration
268 if (this->m_loaded) {
269 for (auto p : this->m_factorySet) {
270 if (!p->registerGlobally()) {
271 SU_ERROR(
272 "%s: failed to register factory %s globally, unloading plugin\n",
273 this->m_path.c_str(),
274 p->name());
275 this->unload();
276
277 break;
278 }
279 }
280 }
281
282 return this->m_loaded;
283}
284
285bool
286Plugin::unload(void)

Callers 1

init_pluginsMethod · 0.45

Calls 4

resolveSymMethod · 0.95
unloadMethod · 0.95
registerGloballyMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected