mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-11-27 07:44:02 +08:00
rs length changed
This commit is contained in:
parent
06503ed972
commit
16852394ff
@ -154,11 +154,11 @@ int HookStrLen(HookParam* hp,BYTE* data){
|
|||||||
if(data==0)return 0;
|
if(data==0)return 0;
|
||||||
|
|
||||||
if(hp->type&CODEC_UTF16)
|
if(hp->type&CODEC_UTF16)
|
||||||
return wcslen((wchar_t*)data)*2;
|
return wcsnlen((wchar_t*)data,TEXT_BUFFER_SIZE)*2;
|
||||||
else if(hp->type&CODEC_UTF32)
|
else if(hp->type&CODEC_UTF32)
|
||||||
return u32strlen((uint32_t*)data)*4;
|
return u32strlen((uint32_t*)data)*4;
|
||||||
else
|
else
|
||||||
return strlen((char*)data);
|
return strnlen((char*)data,TEXT_BUFFER_SIZE);
|
||||||
|
|
||||||
}
|
}
|
||||||
static std::mutex maplock;
|
static std::mutex maplock;
|
||||||
|
@ -413,7 +413,12 @@ void TextHook::Read()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (WaitForSingleObject(readerEvent, 500) == WAIT_TIMEOUT) if (location&&(memcmp(pbData, location, dataLen) != 0)) if (int currentLen = HookStrlen((BYTE*)location))
|
while (WaitForSingleObject(readerEvent, 500) == WAIT_TIMEOUT)
|
||||||
|
{
|
||||||
|
if(!location)continue;
|
||||||
|
int currentLen = HookStrlen((BYTE*)location);
|
||||||
|
bool changed=memcmp(pbData, location, dataLen) != 0;
|
||||||
|
if(changed ||(currentLen!=dataLen))
|
||||||
{
|
{
|
||||||
dataLen = min(currentLen, TEXT_BUFFER_SIZE);
|
dataLen = min(currentLen, TEXT_BUFFER_SIZE);
|
||||||
memcpy(pbData, location, dataLen);
|
memcpy(pbData, location, dataLen);
|
||||||
@ -422,6 +427,7 @@ void TextHook::Read()
|
|||||||
memcpy(pbData, location, dataLen);
|
memcpy(pbData, location, dataLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
Loading…
Reference in New Issue
Block a user