Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
784 B

  1. #
  2. # bintoc.pl:
  3. #
  4. # Nadim Abdo 2002
  5. # CopyRight Microsoft Corporation
  6. #
  7. # Converts a binary data file to a format suitable for inclusion in a .C file
  8. #
  9. $input_filename = shift || die "Usage: bintoc.pl infile outfile\n";
  10. $output_filename = shift || die "Usage: bintoc.pl infile outfile\n";;
  11. print "Converting: $input_filename to: $output_filename \n";
  12. open INFILE, $input_filename or die "Can't open $input_filename\n";
  13. open(OUTFILE, "> $output_filename") or die "Can't open $output_filename\n";
  14. binmode INFILE;
  15. $count = 0;
  16. while (read INFILE, $buf, 4) {
  17. #byte swap
  18. $buf = pack("N*",unpack("V*",$buf));
  19. $extracted = unpack 'H*', $buf;
  20. print OUTFILE "0x$extracted,";
  21. if ($count++ > 5 ) {
  22. print OUTFILE "\n";
  23. $count = 0;
  24. }
  25. }