Skip to content
⌘ NSIS Forum Archive

Full color icon, XP style without recompiling and smaller header size

136 posts

kichik#

Full color icon, XP style without recompiling and smaller header size

I have worked on this for quite a while now, but it is finally ready 🙂

This is a modification of NSIS 1.98.

I have added:

* Ability to add XP manifest without recompiling (XPStyle on)
* Support for all types of icons. Uninstall icon shuold still be the same structure as the installer icon, if used. You can even add an icon with 3 different sizes in it (this mod's installer includes one with 9).
* Stripping of unused resources from the exe header. For example, if you didn't use the license page, the license dialog resource will be stripped down resulting in an even smaller exe header.
* ${NSISDIR} - A constant holding the path in which NSIS is installed, on the compiler machine of course...

I am suggesting this mod as NSIS 1.99.

Sunjammer kindly helped me by hosting the file on his NSIS archive.

You can download it from:


I hope you enjoy it 🙂
KiCHiK
Yathosho#
${NSISDIR} is nice, thank you!

about my previously posted question. i'm really hot for the fullcolor icons, but i just modified my code for some new features of 2.0 alpha. maybe there could be a new alpha with your features beside the 1.99 ?
rainwater#
If you let me know which files you changed for each new feature, I will try to incorporate them into 2.0a.
spanky#
kichik,
Using your mod I get an error using InstallColors. It worked with NSIS 1.98 but it doesn't work with yours.

I'm using:
InstallColors 0066C8 000000

From MakeNSISW:
"InstallColors: fg=0066C8 bg=000000
Usage: InstallColors (/windows | (foreground_color background_color))
Error in script "poop.nsi" on line 86 -- aborting creation process"

Any knowledge as to why this occurs?
Sunjammer#
Keep me posted about whether or not this *is* a bug, if it is I'll list it as a known bug on the info page about this mod.
Sunjammer#
Rainwater said:
If you let me know which files you changed for each new feature, I will try to incorporate them into 2.0a.
1.98 -> KiCHiK 1.99 diffs attached (placed here so anyone who cares can see). The zip contains a text file listing the changed files plus the diffs of the changed files, I haven't had time to strip out the unchanged code so the diff files are complete files if you see what I mean.
kichik#
Thanks spanky,

It was indeed a bug, and a very stupid one may I add...
I have fixed this bug and another one relating the default uninstall icon. I have also updated the makefiles (I hope I did it right...).

I hope the new file will be up soon on Sunjammer's NSIS Archive. I will let you know when it is there.
kichik#
Sunjammer, you forgot the core of it all in the diffs zip you posted earlier. You forgot ResourceEditor.cpp and ResourceEditor.h.
Sunjammer#
Ahha of course that would be because I posted differences and forgot additions, twit. Well you've pointed it out now, can't believe I forgot to mention that!
CodeSquid#
Compile error with !packhdr

I'm using the packhdr command to further reduce the size of the installer. I'm using the latest version of UPX for exe compression.

But everytime I use !packhdr in my scripts, NSIS 1.99 always reports this error message:
"Locating install icon after compress: find_data_offset: error searching data -- failing!"
rainwater#
Re: Compile error with !packhdr

Originally posted by CodeSquid
I'm using the packhdr command to further reduce the size of the installer. I'm using the latest version of UPX for exe compression.

But everytime I use !packhdr in my scripts, NSIS 1.99 always reports this error message:
"Locating install icon after compress: find_data_offset: error searching data -- failing!"
It sounds like there could be a problem with the patch that is stripping the unused resources. Maybe people should use upx to take care of that?
kichik#
My patch doesn't ever remove the icon. I don't see any reason for it to fail. The icon is there. Did this work with NSIS 1.98? Maybe UPX compresses the icons as well. But then, how could Windows read them?

Please send me the script so I can look further into it.

EDIT:
I think I know what is wrong. Maybe UPX compress all of the icon resource together, and doesn't align each raw data section size to 8 like my resource editor does.

I will look into it, and if this is the case I will just rewrite the find_data_offset function to match this case.

Does it only happen when you add an icon file with more than one icon?
CodeSquid#
Yes, it worked before with 1.98
When I call upx with --compress-icons=0 1.99 still doesn't work

EDIT:
My icon files have more than one icon: 32x32 and 16x16, each in 16 and 256 colors
kichik#
OK, so that must be the problem... UPX eliminates the space between icons... I will fix this bug tomorrow.
spanky#
Normally, compressing the icons is not a good idea.
Use this instead:
!packhdr tmp.dat "upx --best --crp-ms=500000 --color --compress-icons=0 tmp.dat
kichik#
I have found out what the problem is, and it is a pretty funny one 🙂
It seems UPX doesn't eliminate the space between icons, it adds more! 😱 Some compression eh?

I won't make the fix today, maybe tomorrow. If anyone else wants to do it instead of me here is my idea (if you have a better one please post it):
The uninstaller icon data should be saved as an array of variable length entries. Each entry of the array would contain:
1) The size of the icon
2) The offset in which it should saved
3) The icon data itself

