1
0
mirror of synced 2024-11-12 02:00:52 +01:00

patterns: Updated pattern language

This commit is contained in:
WerWolv 2023-01-27 10:45:07 +01:00
parent d928325fdf
commit 1cf9f7e990
5 changed files with 23 additions and 19 deletions

@ -1 +1 @@
Subproject commit 1fe5aa0db6277b852e60d3b622886550d901eab8
Subproject commit b478a39e269734882f56837ae2168d643ca0cd77

View File

@ -121,12 +121,14 @@ namespace hex::plugin::builtin {
}
}
void drawImageVisualizer(pl::ptrn::Pattern &pattern, pl::ptrn::Iteratable &, bool shouldReset, const std::vector<pl::core::Token::Literal> &) {
void drawImageVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, const std::vector<pl::core::Token::Literal> &arguments) {
static ImGui::Texture texture;
if (shouldReset) {
auto pattern = arguments[1].toPattern();
std::vector<u8> data;
data.resize(pattern.getSize());
pattern.getEvaluator()->readData(pattern.getOffset(), data.data(), data.size(), pattern.getSection());
data.resize(pattern->getSize());
pattern->getEvaluator()->readData(pattern->getOffset(), data.data(), data.size(), pattern->getSection());
texture = ImGui::Texture(data.data(), data.size());
}
@ -134,13 +136,14 @@ namespace hex::plugin::builtin {
ImGui::Image(texture, texture.getSize());
}
void drawBitmapVisualizer(pl::ptrn::Pattern &pattern, pl::ptrn::Iteratable &, bool shouldReset, const std::vector<pl::core::Token::Literal> &arguments) {
void drawBitmapVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, const std::vector<pl::core::Token::Literal> &arguments) {
static ImGui::Texture texture;
if (shouldReset) {
auto width = arguments[1].toUnsigned();
auto height = arguments[2].toUnsigned();
auto pattern = arguments[1].toPattern();
auto width = arguments[2].toUnsigned();
auto height = arguments[3].toUnsigned();
auto data = patternToArray<u8>(&pattern);
auto data = patternToArray<u8>(pattern);
texture = ImGui::Texture(data.data(), data.size(), width, height);
}
@ -148,7 +151,7 @@ namespace hex::plugin::builtin {
ImGui::Image(texture, texture.getSize());
}
void drawDisassemblyVisualizer(pl::ptrn::Pattern &pattern, pl::ptrn::Iteratable &, bool shouldReset, const std::vector<pl::core::Token::Literal> &arguments) {
void drawDisassemblyVisualizer(pl::ptrn::Pattern &, pl::ptrn::Iteratable &, bool shouldReset, const std::vector<pl::core::Token::Literal> &arguments) {
struct Disassembly {
u64 address;
std::vector<u8> bytes;
@ -157,9 +160,10 @@ namespace hex::plugin::builtin {
static std::vector<Disassembly> disassembly;
if (shouldReset) {
auto baseAddress = arguments[1].toUnsigned();
auto architecture = arguments[2].toUnsigned();
auto mode = arguments[3].toUnsigned();
auto pattern = arguments[1].toPattern();
auto baseAddress = arguments[2].toUnsigned();
auto architecture = arguments[3].toUnsigned();
auto mode = arguments[4].toUnsigned();
disassembly.clear();
@ -167,7 +171,7 @@ namespace hex::plugin::builtin {
if (cs_open(static_cast<cs_arch>(architecture), static_cast<cs_mode>(mode), &capstone) == CS_ERR_OK) {
cs_option(capstone, CS_OPT_SKIPDATA, CS_OPT_ON);
auto data = patternToArray<u8>(&pattern);
auto data = patternToArray<u8>(pattern);
cs_insn *instructions = nullptr;
size_t instructionCount = cs_disasm(capstone, data.data(), data.size(), baseAddress, 0, &instructions);

View File

@ -115,7 +115,7 @@ namespace hex::plugin::builtin {
const auto &patterns = runtime.getAllPatterns();
for (const auto &pattern : patterns) {
if (pattern->isHidden())
if (pattern->getVisibility() == pl::ptrn::Visibility::Hidden)
continue;
this->m_workData.push_back({

View File

@ -447,7 +447,7 @@ namespace hex::plugin::builtin {
std::optional<ImColor> color;
for (const auto &pattern : ProviderExtraData::getCurrent().patternLanguage.runtime->getPatternsAtAddress(address, id)) {
if (pattern->isHidden())
if (pattern->getVisibility() == pl::ptrn::Visibility::Hidden)
continue;
if (color.has_value())
@ -973,7 +973,7 @@ namespace hex::plugin::builtin {
std::optional<ImColor> color;
for (const auto &pattern : ProviderExtraData::getCurrent().patternLanguage.runtime->getPatternsAtAddress(address)) {
if (pattern->isHidden())
if (pattern->getVisibility() != pl::ptrn::Visibility::Visible)
continue;
if (color.has_value())
@ -989,11 +989,11 @@ namespace hex::plugin::builtin {
hex::unused(data, size);
auto patterns = ProviderExtraData::getCurrent().patternLanguage.runtime->getPatternsAtAddress(address);
if (!patterns.empty() && !std::all_of(patterns.begin(), patterns.end(), [](const auto &pattern) { return pattern->isHidden(); })) {
if (!patterns.empty() && !std::all_of(patterns.begin(), patterns.end(), [](const auto &pattern) { return pattern->getVisibility() == pl::ptrn::Visibility::Hidden; })) {
ImGui::BeginTooltip();
for (const auto &pattern : patterns) {
if (pattern->isHidden())
if (pattern->getVisibility() != pl::ptrn::Visibility::Visible)
continue;
auto tooltipColor = (pattern->getColor() & 0x00FF'FFFF) | 0x7000'0000;

View File

@ -630,7 +630,7 @@ namespace hex::plugin::builtin::ui {
}
void PatternDrawer::draw(pl::ptrn::Pattern& pattern) {
if (pattern.isHidden())
if (pattern.getVisibility() == pl::ptrn::Visibility::Hidden)
return;
pattern.accept(*this);