MCPcopy Create free account
hub / github.com/NoMercy-ac/NoMercy / ProcessPatternScan

Method ProcessPatternScan

Source/Client/NM_Engine/PatternScan.cpp:51–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51DWORD CMemoryScanner::ProcessPatternScan(PBYTE pCurAddr, std::size_t uiSize, const CMemoryPattern& memPattern) const
52{
53 auto vBuffer = std::vector <BYTE> (uiSize);
54
55 if (m_cMemHelper->ReadAddressSafe(pCurAddr, &vBuffer[0], uiSize) == false)
56 {
57 DEBUG_LOG(LL_ERR, "Read fail ||| %p - %u(real) - %u(read) | %p", pCurAddr, uiSize, vBuffer.size(), memPattern.GetBytes());
58 return 0UL;
59 }
60
61 DWORD dwResult = 0;
62 for (DWORD i = 0UL; i + memPattern.GetLength() < vBuffer.size(); ++i)
63 {
64 bool bFound = true;
65 for (DWORD j = 0UL; j < memPattern.GetLength() && bFound; ++j)
66 {
67 if (memPattern.GetMask(j) == '?') continue;
68 if (memPattern.GetByte(j) == vBuffer[i + j]) continue;
69 bFound = false;
70 }
71
72 if (bFound)
73 {
74 dwResult = (DWORD)pCurAddr + i + memPattern.GetPatternOffset();
75
76 // printf("w/o extra: %p\n", dwResult);
77 if (m_dwFlags & EScanFlags::MEM_SCAN_WITHEXTRA)
78 dwResult += m_dwExtraCount;
79
80 // printf("w/o read: %p\n", dwResult);
81 if (m_dwFlags & EScanFlags::MEM_SCAN_READ)
82 m_cMemHelper->ReadAddress((LPVOID)dwResult, &dwResult, sizeof(dwResult));
83
84 // printf("w/o subtract: %p\n", dwResult);
85 if (m_dwFlags & EScanFlags::MEM_SCAN_SUBTRACT)
86 dwResult -= m_dwLowAddr;
87
88 // printf("w/o adjust offset: %p\n", dwResult);
89 if (memPattern.GetAddrOffset())
90 dwResult += memPattern.GetAddrOffset();
91
92 break;
93 }
94 }
95
96 //vBuffer.clear();
97 return dwResult;
98}
99
100int CMemoryScanner::ProcessSectionScan(PBYTE pCurAddr, const CMemoryPattern& memPattern, MEMORY_BASIC_INFORMATION mbi, LPDWORD pdwResult) const
101{

Callers

nothing calls this directly

Calls 9

ReadAddressSafeMethod · 0.80
GetBytesMethod · 0.80
GetMaskMethod · 0.80
GetByteMethod · 0.80
GetPatternOffsetMethod · 0.80
ReadAddressMethod · 0.80
GetAddrOffsetMethod · 0.80
sizeMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected