diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index 61299ac..c1e72b7 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -542,8 +542,11 @@ void MainWindow::FindHooks() hookList->setAttribute(Qt::WA_DeleteOnClose); hookList->resize({ 750, 300 }); hookList->setWindowTitle(SEARCH_FOR_HOOKS); - 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 + if (hooks->size() > 5'000) + { + 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 + } hookList->setModel(new QStringListModel(*hooks, hookList)); connect(hookList, &QListView::clicked, [this](QModelIndex i) { AddHook(i.data().toString().split(" => ")[0]); }); hookList->show(); diff --git a/texthook/engine/engine.cc b/texthook/engine/engine.cc index 8fd290c..d3575ca 100644 --- a/texthook/engine/engine.cc +++ b/texthook/engine/engine.cc @@ -16951,7 +16951,6 @@ bool FindPPSSPP() spDefault.minAddress = 0; spDefault.maxAddress = -1ULL; spDefault.padding = (uintptr_t)probe - 0x8000000; - spDefault.maxRecords = 500'000; spDefault.hookPostProcessor = [](HookParam& hp) { hp.type |= NO_CONTEXT | USING_SPLIT | SPLIT_INDIRECT; diff --git a/texthook/engine/match64.cc b/texthook/engine/match64.cc index 9af4c82..371827c 100644 --- a/texthook/engine/match64.cc +++ b/texthook/engine/match64.cc @@ -39,7 +39,6 @@ namespace Engine spDefault.minAddress = 0; spDefault.maxAddress = -1ULL; spDefault.padding = (uintptr_t)probe - 0x8000000; - spDefault.maxRecords = 500'000; spDefault.hookPostProcessor = [](HookParam& hp) { hp.type |= NO_CONTEXT | USING_SPLIT | SPLIT_INDIRECT; diff --git a/texthook/hookfinder.cc b/texthook/hookfinder.cc index 1fdac19..c96fb00 100644 --- a/texthook/hookfinder.cc +++ b/texthook/hookfinder.cc @@ -16,7 +16,7 @@ namespace { 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 { uint64_t address = 0; @@ -198,8 +198,10 @@ void SearchForHooks(SearchParam spUser) sp = spUser.length == 0 ? spDefault : spUser; - try { records = std::make_unique(recordsAvailable = sp.maxRecords); } - catch (std::bad_alloc) { return ConsoleOutput("Textractor: SearchForHooks ERROR (out of memory)"); } + do + try { records = std::make_unique(recordsAvailable = sp.maxRecords); } + 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 moduleStopAddress = moduleStartAddress;