add default codepage option
This commit is contained in:
parent
71f7e9bf29
commit
a99131fa23
@ -126,7 +126,7 @@ namespace
|
|||||||
case HOST_NOTIFICATION_TEXT:
|
case HOST_NOTIFICATION_TEXT:
|
||||||
{
|
{
|
||||||
auto info = *(ConsoleOutputNotif*)buffer;
|
auto info = *(ConsoleOutputNotif*)buffer;
|
||||||
Host::AddConsoleOutput(StringToWideString(info.message, CP_UTF8));
|
Host::AddConsoleOutput(StringToWideString(info.message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -273,7 +273,7 @@ namespace Host
|
|||||||
std::wstring GetHookName(DWORD processId, uint64_t addr)
|
std::wstring GetHookName(DWORD processId, uint64_t addr)
|
||||||
{
|
{
|
||||||
LOCK(hostMutex);
|
LOCK(hostMutex);
|
||||||
return StringToWideString(processRecordsByIds.at(processId)->GetHook(addr).hookName, CP_UTF8);
|
return StringToWideString(processRecordsByIds.at(processId)->GetHook(addr).hookName);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TextThread> GetThread(ThreadParam tp)
|
std::shared_ptr<TextThread> GetThread(ThreadParam tp)
|
||||||
|
@ -30,7 +30,8 @@ namespace Host
|
|||||||
void AddConsoleOutput(std::wstring text);
|
void AddConsoleOutput(std::wstring text);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::wstring StringToWideString(const std::string& text, UINT encoding)
|
inline UINT DEFAULT_CODEPAGE = SHIFT_JIS;
|
||||||
|
inline std::wstring StringToWideString(const std::string& text, UINT encoding = DEFAULT_CODEPAGE)
|
||||||
{
|
{
|
||||||
std::wstring ret(text.size() + 1, 0);
|
std::wstring ret(text.size() + 1, 0);
|
||||||
ret.resize(MultiByteToWideChar(encoding, 0, text.c_str(), -1, ret.data(), ret.capacity()) - 1);
|
ret.resize(MultiByteToWideChar(encoding, 0, text.c_str(), -1, ret.data(), ret.capacity()) - 1);
|
||||||
|
@ -57,7 +57,7 @@ void TextThread::AddText(const BYTE* data, int len)
|
|||||||
LOCK(threadMutex);
|
LOCK(threadMutex);
|
||||||
buffer += hp.type & USING_UNICODE
|
buffer += hp.type & USING_UNICODE
|
||||||
? std::wstring((wchar_t*)data, len / 2)
|
? std::wstring((wchar_t*)data, len / 2)
|
||||||
: StringToWideString(std::string((char*)data, len), hp.codepage);
|
: StringToWideString(std::string((char*)data, len), hp.codepage != 0 ? hp.codepage : DEFAULT_CODEPAGE);
|
||||||
if (std::all_of(buffer.begin(), buffer.end(), [&](wchar_t c) { return repeatingChars.count(c) > 0; })) buffer.clear();
|
if (std::all_of(buffer.begin(), buffer.end(), [&](wchar_t c) { return repeatingChars.count(c) > 0; })) buffer.clear();
|
||||||
timestamp = GetTickCount();
|
timestamp = GetTickCount();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect());
|
if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect());
|
||||||
// TODO: add GUI for changing these
|
// TODO: add GUI for changing these
|
||||||
|
if (settings.contains("Default_Codepage")) DEFAULT_CODEPAGE = settings.value("Default_Codepage").toInt();
|
||||||
if (settings.contains("Flush_Delay")) TextThread::flushDelay = settings.value("Flush_Delay").toInt();
|
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();
|
if (settings.contains("Max_Buffer_Size")) TextThread::maxBufferSize = settings.value("Max_Buffer_Size").toInt();
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
settings.setValue("Window", this->geometry());
|
settings.setValue("Window", this->geometry());
|
||||||
|
settings.setValue("Default_Codepage", DEFAULT_CODEPAGE);
|
||||||
settings.setValue("Flush_Delay", TextThread::flushDelay);
|
settings.setValue("Flush_Delay", TextThread::flushDelay);
|
||||||
settings.setValue("Max_Buffer_Size", TextThread::maxBufferSize);
|
settings.setValue("Max_Buffer_Size", TextThread::maxBufferSize);
|
||||||
settings.sync();
|
settings.sync();
|
||||||
|
@ -189,7 +189,7 @@ namespace
|
|||||||
else if (hp.type & USING_UTF8) codeBuilder << "V";
|
else if (hp.type & USING_UTF8) codeBuilder << "V";
|
||||||
else codeBuilder << "S";
|
else codeBuilder << "S";
|
||||||
|
|
||||||
if (hp.codepage != SHIFT_JIS && hp.codepage != CP_UTF8) codeBuilder << hp.codepage << "#";
|
if (hp.codepage != 0 && hp.codepage != CP_UTF8) codeBuilder << hp.codepage << "#";
|
||||||
|
|
||||||
codeBuilder.setIntegerBase(16);
|
codeBuilder.setIntegerBase(16);
|
||||||
codeBuilder.setNumberFlags(QTextStream::UppercaseDigits);
|
codeBuilder.setNumberFlags(QTextStream::UppercaseDigits);
|
||||||
@ -220,7 +220,7 @@ namespace
|
|||||||
}
|
}
|
||||||
if (hp.type & NO_CONTEXT) codeBuilder << "N";
|
if (hp.type & NO_CONTEXT) codeBuilder << "N";
|
||||||
|
|
||||||
if (hp.codepage != SHIFT_JIS && hp.codepage != CP_UTF8) codeBuilder << hp.codepage << "#";
|
if (hp.codepage != 0 && hp.codepage != CP_UTF8) codeBuilder << hp.codepage << "#";
|
||||||
|
|
||||||
codeBuilder.setIntegerBase(16);
|
codeBuilder.setIntegerBase(16);
|
||||||
codeBuilder.setNumberFlags(QTextStream::UppercaseDigits);
|
codeBuilder.setNumberFlags(QTextStream::UppercaseDigits);
|
||||||
|
@ -15,7 +15,7 @@ static QString CodeInfoDump =
|
|||||||
/H{A|B|W|S|Q|V}[N][codepage#]data_offset[*deref_offset1][:split_offset[*deref_offset2]]@addr[:module[:func]]\r\n\
|
/H{A|B|W|S|Q|V}[N][codepage#]data_offset[*deref_offset1][:split_offset[*deref_offset2]]@addr[:module[:func]]\r\n\
|
||||||
OR\r\n\
|
OR\r\n\
|
||||||
Enter read code\r\n\
|
Enter read code\r\n\
|
||||||
/R{S|Q|V}[#codepage][*deref_offset|0]@addr\r\n\
|
/R{S|Q|V}[codepage#][*deref_offset|0]@addr\r\n\
|
||||||
All numbers except codepage in hexadecimal\r\n\
|
All numbers except codepage in hexadecimal\r\n\
|
||||||
A/B: Shift-JIS char little/big endian\r\n\
|
A/B: Shift-JIS char little/big endian\r\n\
|
||||||
W: UTF-16 char\r\n\
|
W: UTF-16 char\r\n\
|
||||||
|
@ -104,6 +104,7 @@ bool TextHook::InsertHook()
|
|||||||
{
|
{
|
||||||
//ConsoleOutput("vnrcli:InsertHook: enter");
|
//ConsoleOutput("vnrcli:InsertHook: enter");
|
||||||
LOCK(*sectionMutex);
|
LOCK(*sectionMutex);
|
||||||
|
if (hp.type & USING_UTF8) hp.codepage = CP_UTF8;
|
||||||
if (hp.type & DIRECT_READ) return InsertReadCode();
|
if (hp.type & DIRECT_READ) return InsertReadCode();
|
||||||
#ifndef _WIN64
|
#ifndef _WIN64
|
||||||
else return InsertHookCode();
|
else return InsertHookCode();
|
||||||
@ -229,9 +230,6 @@ bool TextHook::InsertHookCode()
|
|||||||
else if (HMODULE moduleBase = GetModuleHandleW(hp.module)) hp.insertion_address += (uint64_t)moduleBase;
|
else if (HMODULE moduleBase = GetModuleHandleW(hp.module)) hp.insertion_address += (uint64_t)moduleBase;
|
||||||
else return ConsoleOutput("Textractor: UnsafeInsertHookCode: FAILED: module not present"), false;
|
else return ConsoleOutput("Textractor: UnsafeInsertHookCode: FAILED: module not present"), false;
|
||||||
|
|
||||||
if (hp.type & USING_UTF8) hp.codepage = CP_UTF8;
|
|
||||||
if (hp.codepage == 0) hp.codepage = SHIFT_JIS; // Use Shift-JIS unless custom encoding was specified
|
|
||||||
|
|
||||||
BYTE* original;
|
BYTE* original;
|
||||||
insert:
|
insert:
|
||||||
if (MH_STATUS err = MH_CreateHook((void*)hp.insertion_address, (void*)trampoline, (void**)&original))
|
if (MH_STATUS err = MH_CreateHook((void*)hp.insertion_address, (void*)trampoline, (void**)&original))
|
||||||
|
Loading…
Reference in New Issue
Block a user