How to change the icon, version or another resource of Windows executables built with PAR::Packer


November 2013.

Situation


You're using PAR::Packer to create a nice Windows executable out of one of your perl script.

However, the --info and --icon switch aren't working. You might also want to embed some other resource into your executable.

Trying the usual methods


exe_update.pl



exe_update --icon=jambon.ico jambon.exe

exe_update does not work with PAR::Packer executable. It will destroy your file.

ResHacker



ResHacker.exe -modify "jambon.exe", "jambon.exe", "jambon.ico", ICONGROUP, WINEXE, 0
ResHacker.exe -delete "jambon.exe", "jambon.exe", versioninfo,1,
ResHacker.exe -addoverwrite "jambon.exe", "jambon.exe", "jambon\version_info.res", versioninfo,1,

ResHacker will edit the resource of your file correctly. However, the executable will error when launching since its signature has changed. This is not acceptable.

Where the icon and version comes from


When built statically, a pp compiled executable is made of data stored in Static.pm, which is made from Static.in and boot.exe. This boot.exe file is the one that contains the final resources.

The resources used to build this file are located in cpan\build\PAR-Packer-1.015-?????\myldr\winres. Modifying these files and rebuilding boot.exe will allow you to change your final executable resources.

The ugly solution that works


Before packing your perl script, rebuild boot.exe with your custom information.

This can easily be automated using a makefile, like this one:

PERL_DIR = C:\StupidPrograms\strawberryperl\perl
PAR_PACKER_SRC = C:\StupidPrograms\strawberryperl\cpan\build\PAR-Packer-1.015-2TLZDS

all:
copy /Y medias\jambon.ico $(PAR_PACKER_SRC)\myldr\winres\pp.ico
copy /Y medias\jambon.rc $(PAR_PACKER_SRC)\myldr\winres\pp.rc
del $(PAR_PACKER_SRC)\myldr\ppresource.coff
cd /D $(PAR_PACKER_SRC)\myldr\ && perl Makefile.PL
cd /D $(PAR_PACKER_SRC)\myldr\ && dmake boot.exe
cd /D $(PAR_PACKER_SRC)\myldr\ && dmake Static.pm
attrib -R $(PERL_DIR)\site\lib\PAR\StrippedPARL\Static.pm
copy /Y $(PAR_PACKER_SRC)\myldr\Static.pm $(PERL_DIR)\site\lib\PAR\StrippedPARL\Static.pm

pp -o jambon.exe -f PodStrip -f Bleach -f Obfuscate --compress=9 jambon.pl

Your perl installation might be different than mine, so you'll want to adapt the scripts.

This solution is quite ugly, but it does work.