parent
44a1bbf414
commit
d2704242f2
@ -718,16 +718,14 @@ namespace hex::pl {
|
||||
LogConsole::abortEvaluation("pointer base function needs exactly one parameter", node);
|
||||
|
||||
if (auto pointerPattern = dynamic_cast<PatternDataPointer*>(pattern)) {
|
||||
u128 value = 0;
|
||||
evaluator->getProvider()->read(pattern->getOffset(), &value, pattern->getSize());
|
||||
value = hex::changeEndianess(value, pattern->getSize(), pattern->getEndian());
|
||||
u128 pointerValue = pointerPattern->getPointedAtAddress();
|
||||
|
||||
auto result = function.func(evaluator, { value });
|
||||
auto result = function.func(evaluator, { pointerValue });
|
||||
|
||||
if (!result.has_value())
|
||||
LogConsole::abortEvaluation("pointer base function did not return a value", node);
|
||||
|
||||
pointerPattern->rebase(Token::literalToUnsigned(result.value()));
|
||||
pointerPattern->setPointedAtAddress(Token::literalToUnsigned(result.value()) + pointerValue);
|
||||
} else {
|
||||
LogConsole::abortEvaluation("pointer_base attribute may only be applied to a pointer");
|
||||
}
|
||||
@ -1130,24 +1128,27 @@ namespace hex::pl {
|
||||
}, offset->getValue());
|
||||
}
|
||||
|
||||
auto offset = evaluator->dataOffset();
|
||||
auto startOffset = evaluator->dataOffset();
|
||||
|
||||
auto sizePattern = this->m_sizeType->createPatterns(evaluator).front();
|
||||
ON_SCOPE_EXIT { delete sizePattern; };
|
||||
|
||||
auto pattern = new PatternDataPointer(offset, sizePattern->getSize(), evaluator);
|
||||
auto pattern = new PatternDataPointer(startOffset, sizePattern->getSize(), evaluator);
|
||||
pattern->setVariableName(this->m_name);
|
||||
|
||||
applyVariableAttributes(evaluator, this, pattern);
|
||||
|
||||
offset = evaluator->dataOffset();
|
||||
auto endOffset = evaluator->dataOffset();
|
||||
|
||||
{
|
||||
u128 pointerAddress = 0;
|
||||
evaluator->getProvider()->read(pattern->getOffset(), &pointerAddress, pattern->getSize());
|
||||
pointerAddress = hex::changeEndianess(pointerAddress, sizePattern->getSize(), sizePattern->getEndian());
|
||||
|
||||
evaluator->dataOffset() = pointerAddress;
|
||||
evaluator->dataOffset() = startOffset;
|
||||
|
||||
pattern->setPointedAtAddress(pointerAddress);
|
||||
applyVariableAttributes(evaluator, this, pattern);
|
||||
|
||||
evaluator->dataOffset() = pattern->getPointedAtAddress();
|
||||
|
||||
auto pointedAtPattern = this->m_type->createPatterns(evaluator).front();
|
||||
|
||||
@ -1155,7 +1156,7 @@ namespace hex::pl {
|
||||
pattern->setEndian(sizePattern->getEndian());
|
||||
}
|
||||
|
||||
evaluator->dataOffset() = offset;
|
||||
evaluator->dataOffset() = endOffset;
|
||||
|
||||
return { pattern };
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ namespace hex::pl {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", this->getFormattedName());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextFormatted("*(0x{0})", data);
|
||||
ImGui::TextFormatted("*(0x{0:X})", data);
|
||||
|
||||
if (open) {
|
||||
this->m_pointedAt->createEntry(provider);
|
||||
@ -423,6 +423,15 @@ namespace hex::pl {
|
||||
void setPointedAtPattern(PatternData *pattern) {
|
||||
this->m_pointedAt = pattern;
|
||||
this->m_pointedAt->setVariableName(hex::format("*({})", this->getVariableName()));
|
||||
this->m_pointedAt->setOffset(this->m_pointedAtAddress);
|
||||
}
|
||||
|
||||
void setPointedAtAddress(u64 address) {
|
||||
this->m_pointedAtAddress = address;
|
||||
}
|
||||
|
||||
[[nodiscard]] u64 getPointedAtAddress() const {
|
||||
return this->m_pointedAtAddress;
|
||||
}
|
||||
|
||||
[[nodiscard]] PatternData* getPointedAtPattern() {
|
||||
@ -440,14 +449,18 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
void rebase(u64 base) {
|
||||
if (this->m_pointedAt != nullptr)
|
||||
this->m_pointedAt->setOffset((this->m_pointedAt->getOffset() - this->m_pointerBase) + base);
|
||||
if (this->m_pointedAt != nullptr) {
|
||||
this->m_pointedAtAddress = (this->m_pointedAt->getOffset() - this->m_pointerBase) + base;
|
||||
this->m_pointedAt->setOffset(this->m_pointedAtAddress);
|
||||
}
|
||||
|
||||
this->m_pointerBase = base;
|
||||
}
|
||||
|
||||
private:
|
||||
PatternData *m_pointedAt = nullptr;
|
||||
u64 m_pointedAtAddress = 0;
|
||||
|
||||
u64 m_pointerBase = 0;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user