From 7e080b1b442e403597a97c0f62fed6dc64b038af Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 21 Jan 2019 14:23:26 -0500 Subject: [PATCH] compare using wchar null terminator --- vnrhook/texthook.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vnrhook/texthook.cc b/vnrhook/texthook.cc index af03a11..f6eca4a 100644 --- a/vnrhook/texthook.cc +++ b/vnrhook/texthook.cc @@ -230,7 +230,7 @@ DWORD WINAPI TextHook::Reader(LPVOID hookPtr) while (WaitForSingleObject(This->readerEvent, 500) == WAIT_TIMEOUT) { if (This->hp.type & DATA_INDIRECT) currentAddress = *(uintptr_t*)This->address + This->hp.index; - if (memcmp(buffer, (void*)currentAddress, dataLen + 1) == 0) + if (memcmp(buffer, (void*)currentAddress, dataLen + 2) == 0) { changeCount = 0; continue; @@ -244,8 +244,8 @@ DWORD WINAPI TextHook::Reader(LPVOID hookPtr) if (This->hp.type & USING_UNICODE) dataLen = wcslen((wchar_t*)currentAddress) * 2; else dataLen = strlen((char*)currentAddress); - if (dataLen > PIPE_BUFFER_SIZE - 1) continue; // results in silly error msg but oh well - memcpy(buffer, (void*)currentAddress, dataLen + 1); + if (dataLen > PIPE_BUFFER_SIZE - 2) continue; // results in silly error msg but oh well + memcpy(buffer, (void*)currentAddress, dataLen + 2); TextOutput({ GetCurrentProcessId(), This->address, 0, 0 }, buffer, dataLen); } }