Page 1 of 1

c++ Builder 6 help :-)

PostPosted: Mon Nov 06, 2006 7:57 pm
by mhmda
Hi, first of all i would like to thank u very mutch for the code and wish u good luck...
I need help to change my exe icon, i mean all icon folder (16x16,32x32, 48x48...), so i tried the MadRes under c++ builder, the code:

Code: Select all
DWORD res;

the "res" value always "0", and can't update the file, i don't know why, can u help me, and i don't know how to force the c++ builder to use yours override Api "BeginUpdateResourceW" and not the system one.

BTW i tried the BeginUpdateResource whithout 'W' it works, i think maybe i should change the compiler option, but what???


PostPosted: Tue Nov 07, 2006 7:56 am
by madshi
I'm not sure you can use "PWideChar()" like that. Please try this instead:


Does that work better? I'm not sure how you can force BCB to use a specific version of BeginUpdateResourceW. Maybe using "madRes::BeginUpdateResourceW" works?

PostPosted: Tue Nov 07, 2006 4:27 pm
by mhmda
Yes, "L" works fine but the exe size is changed so when i try to run it i get an system error, and can't run the exe file.
BTW i'm trying to change a flash ( short movie) exe file icon.

Code: Select all
 DWORD hUpdateRes=BeginUpdateResourceW(L"PickupCall.exe",true);

EndUpdateResourceW(hUpdateRes, false);

PostPosted: Tue Nov 07, 2006 4:37 pm
by madshi
Hmmm... How much does the exe size change?

Using madRes doesn't work on UPX (or similar) compressed exes. Is this exe compressed?

PostPosted: Wed Nov 08, 2006 9:15 am
by mhmda
How can i check if the file is compress and how can Decompress it. the exe file origin size is: 1,708,248 bytes and the size after using MadRes is: 1,316,568 bytes.
The exe was generated using: Adobe - Captivate and just want to change the icon of the final exe file.

PostPosted: Wed Nov 08, 2006 9:30 am
by madshi
Do you need to do this by code? Try the Resource Hacker. Is that tool able to change the icon?

PostPosted: Wed Nov 08, 2006 9:54 am
by mhmda
Yes it's important to me to change the icon using the code.
I try many of resource hackers (PE Explorer...) but they didn't succeded to change the icon and most of them failed to load the file, EXCEPT one program called "Executable File Icons Changer",, this program changed the resource icon succefully, I know that the program was written in Delphi/BCB but i couldn't decompile it jus to see how the program do that, I even used W32Disasm to view the exe file and to see the API's that it used but the w32disasm shut down immediatly while trying to open the file.

PostPosted: Wed Nov 08, 2006 10:43 am
by madshi
Ok. Does the icon change correctly when using madRes? How does the crash look like? Any details?

PostPosted: Wed Nov 08, 2006 11:27 am
by mhmda
The icon changed succefully using Madres, and I see the new icon we i explore the folder that contains the file.
But when i try to run it I got the error "The application failed to initialize properly (0xc0000005). Click OK to terminate the application."
I got the error twice (the same error).

PostPosted: Wed Nov 08, 2006 11:39 am
by madshi
I can see 2 possible reasons:

(1) Either the exe is UPX (or similiar) compressed.
(2) Or there is data being appended to the end of the application which madRes eventually removes.

When using that tool which is successfully able to change the icon, does the exe file size not change AT ALL? Or does it change, too, but only slightly?

PostPosted: Wed Nov 08, 2006 2:46 pm
by mhmda
After i change the icon collection (16x16,32x32...) the size of the files DOSN'T change it remains the same, and the file runs without any errors, the program dosn't change all the icons in one step, it's drawing all the icons (source, destination) and i choose witch one to change i can change just the 32x32 True or what ever i want, so i repeat the change (9 times) and after that the file was the same size and it runs ok, BTW when i tried to change one of the icons (48x48 True) i get dialog that says the size of source icon and the destination doesn't match i have the apility to choose "convert" and the program converts the icon to match the destination one.
I think if there is program that can do so, so why we can't !!!

PostPosted: Wed Nov 08, 2006 3:24 pm
by madshi
I think that probably there are some hard coded addresses in the exe. And if you use madRes to change the icons, madRes rewrites the resource section, which may result in a smaller or equal or bigger resource section, which may eventually move the code section to another location. Usually that is not problem at all. But it seems with this specific exe it is a problem. I guess the program which can change the icons successfully only works because it doesn't change the size of the resource section.