diff --git a/vnr/texthook/host/host.cc b/vnr/texthook/host/host.cc index ce738ad..853c3b8 100644 --- a/vnr/texthook/host/host.cc +++ b/vnr/texthook/host/host.cc @@ -19,25 +19,13 @@ #include "ccutil/ccmacro.h" #include -//#define ITH_WINE -//#define ITH_USE_UX_DLLS IthIsWine() -//#define ITH_USE_XP_DLLS (IthIsWindowsXp() && !IthIsWine()) - #define DEBUG "vnrhost/host.cc" #include "sakurakit/skdebug.h" namespace { // unnamed -//enum { HOOK_TIMEOUT = -50000000 }; // in nanoseconds = 5 seconds - CRITICAL_SECTION hostCs; - //WCHAR exist[] = ITH_PIPEEXISTS_EVENT; - //WCHAR mutex[] = L"ITH_RUNNING"; - //WCHAR EngineName[] = ITH_ENGINE_DLL; - //WCHAR EngineNameXp[] = ITH_ENGINE_XP_DLL; - //WCHAR DllName[] = ITH_CLIENT_DLL; - //WCHAR DllNameXp[] = ITH_CLIENT_XP_DLL; HANDLE preventDuplicationMutex; // jichi 9/28/2013: used to guard pipe HANDLE hookMutex; // jichi 9/28/2013: used to guard hook modification } // unnamed namespace diff --git a/vnr/texthook/host/pipe.cc b/vnr/texthook/host/pipe.cc index 14896f7..271da2e 100644 --- a/vnr/texthook/host/pipe.cc +++ b/vnr/texthook/host/pipe.cc @@ -78,8 +78,8 @@ void CreateNewPipe() { HANDLE hookPipe, hostPipe, TextReceivingThread; - hookPipe = CreateNamedPipeW(ITH_TEXT_PIPE, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, 0x1000, 0x1000, MAXDWORD, NULL); - hostPipe = CreateNamedPipeW(ITH_COMMAND_PIPE, PIPE_ACCESS_OUTBOUND, 0, PIPE_UNLIMITED_INSTANCES, 0x1000, 0x1000, MAXDWORD, NULL); + hookPipe = CreateNamedPipeW(ITH_TEXT_PIPE, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, MAXDWORD, NULL); + hostPipe = CreateNamedPipeW(ITH_COMMAND_PIPE, PIPE_ACCESS_OUTBOUND, 0, PIPE_UNLIMITED_INSTANCES, PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, MAXDWORD, NULL); TextReceivingThread = CreateThread(nullptr, 0, TextReceiver, hookPipe, 0, nullptr); man->RegisterPipe(hookPipe, hostPipe, TextReceivingThread); } @@ -89,7 +89,6 @@ DWORD WINAPI TextReceiver(LPVOID lpThreadParameter) HANDLE hookPipe = (HANDLE)lpThreadParameter; ConnectNamedPipe(hookPipe, nullptr); - enum { PIPE_BUFFER_SIZE = 0x1000 }; BYTE* buffer = new BYTE[PIPE_BUFFER_SIZE]; DWORD bytesRead, processId; diff --git a/vnr/vnrhook/include/const.h b/vnr/vnrhook/include/const.h index 8a766dc..ebf2079 100644 --- a/vnr/vnrhook/include/const.h +++ b/vnr/vnrhook/include/const.h @@ -114,6 +114,8 @@ enum HookParamType : unsigned long { // Fuse all threads, and prevent floating enum { FIXED_SPLIT_VALUE = 0x10001 }; +enum { PIPE_BUFFER_SIZE = 0x1000}; + // jichi 12/18/2013: // These dlls are used to guess the range for non-NO_CONTEXT hooks. // diff --git a/vnr/vnrhook/src/pipe.cc b/vnr/vnrhook/src/pipe.cc index 706cd4c..03a97af 100644 --- a/vnr/vnrhook/src/pipe.cc +++ b/vnr/vnrhook/src/pipe.cc @@ -25,7 +25,7 @@ DWORD WINAPI PipeManager(LPVOID unused) while (::running) { DWORD count; - BYTE* buffer = new BYTE[0x1000]; + BYTE* buffer = new BYTE[PIPE_BUFFER_SIZE]; HANDLE hostPipe = ::hookPipe = INVALID_HANDLE_VALUE, pipeAcquisitionMutex = CreateMutexW(nullptr, TRUE, ITH_GRANTPIPE_MUTEX); @@ -62,7 +62,7 @@ DWORD WINAPI PipeManager(LPVOID unused) while (::running) { Sleep(STANDARD_WAIT); - if (!ReadFile(hostPipe, buffer, 0x800, &count, nullptr)) + if (!ReadFile(hostPipe, buffer, PIPE_BUFFER_SIZE / 2, &count, nullptr)) // Artikash 5/21/2018: why / 2? wchar_t? { break; }