Skip to content

Commit b0a5412

Browse files
committed
feat: Add 6.9 support, shallow and deep scanner
1 parent b175bff commit b0a5412

File tree

8 files changed

+172
-389
lines changed

8 files changed

+172
-389
lines changed

HexRaysPyTools.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def hexrays_events_callback(*args):
2727
idaapi.attach_action_to_popup(form, popup, Actions.RecastItemLeft.name, None)
2828

2929
if hx_view.item.get_lvar() and filter(lambda x: x.equals_to(hx_view.item.get_lvar().type()), Const.LEGAL_TYPES):
30-
idaapi.attach_action_to_popup(form, popup, Actions.ScanVariable.name, None)
30+
idaapi.attach_action_to_popup(form, popup, Actions.ShallowScanVariable.name, None)
31+
idaapi.attach_action_to_popup(form, popup, Actions.DeepScanVariable.name, None)
3132
idaapi.attach_action_to_popup(form, popup, Actions.RecognizeShape.name, None)
3233

3334
if item.citype == idaapi.VDI_FUNC:
@@ -158,7 +159,8 @@ def init():
158159
Actions.register(Actions.RemoveArgument)
159160
Actions.register(Actions.RemoveReturn)
160161
Actions.register(Actions.ConvertToUsercall)
161-
Actions.register(Actions.ScanVariable, Helper.temporary_structure)
162+
Actions.register(Actions.ShallowScanVariable, Helper.temporary_structure)
163+
Actions.register(Actions.DeepScanVariable, Helper.temporary_structure)
162164
Actions.register(Actions.RecognizeShape)
163165
Actions.register(Actions.SelectContainingStructure, potential_negatives)
164166
Actions.register(Actions.ResetContainingStructure)
@@ -191,7 +193,8 @@ def term():
191193
Actions.unregister(Actions.RemoveArgument)
192194
Actions.unregister(Actions.RemoveReturn)
193195
Actions.unregister(Actions.ConvertToUsercall)
194-
Actions.unregister(Actions.ScanVariable)
196+
Actions.unregister(Actions.ShallowScanVariable)
197+
Actions.unregister(Actions.DeepScanVariable)
195198
Actions.unregister(Actions.RecognizeShape)
196199
Actions.unregister(Actions.SelectContainingStructure)
197200
Actions.unregister(Actions.ResetContainingStructure)

HexRaysPyTools/Actions.py

+28-2
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,38 @@ def update(self, ctx):
256256
return idaapi.AST_DISABLE_FOR_FORM
257257

258258

259-
class ScanVariable(idaapi.action_handler_t):
259+
class ShallowScanVariable(idaapi.action_handler_t):
260260

261-
name = "my:ScanVariable"
261+
name = "my:ShallowScanVariable"
262262
description = "Scan Variable"
263263
hotkey = "F"
264264

265+
def __init__(self, temporary_structure):
266+
self.temporary_structure = temporary_structure
267+
idaapi.action_handler_t.__init__(self)
268+
269+
def activate(self, ctx):
270+
hx_view = idaapi.get_tform_vdui(ctx.form)
271+
variable = hx_view.item.get_lvar() # lvar_t
272+
if variable and filter(lambda x: x.equals_to(variable.type()), Const.LEGAL_TYPES):
273+
index = list(hx_view.cfunc.get_lvars()).index(variable)
274+
scanner = ShallowSearchVisitor(hx_view.cfunc, self.temporary_structure.main_offset, index)
275+
scanner.process()
276+
for field in scanner.candidates:
277+
self.temporary_structure.add_row(field)
278+
279+
def update(self, ctx):
280+
if ctx.form_title[0:10] == "Pseudocode":
281+
return idaapi.AST_ENABLE_FOR_FORM
282+
return idaapi.AST_DISABLE_FOR_FORM
283+
284+
285+
class DeepScanVariable(idaapi.action_handler_t):
286+
287+
name = "my:DeepScanVariable"
288+
description = "Deep Scan Variable"
289+
hotkey = "shift+F"
290+
265291
def __init__(self, temporary_structure):
266292
self.temporary_structure = temporary_structure
267293
idaapi.action_handler_t.__init__(self)

HexRaysPyTools/Core/Classes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import HexRaysPyTools.Forms
44
import Helper
55

6-
from PySide import QtGui, QtCore
6+
# from PySide import QtGui, QtCore
7+
from HexRaysPyTools.Cute import *
78

89
all_virtual_functions = {} # name -> VirtualMethod
910
all_virtual_tables = {} # ordinal -> VirtualTable

0 commit comments

Comments
 (0)