News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Question about icons

Started by brixton, June 08, 2005, 09:26:14 PM

Previous topic - Next topic

hutch--

Paul,

Its actually done for a reason, while its simpler to use the RES file with the linker, it hides the technique used by the linker which is to call CVTRES to convert the RES to OBJ so it was a design decision so that programmer would know how it all worked. A lot of HLL people don't care but the assembler gang like to know how everything works.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Clueless

Hutch,
You are certainly right about that!  We snoop into all knowledge areas!  It is a part of who and what we are and why we choose assembly (I dislike the word 'compiler' for obvious reasons).

Paul (or Gene, whatever)  :bg

Robert Collins

Quote from: Mark Jones on June 10, 2005, 02:18:10 AM
Interesting. I never knew that an .exe's icon could be changed by digging into its properties. Guess we learn something new every day...

I don't think you can change the exe's icon via the properties. This only changes the desktop icon of the shortcut and not the icon on the title bar of an application.

dsouza123

There is a usefull freeware program called reshacker that allows you to modify your executable
to view/change/add/delete various resource items.

donkey

The icon for an executable is the first icon found in the resource section, there is no way to assign another as it is not your program that is choosing or displaying the icon, it is the shell. Shell32 will only use the first icon of the executable. In order to change the icon you have to either update the resources with a new icon (using UpdateResource if you want to do it at runtime) or using a resource editor (like ResHacker that was mentioned previously). If you use UpdateResource, it only works in NT/2K/XP/2K3 the 9x versions will require MSLU in order to use it though it will not generate any errors in 9x it will not do anything either.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Vortex

Yaroslav's resource linker is able to update resources. Run the batch file Update.bat and watch how the icon of the executable Win.exe is changed.  :)


[attachment deleted by admin]

Vortex

Here is another example with the UpdateResource function

[attachment deleted by admin]

donkey

Well, updating a resource with UpdateResource is fairly simple, I don't really see the need to use external programs or batch files for it. Here is a snippet from an old project that I worked on that inserted binary data into the resources of an executable. It is part of the engine for an install maker, nothing nefarious...

invoke BeginUpdateResource,OFFSET OutFile,FALSE
mov [hUpdate],eax

; Write the compressed file to the resource section
invoke UpdateResource,[hUpdate],RT_RCDATA,[ResNumber],NULL,[pCompHeap],[ComprSize]

add D[ResNumber],1
; Write the file data to the resource section
invoke UpdateResource,[hUpdate],RT_RCDATA,[ResNumber],NULL,[pDataStruct],SIZEOF ResourceHeader

invoke EndUpdateResource,[hUpdate],FALSE


The sequence is essentially the same for any resource type, for icons simply enumerate the icon resources, get the resource number of the first one and replace it.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Vortex

I am really curious Donkey, had you the time to check for what purposes could be used the resource linker rl.com?
I don't claim that using that tool is a big event but if you could check it...

brixton

Thankyou for all the replies, I have got it working, it's as easy as a click in QE  :dance:

Now I just need to create a decent icon  :lol .  Also, it adds a few K onto the filesize, but I suppose that's to be expected as it is storing the icon.
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..