News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Re: Novelty value 1k exe.

Started by Mikl__, August 24, 2016, 11:33:46 AM

Previous topic - Next topic

Mikl__

QuoteThis is of very little
Tiny MessageBox x64 in FASM
Size of exe-file is 298 bytes

hutch--

 :biggrin:

Fine but its not a legal 64 bit PE file. 2 sections are needed to make a valid 64 bit PE file.

Mikl__

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

Raistlin

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?
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

Mikl__

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

hutch--

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.

Mikl__

Hi, hutch--!
I used the standard ml64.exe and link.exe and documented options and keys

jj2007

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 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: