flat assembler
Message board for the users of flat assembler.

Index > Windows > FASM 1.52 includes adds more sections than needed

Author
Thread Post new topic Reply to topic
Daemon



Joined: 08 Jul 2003
Posts: 15
Daemon
Hi, this is two simply examples.

This one -
Code:
format pe gui
entry start

include 'win32a.inc'

section '.code' readable executable

start:
        xor     eax, eax
        ret
    

- produces a 1024 bytes file, while
Code:
include 'win32ax.inc'

.code

start:
        xor     eax, eax
        ret

.end start
    

produces a 1536 bytes file.

The 2nd example produces one more section named '.idata' while there is no imports defined.
I think that there's an error in import macros.

Greetz, Daemon.
Post 24 Apr 2004, 05:51
View user's profile Send private message Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Practically, this is not an error. An executable which doesn't import even a single API function has not much use in normal life. Smile

_________________
Code it... That's all...
Post 24 Apr 2004, 09:24
View user's profile Send private message Visit poster's website Reply with quote
Daemon



Joined: 08 Jul 2003
Posts: 15
Daemon
Have looked at win32ax.inc file:
Code:
macro .end label
 {
   entry label

   section '.idata' import data readable writeable

     library kernel32,'KERNEL32.DLL',\
         user32,'USER32.DLL',\
            gdi32,'GDI32.DLL',\
      advapi32,'ADVAPI32.DLL',\
        comctl32,'COMCTL32.DLL',\
        comdlg32,'COMDLG32.DLL',\
        shell32,'SHELL32.DLL',\
          wsock32,'WSOCK32.DLL'

     include '%fasminc%/apia/kernel32.inc'
     include '%fasminc%/apia/user32.inc'
     include '%fasminc%/apia/gdi32.inc'
     include '%fasminc%/apia/advapi32.inc'
     include '%fasminc%/apia/comctl32.inc'
     include '%fasminc%/apia/comdlg32.inc'
     include '%fasminc%/apia/shell32.inc'
     include '%fasminc%/apia/wsock32.inc'
 }    


I.e. if you use an '.end' macro the import section adds you want it or not...
Code:
include 'win32ax.inc' 

.code 

start: 
        xor     eax, eax 
        ret     


This produces a 1024bytes code. (don't know how is it with entry point... maybe it is set to 1st byte of '.flat' section...)

Other, it's possible to make smaller file if you put import data and code in same section, but first place imports!!! :
Code:
format pe gui
entry start
include 'win32a.inc'

section '.flat' data code import readable writeable executable

library kernel32,'KERNEL32.DLL',\
         user32,'USER32.DLL'

import kernel32, ExitProcess,'ExitProcess'

import user32, MessageBox,'MessageBoxA'

message db 'Hell0w!',0
caption db 'Message',0

start:
        invoke  MessageBox, HWND_DESKTOP, message, caption, MB_OK
        invoke  ExitProcess, eax    


Greetz, Daemon.
Post 24 Apr 2004, 10:44
View user's profile Send private message Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Dunduk
Hi
Daemon wrote:

Other, it's possible to make smaller file if you put import data and code in same section, but first place imports!!! :


You can put import data, export data and code in one section and it will work.
Code:
format PE GUI 4.0 DLL
entry DllEntryPoint
include '%fasminc%\win32a.inc'

proc  DllEntryPoint, hinstDLL,fdwReason,lpvReserved
  xor   eax,eax
  inc   eax
  return
endp

proc Proc1
  ...
  return
endp

proc Proc2
  .local_var dd ?
enter
  ...
  return
endp

data import
  ...
end data

data export
  export 'TEST.DLL',\
    Proc1,'Proc1',\
    Proc2,'Proc2'
end data

data fixups
end data
    
Post 26 Apr 2004, 03:02
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.