From acc85f3a8624c1ae2573d0b26d3414cd09176e75 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 8 Mar 2021 08:41:34 -0700 Subject: [PATCH] minor improvements --- GUI/host/exception.cpp | 2 +- extensions/extrawindow.cpp | 24 ++++++++++++------------ extensions/regexfilter.cpp | 2 +- include/types.h | 2 +- texthook/engine/match.cc | 1 + 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/GUI/host/exception.cpp b/GUI/host/exception.cpp index a838f3e..45e43c2 100644 --- a/GUI/host/exception.cpp +++ b/GUI/host/exception.cpp @@ -5,7 +5,7 @@ namespace { char* GetCppExceptionInfo(EXCEPTION_POINTERS* exception) { - // See https://blogs.msdn.microsoft.com/oldnewthing/20100730-00/?p=13273 + // https://blogs.msdn.microsoft.com/oldnewthing/20100730-00/?p=13273 // Not very reliable so use __try __try { return ((char****)exception->ExceptionRecord->ExceptionInformation[2])[3][1][1] + 8; } __except (EXCEPTION_EXECUTE_HANDLER) { return "Could not find"; } diff --git a/extensions/extrawindow.cpp b/extensions/extrawindow.cpp index 7d3f332..e7174de 100644 --- a/extensions/extrawindow.cpp +++ b/extensions/extrawindow.cpp @@ -47,7 +47,7 @@ struct PrettyWindow : QDialog, Localizer PrettyWindow(const char* name) { ui.setupUi(this); - ui.display->setGraphicsEffect(&outliner); + ui.display->setGraphicsEffect(outliner = new Outliner); setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); @@ -56,14 +56,14 @@ struct PrettyWindow : QDialog, Localizer if (font.fromString(settings.value(FONT, font.toString()).toString())) ui.display->setFont(font); SetBackgroundColor(settings.value(BG_COLOR, backgroundColor).value()); SetTextColor(settings.value(TEXT_COLOR, TextColor()).value()); - outliner.color = settings.value(OUTLINE_COLOR, outliner.color).value(); - outliner.size = settings.value(OUTLINE_SIZE, outliner.size).toDouble(); + outliner->color = settings.value(OUTLINE_COLOR, outliner->color).value(); + outliner->size = settings.value(OUTLINE_SIZE, outliner->size).toDouble(); menu.addAction(FONT, this, &PrettyWindow::RequestFont); menu.addAction(BG_COLOR, [this] { SetBackgroundColor(colorPrompt(this, backgroundColor, BG_COLOR)); }); menu.addAction(TEXT_COLOR, [this] { SetTextColor(colorPrompt(this, TextColor(), TEXT_COLOR)); }); QAction* outlineAction = menu.addAction(TEXT_OUTLINE, this, &PrettyWindow::SetOutline); outlineAction->setCheckable(true); - outlineAction->setChecked(outliner.size >= 0); + outlineAction->setChecked(outliner->size >= 0); connect(ui.display, &QLabel::customContextMenuRequested, [this](QPoint point) { menu.exec(mapToGlobal(point)); }); } @@ -113,13 +113,13 @@ private: { if (enable) { - QColor color = colorPrompt(this, outliner.color, OUTLINE_COLOR); - if (color.isValid()) outliner.color = color; - outliner.size = QInputDialog::getDouble(this, OUTLINE_SIZE, OUTLINE_SIZE_INFO, 0.5, 0, INT_MAX, 2, nullptr, Qt::WindowCloseButtonHint); + QColor color = colorPrompt(this, outliner->color, OUTLINE_COLOR); + if (color.isValid()) outliner->color = color; + outliner->size = QInputDialog::getDouble(this, OUTLINE_SIZE, OUTLINE_SIZE_INFO, 0.5, 0, INT_MAX, 2, nullptr, Qt::WindowCloseButtonHint); } - else outliner.size = -1; - settings.setValue(OUTLINE_COLOR, outliner.color.name(QColor::HexArgb)); - settings.setValue(OUTLINE_SIZE, outliner.size); + else outliner->size = -1; + settings.setValue(OUTLINE_COLOR, outliner->color.name(QColor::HexArgb)); + settings.setValue(OUTLINE_SIZE, outliner->size); } void paintEvent(QPaintEvent*) override @@ -128,7 +128,7 @@ private: } QColor backgroundColor{ palette().window().color() }; - struct : QGraphicsEffect + struct Outliner : QGraphicsEffect { void draw(QPainter* painter) override { @@ -148,7 +148,7 @@ private: } QColor color{ Qt::black }; double size = -1; - } outliner; + }* outliner; }; class ExtraWindow : public PrettyWindow diff --git a/extensions/regexfilter.cpp b/extensions/regexfilter.cpp index 69c1522..c59caf4 100644 --- a/extensions/regexfilter.cpp +++ b/extensions/regexfilter.cpp @@ -58,7 +58,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) { static auto _ = GetSelectedProcessId = (DWORD(*)())sentenceInfo["DWORD (*GetSelectedProcessId)()"]; if (sentenceInfo["text number"] == 0) return false; - if (sentenceInfo["current select"] && !regex) if (auto processName = GetModuleFilename(sentenceInfo["process id"])) + if (/*sentenceInfo["current select"] && */!regex) if (auto processName = GetModuleFilename(sentenceInfo["process id"])) { std::ifstream stream(REGEX_SAVE_FILE, std::ios::binary); BlockMarkupIterator savedFilters(stream, Array{ L"|PROCESS|", L"|FILTER|" }); diff --git a/include/types.h b/include/types.h index 765b189..301e6e3 100644 --- a/include/types.h +++ b/include/types.h @@ -62,7 +62,7 @@ struct SearchParam BYTE pattern[PATTERN_SIZE] = { x64 ? 0xcc : 0x55, x64 ? 0xcc : 0x8b, x64 ? 0x48 : 0xec, 0x89 }; // pattern in memory to search for int length = x64 ? 4 : 3, // length of pattern (zero means this SearchParam is invalid and the default should be used) offset = x64 ? 2 : 0, // offset from start of pattern to add hook - searchTime = 20000, // ms + searchTime = 30000, // ms maxRecords = 100000, codepage = SHIFT_JIS; uintptr_t padding = 0, // same as hook param padding diff --git a/texthook/engine/match.cc b/texthook/engine/match.cc index 817595c..6158f20 100644 --- a/texthook/engine/match.cc +++ b/texthook/engine/match.cc @@ -68,6 +68,7 @@ namespace Engine ConsoleOutput("Textractor: hijacking process located from 0x%p to 0x%p", processStartAddress, processStopAddress); DetermineEngineType(); + if (processStartAddress + 0x40000 > processStopAddress) ConsoleOutput("Textractor: WARNING injected process is very small, possibly a dummy!"); }(), 0); }