本文整理汇总了C++中Symtab::findVariablesByName方法的典型用法代码示例。如果您正苦于以下问题:C++ Symtab::findVariablesByName方法的具体用法?C++ Symtab::findVariablesByName怎么用?C++ Symtab::findVariablesByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symtab
的用法示例。
在下文中一共展示了Symtab::findVariablesByName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeModuleVariable
DysectErrorCode Backend::writeModuleVariable(Dyninst::ProcControlAPI::Process::ptr process, std::string variableName, std::string libraryPath, void *value, int size) {
bool result, found = false;
string libraryName;
Symtab *symtab = NULL;
Offset varOffset;
Address loadAddress;
vector<SymtabAPI::Variable *> variables;
LibraryPool::iterator libsIter;
if (symtabs.find(libraryPath) == symtabs.end()) {
result = Symtab::openFile(symtab, libraryPath.c_str());
if (result == false) {
DYSECTWARN(false, "Failed to find file %s for symtab", libraryPath.c_str());
return Error;
}
}
else {
symtab = symtabs[libraryPath];
}
result = symtab->findVariablesByName(variables, variableName);
if (result == false || variables.size() < 1) {
DYSECTWARN(false, "Failed to find %s variable", variableName.c_str());
return Error;
}
varOffset = variables[0]->getOffset();
DYSECTLOG(true, "found %s at offset 0x%lx", variableName.c_str(), varOffset);
libraryName = basename(libraryPath.c_str());
LibraryPool &libs = process->libraries();
for (libsIter = libs.begin(); libsIter != libs.end(); libsIter++)
{
Library::ptr libraryPtr = *libsIter;
if (libraryPtr->getName().find(libraryName) == string::npos)
continue;
loadAddress = (*libsIter)->getLoadAddress();
found = true;
DYSECTLOG(true, "found library %s at 0x%lx", libraryName.c_str(), loadAddress);
break;
}
if (found == false) {
DYSECTWARN(false, "Failed to find library %s", libraryName.c_str());
return Error;
}
process->writeMemory(loadAddress + varOffset, value, size);
return OK;
}