本文整理汇总了C++中instruction::Ptr::rawByte方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::rawByte方法的具体用法?C++ Ptr::rawByte怎么用?C++ Ptr::rawByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类instruction::Ptr
的用法示例。
在下文中一共展示了Ptr::rawByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateBranch
void SpringboardBuilder::generateBranch(Address from, Address to, codeGen &gen) {
gen.invalidate();
gen.allocate(16);
gen.setAddrSpace(addrSpace_);
gen.setAddr(from);
insnCodeGen::generateBranch(gen, from, to);
springboard_cerr << "Generated springboard branch " << hex << from << "->" << to << dec << endl;
#if 0
#include "InstructionDecoder.h"
using namespace Dyninst::InstructionAPI;
Address base = 0;
InstructionDecoder deco(gen.start_ptr(),gen.size(),Arch_aarch64);
Instruction::Ptr insn = deco.decode();
while(base<gen.used()+5) {
std::stringstream rawInsn;
unsigned idx = insn->size();
while(idx--) rawInsn << hex << setfill('0') << setw(2) << (unsigned int) insn->rawByte(idx);
cerr << "\t" << hex << base << ": " << rawInsn.str() << " "
<< insn->format(base) << dec << endl;
base += insn->size();
insn = deco.decode();
}
#endif
}
示例2: instrumentBasicBlock
void instrumentBasicBlock(BPatch_function * function, BPatch_basicBlock *block)
{
Instruction::Ptr iptr;
void *addr;
unsigned char bytes[MAX_RAW_INSN_SIZE];
size_t nbytes, i;
// iterate backwards (PatchAPI restriction)
PatchBlock::Insns insns;
PatchAPI::convert(block)->getInsns(insns);
PatchBlock::Insns::reverse_iterator j;
for (j = insns.rbegin(); j != insns.rend(); j++) {
// get instruction bytes
addr = (void*)((*j).first);
iptr = (*j).second;
nbytes = iptr->size();
assert(nbytes <= MAX_RAW_INSN_SIZE);
for (i=0; i<nbytes; i++) {
bytes[i] = iptr->rawByte(i);
}
bytes[nbytes] = '\0';
// apply filter
mainDecoder->decode((uint64_t)addr,iptr);
if (mainDecoder->isCall()&&mainDecoder->isCall_indirect())
{
instrumentCallIns(addr, bytes, nbytes,
PatchAPI::convert(function), PatchAPI::convert(block),mainDecoder->isCall_indirect());
}
else if (mainDecoder->isIndirectJmp())
{
instrumentIndirectJmpIns(addr, bytes, nbytes,
PatchAPI::convert(function), PatchAPI::convert(block));
}
else if (mainDecoder->needDepie())
{
instrumentInstruction(addr, bytes, nbytes,
PatchAPI::convert(function), PatchAPI::convert(block));
}
}
}