From 8975d42c4d36fa8cf68aad882acf22b14d7fd18e Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Tue, 14 Sep 2021 01:03:30 +0200 Subject: [PATCH] Better pwndbg.commands.OnlyWithFile error for QEMU targets TL;DR: We don't work well with detecting QEMU targets file path so we better show a proper error message in those cases. --- pwndbg/commands/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pwndbg/commands/__init__.py b/pwndbg/commands/__init__.py index a1be14f88..69b4d3fe8 100644 --- a/pwndbg/commands/__init__.py +++ b/pwndbg/commands/__init__.py @@ -7,6 +7,7 @@ import gdb import pwndbg.chain import pwndbg.color +import pwndbg.color.message as message import pwndbg.enhance import pwndbg.exception import pwndbg.hexdump @@ -209,7 +210,10 @@ def OnlyWithFile(function): if pwndbg.proc.exe: return function(*a, **kw) else: - print("%s: There is no file loaded." % function.__name__) + if pwndbg.qemu.is_qemu(): + print(message.error("Could not determine the target binary on QEMU.")) + else: + print(message.error("%s: There is no file loaded." % function.__name__)) return _OnlyWithFile