generate_uninstall_icon_data would build this array and leave the offsets entries empty. After the file is compressed using UPX or whatever (which is the last the time the exe header can change) the offsets will be written into this array. To find the offsets you will have to write a function like get_addr_of_res.

The function generating the uninstaller must change too (in the exe header).

If all this is done it would be useless for get_addr_of_res to search for the icon offset, and to be called after each use of CResrouceEditor.

If someone is ready to this please tell me. If I get no PMs/E-Mail until tomorrow I will do it my self.
pjw62#
I haven't seen your code yet, but it sounds a bit special sir.

You are a good programmer (or I am extraordinarily poor) and I must admit, I had a go at it and could not get it working very cleanly. Eventually I had to settle with not being able to add named entries, 'cause I just couldn't get them to work.

I am downloading yours now and will take a quick peep 😉

Thanks/
kichik#
Thanks pjw62 😁

If you need some resources of the resource section strcture PM me, I have stumbled ascross some while studying the subject 😉
kichik#
OK, it is ready!
InstallColors, UPX, multiple icons, zlib and bz2. It all works now. This time I wrote the icons handling functions a bit more general so it should be able to handle even the craziest compiler/packer unless it compresses the icons (I hope 😁 ).

I have also added an error message if the NSIS path could not be found in the registry. It does not stop compilation, but I at least now you will know why your include doesn't work.

I have asked Sunjammer to upload the new file. He'll let you know when it is there.
Sunjammer#
Uploaded

KiCHiK's new version has been uploaded. The direct link to the file is http://www.clantpa.co.uk/nsis/hosted/nsis199.exe.
rainwater#
Originally posted by kichik
I have also added an error message if the NSIS path could not be found in the registry. It does not stop compilation, but I at least now you will know why your include doesn't work.
That is not needed. You don't need to read from the registry to get the directory. Just change that code in build.cpp to this:


{
char szNSISDir[NSIS_MAX_STRLEN],*fn2;
GetModuleFileName(NULL,szNSISDir,sizeof(szNSISDir));
fn2=strrchr(szNSISDir,'\\');
if(fn2!=NULL) *fn2=0;
definedlist.add("NSISDIR", (char*)szNSISDir);
}
mlbl#
I think that the stuff that you stripped down causes a problem with having a custom Enabled/Disabled bitmap for the checkboxes/option boxes.

It worked fine in 1.98 but this feature was broken in your copy, hope you can fix it ASAP. Other than that everything else works fine.
kichik#
Err... I can't beleive I did that stupid mistake again! I forgot to call get_addr_of_resource after altering rsources...
A new version will be uploaded ASAP.
T(+)rget#
I was wondering whether or not u could add that Brand Image thingy to your version of NSIS as well with full like bmp support like with da icons if poss.
T(+)rget#
lol soz

Anyway like I said it'll be nice to see that Brand Image thing included with this version of NSIS you know the image on the side of the installer.