Skip Menu |

This queue is for tickets about the Win32-Exe CPAN distribution.

Report information
The Basics
Id: 69570
Status: open
Priority: 0/
Queue: Win32-Exe

People
Owner: Nobody in particular
Requestors: RSCHUPP [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.16
Fixed in: (no value)



Subject: create_resource_section() fails
For an executable without a resource section, create_resource_section() fails to create one. The attached script prints: Show quoted text
C>perl add-res.pl hello.exe
original exe = Win32::Exe::PE::Header::PE32=HASH(0xc4086c) no resource section found, creating one ... No resource section found in file hello.exe at C:/strawberry/perl/site/lib/Win32/Exe.pm line 348. modified exe = Win32::Exe::PE::Header::PE32=HASH(0x1eb02b4) Not an ARRAY reference at C:/strawberry/perl/site/lib/Win32/Exe.pm line 521. hello.exe originally doesn't have a resource section: Show quoted text
C>objdump -h hello-orig.exe
hello-orig.exe: file format pei-i386 Sections: Idx Name Size VMA LMA File off Algn 0 .text 00003b44 00401000 00401000 00000400 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA 1 .data 00165300 00405000 00405000 00004000 2**5 CONTENTS, ALLOC, LOAD, DATA 2 .rdata 00000570 0056b000 0056b000 00169400 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .bss 00008440 0056c000 0056c000 00000000 2**5 ALLOC 4 .idata 0000090c 00575000 00575000 00169a00 2**2 CONTENTS, ALLOC, LOAD, DATA 5 .CRT 00000034 00576000 00576000 0016a400 2**2 CONTENTS, ALLOC, LOAD, DATA 6 .tls 00000020 00577000 00577000 0016a600 2**2 CONTENTS, ALLOC, LOAD, DATA After the script runs there's a strange new section (7) Show quoted text
C>objdump -h hello.exe
hello.exe: file format pei-i386 Sections: Idx Name Size VMA LMA File off Algn 0 .text 00003b44 00401000 00401000 00000400 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA 1 .data 00165300 00405000 00405000 00004000 2**5 CONTENTS, ALLOC, LOAD, DATA 2 .rdata 00000570 0056b000 0056b000 00169400 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .bss 00008440 0056c000 0056c000 00000000 2**5 ALLOC 4 .idata 0000090c 00575000 00575000 00169a00 2**2 CONTENTS, ALLOC, LOAD, DATA 5 .CRT 00000034 00576000 00576000 0016a400 2**2 CONTENTS, ALLOC, LOAD, DATA 6 .tls 00000020 00577000 00577000 0016a600 2**2 CONTENTS, ALLOC, LOAD, DATA 7 00000000 00000000 00000000 00000000 2**2 READONLY This is on Windows XP with Strawberry Perl 5.12.3 and Win32::Exe 0.16. Cheers, Roderich
Subject: add-res.pl
#!/usr/bin/perl use strict; use warnings; use Win32::Exe; @ARGV == 1 or die "usage: $0 file.exe\n"; my ($file) = @ARGV; my $exe = Win32::Exe->new($file); print STDERR "original exe = $exe\n"; if (!$exe->has_resource_section) { print STDERR "no resource section found, creating one ...\n"; $exe = $exe->create_resource_section; print STDERR "modified exe = $exe\n"; } my $rc = $exe->update( info => { ProductName => "HelloWorld", ProductVersion => "42.0", CompanyName => "Hulloh Inc", } ); print STDERR "update => $rc\n"; exit(0);
Subject: create_resource_section() fails on Win XP (not Vista, 7 etc)
Hi, Just updated title to include 'Win XP' as it is only on that version of windows that the issues occurs. On recent Windows releases there does not appear to be a problem. Apologies - this is a known issue for some time - I thought there was already an open bug report. I shall take another look at fixing for XP. The XS file does look 'wrong' so maybe I shall have success. F.Y.I. the example script would not work ( but it never gets that far because of breakage on XP). info => param needs to be an array ref my $rc = $exe->update( info => [ "ProductName=HelloWorld", "ProductVersion=42.0", "CompanyName=Hulloh Inc", ] ); Regards Mark On Tue Jul 19 04:45:09 2011, RSCHUPP wrote: Show quoted text
> For an executable without a resource section,
create_resource_section() Show quoted text
> fails to create one. The attached script prints: >
> C>perl add-res.pl hello.exe
> original exe = Win32::Exe::PE::Header::PE32=HASH(0xc4086c) > no resource section found, creating one ... > No resource section found in file hello.exe at > C:/strawberry/perl/site/lib/Win32/Exe.pm line 348. > modified exe = Win32::Exe::PE::Header::PE32=HASH(0x1eb02b4) > Not an ARRAY reference at C:/strawberry/perl/site/lib/Win32/Exe.pm
line 521. Show quoted text
> > hello.exe originally doesn't have a resource section: >
> C>objdump -h hello-orig.exe
> > hello-orig.exe: file format pei-i386 > > Sections: > Idx Name Size VMA LMA File off Algn > 0 .text 00003b44 00401000 00401000 00000400 2**4 > CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA > 1 .data 00165300 00405000 00405000 00004000 2**5 > CONTENTS, ALLOC, LOAD, DATA > 2 .rdata 00000570 0056b000 0056b000 00169400 2**2 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 3 .bss 00008440 0056c000 0056c000 00000000 2**5 > ALLOC > 4 .idata 0000090c 00575000 00575000 00169a00 2**2 > CONTENTS, ALLOC, LOAD, DATA > 5 .CRT 00000034 00576000 00576000 0016a400 2**2 > CONTENTS, ALLOC, LOAD, DATA > 6 .tls 00000020 00577000 00577000 0016a600 2**2 > CONTENTS, ALLOC, LOAD, DATA > > After the script runs there's a strange new section (7) >
> C>objdump -h hello.exe
> > hello.exe: file format pei-i386 > > Sections: > Idx Name Size VMA LMA File off Algn > 0 .text 00003b44 00401000 00401000 00000400 2**4 > CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA > 1 .data 00165300 00405000 00405000 00004000 2**5 > CONTENTS, ALLOC, LOAD, DATA > 2 .rdata 00000570 0056b000 0056b000 00169400 2**2 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 3 .bss 00008440 0056c000 0056c000 00000000 2**5 > ALLOC > 4 .idata 0000090c 00575000 00575000 00169a00 2**2 > CONTENTS, ALLOC, LOAD, DATA > 5 .CRT 00000034 00576000 00576000 0016a400 2**2 > CONTENTS, ALLOC, LOAD, DATA > 6 .tls 00000020 00577000 00577000 0016a600 2**2 > CONTENTS, ALLOC, LOAD, DATA > 7 00000000 00000000 00000000 00000000 2**2 > READONLY > > This is on Windows XP with Strawberry Perl 5.12.3 and Win32::Exe 0.16. > > Cheers, Roderich
Subject: Windows XP create_resource_section() fails
Update, I have confirmed that the windows API call UpdateResource simply does not work on Windows XP for most executables if there is no existing resource section. (I've tested outside of Win32::Exe with a variety of test cases). It does work on Windows Vista, 7, Server 2008. So, Win32::Exe needs a complete re-work to allow creation of a new resource section on Windows XP ( and Windows 2000 I expect ) In the meantime I have uploaded release 0.17 to CPAN that notes this in the POD and provides an extra method $exe->can_create_resource_section that allows to check if 'create_resource_section' can work on the current platform. I also fixed the param parsing so that my $rc = $exe->update( info => { "ProductName" => "HelloWorld", "ProductVersion" => "42.0", "CompanyName" => "Hulloh Inc", } ); works as you would expect. For usage with PAR::Packer include a simple resource section so that pp executables already have resource sections.