Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import struct
- output = []
- with open('NPJH50119.BIN', 'rb') as f:
- f.seek(0x2100d4) #Read in our .data block
- filedata = f.read(0x1a2250)
- #I exported the sheet with just columns A and B as .tsv from Google Sheets
- with open('text.tsv', 'r', encoding='utf-8') as f:
- for line in f:
- line = line.rstrip('\r\n').split('\t')[0] #Get column A
- if line != '': #If column A is not blank...
- data = int(line, 16) + 0x88fffac #Get virt address
- data = struct.pack('<I', data) #Convert to bytes
- matches = [] #Empty match list
- pos = -1 #Starting position
- while True: #Let's look for matches!
- pos = filedata.find(data, pos + 1) #Look for a match
- if pos == -1: #If not found...
- break #Stop looking
- #If the alignment is right, then a match has been found, add the match to the
- #list and then look again for other matches.
- if pos % 4 == 0:
- matches.append(hex(pos + 0x2100d4))
- #Add matches to output
- output.append('\t'.join(matches))
- else:
- #Add a blank line to the output, this helps up match it up easily with
- #our dump in Google Sheets
- output.append('')
- with open('match.txt', 'w') as f:
- f.write('\n'.join(output))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement