mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Added support for adding custom providers through C#
This commit is contained in:
@@ -179,8 +179,19 @@ namespace hex::script::loader {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_loadAssembly = [entryPoint](const std::fs::path &path) -> bool {
|
||||
auto string = wolv::util::toUTF8String(path);
|
||||
m_runMethod = [entryPoint](const std::string &methodName, bool keepLoaded, const std::fs::path &path) -> int {
|
||||
auto pathString = wolv::util::toUTF8String(path);
|
||||
|
||||
auto string = hex::format("{}||{}||{}", keepLoaded ? "LOAD" : "EXEC", methodName, pathString);
|
||||
auto result = entryPoint(string.data(), string.size());
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
m_methodExists = [entryPoint](const std::string &methodName, const std::fs::path &path) -> bool {
|
||||
auto pathString = wolv::util::toUTF8String(path);
|
||||
|
||||
auto string = hex::format("CHECK||{}||{}", methodName, pathString);
|
||||
auto result = entryPoint(string.data(), string.size());
|
||||
|
||||
return result == 0;
|
||||
@@ -211,9 +222,15 @@ namespace hex::script::loader {
|
||||
if (!std::fs::exists(scriptPath))
|
||||
continue;
|
||||
|
||||
this->addScript(entry.path().stem().string(), [this, scriptPath] {
|
||||
hex::unused(m_loadAssembly(scriptPath));
|
||||
});
|
||||
if (m_methodExists("Main", scriptPath)) {
|
||||
this->addScript(entry.path().stem().string(), [this, scriptPath] {
|
||||
hex::unused(m_runMethod("Main", false, scriptPath));
|
||||
});
|
||||
}
|
||||
|
||||
if (m_methodExists("OnLoad", scriptPath)) {
|
||||
hex::unused(m_runMethod("OnLoad", true, scriptPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user