The MASM Forum

64 bit assembler => 64 bit assembler. Conceptual Issues => Topic started by: Mikl__ on August 24, 2016, 11:33:46 AM

Title: Re: Novelty value 1k exe.
Post by: Mikl__ on August 24, 2016, 11:33:46 AM
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)
Title: Re: Re: Novelty value 1k exe.
Post by: hutch-- on August 24, 2016, 02:58:11 PM
 :biggrin:

Fine but its not a legal 64 bit PE file. 2 sections are needed to make a valid 64 bit PE file.
Title: Re: Novelty value 1k exe.
Post by: Mikl__ on August 24, 2016, 03:22:57 PM
Quotebut its not a legal 64 bit PE file. 2 sections are needed to make a valid 64 bit PE file.
asm-fileOPTION 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-filecls
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.exedb 'MZ',62 dup(0)
|head|code and data|import|total size
|480|96|92|668 bytes
Title: Re: Re: Novelty value 1k exe.
Post by: Raistlin on August 24, 2016, 03:28:21 PM
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?
Title: Re: Re: Novelty value 1k exe.
Post by: Mikl__ on August 24, 2016, 03:52:28 PM
QuoteAny recommendations for me to try out?
Hi, Raistlin!
Title: Re: Re: Novelty value 1k exe.
Post by: hutch-- on August 24, 2016, 04:06:42 PM
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.
Title: Re: Novelty value 1k exe.
Post by: Mikl__ on August 24, 2016, 04:16:15 PM
Hi, hutch--!
I used the standard ml64.exe and link.exe and documented options and keys
Title: Re: Re: Novelty value 1k exe.
Post by: jj2007 on August 24, 2016, 06:33:33 PM
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: