Everyone seems to ohh and ahh (me too!) when the correct linker settings produce
the standard message box program at 1024 bytes. One of the smallest valid PE
files.

One of the topics on the main board kinda hit home on one of my "pet projects",
to make the smallest possible fully functional Window. This has been a good
exercise for me because it forces me to think in terms of instruction size -vs-
speed.

One of the easiest ways that I have seen to reduce a files size is to remove as
many sections as possible, which brings me to my main question:
Is there any real point, that I am not aware of, in having a data section at all?

I was actually surprised (dont know why), when I removed my data section
completely and placed the holders before my entry point and it compiled and ran
just fine. Which gave me an exe @ 1536 bytes for a full window.



format PE GUI 4.0
entry WinMain

include 'Macros.inc'
include 'Windows.inc'

;======================================================================================================================
section '.code' data readable writeable
;WNDCLASS
WndClass: dd CS_BYTEALIGNWINDOW or CS_BYTEALIGNCLIENT
dd WndProc
dd 0
dd 0
hInst: dd 0
Msg: dd 0
dd 0
MwParam: dd COLOR_BTNFACE+1
dd 0
dd _class
dd 0
dd 0

_class db 'Test', 0

WinMain:
push 0
invoke GetModuleHandle, 0
mov [hInst], eax
push eax

...
blah, blah, blah
Posted on 2002-08-23 18:14:19 by Graebel