diff --git a/SilentPatch/Patterns.h b/SilentPatch/Patterns.h index e146b9b..3d04d0d 100644 --- a/SilentPatch/Patterns.h +++ b/SilentPatch/Patterns.h @@ -188,6 +188,16 @@ namespace hook return get_one().get(offset); } + template + inline void for_each_result(Pred pred) + { + EnsureMatches(UINT32_MAX); + for ( auto it : m_matches ) + { + pred(it); + } + } + public: #if PATTERNS_USE_HINTS // define a hint diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 7de4213..39b1108 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -4615,9 +4615,7 @@ void Patch_SA_NewSteam_Common() auto patternie = pattern( "8B 75 10 8B ? 14 56" ).count(2); // 0x77C588 and 0x77C5CC in newsteam r2 auto defproc = get_pattern( "8B 4D 14 8B 55 10 8B 45 08" ); - for ( size_t i = 0; i < 2; ++i ) - { - auto match = patternie.get(i); + patternie.for_each_result( [&]( pattern_match match ) { InjectHook( match.get(0x39), defproc, PATCH_JUMP ); Patch( match.get(1), 0x5D ); // esi -> ebx Patch( match.get(6), 0x53 ); // esi -> ebx @@ -4625,7 +4623,7 @@ void Patch_SA_NewSteam_Common() Patch( match.get(8 + 2), -8 ); // use stack space for new lParam Patch( match.get(0x18 + 2), -8 ); // use stack space for new lParam Patch( match.get(0x2B + 2), -8 ); // use stack space for new lParam - } + } ); }