Sign in to follow this  
Followers 0
sensalim

How to write hex to binary file?

2 posts in this topic

#1 ·  Posted (edited)

I want to modify offset 0x58A81A to 0x3B1C of this binary file, but it writes "1C3B" instead.

How do I do it?

2nd question: How do I make 0x58A81A a variable? (what kind of data type)

(also would like to make 0x3B1C a variable, but that's same question as above)

$modified_bin_fh = FileOpen($binary, 17)
FileSetPos($modified_bin_fh, 0x58A81A, 0)
FileWrite($modified_bin_fh, 0x3B1C)
FileClose($modified_bin_fh)

Thanks!

Edit:

I seem to have solved it :mellow:

$offset = Number("0x58A81A")
$mod_to = Binary("0x3B1C")
 
$modified_bin_fh = FileOpen($binary, 17)
FileSetPos($modified_bin_fh, $offset, 0)
FileWrite($modified_bin_fh, $mod_to)
FileClose($modified_bin_fh)

Any better suggestions?

Edited by sensalim

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0