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

Method firstScan

Source/MemoryScanner/MemoryScanner.cpp:15–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15Common::MemOperationReturnCode MemScanner::firstScan(const MemScanner::ScanFilter filter,
16 const std::string& searchTerm1,
17 const std::string& searchTerm2)
18{
19 m_scanRAMCache = nullptr;
20 u32 ramSize = static_cast<u32>(DolphinComm::DolphinAccessor::getRAMTotalSize());
21 m_scanRAMCache = new char[ramSize];
22 DolphinComm::DolphinAccessor::readEntireRAM(m_scanRAMCache);
23
24 u32 beginA = m_searchInRangeBegin ? m_beginSearchRange : 0;
25 u32 endA = m_searchInRangeEnd ? m_endSearchRange : ramSize;
26
27 if (m_searchInRangeBegin || m_searchInRangeEnd)
28 {
29 ramSize = endA - beginA;
30 }
31
32 if (filter == ScanFilter::unknownInitial)
33 {
34 if (m_searchInRangeBegin || m_searchInRangeEnd)
35 {
36 int alignmentDivision =
37 m_enforceMemAlignment ? Common::getNbrBytesAlignmentForType(m_memType) : 1;
38 m_wasUnknownInitialValue = false;
39 m_memSize = Common::getSizeForType(m_memType, static_cast<size_t>(1));
40 m_scanStarted = true;
41
42 bool aram = DolphinComm::DolphinAccessor::isARAMAccessible();
43
44 u32 alignedBeginA =
45 beginA + ((alignmentDivision - (beginA % alignmentDivision)) % alignmentDivision);
46
47 for (u32 i = alignedBeginA; i < endA - m_memSize; i += alignmentDivision)
48 {
49 m_resultsConsoleAddr.push_back(Common::offsetToDolphinAddr(i, aram));
50 }
51
52 m_resultCount = m_resultsConsoleAddr.size();
53 }
54 else
55 {
56 int alignementDivision =
57 m_enforceMemAlignment ? Common::getNbrBytesAlignmentForType(m_memType) : 1;
58 m_resultCount = ((ramSize / alignementDivision) -
59 Common::getSizeForType(m_memType, static_cast<size_t>(1)));
60 m_wasUnknownInitialValue = true;
61 m_memSize = 1;
62 m_scanStarted = true;
63 }
64
65 return Common::MemOperationReturnCode::OK;
66 }
67
68 m_wasUnknownInitialValue = false;
69 Common::MemOperationReturnCode scanReturn = Common::MemOperationReturnCode::OK;
70 size_t termActualLength = 0;
71 size_t termMaxLength = 0;
72 if (m_memType == Common::MemType::type_string)

Callers 1

onFirstScanMethod · 0.80

Calls 7

getSizeForTypeFunction · 0.85
offsetToDolphinAddrFunction · 0.85
formatStringToMemoryFunction · 0.85
formatMemoryToStringFunction · 0.85
cacheIndexToOffsetFunction · 0.85
shouldBeBSwappedForTypeFunction · 0.85

Tested by

no test coverage detected