本文整理汇总了C++中MemoryMap::traverse方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryMap::traverse方法的具体用法?C++ MemoryMap::traverse怎么用?C++ MemoryMap::traverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryMap
的用法示例。
在下文中一共展示了MemoryMap::traverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
// Obtain a memory map for disassembly
MemoryMap *disassembly_map(RSIM_Process *proc) {
MemoryMap *map = new MemoryMap(proc->get_memory(), MemoryMap::COPY_SHALLOW);
map->prune(MemoryMap::MM_PROT_READ); // don't let the disassembler read unreadable memory, else it will segfault
// Removes execute permission for any segment whose debug name does not contain the name of the executable. When
// comparing two different executables for clones, we probably don't need to compare code that came from dynamically
// linked libraries since they will be identical in both executables.
struct Pruner: MemoryMap::Visitor {
std::string exename;
Pruner(const std::string &exename): exename(exename) {}
virtual bool operator()(const MemoryMap*, const Extent&, const MemoryMap::Segment &segment_) {
MemoryMap::Segment *segment = const_cast<MemoryMap::Segment*>(&segment_);
if (segment->get_name().find(exename)==std::string::npos) {
unsigned p = segment->get_mapperms();
p &= ~MemoryMap::MM_PROT_EXEC;
segment->set_mapperms(p);
}
return true;
}
} pruner(proc->get_exename());
map->traverse(pruner);
return map;
}