Dump GPS result object fields

This commit is contained in:
2026-06-20 13:13:08 -05:00
parent 751e2175f7
commit 9c6919e722
2 changed files with 126 additions and 9 deletions
+106
View File
@@ -665,6 +665,38 @@ void AppendUint32Field(std::ostringstream& aLine, const char* aLabel, void* aObj
}
}
void AppendUint16Field(std::ostringstream& aLine, const char* aLabel, void* aObject, uintptr_t aOffset)
{
uint16_t value = 0;
const auto hasValue = aObject && TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aObject) + aOffset),
value);
aLine << " " << aLabel << "=";
if (hasValue)
{
aLine << value << "/0x" << std::hex << value << std::dec;
}
else
{
aLine << "<unreadable>";
}
}
void AppendUint64Field(std::ostringstream& aLine, const char* aLabel, void* aObject, uintptr_t aOffset)
{
uint64_t value = 0;
const auto hasValue = aObject && TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aObject) + aOffset),
value);
aLine << " " << aLabel << "=";
if (hasValue)
{
aLine << value << "/0x" << std::hex << value << std::dec;
}
else
{
aLine << "<unreadable>";
}
}
void AppendByteField(std::ostringstream& aLine, const char* aLabel, void* aObject, uintptr_t aOffset)
{
uint8_t value = 0;
@@ -681,6 +713,28 @@ void AppendByteField(std::ostringstream& aLine, const char* aLabel, void* aObjec
}
}
void AppendBytesField(std::ostringstream& aLine, const char* aLabel, void* aObject, uintptr_t aOffset, size_t aSize)
{
const auto* address = aObject ? reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aObject) + aOffset) : nullptr;
aLine << " " << aLabel << "=";
if (!address || !IsReadableMemory(address, 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*>(address) + index);
aLine << std::setw(2) << static_cast<uint32_t>(byte);
}
aLine.flags(flags);
aLine.fill(fill);
}
struct Vector4Value
{
float x;
@@ -714,6 +768,32 @@ void AppendVector4Field(std::ostringstream& aLine, const char* aLabel, void* aOb
AppendVector4Pointer(aLine, aLabel, reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aObject) + aOffset));
}
void AppendVectorListCandidate(std::ostringstream& aLine, const char* aPrefix, void* aObject, uintptr_t aDataOffset,
uintptr_t aCountOffset, uintptr_t aStride)
{
uint32_t count = 0;
auto* data = ReadPointerField(aObject, aDataOffset);
TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aObject) + aCountOffset), count);
const auto dataLabel = std::string(aPrefix) + "_data";
const auto countLabel = std::string(aPrefix) + "_count";
AppendPointerWithRva(aLine, dataLabel.c_str(), data);
aLine << " " << countLabel << "=" << count;
if (!data || reinterpret_cast<uintptr_t>(data) < 0x10000 || count == 0 || count > 10000)
{
return;
}
AppendVector4Pointer(aLine, (std::string(aPrefix) + "_first").c_str(), data);
if (count > 1)
{
AppendVector4Pointer(aLine, (std::string(aPrefix) + "_last").c_str(),
reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(data) +
static_cast<uintptr_t>(count - 1) * aStride));
}
}
void AppendPathBufferSummary(std::ostringstream& aLine, const char* aPrefix, void* aPathBuffer)
{
AppendPointerWithRva(aLine, aPrefix, aPathBuffer);
@@ -743,6 +823,28 @@ void AppendPathBufferSummary(std::ostringstream& aLine, const char* aPrefix, voi
}
}
void AppendGpsResultObjectSummary(std::ostringstream& aLine, const char* aPrefix, void* aResultObject)
{
if (!aResultObject)
{
aLine << " " << aPrefix << "_result=<null>";
return;
}
AppendBytesField(aLine, (std::string(aPrefix) + "_bytes20").c_str(), aResultObject, 0x20, 0x40);
AppendVectorListCandidate(aLine, (std::string(aPrefix) + "_vec20").c_str(), aResultObject, 0x20, 0x2C, 12);
AppendVectorListCandidate(aLine, (std::string(aPrefix) + "_vec20s16").c_str(), aResultObject, 0x20, 0x2C, 16);
AppendUint32Field(aLine, (std::string(aPrefix) + "_u2c").c_str(), aResultObject, 0x2C);
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);
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);
AppendUint64Field(aLine, (std::string(aPrefix) + "_u48").c_str(), aResultObject, 0x48);
AppendUint64Field(aLine, (std::string(aPrefix) + "_u50").c_str(), aResultObject, 0x50);
}
void TrackGpsQuery(uint32_t aQueryId, void* aManager, uintptr_t aSubmitReturnRva, uint32_t aSubmitCall)
{
if (aQueryId == UINT32_MAX)
@@ -2122,6 +2224,10 @@ bool DetourGpsQueryResultFetch(void* aManager, uint32_t aQueryId, void* aOutPath
AppendPointerWithRva(line, "outPath", aOutPath);
AppendReturnRva(line, returnAddress);
AppendPathBufferSummary(line, "outPath", aOutPath);
if (result && isTracked && trackedQuery.submitReturnRva == 0x8D20D4)
{
AppendGpsResultObjectSummary(line, "gpsResult", aOutPath);
}
LogRed4ext(line.str());
}