Guard GPS solver node reads
This commit is contained in:
@@ -210,6 +210,7 @@ constexpr uint16_t kTrafficLaneFlagGpsOnly = 0x0200;
|
||||
constexpr uint16_t kTrafficLaneFlagNoAiDriving = 0x2000;
|
||||
constexpr uint16_t kTrafficLaneFlagHighway = 0x4000;
|
||||
constexpr uint16_t kTrafficLaneFlagNoAutodrive = 0x8000;
|
||||
constexpr uintptr_t kMinimumReadableAddress = 0x10000;
|
||||
constexpr float kGpsSolverHighwayMultiplier = 0.35f;
|
||||
constexpr float kGpsSolverGpsOnlyMultiplier = 1.10f;
|
||||
constexpr float kGpsSolverPavementMultiplier = 1.25f;
|
||||
@@ -927,7 +928,7 @@ bool IsReadableMemory(const void* aPointer, size_t aSize)
|
||||
|
||||
const auto begin = reinterpret_cast<uintptr_t>(aPointer);
|
||||
const auto end = begin + aSize;
|
||||
if (end < begin)
|
||||
if (begin < kMinimumReadableAddress || end < begin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -4878,18 +4879,19 @@ float DetourGpsNodeMultiplier(void* aJob, void* aNode)
|
||||
}
|
||||
|
||||
uint32_t mode = 0;
|
||||
uint16_t nodeFlags = 0;
|
||||
const auto jobAddress = reinterpret_cast<uintptr_t>(aJob);
|
||||
const auto nodeAddress = reinterpret_cast<uintptr_t>(aNode);
|
||||
const auto hasMode = aJob && TryReadMemory(reinterpret_cast<const void*>(jobAddress + 0xC4), mode);
|
||||
const auto hasFlags = aNode && TryReadMemory(reinterpret_cast<const void*>(nodeAddress + 0x88), nodeFlags);
|
||||
|
||||
if (hasMode && hasFlags && mode == 2 && std::isfinite(result))
|
||||
if (hasMode && mode == 2 && std::isfinite(result))
|
||||
{
|
||||
const auto patchMultiplier = GpsSolverNodeWeightMultiplier(nodeFlags);
|
||||
if (patchMultiplier != 1.0f)
|
||||
uint16_t nodeFlags = 0;
|
||||
const auto nodeAddress = reinterpret_cast<uintptr_t>(aNode);
|
||||
if (aNode && TryReadMemory(reinterpret_cast<const void*>(nodeAddress + 0x88), nodeFlags))
|
||||
{
|
||||
result *= patchMultiplier;
|
||||
const auto patchMultiplier = GpsSolverNodeWeightMultiplier(nodeFlags);
|
||||
if (patchMultiplier != 1.0f)
|
||||
{
|
||||
result *= patchMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user