From 7b1a146976e8e4b949164b3cb921269883e21ebe Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 29 Jan 2022 12:40:49 +0100 Subject: [PATCH] pattern: Fixed crashes, removed reference to evaluator in every pattern --- .../include/hex/pattern_language/ast_node.hpp | 38 +++---- .../hex/pattern_language/pattern_data.hpp | 100 +++++++++--------- .../source/pattern_language/evaluator.cpp | 17 +-- .../test_patterns/test_pattern_bitfields.hpp | 10 +- .../test_patterns/test_pattern_enums.hpp | 2 +- .../test_patterns/test_pattern_padding.hpp | 10 +- .../test_patterns/test_pattern_placement.hpp | 6 +- .../test_patterns/test_pattern_pointers.hpp | 4 +- .../test_patterns/test_pattern_structs.hpp | 8 +- .../test_patterns/test_pattern_unions.hpp | 8 +- 10 files changed, 105 insertions(+), 98 deletions(-) diff --git a/lib/libimhex/include/hex/pattern_language/ast_node.hpp b/lib/libimhex/include/hex/pattern_language/ast_node.hpp index 7be236ea3..ec4bf9dc6 100644 --- a/lib/libimhex/include/hex/pattern_language/ast_node.hpp +++ b/lib/libimhex/include/hex/pattern_language/ast_node.hpp @@ -402,21 +402,21 @@ namespace hex::pl { PatternData *pattern; if (Token::isUnsigned(this->m_type)) - pattern = new PatternDataUnsigned(offset, size, evaluator); + pattern = new PatternDataUnsigned(offset, size); else if (Token::isSigned(this->m_type)) - pattern = new PatternDataSigned(offset, size, evaluator); + pattern = new PatternDataSigned(offset, size); else if (Token::isFloatingPoint(this->m_type)) - pattern = new PatternDataFloat(offset, size, evaluator); + pattern = new PatternDataFloat(offset, size); else if (this->m_type == Token::ValueType::Boolean) - pattern = new PatternDataBoolean(offset, evaluator); + pattern = new PatternDataBoolean(offset); else if (this->m_type == Token::ValueType::Character) - pattern = new PatternDataCharacter(offset, evaluator); + pattern = new PatternDataCharacter(offset); else if (this->m_type == Token::ValueType::Character16) - pattern = new PatternDataCharacter16(offset, evaluator); + pattern = new PatternDataCharacter16(offset); else if (this->m_type == Token::ValueType::Padding) - pattern = new PatternDataPadding(offset, 1, evaluator); + pattern = new PatternDataPadding(offset, 1); else if (this->m_type == Token::ValueType::String) - pattern = new PatternDataString(offset, 1, evaluator); + pattern = new PatternDataString(offset, 1); else if (this->m_type == Token::ValueType::Auto) return { nullptr }; else @@ -965,13 +965,13 @@ namespace hex::pl { PatternData *outputPattern; if (dynamic_cast(templatePattern)) { - outputPattern = new PatternDataPadding(startOffset, 0, evaluator); + outputPattern = new PatternDataPadding(startOffset, 0); } else if (dynamic_cast(templatePattern)) { - outputPattern = new PatternDataString(startOffset, 0, evaluator); + outputPattern = new PatternDataString(startOffset, 0); } else if (dynamic_cast(templatePattern)) { - outputPattern = new PatternDataString16(startOffset, 0, evaluator); + outputPattern = new PatternDataString16(startOffset, 0); } else { - auto arrayPattern = new PatternDataStaticArray(startOffset, 0, evaluator); + auto arrayPattern = new PatternDataStaticArray(startOffset, 0); arrayPattern->setEntries(templatePattern->clone(), entryCount); outputPattern = arrayPattern; } @@ -988,7 +988,7 @@ namespace hex::pl { } PatternData *createDynamicArray(Evaluator *evaluator) const { - auto arrayPattern = new PatternDataDynamicArray(evaluator->dataOffset(), 0, evaluator); + auto arrayPattern = new PatternDataDynamicArray(evaluator->dataOffset(), 0); arrayPattern->setVariableName(this->m_name); std::vector entries; @@ -1185,7 +1185,7 @@ namespace hex::pl { auto sizePattern = this->m_sizeType->createPatterns(evaluator).front(); ON_SCOPE_EXIT { delete sizePattern; }; - auto pattern = new PatternDataPointer(startOffset, sizePattern->getSize(), evaluator); + auto pattern = new PatternDataPointer(startOffset, sizePattern->getSize()); pattern->setVariableName(this->m_name); auto endOffset = evaluator->dataOffset(); @@ -1291,7 +1291,7 @@ namespace hex::pl { } [[nodiscard]] std::vector createPatterns(Evaluator *evaluator) const override { - auto pattern = new PatternDataStruct(evaluator->dataOffset(), 0, evaluator); + auto pattern = new PatternDataStruct(evaluator->dataOffset(), 0); u64 startOffset = evaluator->dataOffset(); std::vector memberPatterns; @@ -1363,7 +1363,7 @@ namespace hex::pl { } [[nodiscard]] std::vector createPatterns(Evaluator *evaluator) const override { - auto pattern = new PatternDataUnion(evaluator->dataOffset(), 0, evaluator); + auto pattern = new PatternDataUnion(evaluator->dataOffset(), 0); size_t size = 0; std::vector memberPatterns; @@ -1423,7 +1423,7 @@ namespace hex::pl { } [[nodiscard]] std::vector createPatterns(Evaluator *evaluator) const override { - auto pattern = new PatternDataEnum(evaluator->dataOffset(), 0, evaluator); + auto pattern = new PatternDataEnum(evaluator->dataOffset(), 0); auto enumCleanup = SCOPE_GUARD { delete pattern; }; @@ -1480,7 +1480,7 @@ namespace hex::pl { void addEntry(const std::string &name, ASTNode *size) { this->m_entries.emplace_back(name, size); } [[nodiscard]] std::vector createPatterns(Evaluator *evaluator) const override { - auto pattern = new PatternDataBitfield(evaluator->dataOffset(), 0, evaluator); + auto pattern = new PatternDataBitfield(evaluator->dataOffset(), 0); size_t bitOffset = 0; std::vector fields; @@ -1504,7 +1504,7 @@ namespace hex::pl { // If a field is named padding, it was created through a padding expression and only advances the bit position if (name != "padding") { - auto field = new PatternDataBitfieldField(evaluator->dataOffset(), bitOffset, bitSize, pattern, evaluator); + auto field = new PatternDataBitfieldField(evaluator->dataOffset(), bitOffset, bitSize, pattern); field->setVariableName(name); fields.push_back(field); } diff --git a/lib/libimhex/include/hex/pattern_language/pattern_data.hpp b/lib/libimhex/include/hex/pattern_language/pattern_data.hpp index c61cebce9..11f6ab60a 100644 --- a/lib/libimhex/include/hex/pattern_language/pattern_data.hpp +++ b/lib/libimhex/include/hex/pattern_language/pattern_data.hpp @@ -56,33 +56,32 @@ namespace hex::pl { class PatternCreationLimiter { public: - explicit PatternCreationLimiter(Evaluator *evaluator) : m_evaluator(evaluator) { - if (this->m_evaluator == nullptr) return; + explicit PatternCreationLimiter() { + if (PatternCreationLimiter::s_evaluator == nullptr) return; - this->m_evaluator->patternCreated(); + PatternCreationLimiter::s_evaluator->patternCreated(); } PatternCreationLimiter(const PatternCreationLimiter &other) { - this->m_evaluator = other.m_evaluator; + if (PatternCreationLimiter::s_evaluator == nullptr) return; - if (this->m_evaluator == nullptr) return; - this->m_evaluator->patternCreated(); + PatternCreationLimiter::s_evaluator->patternCreated(); } virtual ~PatternCreationLimiter() { - if (this->m_evaluator == nullptr) return; + if (PatternCreationLimiter::s_evaluator == nullptr) return; - this->m_evaluator->patternDestroyed(); + PatternCreationLimiter::s_evaluator->patternDestroyed(); } - protected: - Evaluator *m_evaluator = nullptr; + public: + static Evaluator *s_evaluator; }; class PatternData : public PatternCreationLimiter { public: - PatternData(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternCreationLimiter(evaluator), m_offset(offset), m_size(size), m_color(color) { + PatternData(u64 offset, size_t size, u32 color = 0) + : PatternCreationLimiter(), m_offset(offset), m_size(size), m_color(color) { constexpr u32 Palette[] = { 0x70b4771f, 0x700e7fff, 0x702ca02c, 0x702827d6, 0x70bd6794, 0x704b568c, 0x70c277e3, 0x707f7f7f, 0x7022bdbc, 0x70cfbe17 }; if (color != 0) @@ -123,14 +122,17 @@ namespace hex::pl { } [[nodiscard]] bool hasOverriddenColor() const { return this->m_manualColor; } - [[nodiscard]] std::endian getEndian() const { return this->m_endian.value_or(this->getEvaluator()->getDefaultEndian()); } + [[nodiscard]] std::endian getEndian() const { + if (this->getEvaluator() == nullptr) return std::endian::native; + else return this->m_endian.value_or(this->getEvaluator()->getDefaultEndian()); + } virtual void setEndian(std::endian endian) { this->m_endian = endian; } [[nodiscard]] bool hasOverriddenEndian() const { return this->m_endian.has_value(); } [[nodiscard]] std::string getDisplayName() const { return this->m_displayName.value_or(this->m_variableName); } void setDisplayName(const std::string &name) { this->m_displayName = name; } - [[nodiscard]] Evaluator *getEvaluator() const { return this->m_evaluator; } + [[nodiscard]] Evaluator *getEvaluator() const { return PatternCreationLimiter::s_evaluator; } [[nodiscard]] const auto &getTransformFunction() const { return this->m_transformFunction; } void setTransformFunction(const ContentRegistry::PatternLanguage::Function &function) { this->m_transformFunction = function; } @@ -153,7 +155,7 @@ namespace hex::pl { for (u64 i = 0; i < this->getSize(); i++) highlight.insert({ this->getOffset() + i, this->getColor() }); - this->m_evaluator->handleAbort(); + this->getEvaluator()->handleAbort(); } virtual void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) { } @@ -242,7 +244,7 @@ namespace hex::pl { this->m_offset == other.m_offset && this->m_size == other.m_size && this->m_hidden == other.m_hidden && - this->m_endian == other.m_endian && + (this->m_endian == other.m_endian || (!this->m_endian.has_value() && other.m_endian == std::endian::native) || (!other.m_endian.has_value() && this->m_endian == std::endian::native)) && this->m_variableName == other.m_variableName && this->m_typeName == other.m_typeName && this->m_comment == other.m_comment && @@ -324,7 +326,7 @@ namespace hex::pl { class PatternDataPadding : public PatternData { public: - PatternDataPadding(u64 offset, size_t size, Evaluator *evaluator) : PatternData(offset, size, evaluator, 0xFF000000) { } + PatternDataPadding(u64 offset, size_t size) : PatternData(offset, size, 0xFF000000) { } PatternData *clone() override { return new PatternDataPadding(*this); @@ -342,8 +344,8 @@ namespace hex::pl { class PatternDataPointer : public PatternData { public: - PatternDataPointer(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color), m_pointedAt(nullptr) { + PatternDataPointer(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color), m_pointedAt(nullptr) { } PatternDataPointer(const PatternDataPointer &other) : PatternData(other) { @@ -472,8 +474,8 @@ namespace hex::pl { class PatternDataUnsigned : public PatternData { public: - PatternDataUnsigned(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { } + PatternDataUnsigned(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternData *clone() override { return new PatternDataUnsigned(*this); @@ -509,8 +511,8 @@ namespace hex::pl { class PatternDataSigned : public PatternData { public: - PatternDataSigned(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { } + PatternDataSigned(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternData *clone() override { return new PatternDataSigned(*this); @@ -547,8 +549,8 @@ namespace hex::pl { class PatternDataFloat : public PatternData { public: - PatternDataFloat(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { } + PatternDataFloat(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternData *clone() override { return new PatternDataFloat(*this); @@ -586,8 +588,8 @@ namespace hex::pl { class PatternDataBoolean : public PatternData { public: - explicit PatternDataBoolean(u64 offset, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, 1, evaluator, color) { } + explicit PatternDataBoolean(u64 offset, u32 color = 0) + : PatternData(offset, 1, color) { } PatternData *clone() override { return new PatternDataBoolean(*this); @@ -614,8 +616,8 @@ namespace hex::pl { class PatternDataCharacter : public PatternData { public: - explicit PatternDataCharacter(u64 offset, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, 1, evaluator, color) { } + explicit PatternDataCharacter(u64 offset, u32 color = 0) + : PatternData(offset, 1, color) { } PatternData *clone() override { return new PatternDataCharacter(*this); @@ -637,8 +639,8 @@ namespace hex::pl { class PatternDataCharacter16 : public PatternData { public: - explicit PatternDataCharacter16(u64 offset, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, 2, evaluator, color) { } + explicit PatternDataCharacter16(u64 offset, u32 color = 0) + : PatternData(offset, 2, color) { } PatternData *clone() override { return new PatternDataCharacter16(*this); @@ -670,8 +672,8 @@ namespace hex::pl { class PatternDataString : public PatternData { public: - PatternDataString(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { } + PatternDataString(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternData *clone() override { return new PatternDataString(*this); @@ -714,8 +716,8 @@ namespace hex::pl { class PatternDataString16 : public PatternData { public: - PatternDataString16(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { } + PatternDataString16(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternData *clone() override { return new PatternDataString16(*this); @@ -766,8 +768,8 @@ namespace hex::pl { class PatternDataDynamicArray : public PatternData, public Inlinable { public: - PatternDataDynamicArray(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { + PatternDataDynamicArray(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternDataDynamicArray(const PatternDataDynamicArray &other) : PatternData(other) { @@ -922,8 +924,8 @@ namespace hex::pl { class PatternDataStaticArray : public PatternData, public Inlinable { public: - PatternDataStaticArray(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { + PatternDataStaticArray(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternDataStaticArray(const PatternDataStaticArray &other) : PatternData(other) { @@ -1079,8 +1081,8 @@ namespace hex::pl { class PatternDataStruct : public PatternData, public Inlinable { public: - PatternDataStruct(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { + PatternDataStruct(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternDataStruct(const PatternDataStruct &other) : PatternData(other) { @@ -1224,8 +1226,8 @@ namespace hex::pl { class PatternDataUnion : public PatternData, public Inlinable { public: - PatternDataUnion(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { + PatternDataUnion(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternDataUnion(const PatternDataUnion &other) : PatternData(other) { @@ -1370,8 +1372,8 @@ namespace hex::pl { class PatternDataEnum : public PatternData { public: - PatternDataEnum(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { + PatternDataEnum(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternData *clone() override { @@ -1465,8 +1467,8 @@ namespace hex::pl { class PatternDataBitfieldField : public PatternData { public: - PatternDataBitfieldField(u64 offset, u8 bitOffset, u8 bitSize, PatternData *bitField, Evaluator *evaluator, u32 color = 0) - : m_bitOffset(bitOffset), m_bitSize(bitSize), m_bitField(bitField), PatternData(offset, 0, evaluator, color) { + PatternDataBitfieldField(u64 offset, u8 bitOffset, u8 bitSize, PatternData *bitField, u32 color = 0) + : m_bitOffset(bitOffset), m_bitSize(bitSize), m_bitField(bitField), PatternData(offset, 0, color) { } PatternData *clone() override { @@ -1534,8 +1536,8 @@ namespace hex::pl { class PatternDataBitfield : public PatternData, public Inlinable { public: - PatternDataBitfield(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0) - : PatternData(offset, size, evaluator, color) { + PatternDataBitfield(u64 offset, size_t size, u32 color = 0) + : PatternData(offset, size, color) { } PatternDataBitfield(const PatternDataBitfield &other) : PatternData(other) { diff --git a/lib/libimhex/source/pattern_language/evaluator.cpp b/lib/libimhex/source/pattern_language/evaluator.cpp index 78b4e098d..7ce8b29fd 100644 --- a/lib/libimhex/source/pattern_language/evaluator.cpp +++ b/lib/libimhex/source/pattern_language/evaluator.cpp @@ -1,8 +1,11 @@ #include #include +#include namespace hex::pl { + Evaluator *PatternCreationLimiter::s_evaluator = nullptr; + void Evaluator::createVariable(const std::string &name, ASTNode *type, const std::optional &value, bool outVariable) { auto &variables = *this->getScope(0).scope; for (auto &variable : variables) { @@ -21,19 +24,19 @@ namespace hex::pl { LogConsole::abortEvaluation("cannot determine type of auto variable", type); if (std::get_if(&value.value()) != nullptr) - pattern = new PatternDataUnsigned(0, sizeof(u128), this); + pattern = new PatternDataUnsigned(0, sizeof(u128)); else if (std::get_if(&value.value()) != nullptr) - pattern = new PatternDataSigned(0, sizeof(i128), this); + pattern = new PatternDataSigned(0, sizeof(i128)); else if (std::get_if(&value.value()) != nullptr) - pattern = new PatternDataFloat(0, sizeof(double), this); + pattern = new PatternDataFloat(0, sizeof(double)); else if (std::get_if(&value.value()) != nullptr) - pattern = new PatternDataBoolean(0, this); + pattern = new PatternDataBoolean(0); else if (std::get_if(&value.value()) != nullptr) - pattern = new PatternDataCharacter(0, this); + pattern = new PatternDataCharacter(0); else if (std::get_if(&value.value()) != nullptr) pattern = std::get(value.value())->clone(); else if (std::get_if(&value.value()) != nullptr) - pattern = new PatternDataString(0, 1, this); + pattern = new PatternDataString(0, 1); else __builtin_unreachable(); } @@ -144,6 +147,8 @@ namespace hex::pl { std::vector patterns; + PatternCreationLimiter::s_evaluator = this; + try { this->setCurrentControlFlowStatement(ControlFlowStatement::None); pushScope(nullptr, patterns); diff --git a/tests/pattern_language/include/test_patterns/test_pattern_bitfields.hpp b/tests/pattern_language/include/test_patterns/test_pattern_bitfields.hpp index 317fdfa5a..c58337a75 100644 --- a/tests/pattern_language/include/test_patterns/test_pattern_bitfields.hpp +++ b/tests/pattern_language/include/test_patterns/test_pattern_bitfields.hpp @@ -7,12 +7,12 @@ namespace hex::test { class TestPatternBitfields : public TestPattern { public: TestPatternBitfields() : TestPattern("Bitfields") { - auto testBitfield = create("TestBitfield", "testBitfield", 0x12, (4 * 4) / 8, nullptr); + auto testBitfield = create("TestBitfield", "testBitfield", 0x12, (4 * 4) / 8); testBitfield->setEndian(std::endian::big); - testBitfield->setFields({ create("", "a", 0x12, 0, 4, testBitfield, nullptr), - create("", "b", 0x12, 4, 4, testBitfield, nullptr), - create("", "c", 0x12, 8, 4, testBitfield, nullptr), - create("", "d", 0x12, 12, 4, testBitfield, nullptr) }); + testBitfield->setFields({ create("", "a", 0x12, 0, 4, testBitfield), + create("", "b", 0x12, 4, 4, testBitfield), + create("", "c", 0x12, 8, 4, testBitfield), + create("", "d", 0x12, 12, 4, testBitfield) }); addPattern(testBitfield); } diff --git a/tests/pattern_language/include/test_patterns/test_pattern_enums.hpp b/tests/pattern_language/include/test_patterns/test_pattern_enums.hpp index 49eb49f94..110019cb1 100644 --- a/tests/pattern_language/include/test_patterns/test_pattern_enums.hpp +++ b/tests/pattern_language/include/test_patterns/test_pattern_enums.hpp @@ -7,7 +7,7 @@ namespace hex::test { class TestPatternEnums : public TestPattern { public: TestPatternEnums() : TestPattern("Enums") { - auto testEnum = create("TestEnum", "testEnum", 0x08, sizeof(u32), nullptr); + auto testEnum = create("TestEnum", "testEnum", 0x08, sizeof(u32)); testEnum->setEnumValues({ {u128(0x0000), "A"}, { i128(0x0C), "B"}, diff --git a/tests/pattern_language/include/test_patterns/test_pattern_padding.hpp b/tests/pattern_language/include/test_patterns/test_pattern_padding.hpp index 41fc0e565..9d5c84b3e 100644 --- a/tests/pattern_language/include/test_patterns/test_pattern_padding.hpp +++ b/tests/pattern_language/include/test_patterns/test_pattern_padding.hpp @@ -7,12 +7,12 @@ namespace hex::test { class TestPatternPadding : public TestPattern { public: TestPatternPadding() : TestPattern("Padding") { - auto testStruct = create("TestStruct", "testStruct", 0x100, sizeof(i32) + 20 + sizeof(u8[0x10]), nullptr); + auto testStruct = create("TestStruct", "testStruct", 0x100, sizeof(i32) + 20 + sizeof(u8[0x10])); - auto variable = create("s32", "variable", 0x100, sizeof(i32), nullptr); - auto padding = create("padding", "", 0x100 + sizeof(i32), 20, nullptr); - auto array = create("u8", "array", 0x100 + sizeof(i32) + 20, sizeof(u8[0x10]), nullptr); - array->setEntries(create("u8", "", 0x100 + sizeof(i32) + 20, sizeof(u8), nullptr), 0x10); + auto variable = create("s32", "variable", 0x100, sizeof(i32)); + auto padding = create("padding", "", 0x100 + sizeof(i32), 20); + auto array = create("u8", "array", 0x100 + sizeof(i32) + 20, sizeof(u8[0x10])); + array->setEntries(create("u8", "", 0x100 + sizeof(i32) + 20, sizeof(u8)), 0x10); testStruct->setMembers({ variable, padding, array }); diff --git a/tests/pattern_language/include/test_patterns/test_pattern_placement.hpp b/tests/pattern_language/include/test_patterns/test_pattern_placement.hpp index 79ff52afc..d4ba43765 100644 --- a/tests/pattern_language/include/test_patterns/test_pattern_placement.hpp +++ b/tests/pattern_language/include/test_patterns/test_pattern_placement.hpp @@ -9,13 +9,13 @@ namespace hex::test { TestPatternPlacement() : TestPattern("Placement") { // placementVar { - addPattern(create("u32", "placementVar", 0x00, sizeof(u32), nullptr)); + addPattern(create("u32", "placementVar", 0x00, sizeof(u32))); } // placementArray { - auto placementArray = create("u8", "placementArray", 0x10, sizeof(u8) * 10, nullptr); - placementArray->setEntries(create("u8", "", 0x10, sizeof(u8), nullptr), 10); + auto placementArray = create("u8", "placementArray", 0x10, sizeof(u8) * 10); + placementArray->setEntries(create("u8", "", 0x10, sizeof(u8)), 10); addPattern(placementArray); } } diff --git a/tests/pattern_language/include/test_patterns/test_pattern_pointers.hpp b/tests/pattern_language/include/test_patterns/test_pattern_pointers.hpp index b8259ae8a..c8ade6db3 100644 --- a/tests/pattern_language/include/test_patterns/test_pattern_pointers.hpp +++ b/tests/pattern_language/include/test_patterns/test_pattern_pointers.hpp @@ -9,10 +9,10 @@ namespace hex::test { TestPatternPointers() : TestPattern("Pointers") { // placementPointer { - auto placementPointer = create("", "placementPointer", 0x0C, sizeof(u8), nullptr); + auto placementPointer = create("", "placementPointer", 0x0C, sizeof(u8)); placementPointer->setPointedAtAddress(0x49); - auto pointedTo = create("u32", "", 0x49, sizeof(u32), nullptr); + auto pointedTo = create("u32", "", 0x49, sizeof(u32)); placementPointer->setPointedAtPattern(pointedTo); addPattern(placementPointer); } diff --git a/tests/pattern_language/include/test_patterns/test_pattern_structs.hpp b/tests/pattern_language/include/test_patterns/test_pattern_structs.hpp index 438afd6ea..b76bfbfbb 100644 --- a/tests/pattern_language/include/test_patterns/test_pattern_structs.hpp +++ b/tests/pattern_language/include/test_patterns/test_pattern_structs.hpp @@ -7,11 +7,11 @@ namespace hex::test { class TestPatternStructs : public TestPattern { public: TestPatternStructs() : TestPattern("Structs") { - auto testStruct = create("TestStruct", "testStruct", 0x100, sizeof(i32) + sizeof(u8[0x10]), nullptr); + auto testStruct = create("TestStruct", "testStruct", 0x100, sizeof(i32) + sizeof(u8[0x10])); - auto variable = create("s32", "variable", 0x100, sizeof(i32), nullptr); - auto array = create("u8", "array", 0x100 + sizeof(i32), sizeof(u8[0x10]), nullptr); - array->setEntries(create("u8", "", 0x100 + sizeof(i32), sizeof(u8), nullptr), 0x10); + auto variable = create("s32", "variable", 0x100, sizeof(i32)); + auto array = create("u8", "array", 0x100 + sizeof(i32), sizeof(u8[0x10])); + array->setEntries(create("u8", "", 0x100 + sizeof(i32), sizeof(u8)), 0x10); testStruct->setMembers({ variable, array }); diff --git a/tests/pattern_language/include/test_patterns/test_pattern_unions.hpp b/tests/pattern_language/include/test_patterns/test_pattern_unions.hpp index afb185c43..38ba20a43 100644 --- a/tests/pattern_language/include/test_patterns/test_pattern_unions.hpp +++ b/tests/pattern_language/include/test_patterns/test_pattern_unions.hpp @@ -7,11 +7,11 @@ namespace hex::test { class TestPatternUnions : public TestPattern { public: TestPatternUnions() : TestPattern("Unions") { - auto testUnion = create("TestUnion", "testUnion", 0x200, sizeof(u128), nullptr); + auto testUnion = create("TestUnion", "testUnion", 0x200, sizeof(u128)); - auto array = create("s32", "array", 0x200, sizeof(i32[2]), nullptr); - array->setEntries(create("s32", "", 0x200, sizeof(i32), nullptr), 2); - auto variable = create("u128", "variable", 0x200, sizeof(u128), nullptr); + auto array = create("s32", "array", 0x200, sizeof(i32[2])); + array->setEntries(create("s32", "", 0x200, sizeof(i32)), 2); + auto variable = create("u128", "variable", 0x200, sizeof(u128)); testUnion->setMembers({ array, variable });