diff --git a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp index d1102b750..2eaa60807 100644 --- a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp +++ b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp @@ -1382,7 +1382,7 @@ namespace hex::pl { return false; for (u64 i = 0; i < this->m_fields.size(); i++) { - if (this->m_fields[i] != otherBitfield.m_fields[i]) + if (*this->m_fields[i] != *otherBitfield.m_fields[i]) return false; } diff --git a/plugins/libimhex/source/pattern_language/evaluator.cpp b/plugins/libimhex/source/pattern_language/evaluator.cpp index e141dfc68..8919132f3 100644 --- a/plugins/libimhex/source/pattern_language/evaluator.cpp +++ b/plugins/libimhex/source/pattern_language/evaluator.cpp @@ -250,19 +250,13 @@ namespace hex::pl { default: this->getConsole().abortEvaluation("invalid rvalue size"); } } else if (auto bitfieldFieldPattern = dynamic_cast(currPattern); bitfieldFieldPattern != nullptr) { - u8 value[bitfieldFieldPattern->getSize()]; + std::vector value(bitfieldFieldPattern->getSize()); if (currPattern->isLocal()) - std::memcpy(value, this->m_localStack.data() + bitfieldFieldPattern->getOffset(), bitfieldFieldPattern->getSize()); + std::memcpy(value.data(), this->m_localStack.data() + bitfieldFieldPattern->getOffset(), value.size()); else - this->m_provider->read(bitfieldFieldPattern->getOffset(), value, bitfieldFieldPattern->getSize()); + this->m_provider->read(bitfieldFieldPattern->getOffset(), value.data(), value.size()); - u8 bitOffset = bitfieldFieldPattern->getBitOffset(); - u8 bitSize = bitfieldFieldPattern->getBitSize(); - - u128 fieldValue = 0; - std::memcpy(&fieldValue, value + (bitOffset / 8), (bitSize / 8) + 1); - - return new ASTNodeIntegerLiteral(hex::extract((bitOffset + bitSize) - 1 - ((bitOffset / 8) * 8), bitOffset - ((bitOffset / 8) * 8), fieldValue)); + return new ASTNodeIntegerLiteral(hex::extract(bitfieldFieldPattern->getBitOffset() + (bitfieldFieldPattern->getBitSize() - 1), bitfieldFieldPattern->getBitOffset(), value)); } else this->getConsole().abortEvaluation("tried to use non-integer value in numeric expression"); }