2021-12-07 22:47:41 +01:00
|
|
|
#include "content/views/view_yara.hpp"
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
#include <hex/api/content_registry.hpp>
|
2023-01-28 14:15:15 +01:00
|
|
|
#include <hex/api/project_file_manager.hpp>
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2022-03-04 11:36:37 +01:00
|
|
|
#include <hex/helpers/fs.hpp>
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-12-26 00:22:47 +01:00
|
|
|
#include <toasts/toast_notification.hpp>
|
2023-12-23 21:09:41 +01:00
|
|
|
#include <popups/popup_file_chooser.hpp>
|
2023-04-08 00:58:53 +02:00
|
|
|
|
2021-02-26 13:35:19 +01:00
|
|
|
#include <filesystem>
|
|
|
|
|
2023-03-12 18:27:29 +01:00
|
|
|
#include <wolv/io/fs.hpp>
|
2023-03-16 13:35:09 +01:00
|
|
|
#include <wolv/literals.hpp>
|
2023-03-12 18:27:29 +01:00
|
|
|
|
2023-12-23 21:09:41 +01:00
|
|
|
namespace hex::plugin::yara {
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-03-16 13:35:09 +01:00
|
|
|
using namespace wolv::literals;
|
|
|
|
|
2024-01-08 21:51:48 +01:00
|
|
|
ViewYara::ViewYara() : View::Window("hex.yara_rules.view.yara.name", ICON_VS_BUG) {
|
2024-02-21 22:08:26 +01:00
|
|
|
YaraRule::init();
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-01-28 00:01:53 +01:00
|
|
|
ContentRegistry::FileHandler::add({ ".yar", ".yara" }, [](const auto &path) {
|
2022-03-04 11:36:37 +01:00
|
|
|
for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Yara)) {
|
2023-03-12 18:27:29 +01:00
|
|
|
if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
|
2023-12-26 00:22:47 +01:00
|
|
|
ui::ToastInfo::open("hex.yara_rules.view.yara.rule_added"_lang);
|
2022-01-13 14:34:19 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2023-01-28 14:15:15 +01:00
|
|
|
|
|
|
|
ProjectFile::registerPerProviderHandler({
|
|
|
|
.basePath = "yara.json",
|
|
|
|
.required = false,
|
2023-12-27 16:33:49 +01:00
|
|
|
.load = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool {
|
2023-03-23 11:23:07 +01:00
|
|
|
auto fileContent = tar.readString(basePath);
|
2023-01-28 14:15:15 +01:00
|
|
|
if (fileContent.empty())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
auto data = nlohmann::json::parse(fileContent.begin(), fileContent.end());
|
|
|
|
|
|
|
|
if (!data.contains("rules"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &rules = data["rules"];
|
|
|
|
if (!rules.is_array())
|
|
|
|
return false;
|
|
|
|
|
2023-12-19 13:10:25 +01:00
|
|
|
m_matches.get(provider).clear();
|
2023-01-28 14:15:15 +01:00
|
|
|
|
|
|
|
for (auto &rule : rules) {
|
|
|
|
if (!rule.contains("name") || !rule.contains("path"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &name = rule["name"];
|
|
|
|
auto &path = rule["path"];
|
|
|
|
|
|
|
|
if (!name.is_string() || !path.is_string())
|
|
|
|
return false;
|
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
m_rulePaths.get(provider).emplace_back(std::fs::path(name.get<std::string>()), std::fs::path(path.get<std::string>()));
|
2023-01-28 14:15:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
2023-12-27 16:33:49 +01:00
|
|
|
.store = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) -> bool {
|
2023-01-28 14:15:15 +01:00
|
|
|
nlohmann::json data;
|
|
|
|
|
|
|
|
data["rules"] = nlohmann::json::array();
|
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
for (auto &[name, path] : m_rulePaths.get(provider)) {
|
2023-01-28 14:15:15 +01:00
|
|
|
data["rules"].push_back({
|
2023-03-12 18:43:05 +01:00
|
|
|
{ "name", wolv::util::toUTF8String(name) },
|
|
|
|
{ "path", wolv::util::toUTF8String(path) }
|
2023-01-28 14:15:15 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-03-23 11:23:07 +01:00
|
|
|
tar.writeString(basePath, data.dump(4));
|
2023-01-28 14:15:15 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2021-02-26 13:35:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ViewYara::~ViewYara() {
|
2024-02-21 22:08:26 +01:00
|
|
|
YaraRule::cleanup();
|
2021-02-26 13:35:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewYara::drawContent() {
|
2023-12-23 21:09:41 +01:00
|
|
|
ImGuiExt::Header("hex.yara_rules.view.yara.header.rules"_lang, true);
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
if (ImGui::BeginListBox("##rules", ImVec2(-FLT_MIN, ImGui::GetTextLineHeightWithSpacing() * 5))) {
|
2024-02-21 22:08:26 +01:00
|
|
|
for (u32 i = 0; i < m_rulePaths->size(); i++) {
|
|
|
|
const bool selected = (*m_selectedRule == i);
|
|
|
|
if (ImGui::Selectable(wolv::util::toUTF8String((*m_rulePaths)[i].first).c_str(), selected)) {
|
|
|
|
*m_selectedRule = i;
|
2023-01-27 12:17:10 +01:00
|
|
|
}
|
|
|
|
}
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::EndListBox();
|
|
|
|
}
|
2023-01-27 12:17:10 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
if (ImGuiExt::IconButton(ICON_VS_ADD, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
|
|
|
const auto basePaths = fs::getDefaultPaths(fs::ImHexPath::Yara);
|
|
|
|
std::vector<std::fs::path> paths;
|
|
|
|
for (const auto &path : basePaths) {
|
|
|
|
std::error_code error;
|
|
|
|
for (const auto &entry : std::fs::recursive_directory_iterator(path, error)) {
|
|
|
|
if (!entry.is_regular_file()) continue;
|
|
|
|
if (entry.path().extension() != ".yara" && entry.path().extension() != ".yar") continue;
|
2023-01-27 12:17:10 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
paths.push_back(entry);
|
2021-02-26 13:35:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-29 10:41:25 +01:00
|
|
|
ui::PopupFileChooser::open(basePaths, paths, std::vector<hex::fs::ItemFilter>{ { "Yara File", "yara" }, { "Yara File", "yar" } }, true,
|
2023-11-21 13:47:50 +01:00
|
|
|
[&](const auto &path) {
|
2024-02-21 22:08:26 +01:00
|
|
|
m_rulePaths->push_back({ path.filename(), path });
|
2023-12-29 10:41:25 +01:00
|
|
|
});
|
2023-11-21 13:47:50 +01:00
|
|
|
}
|
2023-01-27 12:17:10 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGuiExt::IconButton(ICON_VS_REMOVE, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
2024-02-21 22:08:26 +01:00
|
|
|
if (*m_selectedRule < m_rulePaths->size()) {
|
|
|
|
m_rulePaths->erase(m_rulePaths->begin() + *m_selectedRule);
|
|
|
|
m_selectedRule = std::min(*m_selectedRule, u32(m_rulePaths->size() - 1));
|
2023-01-27 12:17:10 +01:00
|
|
|
}
|
2023-11-21 13:47:50 +01:00
|
|
|
}
|
2023-01-27 12:17:10 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::NewLine();
|
2023-12-23 21:09:41 +01:00
|
|
|
if (ImGui::Button("hex.yara_rules.view.yara.match"_lang)) this->applyRules();
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::SameLine();
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-12-19 13:10:25 +01:00
|
|
|
if (m_matcherTask.isRunning()) {
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::SameLine();
|
2023-12-23 21:09:41 +01:00
|
|
|
ImGuiExt::TextSpinner("hex.yara_rules.view.yara.matching"_lang);
|
2023-11-21 13:47:50 +01:00
|
|
|
}
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-12-23 21:09:41 +01:00
|
|
|
ImGuiExt::Header("hex.yara_rules.view.yara.header.matches"_lang);
|
2023-11-21 13:47:50 +01:00
|
|
|
|
|
|
|
auto matchesTableSize = ImGui::GetContentRegionAvail();
|
|
|
|
matchesTableSize.y *= 3.75 / 5.0;
|
|
|
|
matchesTableSize.y -= ImGui::GetTextLineHeightWithSpacing();
|
|
|
|
|
|
|
|
if (ImGui::BeginTable("matches", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, matchesTableSize)) {
|
|
|
|
ImGui::TableSetupScrollFreeze(0, 1);
|
2023-12-23 21:09:41 +01:00
|
|
|
ImGui::TableSetupColumn("hex.yara_rules.view.yara.matches.identifier"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("identifier"));
|
|
|
|
ImGui::TableSetupColumn("hex.yara_rules.view.yara.matches.variable"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("variable"));
|
|
|
|
ImGui::TableSetupColumn("hex.ui.common.address"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("address"));
|
|
|
|
ImGui::TableSetupColumn("hex.ui.common.size"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("size"));
|
2023-11-21 13:47:50 +01:00
|
|
|
|
|
|
|
ImGui::TableHeadersRow();
|
|
|
|
|
|
|
|
auto sortSpecs = ImGui::TableGetSortSpecs();
|
2023-12-19 13:10:25 +01:00
|
|
|
if (!m_matches->empty() && (sortSpecs->SpecsDirty || m_sortedMatches->empty())) {
|
|
|
|
m_sortedMatches->clear();
|
|
|
|
std::transform(m_matches->begin(), m_matches->end(), std::back_inserter(*m_sortedMatches), [](auto &match) {
|
2023-11-21 13:47:50 +01:00
|
|
|
return &match;
|
|
|
|
});
|
|
|
|
|
2023-12-19 13:10:25 +01:00
|
|
|
std::sort(m_sortedMatches->begin(), m_sortedMatches->end(), [&sortSpecs](const YaraMatch *left, const YaraMatch *right) -> bool {
|
2023-11-21 13:47:50 +01:00
|
|
|
if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("identifier"))
|
2024-02-21 22:08:26 +01:00
|
|
|
return left->match.identifier < right->match.identifier;
|
2023-11-21 13:47:50 +01:00
|
|
|
else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("variable"))
|
2024-02-21 22:08:26 +01:00
|
|
|
return left->match.variable < right->match.variable;
|
2023-11-21 13:47:50 +01:00
|
|
|
else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("address"))
|
2024-02-21 22:08:26 +01:00
|
|
|
return left->match.region.getStartAddress() < right->match.region.getStartAddress();
|
2023-11-21 13:47:50 +01:00
|
|
|
else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("size"))
|
2024-02-21 22:08:26 +01:00
|
|
|
return left->match.region.getSize() < right->match.region.getSize();
|
2023-11-21 13:47:50 +01:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
});
|
2023-03-16 13:35:09 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Descending)
|
2023-12-19 13:10:25 +01:00
|
|
|
std::reverse(m_sortedMatches->begin(), m_sortedMatches->end());
|
2023-03-16 13:35:09 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
sortSpecs->SpecsDirty = false;
|
|
|
|
}
|
2023-03-16 13:35:09 +01:00
|
|
|
|
2023-12-19 13:10:25 +01:00
|
|
|
if (!m_matcherTask.isRunning()) {
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGuiListClipper clipper;
|
2023-12-19 13:10:25 +01:00
|
|
|
clipper.Begin(m_sortedMatches->size());
|
2023-03-16 13:35:09 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
while (clipper.Step()) {
|
|
|
|
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
2024-02-21 22:08:26 +01:00
|
|
|
auto &[match, highlightId, tooltipId] = *(*m_sortedMatches)[i];
|
|
|
|
auto &[identifier, variableName, region, wholeDataMatch] = match;
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::PushID(i);
|
|
|
|
if (ImGui::Selectable("match", false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap)) {
|
2024-02-21 22:08:26 +01:00
|
|
|
ImHexApi::HexEditor::setSelection(region.getStartAddress(), region.getSize());
|
2023-11-21 13:47:50 +01:00
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::TextUnformatted(identifier.c_str());
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextUnformatted(variableName.c_str());
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
if (!wholeDataMatch) {
|
|
|
|
ImGui::TableNextColumn();
|
2024-02-21 22:08:26 +01:00
|
|
|
ImGuiExt::TextFormatted("0x{0:X} : 0x{1:X}", region.getStartAddress(), region.getEndAddress());
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::TableNextColumn();
|
2024-02-21 22:08:26 +01:00
|
|
|
ImGuiExt::TextFormatted("0x{0:X}", region.getSize());
|
2023-11-21 13:47:50 +01:00
|
|
|
} else {
|
2021-02-26 13:35:19 +01:00
|
|
|
ImGui::TableNextColumn();
|
2023-12-23 21:09:41 +01:00
|
|
|
ImGuiExt::TextFormattedColored(ImVec4(0.92F, 0.25F, 0.2F, 1.0F), "{}", "hex.yara_rules.view.yara.whole_data"_lang);
|
2021-02-26 13:35:19 +01:00
|
|
|
ImGui::TableNextColumn();
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::TextUnformatted("");
|
2021-02-26 13:35:19 +01:00
|
|
|
}
|
|
|
|
}
|
2022-03-15 23:48:49 +01:00
|
|
|
}
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
clipper.End();
|
2021-02-26 13:35:19 +01:00
|
|
|
}
|
2022-03-15 23:48:49 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
2022-03-15 23:48:49 +01:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
auto consoleSize = ImGui::GetContentRegionAvail();
|
2022-08-03 23:32:34 +02:00
|
|
|
|
2023-11-21 13:47:50 +01:00
|
|
|
if (ImGui::BeginChild("##console", consoleSize, true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_HorizontalScrollbar)) {
|
|
|
|
ImGuiListClipper clipper;
|
2022-03-15 23:48:49 +01:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
clipper.Begin(m_consoleMessages->size());
|
2023-12-27 16:33:49 +01:00
|
|
|
while (clipper.Step()) {
|
2023-11-21 13:47:50 +01:00
|
|
|
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
2024-02-21 22:08:26 +01:00
|
|
|
const auto &message = m_consoleMessages->at(i);
|
2023-11-21 13:47:50 +01:00
|
|
|
|
|
|
|
if (ImGui::Selectable(message.c_str()))
|
|
|
|
ImGui::SetClipboardText(message.c_str());
|
|
|
|
}
|
2023-12-27 16:33:49 +01:00
|
|
|
}
|
2021-02-26 13:35:19 +01:00
|
|
|
}
|
2023-11-21 13:47:50 +01:00
|
|
|
ImGui::EndChild();
|
2021-02-26 13:35:19 +01:00
|
|
|
}
|
|
|
|
|
2022-03-15 23:48:49 +01:00
|
|
|
void ViewYara::clearResult() {
|
2023-12-19 13:10:25 +01:00
|
|
|
for (const auto &match : *m_matches) {
|
2022-05-27 20:42:07 +02:00
|
|
|
ImHexApi::HexEditor::removeBackgroundHighlight(match.highlightId);
|
|
|
|
ImHexApi::HexEditor::removeTooltip(match.tooltipId);
|
|
|
|
}
|
2022-03-15 23:48:49 +01:00
|
|
|
|
2023-12-19 13:10:25 +01:00
|
|
|
m_matches->clear();
|
2024-02-21 22:08:26 +01:00
|
|
|
m_consoleMessages->clear();
|
2022-03-15 23:48:49 +01:00
|
|
|
}
|
|
|
|
|
2021-02-26 13:35:19 +01:00
|
|
|
void ViewYara::applyRules() {
|
2023-01-28 14:15:15 +01:00
|
|
|
this->clearResult();
|
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
auto provider = ImHexApi::Provider::get();
|
|
|
|
if (provider == nullptr)
|
|
|
|
return;
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
m_matcherTask = TaskManager::createTask("hex.yara_rules.view.yara.matching", 0, [this, provider](auto &task) {
|
|
|
|
u32 progress = 0;
|
2022-03-15 23:48:49 +01:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
std::vector<YaraRule::Result> results;
|
|
|
|
for (const auto &[fileName, filePath] : *m_rulePaths) {
|
|
|
|
YaraRule rule(filePath);
|
2022-03-15 23:48:49 +01:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
task.setInterruptCallback([&rule] {
|
|
|
|
rule.interrupt();
|
|
|
|
});
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2024-02-21 23:17:12 +01:00
|
|
|
auto result = rule.match(provider, { provider->getBaseAddress(), provider->getSize() });
|
2024-02-21 22:08:26 +01:00
|
|
|
if (!result.has_value()) {
|
|
|
|
TaskManager::doLater([this, error = result.error()] {
|
|
|
|
m_consoleMessages->emplace_back(error.message);
|
2023-01-27 12:17:10 +01:00
|
|
|
});
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
break;
|
2023-01-27 12:17:10 +01:00
|
|
|
}
|
2021-02-26 13:35:19 +01:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
results.emplace_back(result.value());
|
2022-02-02 21:08:46 +01:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
task.update(progress);
|
|
|
|
progress += 1;
|
2023-01-27 12:17:10 +01:00
|
|
|
}
|
2024-02-21 22:08:26 +01:00
|
|
|
|
|
|
|
TaskManager::doLater([this, results = std::move(results)] {
|
2023-12-19 13:10:25 +01:00
|
|
|
for (const auto &match : *m_matches) {
|
2022-10-28 14:32:56 +02:00
|
|
|
ImHexApi::HexEditor::removeBackgroundHighlight(match.highlightId);
|
|
|
|
ImHexApi::HexEditor::removeTooltip(match.tooltipId);
|
|
|
|
}
|
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
for (auto &result : results) {
|
|
|
|
for (auto &match : result.matches) {
|
|
|
|
m_matches->emplace_back(YaraMatch { std::move(match), 0, 0 });
|
|
|
|
}
|
2022-03-15 23:48:49 +01:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
m_consoleMessages->append_range(result.consoleMessages);
|
|
|
|
}
|
2022-10-28 14:32:56 +02:00
|
|
|
|
2024-02-21 22:08:26 +01:00
|
|
|
auto uniques = std::set(m_matches->begin(), m_matches->end(), [](const auto &leftMatch, const auto &rightMatch) {
|
|
|
|
const auto &l = leftMatch.match;
|
|
|
|
const auto &r = rightMatch.match;
|
|
|
|
return std::tie(l.region.address, l.wholeDataMatch, l.identifier, l.variable) <
|
|
|
|
std::tie(r.region.address, r.wholeDataMatch, r.identifier, r.variable);
|
2022-10-28 14:32:56 +02:00
|
|
|
});
|
2023-04-17 16:18:48 +02:00
|
|
|
|
2023-12-19 13:10:25 +01:00
|
|
|
m_matches->clear();
|
|
|
|
std::move(uniques.begin(), uniques.end(), std::back_inserter(*m_matches));
|
2022-10-28 14:32:56 +02:00
|
|
|
|
2022-05-27 20:42:07 +02:00
|
|
|
constexpr static color_t YaraColor = 0x70B4771F;
|
2024-02-21 22:08:26 +01:00
|
|
|
for (const YaraMatch &yaraMatch : uniques) {
|
|
|
|
yaraMatch.highlightId = ImHexApi::HexEditor::addBackgroundHighlight(yaraMatch.match.region, YaraColor);
|
|
|
|
yaraMatch.tooltipId = ImHexApi::HexEditor::addTooltip(yaraMatch.match.region, hex::format("{0} [{1}]", yaraMatch.match.identifier, yaraMatch.match.variable), YaraColor);
|
2022-03-15 23:48:49 +01:00
|
|
|
}
|
|
|
|
});
|
2022-08-17 16:15:36 +02:00
|
|
|
});
|
2021-02-26 13:35:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|