mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Make custom disassemblers reload on run
This commit is contained in:
2
lib/external/disassembler
vendored
2
lib/external/disassembler
vendored
Submodule lib/external/disassembler updated: a2217dd3bc...bb343eb028
@@ -10,9 +10,11 @@ namespace hex::plugin::disasm {
|
||||
|
||||
class CustomArchitecture : public ContentRegistry::Disassembler::Architecture {
|
||||
public:
|
||||
CustomArchitecture(::disasm::spec::Spec spec) : Architecture(spec.getName()), m_spec(std::move(spec)) {}
|
||||
CustomArchitecture(std::string name, std::fs::path path) : Architecture(std::move(name)), m_path(std::move(path)) {}
|
||||
|
||||
bool start() override {
|
||||
m_spec = ::disasm::spec::Loader::load(m_path, { m_path.parent_path() });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,7 +32,7 @@ namespace hex::plugin::disasm {
|
||||
std::ignore = instructionLoadAddress;
|
||||
std::ignore = code;
|
||||
|
||||
auto instructions = m_spec.disassemble(code, 1);
|
||||
const auto instructions = m_spec.disassemble(code, 1);
|
||||
if (instructions.empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -53,7 +55,9 @@ namespace hex::plugin::disasm {
|
||||
}
|
||||
|
||||
private:
|
||||
std::fs::path m_path;
|
||||
::disasm::spec::Spec m_spec;
|
||||
|
||||
};
|
||||
|
||||
void registerCustomArchitectures() {
|
||||
@@ -65,7 +69,7 @@ namespace hex::plugin::disasm {
|
||||
try {
|
||||
auto spec = ::disasm::spec::Loader::load(entry.path(), { entry.path().parent_path() });
|
||||
|
||||
ContentRegistry::Disassembler::add<CustomArchitecture>(std::move(spec));
|
||||
ContentRegistry::Disassembler::add<CustomArchitecture>(spec.getName(), entry.path());
|
||||
} catch (const std::exception &e) {
|
||||
log::error("Failed to load disassembler config '{}': {}", wolv::util::toUTF8String(entry.path()), e.what());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user