QuoteThis is of very little
Tiny MessageBox x64 in FASM (http://masm32.com/board/index.php?topic=4190.msg57973#msg57973)
Size of exe-file is 298 bytes (http://www.kolobok.us/smiles/light_skin/mosking.gif)
:biggrin:
Fine but its not a legal 64 bit PE file. 2 sections are needed to make a valid 64 bit PE file.
Quotebut its not a legal 64 bit PE file. 2 sections are needed to make a valid 64 bit PE file.
asm-file
OPTION DOTNAME
include temphls.inc
include win64.inc
include user32.inc
includelib user32.lib
OPTION PROLOGUE:rbpFramePrologue
OPTION EPILOGUE:none
.code
MsgBoxText db 'Win64 Assembly is Great!',0
MsgCaption db 'Win64 Iczelion''s lesson #2: MessageBox',0
WinMain proc
push rbp
mov edx,offset MsgBoxText
lea r8d,[rdx+sizeof MsgBoxText]
invoke MessageBox,NULL,,,MB_OK
pop rbp
retn
WinMain endp
end
bat-file
cls
set masm64_path=c:\masm64\
set filename=tut_02a
%masm64_path%bin\ml64 /c /Cp /I"%masm64_path%Include" %filename%.asm
%masm64_path%bin\link /SUBSYSTEM:WINDOWS /LIBPATH:"%masm64_path%Lib" ^
/ALIGN:16 /entry:WinMain /SECTION:.text,W %filename%.obj ^
/STUB:%masm64_path%bin\stubby.exe /LARGEADDRESSAWARE:NO /BASE:0x400000
del %filename%.obj
stubby.exe
db 'MZ',62 dup(0)
|head | |code and data | |import | |total size |
|480 | |96 | |92 | |668 bytes |
I'am reminded of the so called "Packers" or executable file compressors for some reason.
People in the "olden days" used them for obfuscation purposes and for writing demo's within 4k and 64k
bounds. Yes, probably not relevant to the discussion at hand but peaked my interest in these
again for some reason. We know assembly apps are small and fast - how small is relative. But if
there are options available to make them even smaller..... Depends obviously - but had anyone
played around with these? Any recommendations for me to try out?
QuoteAny recommendations for me to try out?
Hi,
Raistlin!
- Algorithmic optimization -- use instead of 50 WinAPI procedures - use only two or three WinAPI procedures
- use the key /ALIGN
- combine code and data in code section /SECTION:.text,W
- reduce the program PE-header
- minimize the DOS header
- minimize import
I have heard this discussion many times over the last 20 years, make a non standard PE file to get it under the specification and expect that it will be reliable across multiple OS versions. I have seen 32 bit files smaller again but they are still not compliant to the PE specifications and you have no reason to assume that it will run on all compatible OS versions.
Hi, hutch--!
I used the standard ml64.exe and link.exe and documented options and keys
Quote from: hutch-- on August 24, 2016, 04:06:42 PM
I have heard this discussion many times over the last 20 years
Me too. But it's just a little demo to show off against the QT brigade (https://www.quora.com/Skype-product/What-programming-language-was-Skype-originally-written-in) who can't produce a Hello World below 8 MB :icon_mrgreen:
Nobody would use a 1k or 298 bytes file in a commercial application. It's really just for fun :biggrin: