Hex editting
Posted: Mon Mar 31, 2008 7:34 pm
Is there anyway in PHP to change hex values like in C?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Untested:aquadeluxe wrote:Sorry I didn't explain myself well enough. I wanted to know how I can edit hex values from a file. An example would be change the offset 0x103 from 74 to 6E.
Code: Select all
$fp = fopen($path_to_file, "w+b"); //Open file for reading and writing in binary mode
fseek($fp, 0x103, SEEK_SET); //Seek to 0x103
fwrite($fp, pack('H*', '6E')); //Write 0x6E packed into a binary byte
fclose($fp); //Close the file