@@ -1178,18 +1178,44 @@ HRESULT PatchUnifiedTilePinUnpinProvider(HMODULE hModule)
11781178 RETURN_IF_WIN32_BOOL_FALSE (GetModuleInformation (GetCurrentProcess (), hModule, &mi, sizeof (mi)));
11791179
11801180#if defined(_M_X64)
1181- // 48 89 ?? 24 ?? 4C 8B ?? 4C 8B 44 24 ?? 49 8B ?? ?? 8B ?? E8 ?? ?? ?? ??
1182- // ^^^^^^^^^^^
1183- PBYTE match = (PBYTE)FindPattern (
1184- hModule,
1185- mi.SizeOfImage ,
1186- " \x48\x89\x00\x24\x00\x4C\x8B\x00\x4C\x8B\x44\x24\x00\x49\x8B\x00\x00\x8B\x00\xE8 " ,
1187- " xx?x?xx?xxxx?xx??x?x"
1188- );
1189- if (match)
1190- {
1181+ PBYTE match;
1182+ SIZE_T offset = (SIZE_T)hModule;
1183+ while (true )
1184+ {
1185+ // 48 89 ?? 24 ?? 4C 8B ?? 4C 8B 44 24 ?? 49 8B ?? ?? 8B ?? E8 ?? ?? ?? ??
1186+ // ^^^^^^^^^^^
1187+ match = (PBYTE)FindPattern (
1188+ (PVOID)offset,
1189+ mi.SizeOfImage - (DWORD)(offset - (SIZE_T)hModule),
1190+ " \x48\x89\x00\x24\x00\x4C\x8B\x00\x4C\x8B\x44\x24\x00\x49\x8B\x00\x00\x8B\x00\xE8 " ,
1191+ " xx?x?xx?xxxx?xx??x?x"
1192+ );
1193+ if (!match)
1194+ {
1195+ // We tried our best, but we found nothing...
1196+ break ;
1197+ }
1198+
1199+ // Possible match, prepare the start offset for the next search
1200+ offset += ((SIZE_T)match - offset) + 24 /* first pattern size*/ ;
1201+
1202+ // Check the referred function's preamble to see if this is what we're looking for
11911203 match += 19 ;
11921204 match += 5 + *(int *)(match + 1 );
1205+
1206+ // 41 54 41 55 41 56 41 57 48
1207+ PBYTE matchPreambleTest = (PBYTE)FindPattern (
1208+ match,
1209+ 9 /* second pattern size*/ + 8 /* should start within these first bytes*/ ,
1210+ " \x41\x54\x41\x55\x41\x56\x41\x57\x48 " ,
1211+ " xxxxxxxxx"
1212+ );
1213+
1214+ if (matchPreambleTest)
1215+ {
1216+ // Got it!
1217+ break ;
1218+ }
11931219 }
11941220#elif defined(_M_ARM64)
11951221 // E4 06 40 F9 E3 03 15 AA E2 0E 40 F9 E1 03 19 AA E0 03 16 AA ?? ?? ?? ?? E3 03 00 2A
0 commit comments