From aa3b9ee14f11fdb5c7ae50f50b6bfc6e3f1c5b31 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 11 May 2019 08:25:04 -0400 Subject: [PATCH] fix nulls not being reset --- texthook/texthook.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/texthook/texthook.cc b/texthook/texthook.cc index d803db4..8c91251 100644 --- a/texthook/texthook.cc +++ b/texthook/texthook.cc @@ -326,8 +326,10 @@ int TextHook::GetLength(uintptr_t base, uintptr_t in) int TextHook::HookStrlen(BYTE* data) { BYTE* orig = data; - for (int nullsRemaining = hp.null_length ? hp.null_length : hp.type & USING_UNICODE ? 2 : 1; nullsRemaining >= 0; ++data) + int nulls = hp.null_length ? hp.null_length : hp.type & USING_UNICODE ? 2 : 1; + for (int nullsRemaining = nulls; nullsRemaining >= 0; ++data) if (*data == 0) nullsRemaining -= 1; + else nullsRemaining = nulls; return data - orig; }