Skip to content

Commit

Permalink
Fix exception when propagating system table, and fix logic around res…
Browse files Browse the repository at this point in the history
…olution of GUIDs stored on the stack
  • Loading branch information
D0ntPanic committed Jun 15, 2023
1 parent 0a2c9ba commit d570038
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Windows": "no special instructions, package manager is recommended"
},
"dependencies": {},
"version": "1.0.0",
"version": "1.0.1",
"author": "Vector 35 Inc",
"minimumbinaryninjaversion": 4333
}
}
27 changes: 17 additions & 10 deletions protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,24 @@ def define_protocol_types_for_refs(bv: BinaryView, func_name: str, refs, guid_pa
mlil = hlil.mlil
if mlil is None:
continue
low = mlil.get_stack_contents(guid_addr.value, 8)
high = mlil.get_stack_contents(guid_addr.value + 8, 8)
if low.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue]:
low = low.value
else:
continue
if high.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue]:
high = high.value
else:
guid = b""
offset = 0
while offset < 16:
var = mlil.get_var_for_stack_location(guid_addr.value + offset)
if var is None or var.type is None:
break
width = var.type.width
if width == 0 or width > 8:
break
value = mlil.get_stack_contents(guid_addr.value + offset, width)
if value.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue]:
value = value.value
else:
break
guid += struct.pack("<Q", value)[0:width]
offset += width
if len(guid) != 16:
continue
guid = struct.pack("<QQ", low, high)
elif isinstance(hlil.params[guid_param], HighLevelILVar):
# See if GUID variable is an incoming parameter
ssa = hlil.params[guid_param].ssa_form
Expand Down
2 changes: 1 addition & 1 deletion system_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def propagate_variable_uses(bv: BinaryView, func: Function, var: SSAVariable, fu
target = deref_parent.dest
if not isinstance(target, HighLevelILVarSsa):
continue
target = deref_parent.var
target = target.var
elif isinstance(deref_parent, HighLevelILAssignMemSsa):
# Assignment to memory, if assigning to a global variable, propagate directly
target = deref_parent.dest
Expand Down

0 comments on commit d570038

Please sign in to comment.