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

TypeError: getBytes(): 2nd arg can't be coerced to int #12

Open
TheBeardOfTruth opened this issue Jan 31, 2021 · 0 comments
Open

TypeError: getBytes(): 2nd arg can't be coerced to int #12

TheBeardOfTruth opened this issue Jan 31, 2021 · 0 comments

Comments

@TheBeardOfTruth
Copy link

I took the liberty of patching the relevant code a bit quickly to find the problem:

    while funk is not None:
        funk_start = int(funk.entryPoint.toString(), 16)
        funk_end   = get_function_end(funk)
        print(funk_end)
        print(type(funk_end))
        funk_buf   = getBytes(parseAddress(hex(funk_start).strip('L')), (funk_end - funk_start + 0x100))
        #print('%x - %x' % (funk_start, funk_end))
        match_function(flirt, funk_buf, funk_start, funk_rename)
        funk = getFunctionAfter(funk)

Output:

ApplySig.py> Running...
Load File:/home/cocaine/Downloads/generated/n64-sdk-1.2/n64-sdk-1.2.sig
Parse Flirt File.....
Name:  n64-sdk-1.2
Count: 295
Apply Signatures.....
532676819
<type 'int'>
532677207
<type 'int'>
532678179
<type 'int'>
532678207
<type 'int'>
2751464787
<type 'long'>
Traceback (most recent call last):
  File "/home/cocaine/bin/Ghidra_Scripts/ApplySig.py", line 729, in <module>
    apply_sig(flirt)
  File "/home/cocaine/bin/Ghidra_Scripts/ApplySig.py", line 713, in apply_sig
    funk_buf   = getBytes(parseAddress(hex(funk_start).strip('L')), (funk_end - funk_start + 0x100))
TypeError: getBytes(): 2nd arg can't be coerced to int
ApplySig.py> Finished!

This reveals that funk_end is not guaranteed to be constrained to an int, and getBytes() clearly does not want to take a long as input.

This appears to be relevant when working on N64 titles when trying to apply the n64 SDK signatures to eliminate standard library calls.

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

No branches or pull requests

1 participant