flat assembler
Message board for the users of flat assembler.
Index
> Windows > Extract Icon from File |
Author |
|
mike.dld 07 Dec 2004, 02:44
That's your problem - you don't know which icon exactly you want to extract from executable. It may contain many of them... Anyway, try using ExtractIcon to extract icon from file using its index.
|
|||
07 Dec 2004, 02:44 |
|
vbVeryBeginner 07 Dec 2004, 07:12
from PSDK
If all bits except the least significant 16 bits of the lpName or lpType parameter are zero, the low-order word specifies the integer identifier of the name or type of the given resource. Otherwise, those parameters are long pointers to null-terminated strings. If the first character of the string is a pound sign (#), the remaining characters represent a decimal number that specifies the integer identifier of the resource's name or type. For example, the string "#258" represents the integer identifier 258. An application should reduce the amount of memory required for the resources by referring to them by integer identifier instead of by name. An application can use FindResource to find any type of resource, but this function should be used only if the application must access the binary resource data when making subsequent calls to LockResource. To use a resource immediately, an application should use one of the following resource-specific functions to find and load the resources in one call well, i suggest you to get a PSDK from microsoft, it is FREE download. |
|||
07 Dec 2004, 07:12 |
|
thirteen 07 Dec 2004, 13:53
@mike.dld: Yes, I know ExtractIcon, but how to get the Resource Size then? I only want to extract first icon from the file...
@vbVeryBeginner: of course i have the psdk from microsoft, but it only say a example, and not the specific name for the icon. ("#???",0) |
|||
07 Dec 2004, 13:53 |
|
vbVeryBeginner 08 Dec 2004, 06:50
well, if u did read the PSDK carefully, you might found the EnumResourceNames function under the resource reference.
i quote part of its saying. The EnumResourceNames function searches a module for each resource of the specified type and passes either the name or the ID of each resource it locates to an application-defined callback function. well, u could use the EnumResourceTypes first then EnumResourceNames to get all resources an executable or dll provided. wonder why u didn't use these two function in ur .exe? Quote:
|
|||
08 Dec 2004, 06:50 |
|
thirteen 08 Dec 2004, 19:45
Hmm, well, I see this functions, but dont think they are not neccesary if someone know what name stands for icon resource. So can you give me an example how to handle with this callback? I know that it is nearly the same with createing a window...but i dont try to create a window yet
and i like mov dword [Name], eax more then simply mov [Name], eax. I only use this for better source looking (in my opinion) thx, thirteen |
|||
08 Dec 2004, 19:45 |
|
gnomen 08 Dec 2004, 20:01
Quote: ... but dont think they are not neccesary if someone know what name stands for icon resource. look at this page for all the predefined resource types: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Resources/IntroductiontoResources/resourcereference/resourcetypes.asp[/quote] |
|||
08 Dec 2004, 20:01 |
|
vbVeryBeginner 09 Dec 2004, 03:11
Quote:
Quote:
the EnumResourceNames is basically to loop a particular resource type (RT_ICON) on an executable so that you could use its result as lpName or lpIconName pair with LoadIcon to get the handle for that Icon. if u use ExtractIcon, u don't have to get the identifier for icon coz it is index based. |
|||
09 Dec 2004, 03:11 |
|
thirteen 09 Dec 2004, 14:38
ok, when i use ExtractIcon API i have the handle for the icon, but whats about the size i need for UpdateResource? I search for some example, and see some post at win32asm community forum, he asks the same question but not really a answer... Best would be if i see a working example...but dont find it yet.
thx, thirteen |
|||
09 Dec 2004, 14:38 |
|
vbVeryBeginner 10 Dec 2004, 13:19
Quote:
did u notice the SizeofResource function? |
|||
10 Dec 2004, 13:19 |
|
thirteen 10 Dec 2004, 14:28
i did! but with ExtractIcon handle it dont work... this fails:
Quote: hResInfo thirteen |
|||
10 Dec 2004, 14:28 |
|
vbVeryBeginner 11 Dec 2004, 05:53
Code: HICON ExtractIcon( HINSTANCE hInst, // instance handle LPCTSTR lpszExeFileName, // file name UINT nIconIndex // icon index ); it would be nice if u plez elaborate ur problem did u have PSDK? |
|||
11 Dec 2004, 05:53 |
|
thirteen 13 Dec 2004, 18:02
i am sorry, i think we misunderstand us yes, of course i have the api reference, i know how to handle ExtractIcon! But my problem now is that SizeofResource API dont work with handle of the icon get'n from ExtractIcon. OK, here is the code with the extracticon api, it fails on getting the size of the resource....:
Code: include "%fasminc%\win32ax.inc" .data ModuleHandle dd ? IconSource db "Icon.exe",0 IconHandle dd ? ResourceSize dd ? UpdateFile db "test.exe",0 UpdateHandle dd ? ResType db "RT_ICON",0 ResName db "test",0 .code start: invoke GetModuleHandle,\ 0 mov dword [ModuleHandle], eax invoke ExtractIcon,\ dword [ModuleHandle],\ ;module handle IconSource,\ ;extract icon from this 0 ;first icon mov dword [IconHandle], eax invoke SizeofResource,\ dword [ModuleHandle],\ dword [IconHandle] ;resource handle: ;hResInfo ;Identifies the resource. This handle must be created by using ;the FindResource or FindResourceEx function. mov dword [ResourceSize], eax invoke BeginUpdateResource,\ UpdateFile,\ ;update this file 0 ;change only icon, no other resource mov dword [UpdateHandle], eax invoke UpdateResource,\ dword [UpdateHandle],\ ResType,\ ;RT_ICON ResName,\ LANG_ENGLISH,\ dword [IconHandle],\ dword [ResourceSize] invoke EndUpdateResource,\ dword [UpdateHandle],\ 0 invoke ExitProcess,\ 0 .end start sorry if i steal your time, but much thx for helping |
|||
13 Dec 2004, 18:02 |
|
vbVeryBeginner 14 Dec 2004, 05:33
it should be
Code: invoke GetModuleHandle,IconSource invoke SizeofResource,\ eax,\ dword [IconHandle] ;resource handle: ;hResInfo ;Identifies the resource. This handle must be created by using ;the FindResource or FindResourceEx function. i try ur example, i guess u have to use the FindResource as remark by the PSDK so, i guess u need to EnumResourceNames |
|||
14 Dec 2004, 05:33 |
|
mike.dld 14 Dec 2004, 08:42
IIRC GetModuleHandle returns all the same values on NT systems so you'll get handle of you own module
|
|||
14 Dec 2004, 08:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.