Skip to content
This repository was archived by the owner on Jan 1, 2026. It is now read-only.

idb2pat: incorporate fixes from @HongThatCong#98

Open
williballenthin wants to merge 1 commit into
masterfrom
williballenthin-patch-1
Open

idb2pat: incorporate fixes from @HongThatCong#98
williballenthin wants to merge 1 commit into
masterfrom
williballenthin-patch-1

Conversation

@williballenthin
Copy link
Copy Markdown
Contributor

@williballenthin williballenthin commented Sep 21, 2020

this is the updated script that @HongThatCong referenced in #97

Comment thread python/flare/idb2pat.py
if ea > func.start_ea: # skip first byte
name = idc.get_name(ea)
if name != "" and idaapi.is_uname(name):
logger.debug(str("ea 0x%X has a name %s" % (ea, name)))
Copy link
Copy Markdown
Contributor Author

@williballenthin williballenthin Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first parameter to a log method is a format string, so we can do this instead:

logger.debug("ea 0x%X has a name %s", ea, name)

Comment thread python/flare/idb2pat.py
f.write("---")
if os.path.exists(filename):
with open(filename, "rb") as f:
old_sigs = f.readlines()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need to decode the bytes into a string, like:

old_sigs = f.read().decode("utf-8").split("\n")

Comment thread python/flare/idb2pat.py
for sig in sigs:
f.write(sig)
f.write("\r\n")
f.write("---")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be writing bytes, not str, since the file is open in binary mode.

Comment thread python/flare/idb2pat.py
sigs.append(sig)

for sig in sigs:
f.write(sig)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sig.encode("utf-8")

@williballenthin
Copy link
Copy Markdown
Contributor Author

need to test this on py3, since i think there's some issues around str/bytes handling.

@HongThatCong
Copy link
Copy Markdown

Hi !
I have add Python 3 support to idb2pat.py.
https://github.com/HongThatCong/idb2sig
Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants