bugfix read code

This commit is contained in:
Akash Mozumdar 2018-08-21 23:41:19 -04:00
parent 2c37a50f7b
commit 1312a80ddd

View File

@ -448,13 +448,13 @@ DWORD WINAPI ReaderThread(LPVOID threadParam)
{ {
TextHook* hook = (TextHook*)threadParam; TextHook* hook = (TextHook*)threadParam;
BYTE buffer[PIPE_BUFFER_SIZE] = {}; BYTE buffer[PIPE_BUFFER_SIZE] = {};
char testChar1 = 0, testChar2 = 0; // Artikash 8/20/2018: two testChars in case the first character of the string is the same
unsigned int changeCount = 0; unsigned int changeCount = 0;
int dataLen = 0;
const char* currentAddress = (char*)hook->hp.address; const char* currentAddress = (char*)hook->hp.address;
while (true) while (true)
{ {
Sleep(1000); Sleep(500);
if (testChar1 == *currentAddress && testChar2 == *(currentAddress + 3)) if (memcmp(buffer + HEADER_SIZE, currentAddress, dataLen) == 0)
{ {
changeCount = 0; changeCount = 0;
continue; continue;
@ -466,7 +466,6 @@ DWORD WINAPI ReaderThread(LPVOID threadParam)
break; break;
} }
int dataLen;
if (hook->hp.type & USING_UNICODE) if (hook->hp.type & USING_UNICODE)
dataLen = wcslen((const wchar_t*)currentAddress) * 2; dataLen = wcslen((const wchar_t*)currentAddress) * 2;
else else
@ -478,9 +477,6 @@ DWORD WINAPI ReaderThread(LPVOID threadParam)
memcpy(buffer + HEADER_SIZE, currentAddress, dataLen); memcpy(buffer + HEADER_SIZE, currentAddress, dataLen);
DWORD unused; DWORD unused;
WriteFile(::hookPipe, buffer, dataLen + HEADER_SIZE, &unused, nullptr); WriteFile(::hookPipe, buffer, dataLen + HEADER_SIZE, &unused, nullptr);
testChar1 = *currentAddress;
testChar2 = *(currentAddress + 3);
} }
hook->ClearHook(); hook->ClearHook();
return 0; return 0;