Jump to content

How to write hex to binary file?


sensalim
 Share

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)
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...