I'm trying to create a self-extractable (SFX) rar archive, which will have both icon and image. I'm using the following command line:
winrar.exe a -r0 -sfx -ibck -z"MyConfFile.conf" -iimg"MyImage.bmp" -iicon"MyIcon.ico" MyPackage.exe @"MyFileList.txt"
Trouble is - the resulting .exe can't be unpacked. Instead it says "The archive is either in unknown format or damaged". If I set only icon or only image, then everything is fine. But if I set both, I'm in trouble. Strangest thing.
The code of the SFX module + the data of the bitmap file + data of the icon file + SFX comment file + other data (signature) are written first to the SFX archive file and next the actual archive with the compressed data is appended to the file.
The maximum size of all data preceding the archive data must be at the moment smaller than 1 MB according to RAR 5.0 archive format technote documentation.
Possible solutions:
But take into account that with compression of the SFX module itself the bitmap and the icon must be in the resources of the SFX module itself instead of being appended separately.
A tool like Resource Hacker can be used to replace the standard bitmap by own bitmap and the standard icons by own icons as well as changing dialog layout. That reduces the total size of the data preceding the archive data even without compressing the SFX module with a runtime packer like UPX.
Using tools like Resource Hacker to customize the resources of one of the standard SFX modules of WinRAR is permitted by the copyright owners of WinRAR. See in help of WinRAR (winrar.chm) the page with title GUI RAR and ZIP SFX modules (Default.SFX and Zip.SFX) via Index tab or via Contents tab (first entry of Self-extracting modules) of help.