Skip to content

Commit

Permalink
Removed lots of debugging code, including uses of Data::Dumper and Da…
Browse files Browse the repository at this point in the history
…ta::Hexdump
  • Loading branch information
onitake committed Dec 7, 2015
1 parent 9145d7f commit 1bde8ae
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 47 deletions.
4 changes: 2 additions & 2 deletions ParserGenerator.pm
@@ -1,8 +1,8 @@
use strict;
use Switch 'Perl6';
use Carp;
use Data::Dumper;
$Data::Dumper::Indent = 1;
#use Data::Dumper;
#$Data::Dumper::Indent = 1;

sub ParserGenerator::unit::types {
my $self = shift;
Expand Down
3 changes: 0 additions & 3 deletions Setup/Inno.pm
Expand Up @@ -10,7 +10,6 @@ use Win::Exe;
use Win::Exe::Util;
use Setup::Inno::Interpret;
use Carp;
use Data::Dumper;

our $SetupLdrExeHeaderOffset = 0x30;
our $SetupLdrExeHeaderID = 0x6F6E6E49; # 'Inno'
Expand Down Expand Up @@ -210,8 +209,6 @@ sub ReadFile {
my $file = $self->{Setup0}->{Files}->[$index];
my $location = $locations->[$file->{LocationEntry}];
if ($self->DiskSpanning()) {
#print Dumper($self->DiskInfo);
#print Dumper($location);
my @slices;
for my $slice ($location->{FirstSlice}..$location->{LastSlice}) {
push(@slices, $self->DiskInfo->[$slice]);
Expand Down
3 changes: 0 additions & 3 deletions Setup/Inno/BlockReader.pm
Expand Up @@ -19,7 +19,6 @@ sub open {
my $crc = Digest->new('CRC-32');
$crc->add(substr($buffer, 4, 5));
my $digest = $crc->digest;
#print(STDERR "Header CRC: file=$headercrc calculated=$digest\n");
($digest == $headercrc) || croak("Invalid CRC in compression header");

$handle->read(my $indata, $storedsize);
Expand Down Expand Up @@ -63,7 +62,6 @@ sub open {
my $lclp = $lclppb - $pb * 45;
my $lp = int($lclp / 9);
my $lc = $lclp - $lp * 9;
#print(STDERR "lc=$lc,lp=$lp,pb=$pb,dict=$dictsize\n");
if (!exec("xz --stdout --decompress --format=raw --lzma1=lc=$lc,lp=$lp,pb=$pb,dict=$dictsize")) {
print(STDERR "Can't execute xz utility\n");
exit(5);
Expand All @@ -75,7 +73,6 @@ sub open {

my ($offset, $bytes) = (0, 0);
do {
#print(STDERR time() . ": Reading\n");
$bytes = $framesize < $storedsize - $offset ? $framesize : $storedsize - $offset;
if ($bytes > 4) {
my $blockcrc = unpack('L<', substr($indata, $offset, 4));
Expand Down
26 changes: 0 additions & 26 deletions Setup/Inno/Interpret4000.pm
Expand Up @@ -13,16 +13,13 @@ use IO::Uncompress::AnyInflate;
use IO::Uncompress::Bunzip2;
use File::Basename;
use Setup::Inno::LzmaReader;
use Data::Hexdumper;
use Data::Dumper;
use Digest;

our $ZLIBID = "zlb\x{1a}";
our $DISKSLICEID = "idska32\x{1a}";

sub CheckFile {
my ($self, $data, $location) = @_;
print Dumper($location);
if (defined($location->{Checksum})) {
my $digest = Digest->new('CRC-32');
$digest->add($data);
Expand Down Expand Up @@ -56,7 +53,6 @@ sub DiskInfo {
my @unsorted = grep(/^$basename-[0-9]+\.bin$/, readdir($dir));
closedir($dir);
my @bins = map({ $basedir . '/' . $_ } sort({ $a =~ /-([0-9]+)\.bin$/; my $first = $1; $b =~ /-([0-9]+)\.bin$/; my $second = $1; $first cmp $second; } @unsorted));
#print Dumper(@bins);
my @ret = ();
my $start = 0;
my $disk = 0;
Expand Down Expand Up @@ -89,24 +85,13 @@ sub DiskInfo {
}
$disk++;
}
#print Dumper(@ret);
return \@ret;
}

# IS 4.0.0 might still be using 2.0.8 semantics, needs verification
sub ReadFile {
my ($self, $input, $header, $location, $offset1, $password, @slices) = @_;

#print Dumper \@slices;
#print Dumper $header;
#print Dumper $location;
#print("Offset1=$offset1 StartOffset=$location->{StartOffset}\n");
#$input->seek($offset1 + $location->{StartOffset}, Fcntl::SEEK_SET);
#$input->read(my $dump, $location->{ChunkCompressedSize}) || croak("Can't read compressed data");
#open(my $temp, '>', "/tmp/data.lzma2");
#print($temp $dump);
#undef($temp);

# Note: once we support decryption, make sure the password is interpreted as UTF-16LE (why?)
if ($location->{Flags}->{ChunkEncrypted} || $location->{Flags}->{foChunkEncrypted}) {
!defined($password) && croak("File is encrypted, but no password was given");
Expand All @@ -121,26 +106,21 @@ sub ReadFile {
my $offset = $offset1 + $location->{StartOffset} - $slices[$i]->{SliceOffset};
my $available = $slices[$i]->{Size} - $offset;
my $slicesize = $available < $size ? $available : $size;
#printf("slice=$i size=$size offset=$offset available=$available slicesize=$slicesize\n");
$slices[$i]->{Input}->seek($offset, Fcntl::SEEK_SET);
$slices[$i]->{Input}->read($buffer, $slicesize);
#print hexdump(data => $buffer, end_position => 127);
my $slicedata = $buffer;
$size -= $slicesize;
$i++;
while ($i < @slices && $size > 0) {
$offset = $slices[$i]->{DataOffset};
$available = $slices[$i]->{Size};
$slicesize = $available < $size ? $available : $size;
#printf("slice=$i size=$size offset=$offset available=$available slicesize=$slicesize\n");
$slices[$i]->{Input}->seek($offset, Fcntl::SEEK_SET);
$slices[$i]->{Input}->read($buffer, $slicesize);
#print hexdump(data => $buffer, end_position => 127);
$slicedata .= $buffer;
$size -= $slicesize;
$i++;
}
#print hexdump(data => $slicedata, end_position => 127);
# Replace input handle with virtual handle over concatenated data
# This requires Perl 5.6 or later, use IO::String or IO::Scalar for earlier versions
$input = IO::File->new(\$slicedata, 'r') || croak("Can't create file handle for preprocessed data: $!");
Expand Down Expand Up @@ -175,13 +155,10 @@ sub ReadFile {
$reader = $input;
}

#printf("Seeking to 0x%08x...\n", $location->{ChunkSuboffset});
$reader->seek($location->{ChunkSuboffset}, Fcntl::SEEK_CUR);
#print("Reading $location->{OriginalSize} bytes...\n");
($reader->read($buffer, $location->{OriginalSize}) >= $location->{OriginalSize}) || croak("Can't uncompress file: $!");

if ($location->{Flags}->{CallInstructionOptimized} || $location->{Flags}->{foCallInstructionOptimized}) {
#print("Transforming binary file...\n");
# We could just transform the whole data, but this will expose a flaw in the original algorithm:
# It doesn't detect jump instructions across block boundaries.
# This means we need to process block by block like the original.
Expand All @@ -191,9 +168,6 @@ sub ReadFile {
}
}

#print hexdump($buffer);

#print("Verifying checksum...\n");
($self->CheckFile($buffer, $location)) || croak("Invalid file checksum");

return $buffer;
Expand Down
6 changes: 0 additions & 6 deletions Setup/Inno/LzmaReader.pm
Expand Up @@ -179,7 +179,6 @@ sub new {
die("Can't fork decompression feeder");
} elsif ($pidi == 0) {
# Child; fork and pipe data to xz
#print(STDERR "xz --stdout --decompress --format=raw --lzma1=lc=$lc,lp=$lp,pb=$pb,dict=$dictsize\n");
my $pido = open(my $fdo, "|xz --stdout --decompress --format=raw --lzma1=lc=$lc,lp=$lp,pb=$pb,dict=$dictsize");
if (!defined($pido)) {
die("Can't fork xz decompressor");
Expand All @@ -195,8 +194,6 @@ sub new {
$rdbytes = $reader->read(my $buffer, 4096) || die("Can't read from stream");
if ($rdbytes) {
print(STDERR "Writing " . length($buffer) . " bytes\n");
#use Data::Hexdumper;
#print(STDERR hexdump($buffer));
$xz->write($buffer) || die("Can't write to decompressor");
}
}
Expand All @@ -209,9 +206,6 @@ sub new {
# Parent; return handle
print(STDERR "Returning stdout from xz subprocess $pidi\n");
my $input = IO::Handle->new_from_fd($fdi, 'r');
#$input->read(my $buffer, 128);
#use Data::Hexdumper;
#print(STDERR hexdump($buffer));
return bless($input, $class);
}
}
Expand Down
1 change: 0 additions & 1 deletion Win/Exe.pm
Expand Up @@ -13,7 +13,6 @@ use Win::Exe::OptionalHeader;
use Win::Exe::Section;
use Win::Exe::Table;
use Carp;
use Data::Dumper;

use overload (
'""' => \&Describe,
Expand Down
1 change: 0 additions & 1 deletion Win/Exe/Table.pm
Expand Up @@ -69,7 +69,6 @@ use strict;
use Encode qw(decode);
use Win::Exe::Util;
#use File::Type;
use Data::Dumper;

#our $FileType = File::Type->new();
our $ResourceTypes = {
Expand Down
5 changes: 0 additions & 5 deletions extract.pl
Expand Up @@ -3,7 +3,6 @@
use strict;
use warnings;
use diagnostics;
use Data::Dumper;
use Setup::Inno;
use Getopt::Long;
use Text::Glob 'glob_to_regex';
Expand Down Expand Up @@ -51,8 +50,6 @@
}
}
} elsif ($mode eq 'extract') {
#my @files = map({ $inno->FindFiles($_) } @patterns);
#for (my $i = 0; $i < $inno->FileCount; $i++) {
for my $i (map({ $inno->FindFiles($_) } @patterns)) {
my $file = $inno->FileInfo($i);
if ($file->{Type} eq 'App') {
Expand All @@ -67,10 +64,8 @@
$name = catfile($outdir, $name);
my $path = dirname($name);
if (!stat($path)) {
#print("Creating $path\n");
make_path($path);
}
#print("Writing to $name\n");
my $writeone = $overwriteall;
if (stat($name) && !$writeone) {
print(" $name exists. Overwrite? [y/N/a]");
Expand Down

0 comments on commit 1bde8ae

Please sign in to comment.