flat assembler
Message board for the users of flat assembler.

Index > Windows > icon_dataEx

Author
Thread Post new topic Reply to topic
semiono



Joined: 31 Aug 2007
Posts: 192
Location: section '.code' executable
semiono 30 Jun 2009, 23:40
Code:
        resource icons,\
        1,LANG_NEUTRAL,icon_data1,\
        2,LANG_NEUTRAL,icon_data2,\
        3,LANG_NEUTRAL,icon_data3,\
        4,LANG_NEUTRAL,icon_data4
        resource group_icons,17,LANG_NEUTRAL,main_icon

        icon main_icon,\
        icon_data1,'.\Icons\exec_16x16.ico',\
        icon_data2,'.\Icons\exec_32x32.ico',\
        icon_data3,'.\Icons\exec_48x48.ico',\
        icon_data4,'.\Icons\exec_64x64.ico'    


It could be better:
Code:
        icon main_icon,icon_data,'%SystemRoot%\SysWOW64\shell32.dll,-239',\ ; etc...    

winfasm it's required Very Happy

& --
Is it possible a manifest.xml file code keep as directly code asm?
Code:
db <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> ;etc...    

howto?

_________________
Windows 9, FL Studio 19
Post 30 Jun 2009, 23:40
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 01 Jul 2009, 02:04
All possible (well, the first would require "-239" out of the string).

The second, besides doing something like this for every line:
Code:
db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">'    

You could have a manifest.xml file and then, inside the source code do this
Code:
file 'manifest.xml'    

That way, the entire content of the file will be included (kinda "include" directive but this one is processed by the assembler stage and the content of the file is included in the output binary as is).

The first part, if I understand correctly that fasm must suck the icon from an existing DLL in the same way it does when you provide an icon file then it is possible, but it is not a ten lines of code solution.
Post 01 Jul 2009, 02:04
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 192
Location: section '.code' executable
semiono 01 Jul 2009, 07:35
Yes! Manifesto into! Very Happy (I know about the file 'manifest.xml')

Code:
include '%fasm%\win32ax.inc'
entry start

section '.rsrc' resource data readable
        directory RT_ICON,icons,RT_GROUP_ICON,group_icons,RT_VERSION,versions,RT_MANIFEST,manifest

        resource icons,\
        1,LANG_NEUTRAL,icon_data1,\
        2,LANG_NEUTRAL,icon_data2,\
        3,LANG_NEUTRAL,icon_data3,\
        4,LANG_NEUTRAL,icon_data4
        resource group_icons,17,LANG_NEUTRAL,main_icon
        resource versions,1,LANG_NEUTRAL,version
        resource manifest,1,LANG_NEUTRAL,man

        icon main_icon,\
        icon_data1,'.\Icons\exec_16x16.ico',\
        icon_data2,'.\Icons\exec_32x32.ico',\
        icon_data3,'.\Icons\exec_48x48.ico',\
        icon_data4,'.\Icons\exec_64x64.ico'

        versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
                    'FileDescription','GetCurrentDirectory',\
                    'LegalCopyright','2001-2005 GmbH',\
                    'FileVersion','1.0.0.0',\
                    'ProductVersion','1.0.0.0',\
                    'OriginalFilename','GetCurrentDirectory.exe',\
                    'Company','Semiono'

        resdata man
                db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',13,10
                db '<dependency>',13,10
                db '<dependentAssembly>',13,10,32,32,32,32,32,32,32,32
                    db '<assemblyIdentity ',13,10,32,32,32,32,32,32,32,32,32,32,32,32
                        db 'type="win32" ',13,10,32,32,32,32,32,32,32,32,32,32,32,32
                        db 'name="Microsoft.Windows.Common-Controls" ',13,10,32,32,32,32,32,32,32,32,32,32,32,32
                        db 'version="6.0.0.0" ',13,10,32,32,32,32,32,32,32,32,32,32,32,32
                        db 'processorArchitecture="X86" ',13,10,32,32,32,32,32,32,32,32,32,32,32,32
                        db 'publicKeyToken="6595b64144ccf1df" ',13,10,32,32,32,32,32,32,32,32,32,32,32,32
                        db 'language="*"',13,10,32,32,32,32,32,32,32,32
                    db '/>',13,10
                db '</dependentAssembly>',13,10
                db '</dependency>',13,10
                db '</assembly>',13,10
        endres

section '.idata' import data readable writeable
        library kernel32,'KERNEL32.DLL',user32,'USER32.DLL'
        include '%fasm%\api\kernel32.inc'
        include '%fasm%\api\user32.inc'

nBufferLength dw ?
lpBuffer db ?

start:
        invoke GetCurrentDirectory,nBufferLength,lpBuffer
        invoke MessageBox,NULL,lpBuffer,'I''m here:',MB_OK
exit:
        invoke ExitProcess,0
    


Quote:
the first would require "-239" out of the string

this is not a code constant, this is a prompt windows comandline number...
so as HKLM...Classes\exefile\DefaultIcon = "%1" etc.

The properties has not in fasmw Crying or Very sad dll, icl...

_________________
Windows 9, FL Studio 19
Post 01 Jul 2009, 07:35
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 01 Jul 2009, 15:06
But if you look shell32.dll with resource hacker don't you see the expected icon in Icon>239 (The shutdown icon?).

