flat assembler
Message board for the users of flat assembler.

Index > Windows > Executable size with WinAPI?

Author
Thread Post new topic Reply to topic
jazz



Joined: 16 Jul 2016
Posts: 61
jazz 10 Jan 2017, 17:12
I noticed that a basic Hello World using WriteConsole instead of printf (linked with Microsoft's link.exe) is already taking up 2 KiB on my Windows 10 system. Is that expected or am I doing it wrong?

_________________
invoke Beer
Post 10 Jan 2017, 17:12
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1670
Location: Toronto, Canada
AsmGuru62 10 Jan 2017, 22:29
It is expected.
By default the EXE file is made of sections.
Section size is a multiple of say 512 bytes, so 4 sections will make 2Kb,
even if each section has few useful bytes inside.
You can reduce the EXE size by combining sections.
Search the forum - you will find the details.
Post 10 Jan 2017, 22:29
View user's profile Send private message Send e-mail Reply with quote
jazz



Joined: 16 Jul 2016
Posts: 61
jazz 10 Jan 2017, 22:33
Ah, OK. Thank you!
Post 10 Jan 2017, 22:33
View user's profile Send private message Reply with quote
Mikl___



Joined: 30 Dec 2014
Posts: 140
Location: Russian Federation, Irkutsk
Mikl___ 11 Jan 2017, 00:59
jazz,
Code:
format PE GUI
include 'win32ax.inc'
; import, code, data in the same section
   invoke MessageBox,NULL,wText,wTitle,MB_OK
   retn
wTitle   db   'Iczelion Tutorial #2:MessageBox',0
wText     db   'Win32 Assembly with FASM is Great!',0
data import
 library user32,'USER32.DLL'
 import user32,\
MessageBox,'MessageBoxA'
end data    

Code:
PE-header|code, data, import|  zeros  |size of exe
---------+------------------+---------+----------
512 bytes|     169 bytes    |343 bytes| 1024 byte    


Description:
Download
Filename: tut_02.zip
Filesize: 811 Bytes
Downloaded: 541 Time(s)

Post 11 Jan 2017, 00:59
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.