diff --git a/include/common.h b/include/common.h index 4804e5f..3a50b90 100644 --- a/include/common.h +++ b/include/common.h @@ -26,7 +26,7 @@ constexpr bool x64 = true; constexpr bool x64 = false; #endif -template using Array = T[]; +template using Array = std::conditional_t[], T[]>; template using Functor = std::integral_constant, F>; diff --git a/text.cpp b/text.cpp index 6975fc0..4df966c 100644 --- a/text.cpp +++ b/text.cpp @@ -102,7 +102,7 @@ const char* TOO_MANY_HOOKS = u8"Textractor: too many hooks: can't insert"; const char* STARTING_SEARCH = u8"Textractor: starting search"; const char* NOT_ENOUGH_TEXT = u8"Textractor: not enough text to search accurately"; const char* HOOK_SEARCH_INITIALIZED = u8"Textractor: search initialized with %zd hooks"; -const char* MAKE_GAME_PROCESS_TEXT = u8"Textractor: please click around in the game to force it to process text during the next %d seconds!"; +const char* MAKE_GAME_PROCESS_TEXT = u8"Textractor: please click around in the game to force it to process text during the next %d seconds"; const char* HOOK_SEARCH_FINISHED = u8"Textractor: hook search finished, %d results found"; const char* OUT_OF_RECORDS_RETRY = u8"Textractor: out of search records, please retry if results are poor (default record count increased)"; const char* FUNC_MISSING = u8"Textractor: function not present"; diff --git a/texthook/hookfinder.cc b/texthook/hookfinder.cc index 93c43c6..0118114 100644 --- a/texthook/hookfinder.cc +++ b/texthook/hookfinder.cc @@ -25,6 +25,7 @@ namespace std::unique_ptr records; long recordsAvailable; uint64_t signatureCache[CACHE_SIZE] = {}; + long sumCache[CACHE_SIZE] = {}; uintptr_t pageCache[CACHE_SIZE] = {}; #ifndef _WIN64 @@ -147,6 +148,9 @@ void Send(char** stack, uintptr_t address) uint64_t signature = ((uint64_t)i << 56) | ((uint64_t)(str[2] + str[3]) << 48) | address; if (signatureCache[signature % CACHE_SIZE] == signature) continue; signatureCache[signature % CACHE_SIZE] = signature; + // if there are huge amount of strings that are the same, it's probably garbage: filter them out + // can't store all the strings, so use sum as heuristic instead + if (_InterlockedIncrement(sumCache + (sum % CACHE_SIZE)) > 25) continue; long n = sp.maxRecords - _InterlockedDecrement(&recordsAvailable); if (n < sp.maxRecords) { @@ -243,7 +247,7 @@ void SearchForHooks(SearchParam spUser) } records.reset(); VirtualFree(trampolines, 0, MEM_RELEASE); - for (int i = 0; i < CACHE_SIZE; ++i) signatureCache[i] = 0; + for (int i = 0; i < CACHE_SIZE; ++i) signatureCache[i] = sumCache[i] = 0; }).detach(); }