Skip to content

Commit fc6aff4

Browse files
authored
Merge pull request #1493 from elicn/ida-stderr-fix
Fix logging issues caused by IDA custom stderr
2 parents 53318ba + 2367449 commit fc6aff4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

qiling/extensions/idaplugin/qilingida.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,13 @@ def __init__(self):
886886
self.env = {}
887887

888888
def start(self, *args, **kwargs):
889-
self.ql = Qiling(argv=self.path, rootfs=self.rootfs, verbose=QL_VERBOSE.DEBUG, env=self.env, log_plain=True, *args, **kwargs)
889+
# ida replaces sys.stderr with their own customized class that is not fully compatible with the
890+
# standard stream protocol. here we patch stderr replacement to make it look like a proper file.
891+
# this has to happen before Qiling init
892+
if not hasattr(sys.stderr, 'fileno'):
893+
setattr(sys.stderr, 'fileno', lambda: sys.__stderr__.fileno())
894+
895+
self.ql = Qiling(argv=self.path, rootfs=self.rootfs, verbose=QL_VERBOSE.DEBUG, env=self.env, *args, **kwargs)
890896

891897
if sys.platform != 'win32':
892898
self.ql.os.stdin = QlEmuMisc.QLStdIO('stdin', sys.__stdin__.fileno())

0 commit comments

Comments
 (0)