eedump.pl 750 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/perl
  2. $file = $ARGV[0];
  3. open(IN,$file) || die print "Failed to open file: $file : $!";
  4. read(IN,$buffer,1);
  5. read(IN,$buffer2,1);
  6. if (ord($buffer) != 0x41 && ord($buffer2) != 0x50) {
  7. print "bad header ". $buffer ." ".$buffer2. "\n";
  8. exit;
  9. }
  10. read(IN,$buffer,1);
  11. if (ord($buffer) != 2) {
  12. print "bad version";
  13. exit;
  14. }
  15. # spare
  16. read(IN,$buffer,1);
  17. $a = 0;
  18. while (read(IN,$buffer,1)) {
  19. $pos = (tell(IN) - 1);
  20. $size = ((ord($buffer) & 63));
  21. read(IN,$buffer,1);
  22. if (ord($buffer) == 0xff) {
  23. printf("end sentinel at %u\n", $pos);
  24. last;
  25. }
  26. printf("%04x: key %u size %d\n ", $pos, ord($buffer), $size + 1);
  27. for ($i = 0; $i <= ($size); $i++) {
  28. read(IN,$buffer,1);
  29. printf(" %02x", ord($buffer));
  30. }
  31. print "\n";
  32. }
  33. close IN;