Any Recomended Document?

delphi package - madRes, madTools, madStrings, ...
Post Reply
HaTcHeT
Posts: 4
Joined: Mon Apr 26, 2004 2:16 pm
Location: England
Contact:

Any Recomended Document?

Post by HaTcHeT »

ok, this is loosly connected to your collection..

for MadRes you can edit icons, this is done by editing the pe header. now i was wanting to learn how to do this myself nd was wondering if you recommend any documents on pe headers / editing icons inside executables.

the only reason i'm asking you is because you've already mastered this task ;)

thanks in advance.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I'm not sure. Do you want to know how to use madRes in order to manipulate icons? Or do you want to write a unit similar to madRes? In the latter case: Why do you want to reinvent the wheel? I mean madRes is freeware and even comes with sources! How can it get any better than that!?
HaTcHeT
Posts: 4
Joined: Mon Apr 26, 2004 2:16 pm
Location: England
Contact:

Post by HaTcHeT »

:lol: its nice to see a programmer proud of his creations!

the only reason i ask. is because theres plenty of documents on extracting icons, but i cant fin anything (which i can follow) thats about removing / adding icons to a file. i only want it out of interest, there wont be any HatRes units coming out ;)

{Edit}

PS. i like ur trousers in that photo u got on ur site :crazy:
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Hmmmm... You can begin reading here:

http://msdn.microsoft.com/msdnmag/issue ... fault.aspx
http://msdn.microsoft.com/msdnmag/issue ... fault.aspx

Those articles are about how the PE format looks like. I think the author of those articles also has written (and published) a little program which parses the resource section and lists all contained resources.

Apart from that there simply is not that much documentation about these things...
HaTcHeT
Posts: 4
Joined: Mon Apr 26, 2004 2:16 pm
Location: England
Contact:

Post by HaTcHeT »

yeah i noticed :(

thanks for all ur help madshi, and while ur here, help me with a lil nooby question if u have a few seconds

Code: Select all

VAR update:cardinal;
{..}
 update := BeginUpdateResourceW('file.exe',true);
 LoadIconGroupResourceW(update,??,??,'iconfile.ico');
 EndUpdateResourceW(update,false);
i'm not sure what informtion needs to go into where i placed the ??s (and i thought seein as u took so long to make the code i'd give it a lil go)
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

That depends on what you want to do. The first parameter is the name that the icon resource shall get. The second parameter is the language. You can use any name for the first parameter and "0" for the language.

I suggest using the freeware resource hacker tool to check whether your manipulations worked out the way you planned. A google search will tell you where to download that tool. I'm using it myself.
_pusher_
Posts: 5
Joined: Wed Apr 28, 2004 3:26 pm

Editing icons (iam using Win9x)

Post by _pusher_ »

Hey madshi, i've been looking for working code for a long time ;)
thanks for fixing the bugs.. but heh now there's a small problem..

update := madRes.BeginUpdateResourceW('c:\test.exe'),true);

if update <> 0 then //its not 0 so it keeps going
begin
LoadIconGroupResourceW(update,'MAINICON',0,'c:\someicon.ico');
EndUpdateResourceW(update, false);
end;

but it doest replace MAINICON, i tried replacing 'MAINICON' string
with PWideChar(RT_GROUP_ICON)
but it did't change anything.
Maybe you know whats wrong ? :wink:
_pusher_
Posts: 5
Joined: Wed Apr 28, 2004 3:26 pm

bugs ?

Post by _pusher_ »

update := MadRes.BeginUpdateResourceW('c:\test.exe',true);

if update <> 0 then
begin
MadRes.LoadIconGroupResourceW(update,
//'MAINICON'
PWideChar(RT_GROUP_ICON)
,0,'c:\someicon.ico');
MadRes.EndUpdateResourceW(update, false);
end;

by calling MadRes function unit it works..
but it overwrites my Resource Dialog and other important resources...
any ideas ? :confused:
HaTcHeT
Posts: 4
Joined: Mon Apr 26, 2004 2:16 pm
Location: England
Contact:

Post by HaTcHeT »

okeydokey .. u see the line

Code: Select all

BeginUpdateResourceW('c:\test.exe',true); 
well u can use true or false for that second parameter .. if u use true it will wipe all resources and start fresh .. if u choose false it will keep all existing resources and just overwrite the one u specify in the name paramter .. ie RT_GROUP_ICON

make sense?
_pusher_
Posts: 5
Joined: Wed Apr 28, 2004 3:26 pm

Post by _pusher_ »

Ahhh yes.. thanks.. i did't try that :-x
thanks alot :D
_pusher_
Posts: 5
Joined: Wed Apr 28, 2004 3:26 pm

Post by _pusher_ »

heh.. is there a way to get "mainicon" of all files.. like some files have other resource names.. :-x
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Currently madRes doesn't support to enumerate resources. However, the win32 APIs support that. Look at:

(1) LoadLibraryEx - to load the exe/dll into memory (use the special flags so that the exe/dll doesn't get executed!!)
(2) EnumerateResourceTypes + EnumerateResourceNames
Post Reply