Or there is some kind of special icon resource which makes possible to extract the icon from shell32.dll at run-time automatically?
Post 01 Jul 2009, 15:06
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 192
Location: section '.code' executable
semiono 01 Jul 2009, 20:47
This is not the case. -239 or (+)239 or 32 and 1
Symply problem how to get any icon (1,2,3) from DLL directly in fasm.asm
without extracting before it so like ResHacker tools...

The dll's has compactly contains resources then placed separately exec_16x16.ico, exec_32x32.ico.. files in folders. So convenient.

Sure:
Code:
        resdata manifest
        file 'manifest.xml'
        endres 
        resdata icons
        file 'icons.dll'
        endres
 Smile     
Post 01 Jul 2009, 20:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 01 Jul 2009, 22:07
Be careful what you wish for, because you may get it. Wink

Code:
macro extract_resource pe_file,type,id
{
  ; get PE header offset
  virtual at 0
   file pe_file:3Ch,4
   load __header_offset dword from 0
  end virtual
  ; load PE header
  virtual at 0
   file pe_file:__header_offset,24
   load __number_of_sections word from 6
   load __size_of_optional_header word from 20
   load __characteristics word from 22
  end virtual
  ; load optional header
  virtual at 0
   file pe_file:__header_offset+24,__size_of_optional_header
   load __magic word from 0
   if __magic = 0x10B
    load __resource_base dword from 112
    load __resource_size dword from 112+4
   else
    load __resource_base qword from 128
    load __resource_size qword from 128+8
   end if
  end virtual
  ; load sections and scan for the one containing the resource
  virtual at 0
   file pe_file:__header_offset+24+__size_of_optional_header,__number_of_sections*40
   repeat __number_of_sections
    load __section_base dword from (%-1)*40+12
    load __section_size dword from (%-1)*40+8
    load __section_offset dword from (%-1)*40+20
    if __resource_base>=__section_base & __resource_base+__resource_size<=__section_base+__section_size
      __resource_offset = __section_offset+(__resource_base-__section_base)
      break
    end if
   end repeat
  end virtual
  ; load all the resource and scan the tree for required entry
  virtual at 0
   file pe_file:__resource_offset,__resource_size
   load __type_name_count word from 12
   load __type_id_count word from 14
   repeat __type_id_count
    load __type dword from 16+__type_name_count*8+(%-1)*8
    if __type = type
     load __type_directory dword from 16+__type_name_count*8+(%-1)*8+4
     __type_directory = __type_directory and 7FFFFFFFh
     break
    end if
   end repeat
   load __id_name_count word from __type_directory+12
   load __id_id_count word from __type_directory+14
   repeat __id_id_count
    load __id dword from __type_directory+16+__id_name_count*8+(%-1)*8
    if __id = id
     load __id_directory dword from __type_directory+16+__id_name_count*8+(%-1)*8+4
     __id_directory = __id_directory and 7FFFFFFFh
     break
    end if
   end repeat
   ; take first entry, no matter what language is it
   load __data_entry dword from __id_directory+16+4
   load __data dword from __data_entry+16
   load __size dword from __data_entry+16+4
  end virtual
  ; get the data of selected resource
  file pe_file:__resource_offset+(__data-__resource_base),__size
}    


Code:
section '.rsrc' resource data readable

  directory RT_ICON,icons,\
            RT_GROUP_ICON,group_icons

  resource icons,\
           ICON_ID,LANG_NEUTRAL,icon_data

  resource group_icons,\
           239,LANG_NEUTRAL,main_icon

  resdata main_icon
   __group = $
   extract_resource 'C:\WINDOWS\system32\shell32.dll',RT_GROUP_ICON,238
   load __count word from __group+4 ; count of icons in group
   store word 1 at __group+4 ; cut to just one icon
   load ICON_ID word from __group+6+12
  endres

  resdata icon_data
   extract_resource 'C:\WINDOWS\system32\shell32.dll',RT_ICON,ICON_ID
  endres    
Post 01 Jul 2009, 22:07
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 192
Location: section '.code' executable
semiono 01 Jul 2009, 22:33
Oh! Das ist fantastish! Tomasz Grysztar!
Sorry for me! I'm very young and newbie. Smile
And more I very low speaking in Eanglish.
Big thanks! Yes, good!

extract_resource - cool! Smile
Post 01 Jul 2009, 22:33
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 192
Location: section '.code' executable
semiono 02 Jul 2009, 00:30
The genuine library shell32.dll 7,99 MB (8 384 000 bytes) is well work with the macro!
But tweaked from original lib shell32.dll 26,6 MB (27 993 600 bytes) - fasm reports Out of memory!
Cool Large file or what it? It's fatal? Smile

This lib contained 32x32, 48x48 and 128x128 icons.
Post 02 Jul 2009, 00:30
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 02 Jul 2009, 01:25
Perhaps you have FASMW configured to use little memory?

Try going to Options>Compiler setup... and increase the amount of memory (you are not forced to pick one of the list, write your own size if you have to). The size is expressed in KiB.
Post 02 Jul 2009, 01:25
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 192
Location: section '.code' executable
semiono 02 Jul 2009, 05:22
OK!


Last edited by semiono on 24 Feb 2013, 00:02; edited 1 time in total
Post 02 Jul 2009, 05:22
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 192
Location: section '.code' executable
semiono 24 Feb 2013, 00:01
I'm high!

Code:
[Compiler]
Memory=524288    


Very Happy
Post 24 Feb 2013, 00:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.