use better cache size and recover malloc fails

This commit is contained in:
Akash Mozumdar 2019-09-15 12:57:26 -04:00
parent ab916126b9
commit f7f6b18ad2
4 changed files with 10 additions and 7 deletions

View File

@ -542,8 +542,11 @@ void MainWindow::FindHooks()
hookList->setAttribute(Qt::WA_DeleteOnClose); hookList->setAttribute(Qt::WA_DeleteOnClose);
hookList->resize({ 750, 300 }); hookList->resize({ 750, 300 });
hookList->setWindowTitle(SEARCH_FOR_HOOKS); hookList->setWindowTitle(SEARCH_FOR_HOOKS);
if (hooks->size() > 5'000)
{
hookList->setUniformItemSizes(true); // they aren't actually uniform, but this improves performance hookList->setUniformItemSizes(true); // they aren't actually uniform, but this improves performance
hooks->push_back(QString(2000, '-')); // dumb hack: with uniform item sizes, the last item is assumed to be the largest hooks->push_back(QString(2000, '-')); // dumb hack: with uniform item sizes, the last item is assumed to be the largest
}
hookList->setModel(new QStringListModel(*hooks, hookList)); hookList->setModel(new QStringListModel(*hooks, hookList));
connect(hookList, &QListView::clicked, [this](QModelIndex i) { AddHook(i.data().toString().split(" => ")[0]); }); connect(hookList, &QListView::clicked, [this](QModelIndex i) { AddHook(i.data().toString().split(" => ")[0]); });
hookList->show(); hookList->show();

View File

@ -16951,7 +16951,6 @@ bool FindPPSSPP()
spDefault.minAddress = 0; spDefault.minAddress = 0;
spDefault.maxAddress = -1ULL; spDefault.maxAddress = -1ULL;
spDefault.padding = (uintptr_t)probe - 0x8000000; spDefault.padding = (uintptr_t)probe - 0x8000000;
spDefault.maxRecords = 500'000;
spDefault.hookPostProcessor = [](HookParam& hp) spDefault.hookPostProcessor = [](HookParam& hp)
{ {
hp.type |= NO_CONTEXT | USING_SPLIT | SPLIT_INDIRECT; hp.type |= NO_CONTEXT | USING_SPLIT | SPLIT_INDIRECT;

View File

@ -39,7 +39,6 @@ namespace Engine
spDefault.minAddress = 0; spDefault.minAddress = 0;
spDefault.maxAddress = -1ULL; spDefault.maxAddress = -1ULL;
spDefault.padding = (uintptr_t)probe - 0x8000000; spDefault.padding = (uintptr_t)probe - 0x8000000;
spDefault.maxRecords = 500'000;
spDefault.hookPostProcessor = [](HookParam& hp) spDefault.hookPostProcessor = [](HookParam& hp)
{ {
hp.type |= NO_CONTEXT | USING_SPLIT | SPLIT_INDIRECT; hp.type |= NO_CONTEXT | USING_SPLIT | SPLIT_INDIRECT;

View File

@ -16,7 +16,7 @@ namespace
{ {
SearchParam sp; SearchParam sp;
constexpr int MAX_STRING_SIZE = 500, CACHE_SIZE = 0x40000, GOOD_PAGE = -1; constexpr int MAX_STRING_SIZE = 500, CACHE_SIZE = 749993, GOOD_PAGE = -1;
struct HookRecord struct HookRecord
{ {
uint64_t address = 0; uint64_t address = 0;
@ -198,8 +198,10 @@ void SearchForHooks(SearchParam spUser)
sp = spUser.length == 0 ? spDefault : spUser; sp = spUser.length == 0 ? spDefault : spUser;
do
try { records = std::make_unique<HookRecord[]>(recordsAvailable = sp.maxRecords); } try { records = std::make_unique<HookRecord[]>(recordsAvailable = sp.maxRecords); }
catch (std::bad_alloc) { return ConsoleOutput("Textractor: SearchForHooks ERROR (out of memory)"); } catch (std::bad_alloc) { ConsoleOutput("Textractor: SearchForHooks ERROR: out of memory, retrying to allocate %d", sp.maxRecords /= 2); }
while (!records && sp.maxRecords);
uintptr_t moduleStartAddress = (uintptr_t)GetModuleHandleW(ITH_DLL); uintptr_t moduleStartAddress = (uintptr_t)GetModuleHandleW(ITH_DLL);
uintptr_t moduleStopAddress = moduleStartAddress; uintptr_t moduleStopAddress = moduleStartAddress;