summaryrefslogtreecommitdiff
path: root/inject
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-06-19 23:42:02 +0100
committerJose Fonseca <jfonseca@vmware.com>2015-06-19 23:42:02 +0100
commit3ce516a4ffbac3677876215f632a94425c1c5142 (patch)
tree90d9edcaf49c54cbb5b029adb33cdc8689f305cc /inject
parent56718d3ca262590028f56379bc6d8f490419b903 (diff)
inject: Handle old-style imports.
Prevent infinite loop.
Diffstat (limited to 'inject')
-rw-r--r--inject/injectee.cpp17
1 files changed, 10 insertions, 7 deletions
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<const char>(hModule, pDelayDescriptor->rvaDLLName);
+ if (pDelayDescriptor->grAttrs & dlattrRva) {
+ return rvaToVa<const char>(hModule, pDelayDescriptor->rvaDLLName);
+ } else {
+ // old-stye, with ImgDelayDescr::szName being a LPCSTR
+ return reinterpret_cast<LPCSTR>(pDelayDescriptor->rvaDLLName);
+ }
}
@@ -636,12 +641,10 @@ patchModule(HMODULE hModule,
if (pDelayDescriptor) {
while (pDelayDescriptor->rvaDLLName) {
if (VERBOSITY > 1) {
- const char* szName = rvaToVa<const char>(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);