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