@@ -319,9 +319,9 @@ class CModule : public CMemory
319319 // -----------------------------------------------------------------------------
320320 template <std::size_t SIZE = (s_nDefaultPatternSize - 1 ) / 2 >
321321 [[always_inline, flatten, hot]]
322- inline CMemory FindPattern (const CMemory pPatternMem, const std::string_view svMask, const CMemory pStartAddress, const Section_t* pModuleSection) const
322+ inline CMemory FindPattern (const CMemoryView<std:: uint8_t > pPatternMem, const std::string_view svMask, const CMemory pStartAddress, const Section_t* pModuleSection) const
323323 {
324- const auto * pPattern = pPatternMem.RCast < const std:: uint8_t *> ();
324+ const auto * pPattern = pPatternMem.RCastView ();
325325
326326 const Section_t* pSection = pModuleSection ? pModuleSection : m_pExecutableSection;
327327
@@ -407,17 +407,18 @@ class CModule : public CMemory
407407 [[nodiscard]]
408408 inline CMemory FindPattern (const Pattern_t<SIZE >& copyPattern, const CMemory pStartAddress = nullptr , const Section_t* pModuleSection = nullptr ) const
409409 {
410- return FindPattern<SIZE >(CMemory ( copyPattern.m_aBytes .data () ), std::string_view (copyPattern.m_aMask .data (), copyPattern.m_nSize ), pStartAddress, pModuleSection);
410+ return FindPattern<SIZE >(copyPattern.m_aBytes .data (), std::string_view (copyPattern.m_aMask .data (), copyPattern.m_nSize ), pStartAddress, pModuleSection);
411411 }
412412
413413 template <std::size_t SIZE >
414414 [[nodiscard]]
415415 inline CMemory FindPattern (Pattern_t<SIZE >&& movePattern, const CMemory pStartAddress = nullptr , const Section_t* pModuleSection = nullptr ) const
416416 {
417- return FindPattern<SIZE >(CMemory ( std::move (movePattern.m_aBytes ).data () ), std::string_view (std::move (movePattern.m_aMask ).data (), std::move (movePattern.m_nSize )), pStartAddress, pModuleSection);
417+ return FindPattern<SIZE >(std::move (movePattern.m_aBytes ).data (), std::string_view (std::move (movePattern.m_aMask ).data (), std::move (movePattern.m_nSize )), pStartAddress, pModuleSection);
418418 }
419419
420420 template <std::size_t SIZE , PatternCallback_t FUNC >
421+ [[nodiscard]]
421422 std::size_t FindAllPatterns (const CSignatureView<SIZE >& sig, const FUNC & callback, CMemory pStartAddress = nullptr , const Section_t* pModuleSection = nullptr ) const
422423 {
423424 const Section_t* pSection = pModuleSection ? pModuleSection : m_pExecutableSection;
@@ -429,7 +430,6 @@ class CModule : public CMemory
429430 const std::size_t sectionSize = pSection->m_nSectionSize ;
430431
431432 CMemory pIter = pStartAddress ? pStartAddress : pBase;
432- const CMemory pEnd = pBase + sectionSize;
433433
434434 std::size_t foundCount = 0 ;
435435
@@ -440,20 +440,8 @@ class CModule : public CMemory
440440 if (!callback (foundCount, pIter)) // foundCount = the index of found pattern now.
441441 break ;
442442
443- // Break the loop, stop this madness.
444- if (foundCount > 999 )
445- {
446- std::fprintf (stderr, " %s%s:%d\n " ,
447- " >> Detected an INFINITE LOOP!\n "
448- " >> Breaking from\n " ,
449- __FILE__, __LINE__);
450-
451- #ifdef __cpp_lib_debugging
452- std::breakpoint ();
453- #endif
454-
455- break ;
456- }
443+ // Prevent excessive iterations: ensure pattern is correct.
444+ assert (1000 > foundCount);
457445
458446 ++foundCount;
459447 }
0 commit comments