本文整理汇总了C++中ModulesMap::find方法的典型用法代码示例。如果您正苦于以下问题:C++ ModulesMap::find方法的具体用法?C++ ModulesMap::find怎么用?C++ ModulesMap::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModulesMap
的用法示例。
在下文中一共展示了ModulesMap::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDescriptorName
void
patchDescriptor(HMODULE hModule,
const char *szModule,
T pImportDescriptor)
{
const char* szDescriptorName = getDescriptorName(hModule, pImportDescriptor);
ModulesMap::const_iterator modIt = modulesMap.find(szDescriptorName);
if (modIt != modulesMap.end()) {
const char *szMatchModule = modIt->first; // same as szDescriptorName
const Module & module = modIt->second;
const FunctionMap & functionMap = module.functionMap;
FunctionMap::const_iterator fnIt;
for (fnIt = functionMap.begin(); fnIt != functionMap.end(); ++fnIt) {
const char *szFunctionName = fnIt->first;
LPVOID lpNewAddress = fnIt->second;
BOOL bHooked;
bHooked = patchFunction(hModule, szModule, szMatchModule, pImportDescriptor, szFunctionName, lpNewAddress);
if (bHooked && !module.bInternal && pSharedMem) {
pSharedMem->bReplaced = TRUE;
}
}
}
}
示例2: GetProcAddress
static FARPROC WINAPI
MyGetProcAddress(HMODULE hModule, LPCSTR lpProcName) {
if (VERBOSITY >= 3) {
/* XXX this can cause segmentation faults */
logGetProcAddress(hModule, lpProcName);
}
if (!NOOP) {
char szModule[MAX_PATH];
DWORD dwRet = GetModuleFileNameA(hModule, szModule, sizeof szModule);
assert(dwRet);
const char *szBaseName = getBaseName(szModule);
ModulesMap::const_iterator modIt;
modIt = modulesMap.find(szBaseName);
if (modIt != modulesMap.end()) {
if (VERBOSITY > 1 && VERBOSITY < 3) {
logGetProcAddress(hModule, lpProcName);
}
if (HIWORD(lpProcName) == 0) {
debugPrintf("inject: ignoring %[email protected]%u\n", szBaseName, LOWORD(lpProcName));
return GetProcAddress(hModule, lpProcName);
}
const Module & module = modIt->second;
const FunctionMap & functionMap = module.functionMap;
FunctionMap::const_iterator fnIt;
fnIt = functionMap.find(lpProcName);
if (fnIt != functionMap.end()) {
LPVOID pProcAddress = fnIt->second;
if (VERBOSITY > 0) {
debugPrintf("inject: replacing %s!%s\n", szBaseName, lpProcName);
}
if (!module.bInternal && pSharedMem) {
pSharedMem->bReplaced = TRUE;
}
return (FARPROC)pProcAddress;
} else {
if (VERBOSITY > 0 && !module.bInternal) {
debugPrintf("inject: ignoring %s!%s\n", szBaseName, lpProcName);
}
}
}
}
return GetProcAddress(hModule, lpProcName);
}
示例3: getDescriptorName
void
patchDescriptor(HMODULE hModule,
const char *szModule,
T pImportDescriptor,
Action action)
{
const char* szDescriptorName = getDescriptorName(hModule, pImportDescriptor);
ModulesMap::const_iterator modIt = modulesMap.find(szDescriptorName);
if (modIt != modulesMap.end()) {
const char *szMatchModule = modIt->first; // same as szDescriptorName
const Module & module = modIt->second;
const FunctionMap & functionMap = module.functionMap;
FunctionMap::const_iterator fnIt;
for (fnIt = functionMap.begin(); fnIt != functionMap.end(); ++fnIt) {
const char *szFunctionName = fnIt->first;
LPVOID lpHookAddress = fnIt->second;
// Knowning the real address is useful when patching imports by ordinal
LPVOID lpRealAddress = NULL;
HMODULE hRealModule = GetModuleHandleA(szDescriptorName);
if (hRealModule) {
// FIXME: this assertion can fail when the wrapper name is the same as the original DLL
//assert(hRealModule != g_hHookModule);
if (hRealModule != g_hHookModule) {
lpRealAddress = (LPVOID)GetProcAddress(hRealModule, szFunctionName);
}
}
LPVOID lpOldAddress = lpRealAddress;
LPVOID lpNewAddress = lpHookAddress;
if (action == ACTION_UNHOOK) {
std::swap(lpOldAddress, lpNewAddress);
}
BOOL bPatched;
bPatched = patchFunction(hModule, szModule, szMatchModule, pImportDescriptor, szFunctionName, lpOldAddress, lpNewAddress);
if (action == ACTION_HOOK && bPatched && !module.bInternal && pSharedMem) {
pSharedMem->bReplaced = TRUE;
}
}
}
}
示例4:
static inline bool
isMatchModuleName(const char *szModuleName)
{
ModulesMap::const_iterator modIt = modulesMap.find(szModuleName);
return modIt != modulesMap.end();
}