From bc9f8871da54a3b5e20135d0452a21ce2bac96d9 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Fri, 2 May 2025 11:04:25 -0700 Subject: [SharedCache] Have VirtualMemoryReader get the address size from the underlying VirtualMemory --- view/sharedcache/core/ObjC.cpp | 2 +- view/sharedcache/core/VirtualMemory.cpp | 5 ++--- view/sharedcache/core/VirtualMemory.h | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'view/sharedcache') diff --git a/view/sharedcache/core/ObjC.cpp b/view/sharedcache/core/ObjC.cpp index 2e37fd27..98fc42bb 100644 --- a/view/sharedcache/core/ObjC.cpp +++ b/view/sharedcache/core/ObjC.cpp @@ -88,7 +88,7 @@ std::shared_ptr SharedCacheObjCProcessor::GetReader() // TODO: This should never happen. if (!controller) throw std::runtime_error("SharedCacheController not found for SharedCacheObjCProcessor::GetReader!"); - auto reader = VirtualMemoryReader(controller->GetCache().GetVirtualMemory(), m_data->GetAddressSize()); + auto reader = VirtualMemoryReader(controller->GetCache().GetVirtualMemory()); return std::make_shared(reader); } diff --git a/view/sharedcache/core/VirtualMemory.cpp b/view/sharedcache/core/VirtualMemory.cpp index 292cda06..47206467 100644 --- a/view/sharedcache/core/VirtualMemory.cpp +++ b/view/sharedcache/core/VirtualMemory.cpp @@ -178,10 +178,9 @@ void VirtualMemory::Read(void* dest, uint64_t address, size_t length) region->fileAccessor.lock()->Read(dest, offset, length); } -VirtualMemoryReader::VirtualMemoryReader(std::shared_ptr memory, uint64_t addressSize) +VirtualMemoryReader::VirtualMemoryReader(std::shared_ptr memory) { m_memory = memory; - m_addressSize = addressSize; m_cursor = 0; } @@ -265,7 +264,7 @@ uint64_t VirtualMemoryReader::ReadPointer() uint64_t VirtualMemoryReader::ReadPointer(uint64_t address) { - m_cursor = address + m_addressSize; + m_cursor = address + m_memory->GetAddressSize(); return m_memory->ReadPointer(address); } diff --git a/view/sharedcache/core/VirtualMemory.h b/view/sharedcache/core/VirtualMemory.h index fcaf5c07..c4eb5a70 100644 --- a/view/sharedcache/core/VirtualMemory.h +++ b/view/sharedcache/core/VirtualMemory.h @@ -94,11 +94,10 @@ class VirtualMemoryReader { std::shared_ptr m_memory; uint64_t m_cursor; - uint64_t m_addressSize; BNEndianness m_endianness = LittleEndian; public: - explicit VirtualMemoryReader(std::shared_ptr memory, uint64_t addressSize = 8); + explicit VirtualMemoryReader(std::shared_ptr memory); void SetEndianness(BNEndianness endianness) { m_endianness = endianness; } -- cgit v1.3.1