本文整理汇总了Python中Analysis.find_instr方法的典型用法代码示例。如果您正苦于以下问题:Python Analysis.find_instr方法的具体用法?Python Analysis.find_instr怎么用?Python Analysis.find_instr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analysis
的用法示例。
在下文中一共展示了Analysis.find_instr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DisassemblerView
# 需要导入模块: import Analysis [as 别名]
# 或者: from Analysis import find_instr [as 别名]
#.........这里部分代码省略.........
# Check each block for hits
for block in self.blocks.values():
# Compute coordinate relative to text area in block
blockx = x - (block.x + (2 * self.charWidth))
blocky = y - (block.y + (2 * self.charWidth))
# Check to see if click is within bounds of block
if (blockx < 0) or (blockx > (block.width - 4 * self.charWidth)):
continue
if (blocky < 0) or (blocky > (block.height - 4 * self.charWidth)):
continue
# Compute row and column within text
col = int(blockx / self.charWidth)
row = int(blocky / self.charHeight)
# Check tokens to see if one was clicked
cur_row = 0
for line in block.block.header_text.tokens:
if cur_row == row:
for token in line:
if (col >= token[0]) and (col < (token[0] + token[1])):
# Clicked on a token
return token
cur_row += 1
for instr in block.block.instrs:
for line in instr.text.tokens:
if cur_row == row:
for token in line:
if (col >= token[0]) and (col < (token[0] + token[1])):
# Clicked on a token
return token
cur_row += 1
return None
def find_instr(self, addr):
for block in self.blocks.values():
for instr in block.block.instrs:
if instr.addr == addr:
return instr
return None
def nop_out(self, addr):
instr = self.find_instr(addr)
if instr != None:
self.view.begin_undo()
instr.patch_to_nop(self.data)
self.view.commit_undo()
def always_branch(self, addr):
instr = self.find_instr(addr)
if instr != None:
self.view.begin_undo()
instr.patch_to_always_branch(self.data)
self.view.commit_undo()
def invert_branch(self, addr):
instr = self.find_instr(addr)
if instr != None:
self.view.begin_undo()
instr.patch_to_invert_branch(self.data)
self.view.commit_undo()
def skip_and_return_zero(self, addr):
instr = self.find_instr(addr)
if instr != None:
self.view.begin_undo()
instr.patch_to_zero_return(self.data)