forked from Public-Mirror/Textractor
refactor
This commit is contained in:
parent
7a059cc2e0
commit
4dc7b236c9
@ -6,7 +6,6 @@
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "../vnrhook/hijack/texthook.h"
|
#include "../vnrhook/hijack/texthook.h"
|
||||||
#include <atlbase.h> // A2W
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -116,8 +115,7 @@ namespace
|
|||||||
case HOST_NOTIFICATION_TEXT:
|
case HOST_NOTIFICATION_TEXT:
|
||||||
{
|
{
|
||||||
auto info = *(ConsoleOutputNotif*)buffer;
|
auto info = *(ConsoleOutputNotif*)buffer;
|
||||||
USES_CONVERSION;
|
Host::AddConsoleOutput(ToWString(info.message, CP_UTF8));
|
||||||
Host::AddConsoleOutput(A2W(info.message));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -255,11 +253,10 @@ namespace Host
|
|||||||
if (hooks[i].hp.address == addr)
|
if (hooks[i].hp.address == addr)
|
||||||
{
|
{
|
||||||
buffer.resize(hooks[i].name_length);
|
buffer.resize(hooks[i].name_length);
|
||||||
ReadProcessMemory(pr.processHandle, hooks[i].hook_name, &buffer[0], hooks[i].name_length, nullptr);
|
ReadProcessMemory(pr.processHandle, hooks[i].hook_name, buffer.data(), hooks[i].name_length, nullptr);
|
||||||
}
|
}
|
||||||
ReleaseMutex(pr.sectionMutex);
|
ReleaseMutex(pr.sectionMutex);
|
||||||
USES_CONVERSION;
|
return ToWString(buffer.c_str(), CP_UTF8);
|
||||||
return std::wstring(A2W(buffer.c_str()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextThread* GetThread(ThreadParam tp)
|
TextThread* GetThread(ThreadParam tp)
|
||||||
|
@ -28,4 +28,12 @@ namespace Host
|
|||||||
TextThread* GetThread(ThreadParam tp);
|
TextThread* GetThread(ThreadParam tp);
|
||||||
void AddConsoleOutput(std::wstring text);
|
void AddConsoleOutput(std::wstring text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::wstring ToWString(const char* text, UINT encoding)
|
||||||
|
{
|
||||||
|
std::wstring ret(strlen(text), 0);
|
||||||
|
ret.resize(MultiByteToWideChar(encoding, 0, text, -1, ret.data(), ret.size()));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -27,17 +27,9 @@ void TextThread::Flush()
|
|||||||
std::wstring sentence;
|
std::wstring sentence;
|
||||||
{
|
{
|
||||||
LOCK(ttMutex);
|
LOCK(ttMutex);
|
||||||
if (buffer.size() < 400 && (GetTickCount() - timestamp < 250 || buffer.size() == 0)) return; // TODO: let user change delay before sentence is flushed
|
if (buffer.size() < 400 && (GetTickCount() - timestamp < flushDelay || buffer.size() == 0)) return; // TODO: let user change delay before sentence is flushed
|
||||||
if (status & USING_UNICODE)
|
if (status & USING_UNICODE) sentence = std::wstring((wchar_t*)buffer.data(), buffer.size() / 2);
|
||||||
{
|
else sentence = ToWString(buffer.data(), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
|
||||||
sentence = std::wstring((wchar_t*)buffer.data(), buffer.size() / 2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wchar_t* converted = new wchar_t[buffer.size()];
|
|
||||||
sentence = std::wstring(converted, MultiByteToWideChar(status & USING_UTF8 ? CP_UTF8 : 932, 0, buffer.data(), buffer.size(), converted, buffer.size()));
|
|
||||||
delete[] converted;
|
|
||||||
}
|
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
AddSentence(sentence);
|
AddSentence(sentence);
|
||||||
|
@ -24,6 +24,8 @@ public:
|
|||||||
const std::wstring name;
|
const std::wstring name;
|
||||||
const ThreadParam tp;
|
const ThreadParam tp;
|
||||||
|
|
||||||
|
inline static unsigned flushDelay = 250; // flush every 250ms by default
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// 8/23/2013 jichi
|
// 8/23/2013 jichi
|
||||||
// Branch: ITH/common.h, rev 128
|
// Branch: ITH/common.h, rev 128
|
||||||
|
|
||||||
enum { MESSAGE_SIZE = 500, PIPE_BUFFER_SIZE = 0x1000 };
|
enum { MESSAGE_SIZE = 500, PIPE_BUFFER_SIZE = 0x1000, SHIFT_JIS = 932 };
|
||||||
|
|
||||||
// jichi 375/2014: Add offset of pusha/pushad
|
// jichi 375/2014: Add offset of pusha/pushad
|
||||||
// http://faydoc.tripod.com/cpu/pushad.htm
|
// http://faydoc.tripod.com/cpu/pushad.htm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user