feat: Added cross-platform .NET scripts support (#1185)

This PR intends to add support for .NET scripts that can extend ImHex's
functionality in a portable and cross-platform way.

---------

Co-authored-by: Justus Garbe <55301990+Nowilltolife@users.noreply.github.com>
This commit is contained in:
Nik
2023-07-15 14:29:14 +02:00
committed by GitHub
parent 4e3b8111fd
commit 5171bea0bf
36 changed files with 1219 additions and 34 deletions

View File

@@ -15,7 +15,7 @@ namespace hex {
#if defined(OS_WINDOWS)
this->m_handle = LoadLibraryW(path.c_str());
if (this->m_handle == nullptr) {
if (this->m_handle == INVALID_HANDLE_VALUE || this->m_handle == nullptr) {
log::error("LoadLibraryW failed: {}!", std::system_category().message(::GetLastError()));
return;
}
@@ -76,6 +76,8 @@ namespace hex {
if (this->m_handle == nullptr)
return false;
const auto pluginName = wolv::util::toUTF8String(this->m_path.filename());
const auto requestedVersion = getCompatibleVersion();
if (requestedVersion != ImHexApi::System::getImHexVersion()) {
if (requestedVersion.empty()) {
@@ -87,7 +89,13 @@ namespace hex {
}
if (this->m_initializePluginFunction != nullptr) {
this->m_initializePluginFunction();
try {
this->m_initializePluginFunction();
} catch (const std::exception &e) {
log::error("Plugin '{}' threw an exception on init: {}", pluginName, e.what());
} catch (...) {
log::error("Plugin '{}' threw an exception on init", pluginName);
}
} else {
return false;
}