Jump to content
Sign in to follow this  

How to write hex to binary file?

Recommended Posts


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)



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)

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.