mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-24 01:14:12 +08:00
always use codepage when searching
This commit is contained in:
parent
49d9d7a0c4
commit
103c805cfe
@ -16,4 +16,6 @@ namespace Host
|
|||||||
|
|
||||||
std::shared_ptr<TextThread> GetThread(ThreadParam tp);
|
std::shared_ptr<TextThread> GetThread(ThreadParam tp);
|
||||||
void AddConsoleOutput(std::wstring text);
|
void AddConsoleOutput(std::wstring text);
|
||||||
|
|
||||||
|
inline int defaultCodepage = SHIFT_JIS;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ void TextThread::Push(const BYTE* data, int len)
|
|||||||
if (len < 0) return;
|
if (len < 0) return;
|
||||||
LOCK(bufferMutex);
|
LOCK(bufferMutex);
|
||||||
if (hp.type & USING_UNICODE) buffer += std::wstring((wchar_t*)data, len / 2);
|
if (hp.type & USING_UNICODE) buffer += std::wstring((wchar_t*)data, len / 2);
|
||||||
else if (auto converted = Util::StringToWideString(std::string((char*)data, len), hp.codepage ? hp.codepage : defaultCodepage)) buffer += converted.value();
|
else if (auto converted = Util::StringToWideString(std::string((char*)data, len), hp.codepage ? hp.codepage : Host::defaultCodepage)) buffer += converted.value();
|
||||||
else Host::AddConsoleOutput(INVALID_CODEPAGE);
|
else Host::AddConsoleOutput(INVALID_CODEPAGE);
|
||||||
lastPushTime = GetTickCount();
|
lastPushTime = GetTickCount();
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@ public:
|
|||||||
|
|
||||||
inline static int flushDelay = 400; // flush every 400ms by default
|
inline static int flushDelay = 400; // flush every 400ms by default
|
||||||
inline static int maxBufferSize = 1000;
|
inline static int maxBufferSize = 1000;
|
||||||
inline static int defaultCodepage = SHIFT_JIS;
|
|
||||||
inline static int threadCounter = 0;
|
|
||||||
|
|
||||||
TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name = {});
|
TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name = {});
|
||||||
~TextThread();
|
~TextThread();
|
||||||
@ -29,6 +27,8 @@ public:
|
|||||||
const HookParam hp;
|
const HookParam hp;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
inline static int threadCounter = 0;
|
||||||
|
|
||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
struct TimerDeleter { void operator()(void* h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } };
|
struct TimerDeleter { void operator()(void* h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } };
|
||||||
|
@ -40,7 +40,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
setGeometry(settings.value(WINDOW, geometry()).toRect());
|
setGeometry(settings.value(WINDOW, geometry()).toRect());
|
||||||
TextThread::flushDelay = settings.value(FLUSH_DELAY, TextThread::flushDelay).toInt();
|
TextThread::flushDelay = settings.value(FLUSH_DELAY, TextThread::flushDelay).toInt();
|
||||||
TextThread::maxBufferSize = settings.value(MAX_BUFFER_SIZE, TextThread::maxBufferSize).toInt();
|
TextThread::maxBufferSize = settings.value(MAX_BUFFER_SIZE, TextThread::maxBufferSize).toInt();
|
||||||
TextThread::defaultCodepage = settings.value(DEFAULT_CODEPAGE, TextThread::defaultCodepage).toInt();
|
Host::defaultCodepage = settings.value(DEFAULT_CODEPAGE, Host::defaultCodepage).toInt();
|
||||||
|
|
||||||
Host::Start(
|
Host::Start(
|
||||||
[this](DWORD processId) { ProcessConnected(processId); },
|
[this](DWORD processId) { ProcessConnected(processId); },
|
||||||
@ -242,7 +242,7 @@ void MainWindow::Settings()
|
|||||||
save->setText(SAVE_SETTINGS);
|
save->setText(SAVE_SETTINGS);
|
||||||
layout->addWidget(save);
|
layout->addWidget(save);
|
||||||
for (auto[value, label] : Array<std::tuple<int&, const char*>>{
|
for (auto[value, label] : Array<std::tuple<int&, const char*>>{
|
||||||
{ TextThread::defaultCodepage, DEFAULT_CODEPAGE },
|
{ Host::defaultCodepage, DEFAULT_CODEPAGE },
|
||||||
{ TextThread::maxBufferSize, MAX_BUFFER_SIZE },
|
{ TextThread::maxBufferSize, MAX_BUFFER_SIZE },
|
||||||
{ TextThread::flushDelay, FLUSH_DELAY },
|
{ TextThread::flushDelay, FLUSH_DELAY },
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
#include "host/host.h"
|
||||||
#include "host/util.h"
|
#include "host/util.h"
|
||||||
#include <Psapi.h>
|
#include <Psapi.h>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
@ -65,6 +66,10 @@ namespace
|
|||||||
hp.codepage = codepage.captured(1).toInt();
|
hp.codepage = codepage.captured(1).toInt();
|
||||||
SCode.remove(0, codepage.captured(0).length());
|
SCode.remove(0, codepage.captured(0).length());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hp.codepage = Host::defaultCodepage;
|
||||||
|
}
|
||||||
|
|
||||||
wcscpy_s<MAX_MODULE_SIZE>(hp.text, S(SCode).c_str());
|
wcscpy_s<MAX_MODULE_SIZE>(hp.text, S(SCode).c_str());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user