forked from Public-Mirror/Textractor
readd sum cache, it is useful
This commit is contained in:
parent
cbd5b01385
commit
8e719b2964
@ -26,7 +26,7 @@ constexpr bool x64 = true;
|
||||
constexpr bool x64 = false;
|
||||
#endif
|
||||
|
||||
template <typename T> using Array = T[];
|
||||
template <typename T, typename... X> using Array = std::conditional_t<sizeof...(X), std::tuple<T, X...>[], T[]>;
|
||||
|
||||
template <auto F> using Functor = std::integral_constant<std::decay_t<decltype(F)>, F>;
|
||||
|
||||
|
2
text.cpp
2
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";
|
||||
|
@ -25,6 +25,7 @@ namespace
|
||||
std::unique_ptr<HookRecord[]> 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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user