diff --git a/GUI/host/textthread.cc b/GUI/host/textthread.cc index b52cdc1..e48ca20 100644 --- a/GUI/host/textthread.cc +++ b/GUI/host/textthread.cc @@ -27,7 +27,7 @@ void TextThread::Flush() std::wstring sentence; { LOCK(ttMutex); - if (buffer.size() < 400 && (GetTickCount() - timestamp < FlushDelay || buffer.size() < 2)) return; + if (buffer.size() < MaxBufferSize && (GetTickCount() - timestamp < FlushDelay || buffer.size() < 2)) return; sentence = status & USING_UNICODE ? std::wstring((wchar_t*)buffer.data(), buffer.size() / 2) : StringToWideString(std::string(buffer.data(), buffer.size()), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS); diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index 491d781..cabb49f 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -25,6 +25,7 @@ public: const ThreadParam tp; inline static int FlushDelay = 250; // flush every 250ms by default + inline static int MaxBufferSize = 500; inline static int ThreadCounter = 0; private: @@ -35,7 +36,7 @@ private: std::recursive_mutex ttMutex; HANDLE deletionEvent = CreateEventW(nullptr, FALSE, FALSE, NULL); - std::thread flushThread = std::thread([&] { while (WaitForSingleObject(deletionEvent, 100) == WAIT_TIMEOUT) Flush(); }); + std::thread flushThread = std::thread([&] { while (WaitForSingleObject(deletionEvent, 10) == WAIT_TIMEOUT) Flush(); }); DWORD timestamp = GetTickCount(); ThreadOutputCallback Output; diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index 3433c85..bce07c1 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -5,18 +5,16 @@ #include #include #include -#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); - - QSettings settings("NextHooker.ini", QSettings::IniFormat); if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect()); - // TODO: add GUI for changing this - if (settings.contains("Flush_Delay")) TextThread::FlushDelay = settings.value("Flush_Delay").toUInt(); + // TODO: add GUI for changing these + if (settings.contains("Flush_Delay")) TextThread::FlushDelay = settings.value("Flush_Delay").toInt(); + if (settings.contains("Max_Buffer_Size")) TextThread::MaxBufferSize = settings.value("Max_Buffer_Size").toInt(); processCombo = findChild("processCombo"); ttCombo = findChild("ttCombo"); @@ -41,9 +39,9 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { - QSettings settings("NextHooker.ini", QSettings::IniFormat); settings.setValue("Window", this->geometry()); settings.setValue("Flush_Delay", TextThread::FlushDelay); + settings.setValue("Max_Buffer_Size", TextThread::MaxBufferSize); settings.sync(); Host::Close(); delete ui; diff --git a/GUI/mainwindow.h b/GUI/mainwindow.h index 67bc12c..96e8d52 100644 --- a/GUI/mainwindow.h +++ b/GUI/mainwindow.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "host/host.h" namespace Ui @@ -51,6 +52,7 @@ private: QVector GetAllHooks(DWORD processId); Ui::MainWindow* ui; + QSettings settings = QSettings("NextHooker.ini", QSettings::IniFormat); QComboBox* processCombo; QComboBox* ttCombo; QComboBox* extenCombo;