flat assembler
Message board for the users of flat assembler.

Index > Windows > import section and filesize

Author
Thread Post new topic Reply to topic
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
i was just experimenting with filesize and am wondering why using

Code:
data import
;code
end data
    


as oppose to

Code:
section '.idata' import data readable writeable
    


gives a smaller compile size, what is the difference?, is the data directive not actually creating a new section or?

the fasm documentation states

Quote:

data directive begins the definition of special PE data, it should be followed
by one of the data identifiers (export, import, resource or fixups)
or by the number of data entry in PE header.


i assume the special is the type of data "import"

also somewhat offtopic what would all the flags of a merged .flat section be? "readable writeable executable" ?

again offtopic...

would someone be kind enough to post an example of a procedure export in the export section without the use of the export macro, i had a look at the macro to see what was going on but got a bit lost

thanks in advance


Last edited by RedGhost on 09 Aug 2005, 16:04; edited 1 time in total
Post 09 Aug 2005, 13:07
View user's profile Send private message AIM Address MSN Messenger Reply with quote
polygon7



Joined: 14 Aug 2003
Posts: 62
Location: Poznan, Poland
polygon7
Hi,
if you want to merge import section, code and data then you must have readable writeable and executable attributes set. Becouse import section needs to be "rw" (windows loader binds imports when loadnig, if i remember correctly), data also "rw", and code "re". rw+rw+re = rwe Wink

_________________
best regards
p7
Post 09 Aug 2005, 15:11
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
polygon7 wrote:
Hi,
if you want to merge import section, code and data then you must have readable writeable and executable attributes set. Becouse import section needs to be "rw" (windows loader binds imports when loadnig, if i remember correctly), data also "rw", and code "re". rw+rw+re = rwe Wink


ah so its merging the import section, that would explain the drop in filesize, maybe i didnt read the documentation correctly, yeah i figured those would be the required flags but was unsure
Post 09 Aug 2005, 16:04
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
The PE directories like import, export or resource can be placed anywhere in any section - and so "data" is just for this purposes, it allows you to define the given type of PE directory anywhere inside the section where you put it, without starting any new one.
Post 09 Aug 2005, 16:10
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
Tomasz Grysztar wrote:
The PE directories like import, export or resource can be placed anywhere in any section - and so "data" is just for this purposes, it allows you to define the given type of PE directory anywhere inside the section where you put it, without starting any new one.


ah, hmm i do enjoy how easy it is to do compiler level things with fasm, if i remember correct c wouldnt even let the reloc(fixups) section become merged therefore the filesize would not go below 1.5kb, with fasm i can make a 1024byte functioning dynamic link library and thats cool

well would there be any disadvanges to merging sections maybe some problems that can arise from it?

also not to be a pest but as i learn more and more asm i for some reason want to become less dependant on macroinstructions or includes, and i tried to follow the export macro to see what was going on but i have a hard time following them. i have a project i was doing where i have gotten rid of every macro except for export.inc so if someone is willing to drop me a hardcoded example i would appreciate it greatly!
Post 10 Aug 2005, 00:19
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
Here's a hardcoded export section from the Win32DLL example from fasm 1.04 package (before the includes time Wink):
Code:
section '.edata' export data readable

  dd 0,0,0,rva dlldemo_name,1
  dd 1,1,rva addresses_table,rva names_table,rva hints_table

  addresses_table:
    dd rva WriteText
  names_table:
    dd rva _WriteText
  hints_table:
    dw 0

  dlldemo_name db 'DLLDEMO.DLL',0

  _WriteText db 'WriteText',0    

(if you are interested in old releases, you can browse them here).

Also read the official PE/COFF documentation for detailed information on export section format etc.
Post 10 Aug 2005, 00:43
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
Tomasz Grysztar wrote:
Here's a hardcoded export section from the Win32DLL example from fasm 1.04 package (before the includes time Wink):
Code:
section '.edata' export data readable

  dd 0,0,0,rva dlldemo_name,1
  dd 1,1,rva addresses_table,rva names_table,rva hints_table

  addresses_table:
    dd rva WriteText
  names_table:
    dd rva _WriteText
  hints_table:
    dw 0

  dlldemo_name db 'DLLDEMO.DLL',0

  _WriteText db 'WriteText',0    

(if you are interested in old releases, you can browse them here).

Also read the official PE/COFF documentation for detailed information on export section format etc.


much love, thank you sir! Smile
Post 10 Aug 2005, 04:08
View user's profile Send private message AIM Address MSN Messenger 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.