Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idb2pat: incorporate fixes from @HongThatCong #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

williballenthin
Copy link
Contributor

@williballenthin williballenthin commented Sep 21, 2020

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

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
Contributor Author

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)

f.write("---")
if os.path.exists(filename):
with open(filename, "rb") as f:
old_sigs = f.readlines()
Copy link
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")

f.write("\r\n")
f.write("---")
Copy link
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.

sigs.append(sig)

for sig in sigs:
f.write(sig)
Copy link
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
Contributor Author

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

@HongThatCong
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants