the fwrite output striped the slashes if without length argument given, example:
<?php
$str = "c:\\01.txt";
$out = fopen("out.txt", "w");
fwrite($out, $str);
fclose($out);
?>
the out.txt will be:
c:^@1.txt
the '\\0' without escape will be '\0' ==> 0x00.
the correct one is change fwrite to:
fwrite($out, $str, strlen($str));