WinRar archive with iimg and iicon options becomes corrupted

假装没事ソ 提交于 2019-12-07 23:56:42

问题


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.


回答1:


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:

  • Reduce the size of the bitmap file by making it smaller in width/height.
  • Reduce the size of the bitmap file by decreasing the colors from true color to 256 colors.
  • Reduce the size of the icon file by removing icons from icon file not really needed as a single icon in the dimensions 16x16, 24x24, 32x32 and 48x48 is enough. Some *.ico files contain multiple icons in various dimensions. A single icon in the standard dimensions is enough for an SFX archive. It is even possible to remove some sizes like 24x24 and 48x48 so that the icon file contains only one icon in dimensions 16x16 and 32x32.
  • Reduce the size of the icon file by decreasing all true color icons in the file to icons with only 256 colors using a customized palette or even to 16 colors if that is possible.
  • Reduce the size of the comment file if that is somehow possible like using wildcards for files to delete before installation or shorter text displayed to user on SFX execution.
  • Reduce the size of the SFX module for example by compressing it with UPX.

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.



来源:https://stackoverflow.com/questions/21697556/winrar-archive-with-iimg-and-iicon-options-becomes-corrupted

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!