From ba97573f937819671219c020e129fa94289d60c8 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 25 Sep 2021 18:45:23 +0200 Subject: [PATCH] patterns: Fixed pointers not working correctly --- .../include/hex/pattern_language/ast_node.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp index ce1955986..8b5789510 100644 --- a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp +++ b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp @@ -943,15 +943,29 @@ namespace hex::pl { }, offset->getValue()); } + auto offset = evaluator->dataOffset(); + auto sizePattern = this->m_sizeType->createPatterns(evaluator).front(); ON_SCOPE_EXIT { delete sizePattern; }; - auto pattern = new PatternDataPointer(evaluator->dataOffset(), sizePattern->getSize()); - pattern->setPointedAtPattern(this->m_type->createPatterns(evaluator).front()); + auto pattern = new PatternDataPointer(offset, sizePattern->getSize()); + offset = evaluator->dataOffset(); + + { + auto pointedAtPattern = this->m_type->createPatterns(evaluator).front(); + u128 pointerAddress = 0; + evaluator->getProvider()->read(pattern->getOffset(), &pointerAddress, pattern->getSize()); + pointedAtPattern->setOffset(pointerAddress); + + pattern->setPointedAtPattern(pointedAtPattern); + } + pattern->setVariableName(this->m_name); applyVariableAttributes(evaluator, this, pattern); + evaluator->dataOffset() = offset; + return { pattern }; }