2022-04-17 14:57:30 +00:00
|
|
|
#include <hex/api/content_registry.hpp>
|
|
|
|
#include <hex/providers/provider.hpp>
|
2023-01-09 07:38:19 +00:00
|
|
|
#include <hex/helpers/magic.hpp>
|
2023-05-21 22:01:58 +00:00
|
|
|
#include <hex/helpers/binary_pattern.hpp>
|
|
|
|
#include <optional>
|
2022-04-17 14:57:30 +00:00
|
|
|
|
2022-08-06 19:38:09 +00:00
|
|
|
#include <pl/core/evaluator.hpp>
|
2022-04-17 14:57:30 +00:00
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
void registerPatternLanguagePragmas() {
|
|
|
|
|
|
|
|
ContentRegistry::PatternLanguage::addPragma("base_address", [](pl::PatternLanguage &runtime, const std::string &value) {
|
|
|
|
auto baseAddress = strtoull(value.c_str(), nullptr, 0);
|
|
|
|
|
|
|
|
ImHexApi::Provider::get()->setBaseAddress(baseAddress);
|
2022-08-28 15:53:33 +00:00
|
|
|
runtime.setDataBaseAddress(baseAddress);
|
|
|
|
|
2022-04-17 14:57:30 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2023-01-09 07:38:19 +00:00
|
|
|
ContentRegistry::PatternLanguage::addPragma("MIME", [](pl::PatternLanguage&, const std::string &value) {
|
|
|
|
return magic::isValidMIMEType(value);
|
|
|
|
});
|
2023-05-21 22:01:58 +00:00
|
|
|
|
|
|
|
ContentRegistry::PatternLanguage::addPragma("magic", [](pl::PatternLanguage&, const std::string &) {
|
|
|
|
return true;
|
|
|
|
});
|
2022-04-17 14:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|