Decode GPS route result records

This commit is contained in:
2026-06-20 13:37:21 -05:00
parent aaf319e1b4
commit 56a451a7cb
2 changed files with 114 additions and 3 deletions
+77
View File
@@ -735,6 +735,27 @@ void AppendBytesField(std::ostringstream& aLine, const char* aLabel, void* aObje
aLine.fill(fill);
}
void AppendBytesPointer(std::ostringstream& aLine, const char* aLabel, const void* aPointer, size_t aSize)
{
aLine << " " << aLabel << "=";
if (!aPointer || reinterpret_cast<uintptr_t>(aPointer) < 0x10000 || !IsReadableMemory(aPointer, aSize))
{
aLine << "<unreadable>";
return;
}
const auto flags = aLine.flags();
const auto fill = aLine.fill();
aLine << std::hex << std::setfill('0');
for (size_t index = 0; index < aSize; ++index)
{
const auto byte = *(reinterpret_cast<const uint8_t*>(aPointer) + index);
aLine << std::setw(2) << static_cast<uint32_t>(byte);
}
aLine.flags(flags);
aLine.fill(fill);
}
struct Vector4Value
{
float x;
@@ -870,6 +891,61 @@ void AppendPathBufferSummary(std::ostringstream& aLine, const char* aPrefix, voi
}
}
void AppendGpsResultElementArraySummary(std::ostringstream& aLine, const char* aPrefix, void* aResultObject)
{
uint32_t capacity = 0;
uint32_t count = 0;
auto* data = ReadPointerField(aResultObject, 0x28);
TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aResultObject) + 0x30), capacity);
TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aResultObject) + 0x34), count);
const auto prefix = std::string(aPrefix);
aLine << " " << prefix << "_ptr28_capacity30=" << capacity;
aLine << " " << prefix << "_ptr28_count34=" << count;
if (!data || reinterpret_cast<uintptr_t>(data) < 0x10000 || count == 0 || count > 256)
{
return;
}
const auto rawSize = std::min<size_t>(0x80, static_cast<size_t>(count) * sizeof(void*));
AppendBytesPointer(aLine, (prefix + "_ptr28_ptrsRaw").c_str(), data, rawSize);
const auto appendElement = [&](uint32_t aIndex, const char* aLabel) {
auto* element = ReadPointerField(data, static_cast<uintptr_t>(aIndex) * sizeof(void*));
const auto elementPrefix = prefix + "_ptr28_" + aLabel;
AppendPointerWithRva(aLine, elementPrefix.c_str(), element);
if (!element || reinterpret_cast<uintptr_t>(element) < 0x10000)
{
return;
}
AppendPointerField(aLine, (elementPrefix + "_f68").c_str(), element, 0x68);
AppendUint32Field(aLine, (elementPrefix + "_u74").c_str(), element, 0x74);
AppendPointerField(aLine, (elementPrefix + "_f90").c_str(), element, 0x90);
AppendUint32Field(aLine, (elementPrefix + "_u98").c_str(), element, 0x98);
uint32_t sampleCount = 0;
auto* samples = ReadPointerField(element, 0x68);
TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(element) + 0x74), sampleCount);
if (samples && reinterpret_cast<uintptr_t>(samples) >= 0x10000 && sampleCount > 0 && sampleCount <= 4096)
{
const auto sampleRawSize = std::min<size_t>(0x20, static_cast<size_t>(sampleCount) * 0x08);
AppendBytesPointer(aLine, (elementPrefix + "_f68raw").c_str(), samples, sampleRawSize);
}
};
const auto firstLimit = std::min<uint32_t>(count, 4);
for (uint32_t index = 0; index < firstLimit; ++index)
{
appendElement(index, ("elem" + std::to_string(index)).c_str());
}
if (count > firstLimit)
{
appendElement(count - 1, "last");
}
}
void AppendGpsResultObjectSummary(std::ostringstream& aLine, const char* aPrefix, void* aResultObject)
{
if (!aResultObject)
@@ -890,6 +966,7 @@ void AppendGpsResultObjectSummary(std::ostringstream& aLine, const char* aPrefix
AppendUint64Field(aLine, (std::string(aPrefix) + "_u30").c_str(), aResultObject, 0x30);
AppendUint32Field(aLine, (std::string(aPrefix) + "_u30lo").c_str(), aResultObject, 0x30);
AppendUint32Field(aLine, (std::string(aPrefix) + "_u34hi").c_str(), aResultObject, 0x34);
AppendGpsResultElementArraySummary(aLine, aPrefix, aResultObject);
AppendVectorListCandidate(aLine, (std::string(aPrefix) + "_vec38").c_str(), aResultObject, 0x38, 0x3C, 12);
AppendUint16Field(aLine, (std::string(aPrefix) + "_flags40").c_str(), aResultObject, 0x40);
AppendByteField(aLine, (std::string(aPrefix) + "_state42").c_str(), aResultObject, 0x42);