flat assembler
Message board for the users of flat assembler.

Index > Windows > non default section.Characteristics

Author
Thread Post new topic Reply to topic
sometimes



Joined: 12 Jul 2014
Posts: 5
Location: Russia
sometimes 12 Jul 2014, 07:25
hello, I want see in the compiled file section with IMAGE_SCN_CNT_UNINITIALIZED_DATA characteristics, but fasm support only 'code' and 'data' (IMAGE_SCN_CNT_CODE and IMAGE_SCN_CNT_INITIALIZED_DATA). So i need to modify fasm source, but I could not understand how. Can anyone help me?)
Post 12 Jul 2014, 07:25
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 12 Jul 2014, 08:12
fasm automatically sets this flag when you put only the uninitialized data into your section, i.e. the definitions like "rb 100", "db ?", etc.
Post 12 Jul 2014, 08:12
View user's profile Send private message Visit poster's website Reply with quote
sometimes



Joined: 12 Jul 2014
Posts: 5
Location: Russia
sometimes 12 Jul 2014, 08:15
thx for answer
but I can not manage sections directly, simply by writing the desired value in Hex (like 0C0000040h)

more controllability is good idea Smile
Post 12 Jul 2014, 08:15
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 12 Jul 2014, 09:29
> more controllability is good idea

use format binary for ultimate controllability (check out 2014 files)
Post 12 Jul 2014, 09:29
View user's profile Send private message Reply with quote
sometimes



Joined: 12 Jul 2014
Posts: 5
Location: Russia
sometimes 12 Jul 2014, 09:55
DOS386, it's a really good idea, thank you.

But I'm still interested to understand the FASM source code, could you show where is FASM writing IMAGE_SECTION_HEDER.Characteristics?
I think that somewhere inside FORMATS.INC Wink
Post 12 Jul 2014, 09:55
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 12 Jul 2014, 10:10
> I think that somewhere inside FORMATS.INC

YES

Code:
      pe_entry_init_ok:
        and     [number_of_sections],0
        movzx   ebx,word [edx+14h]
        lea     ebx,[edx+18h+ebx]
        mov     [current_section],ebx
        mov     dword [ebx],'.fla'
        mov     dword [ebx+4],'t'
        mov     [ebx+14h],edi
        mov     [ebx+0Ch],eax
        mov     dword [ebx+24h],0E0000060h ; <<<--- HERE
    


Poke in hardcoded value and later patch it as needed :-\
Post 12 Jul 2014, 10:10
View user's profile Send private message Reply with quote
sometimes



Joined: 12 Jul 2014
Posts: 5
Location: Russia
sometimes 12 Jul 2014, 10:18
No, I plan normal modes, without repeated FASM rebuilding, and add some commands to the parser

Code:
mov     dword [ebx+24h],0E0001060h    


Аnd as I understand it's about ".flat" section only, it is not suitable if I write..

Code:
section 'some' code executable writeable    
Post 12 Jul 2014, 10:18
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 12 Jul 2014, 12:21
In TABLES.INC, in the symbols data structure you can find entries for "code" and "data" flags:
Code:
 db 'code',19h,5    

Code:
 db 'data',19h,6    

The byte 19h is fasm's internal code for PE section flags, the second byte is the number of bit corresponding to the flag.
So you could define the new "udata" flag by inserting this new line into "symbols_5" table:
Code:
 db 'udata',19h,7    
Note that the table has to be sorted alphabetically, so you'd need to insert it between "tword" and "use16".
Post 12 Jul 2014, 12:21
View user's profile Send private message Visit poster's website Reply with quote
sometimes



Joined: 12 Jul 2014
Posts: 5
Location: Russia
sometimes 12 Jul 2014, 13:52
Tomasz Grysztar, this is what I need. thx twice
Post 12 Jul 2014, 13:52
View user's profile Send private message Reply with quote
SokilOff



Joined: 20 Sep 2010
Posts: 15
SokilOff 13 Jul 2014, 01:01
Tomasz Grysztar wrote:
So you could define the new "udata" flag by inserting this new line into "symbols_5" table:
Code:
 db 'udata',19h,7    
Note that the table has to be sorted alphabetically, so you'd need to insert it between "tword" and "use16".
Thanks ! Some time ago I had ran into the same problem but decided that one can live without it :)
Maybe it's even worth to be added in the next FASM version.
Post 13 Jul 2014, 01: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.