file to reference withuse File::Path (make_path, rmtree); use Digest::MD5; use File::Slurp; rmtree 'extracted'; open (my $infile, '<', $ARGV[0]) or die "cannot open file: $!"; binmode ($infile); make_path ('./extracted');#or die "Failed to create Direcotry: $!"; my $curpos = ''; my $fileLocation = ''; my $fileSize = ''; my $fileName = ''; my $file =''; my $chunk = ''; my $exit = ''; #GET File Location, File Size, File Name and write to file seek ($infile, 0x10, 0); until ($exit){ read ($infile, $fileLocation, 0x08); read ($infile, $fileSize, 0x08); read ($infile, $fileName, 0x20); if ($fileLocation =~ 'SCE'){ last; } $fileLocation =~ s/(.)/sprintf("%02x",ord($1))/eg; $fileSize =~ s/(.)/sprintf("%02x",ord($1))/eg; $fileName =~ s/\0+$//; if ($fileLocation =~ 'ffffffffffffffff'){ last; } open($file, '>', "extracted/$fileName") or die "Cannot open $fileName + $!"; binmode($file); sysseek ($infile, hex($fileLocation), 0); sysread ($infile, $chunk, hex($fileSize)); syswrite ($file, $chunk); $fileLocation = ''; $fileSize = ''; }; my $dirname = "extracted"; open (my $sdk, '<', "extracted/sdk_version") or die "cannot open sdk_v +ersion: $!"; seek ($sdk, 0x00, 0); read ($sdk, $buf, 0x03); # my@fn; # my @hash; my @md5s = read_file 'C:/md5'; chomp @hash; chomp @md5s; # open (my $md5file, '>>', 'C:/md5'); foreach my $file (<$dirname/*>) { next if -d $file; open( my $FILE, $file ); binmode($FILE); $file =~ s{.*/}{}; my $md5 = Digest::MD5->new->addfile($FILE)->hexdigest; push (@hash, $md5); # syswrite $md5file, "$md5\n"; } foreach $md5s (@hash) { foreach $md5table (@md5s) { if($md5s ~~ $md5table) { print "$md5s ", "$buf ", "success\n"; } } }
In reply to Re^4: problem with sysseek in loop
by james28909
in thread problem with sysseek in loop
by james28909
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |