Skip to content

Commit

Permalink
inject: Intercept GetProcAddress with ordinals.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfonseca committed Aug 13, 2015
1 parent 830af26 commit 9202092
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions inject/injectee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,15 +870,32 @@ MyGetProcAddress(HMODULE hModule, LPCSTR lpProcName) {
logGetProcAddress(hModule, lpProcName);
}

const Module & module = modIt->second;
const FunctionMap & functionMap = module.functionMap;
FunctionMap::const_iterator fnIt;

if (HIWORD(lpProcName) == 0) {
FARPROC proc = GetProcAddress(hModule, lpProcName);
if (!proc) {
return proc;
}

for (fnIt = functionMap.begin(); fnIt != functionMap.end(); ++fnIt) {
FARPROC pRealProc = GetProcAddress(hModule, fnIt->first);
if (proc == pRealProc) {
if (VERBOSITY > 0) {
debugPrintf("inject: replacing %s!%s\n", szBaseName, lpProcName);
}
return (FARPROC)fnIt->second;
}

}

debugPrintf("inject: ignoring %s!@%u\n", szBaseName, LOWORD(lpProcName));
return GetProcAddress(hModule, lpProcName);
}

const Module & module = modIt->second;
const FunctionMap & functionMap = module.functionMap;
return proc;
}

FunctionMap::const_iterator fnIt;
fnIt = functionMap.find(lpProcName);

if (fnIt != functionMap.end()) {
Expand Down

0 comments on commit 9202092

Please sign in to comment.