Advertisement
Guest User

RTT2 EBOOT Pointer Search 1

a guest
Sep 24th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.52 KB | None | 0 0
  1. import struct
  2.  
  3. output = []
  4. with open('NPJH50119.BIN', 'rb') as f:
  5.     f.seek(0x2100d4)                #Read in our .data block
  6.     filedata = f.read(0x1a2250)
  7. #I exported the sheet with just columns A and B as .tsv from Google Sheets
  8. with open('text.tsv', 'r', encoding='utf-8') as f:
  9.     for line in f:
  10.         line = line.rstrip('\r\n').split('\t')[0]   #Get column A
  11.         if line != '':                              #If column A is not blank...
  12.             data = int(line, 16) + 0x88fffac        #Get virt address
  13.             data = struct.pack('<I', data)          #Convert to bytes
  14.             matches = []                            #Empty match list
  15.             pos = -1                                #Starting position
  16.             while True:                             #Let's look for matches!
  17.                 pos = filedata.find(data, pos + 1)  #Look for a match
  18.                 if pos == -1:                       #If not found...
  19.                     break                           #Stop looking
  20. #If the alignment is right, then a match has been found, add the match to the
  21. #list and then look again for other matches.
  22.                 if pos % 4 == 0:                    
  23.                     matches.append(hex(pos + 0x2100d4))
  24. #Add matches to output
  25.             output.append('\t'.join(matches))
  26.         else:
  27. #Add a blank line to the output, this helps up match it up easily with
  28. #our dump in Google Sheets
  29.             output.append('')
  30. with open('match.txt', 'w') as f:
  31.     f.write('\n'.join(output))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement