c++ Builder 6 help :-)

delphi package - madRes, madTools, madStrings, ...
Post Reply
mhmda
Posts: 6
Joined: Mon Nov 06, 2006 7:49 pm

c++ Builder 6 help :-)

Post 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;
res=BeginUpdateResourceW(PWideChar("d:\\b.exe"),true);
.
.
.
.
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???

Muhammad[/code]
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I'm not sure you can use "PWideChar()" like that. Please try this instead:

res=BeginUpdateResourceW(L"d:\\b.exe",true);

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?
mhmda
Posts: 6
Joined: Mon Nov 06, 2006 7:49 pm

Post 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);

 if(hUpdateRes!=NULL)
 {
  LoadIconGroupResourceW(hUpdateRes,L"MAINICON",LANG_NEUTRAL,L"c:\\w.ico");
EndUpdateResourceW(hUpdateRes, false);
 }
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post 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?
mhmda
Posts: 6
Joined: Mon Nov 06, 2006 7:49 pm

Post 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.
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Do you need to do this by code? Try the Resource Hacker. Is that tool able to change the icon?
mhmda
Posts: 6
Joined: Mon Nov 06, 2006 7:49 pm

Post 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", http://softboy.net/exeico/, 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.
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Ok. Does the icon change correctly when using madRes? How does the crash look like? Any details?
mhmda
Posts: 6
Joined: Mon Nov 06, 2006 7:49 pm

Post 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).
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post 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?
mhmda
Posts: 6
Joined: Mon Nov 06, 2006 7:49 pm

Post 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 !!!
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Post 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.
Post Reply