Skip to content

Commit

Permalink
Merge pull request #14 from elbiazo/dev
Browse files Browse the repository at this point in the history
Fixing demangling problem
  • Loading branch information
elbiazo authored May 5, 2022
2 parents d8ca5b1 + 1f6572a commit feb19d6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Generates call tree

## Releases

* 1.2 -- Bug Fixes
* 1.1 -- Refactoring
* 1.0 -- Public Release
* 0.0 -- Beta Release

Expand Down Expand Up @@ -52,4 +54,11 @@ When working with really big binaries with alot of xrefs, you would want to chan

**Default Recursion Depth in Setting**

![](images/2022-02-09-16-59-03.png)
![](images/2022-02-09-16-59-03.png)

## Contributors

Thanks everyone that have contributed to calltree!

* galenbwill
* droogie
10 changes: 6 additions & 4 deletions calltree.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
QTextEdit,
)

from .demangle import demangle_name

class BNFuncItem(QStandardItem):
def __init__(self, func):
def __init__(self, bv, func):
super().__init__()
self.func = func
self.setText(func.name)
self.bv = bv
self.setText(demangle_name(self.bv, func.name))


class CurrentFunctionLayout(QHBoxLayout):
Expand Down Expand Up @@ -163,7 +165,7 @@ def set_func_calls(self, cur_func, cur_std_item, is_caller: bool, depth=0):
if depth < self._func_depth:
if cur_func_calls:
for cur_func_call in cur_func_calls:
new_std_item = BNFuncItem(cur_func_call)
new_std_item = BNFuncItem(self._binary_view, cur_func_call)
cur_std_item.appendRow(new_std_item)

# Dont search on function that calls itself
Expand All @@ -187,7 +189,7 @@ def update_widget(self, cur_func):
# Set root std Items
if cur_func_calls:
for cur_func_call in cur_func_calls:
root_std_items.append(BNFuncItem(cur_func_call))
root_std_items.append(BNFuncItem(self._binary_view, cur_func_call))
cur_std_item = root_std_items[-1]
if cur_func != cur_func_call:
self.set_func_calls(cur_func_call, cur_std_item, self.is_caller)
Expand Down
12 changes: 12 additions & 0 deletions demangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from binaryninja import demangle_ms, demangle_gnu3, get_qualified_name

def demangle_name(bv, function_name):
ms = demangle_ms(bv.arch, function_name)
gnu = demangle_gnu3(bv.arch, function_name)

if (ms[0] != None):
return get_qualified_name(ms[1])
elif (gnu[0] != None):
return get_qualified_name(gnu[1])
else:
return(function_name)
4 changes: 2 additions & 2 deletions init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from .calltree import CallTreeLayout, CurrentFunctionLayout
from binaryninja.settings import Settings

from .demangle import demangle_name
instance_id = 0
Settings().register_group("calltree", "Calltree")
Settings().register_setting(
Expand Down Expand Up @@ -125,7 +125,7 @@ def notifyOffsetChanged(self, offset):
if cur_funcs[0].start != self.prev_func_offset:
self.prev_func_offset = cur_funcs[0].start
cur_func = cur_funcs[0]
self.cur_func_text.setText(cur_func.name)
self.cur_func_text.setText(demangle_name(self.binary_view, cur_func.name))
self.in_calltree.cur_func = cur_func
self.out_calltree.cur_func = cur_func
self.in_calltree.update_widget(cur_func)
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"Windows": "",
"Linux": ""
},
"version": "1.0",
"version": "1.2",
"minimumbinaryninjaversion": 2966
}

0 comments on commit feb19d6

Please sign in to comment.