ApplySig
ApplySig copied to clipboard
TypeError: getBytes(): 2nd arg can't be coerced to int
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.