add prefilter

This commit is contained in:
Akash Mozumdar 2018-10-04 23:23:57 -04:00
parent 5f74684b46
commit 0b7db9e5ca
3 changed files with 3 additions and 0 deletions

View File

@ -144,6 +144,7 @@ namespace Host
void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove) void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove)
{ {
OnAttach = onAttach; OnDetach = onDetach; OnCreate = onCreate; OnRemove = onRemove; OnAttach = onAttach; OnDetach = onDetach; OnCreate = onCreate; OnRemove = onRemove;
TextThread::Prefilter = (int(*)(wchar_t*, const wchar_t*))GetProcAddress(LoadLibraryW(L"0_Prefilter.dll"), "OnNewData");
OnCreate(textThreadsByParams[CONSOLE] = new TextThread(CONSOLE, USING_UNICODE)); OnCreate(textThreadsByParams[CONSOLE] = new TextThread(CONSOLE, USING_UNICODE));
StartPipe(); StartPipe();
} }

View File

@ -47,6 +47,7 @@ void TextThread::AddText(const BYTE* data, int len)
? std::wstring((wchar_t*)data, len / 2) ? std::wstring((wchar_t*)data, len / 2)
: StringToWideString(std::string((char*)data, len), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS); : StringToWideString(std::string((char*)data, len), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
LOCK(ttMutex); LOCK(ttMutex);
if (Prefilter) wData.resize(Prefilter(wData.data(), storage.c_str()));
buffer.append(wData); buffer.append(wData);
timestamp = GetTickCount(); timestamp = GetTickCount();
} }

View File

@ -24,6 +24,7 @@ public:
const std::wstring name; const std::wstring name;
const ThreadParam tp; const ThreadParam tp;
inline static int(*Prefilter)(wchar_t*, const wchar_t*) = nullptr;
inline static int FlushDelay = 250; // flush every 250ms by default inline static int FlushDelay = 250; // flush every 250ms by default
inline static int MaxBufferSize = 200; inline static int MaxBufferSize = 200;
inline static int ThreadCounter = 0; inline static int ThreadCounter = 0;