X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=geekos%2Fscripts%2Fscan;fp=geekos%2Fscripts%2Fscan;h=cbfe6dc9d0c24e3b468be2c69d75db68f5b63d10;hp=0000000000000000000000000000000000000000;hb=ddc16b0737cf58f7aa90a69c6652cdf4090aec51;hpb=626595465a2c6987606a6bc697df65130ad8c2d3 diff --git a/geekos/scripts/scan b/geekos/scripts/scan new file mode 100755 index 0000000..cbfe6dc --- /dev/null +++ b/geekos/scripts/scan @@ -0,0 +1,29 @@ +#! /usr/bin/perl + +# Scan a file for a 32-bit word with a particular value. +# $Revision: 1.1 $ + +use strict qw(refs vars); +use FileHandle; + +my $filename = shift @ARGV; +my $word_value = shift @ARGV; + +((defined $filename) && (defined $word_value)) + || die "Usage: scan \n"; + +my $fh = new FileHandle("<$filename"); +my $val = hex($word_value); + +my $buf = ' ' x 4; + +my $offset = 0; +while ( read( $fh, $buf, 4) == 4 ) { + my $out = unpack "V", $buf; + if ( $out == $val ) { + print "Found value $word_value at offset $offset\n"; + exit; + } + $offset += 4; +} +print "Didn't find value $word_value\n";