MCPcopy Create free account
hub / github.com/aldelaro5/dolphin-memory-engine / nextScan

Method nextScan

Source/MemoryScanner/MemoryScanner.cpp:283–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283Common::MemOperationReturnCode MemScanner::nextScan(const MemScanner::ScanFilter filter,
284 const std::string& searchTerm1,
285 const std::string& searchTerm2)
286{
287 char* newerRAMCache = nullptr;
288 u32 ramSize = static_cast<u32>(DolphinComm::DolphinAccessor::getRAMTotalSize());
289 newerRAMCache = new char[ramSize];
290 DolphinComm::DolphinAccessor::readEntireRAM(newerRAMCache);
291
292 Common::MemOperationReturnCode scanReturn = Common::MemOperationReturnCode::OK;
293 size_t termActualLength = 0;
294 size_t termMaxLength = 0;
295 if (m_memType == Common::MemType::type_string)
296 // This is just to have the string formatted with the appropriate length, byte arrays don't need
297 // this because they get copied byte per byte
298 termMaxLength = searchTerm1.length();
299 else
300 // Have no restriction on the length for the rest
301 termMaxLength = ramSize;
302
303 char* memoryToCompare1 = nullptr;
304 if (filter != ScanFilter::increased && filter != ScanFilter::decreased &&
305 filter != ScanFilter::changed && filter != ScanFilter::unchanged)
306 {
307 memoryToCompare1 = Common::formatStringToMemory(scanReturn, termActualLength, searchTerm1,
308 m_memBase, m_memType, termMaxLength);
309 if (scanReturn != Common::MemOperationReturnCode::OK)
310 return scanReturn;
311 }
312
313 char* memoryToCompare2 = nullptr;
314 if (filter == ScanFilter::between)
315 {
316 memoryToCompare2 = Common::formatStringToMemory(scanReturn, termActualLength, searchTerm2,
317 m_memBase, m_memType, ramSize);
318 if (scanReturn != Common::MemOperationReturnCode::OK)
319 return scanReturn;
320 }
321
322 m_memSize = Common::getSizeForType(m_memType, termActualLength);
323
324 char* noOffset = new char[m_memSize];
325 std::memset(noOffset, 0, m_memSize);
326
327 std::vector<u32> newerResults = std::vector<u32>();
328 bool aramAccessible = DolphinComm::DolphinAccessor::isARAMAccessible();
329
330 bool wasUninitialized = m_wasUnknownInitialValue;
331
332 if (m_wasUnknownInitialValue)
333 {
334 m_wasUnknownInitialValue = false;
335
336 int increment = m_enforceMemAlignment ? Common::getNbrBytesAlignmentForType(m_memType) : 1;
337 for (u32 i = 0; i < (ramSize - m_memSize); i += increment)
338 {
339 if (isHitNextScan(filter, memoryToCompare1, memoryToCompare2, noOffset, newerRAMCache,
340 m_memSize, i))

Callers 1

onNextScanMethod · 0.80

Calls 7

formatStringToMemoryFunction · 0.85
getSizeForTypeFunction · 0.85
cacheIndexToOffsetFunction · 0.85
offsetToDolphinAddrFunction · 0.85
dolphinAddrToOffsetFunction · 0.85
offsetToCacheIndexFunction · 0.85

Tested by

no test coverage detected