Skip to content

Commit

Permalink
Support for reading stdin, better timeout display.
Browse files Browse the repository at this point in the history
  • Loading branch information
palkeo committed May 8, 2020
1 parent 5e07e40 commit d3462a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pano/decompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _decompile_with_loader(loader, only_func_name=None) -> Decompilation:
if target > 1 and loader.lines[target][1] == "jumpdest":
target += 1

@timeout_decorator.timeout(120, use_signals=True)
@timeout_decorator.timeout(60*3, use_signals=True)
def dec():
trace = VM(loader).run(target, stack=stack, timeout=60)
explain("Initial decompiled trace", trace[1:])
Expand Down
4 changes: 2 additions & 2 deletions pano/prettify.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@ def pretty_line(r, add_color=True):
yield "stop"

elif opcode(r) == "undefined":
_, *params = r
yield COLOR_WARNING + "..." + ENDC + COLOR_GRAY + f" # unusual jump {params}, couldn't decompile, sorry" + ENDC
params = tuple(r[1:])
yield COLOR_WARNING + "..." + ENDC + COLOR_GRAY + f" # Decompilation aborted, sorry: {params}" + ENDC

elif opcode(r) == "invalid":
_, *rest = r
Expand Down
4 changes: 2 additions & 2 deletions pano/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, vm, start, safe, stack, condition=True, trace=None):

def make_trace(self):
if self.trace is None:
return ["...unterminated..."]
return [("undefined", "decompilation didn't finish")]

begin_vars = []
if self.is_label():
Expand Down Expand Up @@ -346,7 +346,7 @@ def _run(self, start, safe, stack, condition):

if i not in lines:
if type(i) != int:
return [("undefined", "remco jump", i)]
return [("undefined", "jump to a parameter computed at runtime", i)]
else:
return [("invalid", "jumdest", i)]

Expand Down
9 changes: 8 additions & 1 deletion panoramix.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ def print_decompilation(this_addr):
if not sys.argv[2].startswith("--"):
function_name = sys.argv[2]

decompilation = decompile_address(this_addr, function_name)
if this_addr == '-':
this_addr = sys.stdin.read().strip()

if len(this_addr) == 42:
decompilation = decompile_address(this_addr, function_name)
else:
decompilation = decompile_bytecode(this_addr, function_name)

print(decompilation.text)


Expand Down

0 comments on commit d3462a7

Please sign in to comment.