From 3ce516a4ffbac3677876215f632a94425c1c5142 Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Fri, 19 Jun 2015 23:42:02 +0100 Subject: inject: Handle old-style imports. Prevent infinite loop. --- inject/injectee.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'inject') diff --git a/inject/injectee.cpp b/inject/injectee.cpp index 1364d840..f76f4635 100644 --- a/inject/injectee.cpp +++ b/inject/injectee.cpp @@ -285,7 +285,12 @@ static const char * getDescriptorName(HMODULE hModule, const PImgDelayDescr pDelayDescriptor) { - return rvaToVa(hModule, pDelayDescriptor->rvaDLLName); + if (pDelayDescriptor->grAttrs & dlattrRva) { + return rvaToVa(hModule, pDelayDescriptor->rvaDLLName); + } else { + // old-stye, with ImgDelayDescr::szName being a LPCSTR + return reinterpret_cast(pDelayDescriptor->rvaDLLName); + } } @@ -636,12 +641,10 @@ patchModule(HMODULE hModule, if (pDelayDescriptor) { while (pDelayDescriptor->rvaDLLName) { if (VERBOSITY > 1) { - const char* szName = rvaToVa(hModule, pDelayDescriptor->rvaDLLName); - debugPrintf("inject: found delay-load import entry for module %s\n", szName); - } - - if (!(pDelayDescriptor->grAttrs & dlattrRva)) { - continue; + const char* szName = getDescriptorName(hModule, pDelayDescriptor); + debugPrintf("inject: found %sdelay-load import entry for module %s\n", + pDelayDescriptor->grAttrs & dlattrRva ? "" : "old-style ", + szName); } patchDescriptor(hModule, szModule, pDelayDescriptor); -- cgit v1.2.3