本文整理汇总了C++中Offsets::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Offsets::insert方法的具体用法?C++ Offsets::insert怎么用?C++ Offsets::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Offsets
的用法示例。
在下文中一共展示了Offsets::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindOffsets
// returns rebased addresses
Offsets HexSearcher::FindOffsets(std::vector<unsigned char> const& pattern, size_t limit)
{
Offsets offsets;
ADDRESS begin = GetModuleBegin();
ADDRESS end = GetModuleEnd();
// loop through every hex value in the binary
for (ADDRESS i = begin; (i + pattern.size()) < end; ++i)
{
if (limit && offsets.size() >= limit)
break;
size_t matches = 0;
for (size_t j = 0; j < pattern.size(); j++)
{
// 0x00, any val
if (pattern[j] == 0)
{
matches++;
continue;
}
//ADDRESS static_address = STATIC_REBASE(i + j);
// pattern doesn't match, retry @ next hex val
unsigned char ch = *(unsigned char*)(i + j);
if (ch != pattern[j])
break;
matches++;
}
if (matches == pattern.size())
{
offsets.insert(i);
i += matches;
}
}
return offsets;
}