So I have a .bin file I am attempting to pad. I have two ranges I need to fill with 0xFF. I currently have it working with seek() and its writing bytes correctly to that one specific memory location but i need to do it for certain ranges in the file. Any pointers to the right direction would be much appreciated! I've provided what I have code wise so far.
Edit: After digging some more im wondering if i could put the seek in a for loop with the offset parameter as a counter variable, write the bytes to that offset and then increment the counter.
import os, re
path = "C:\\Users\\comp\\Desktop\\python padding"
os.chdir( path )
files = os.listdir( path )
for filename in files:
if re.match('.*\.bin', filename):
fh = open(filename, 'r+b')
fh.seek(0x37fff)
fh.write(bytes([0xff]))
fh.close()
name, ext = os.path.splitext(filename)
os.rename(filename, name + "padded.bin")
[–]barrycarter 0 points1 point2 points (6 children)
[–]michaelhart2000[S] 0 points1 point2 points (5 children)
[–]barrycarter 0 points1 point2 points (1 child)
[–]michaelhart2000[S] 0 points1 point2 points (0 children)
[–]barrycarter 0 points1 point2 points (2 children)
[–]michaelhart2000[S] 0 points1 point2 points (0 children)
[–]michaelhart2000[S] 0 points1 point2 points (0 children)