diff --git a/ida_script.py b/ida_script.py index 46818c59f..8968bbd49 100644 --- a/ida_script.py +++ b/ida_script.py @@ -102,11 +102,25 @@ def register_module(module): server.register_function(wrap(function), name) +def decompile(addr): + """ + Function that overwrites `idaapi.decompile` for xmlrpc so that instead + of throwing an exception on `idaapi.DecompilationFailure` it just returns `None`. + (so that we don't have to parse xmlrpc Fault's exception string on pwndbg side + as it differs between IDA versions). + """ + try: + return idaapi.decompile(addr) + except idaapi.DecompilationFailure: + return None + + server = SimpleXMLRPCServer((host, port), logRequests=True, allow_none=True) register_module(idc) register_module(idautils) register_module(idaapi) server.register_function(lambda a: eval(a, globals(), locals()), 'eval') +server.register_function(decompile) # overwrites idaapi/ida_hexrays.decompie server.register_introspection_functions() print('IDA Pro xmlrpc hosted on http://%s:%s' % (host, port)) diff --git a/pwndbg/ida.py b/pwndbg/ida.py index cd060751a..a2481b666 100644 --- a/pwndbg/ida.py +++ b/pwndbg/ida.py @@ -388,13 +388,7 @@ def has_cached_cfunc(addr): @takes_address @pwndbg.memoize.reset_on_stop def decompile(addr): - try: - return _ida.decompile(addr) - except xmlrpclib.Fault as f: - if str(f) == ''':Decompilation failed: ">''': - print('Returning an empty string') - return None - raise + return _ida.decompile(addr) @withIDA