mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user