Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4919

Python • Re: Using Python to patch a binary.

$
0
0
Reading binary file in Python, and find a byte sequence:
https://stackoverflow.com/questions/321 ... on#3217350
Thank you,
So the solution begins with:

Code:

with open(filename, 'wb') as f:    s = f.read()s.find(b'\xff\xc0')
Opening as write, since we will need to change the content, right?

...and then? how to do the overwrite, not a string replacement, finishing with a "null" termination?
It is crucial to keep the oveall file length unchanged.

Please accept my apologies if i am asking something that appears easy to experts.

Statistics: Posted by rin67630 — Wed Jul 03, 2024 4:23 am



Viewing all articles
Browse latest Browse all 4919

Trending Articles