Author Topic: Re: Novelty value 1k exe.  (Read 3057 times)

Mikl__

  • Member
  • *****
  • Posts: 1008
Re: Novelty value 1k exe.
« on: August 24, 2016, 11:33:46 AM »
Quote
This is of very little
Tiny MessageBox x64 in FASM
Size of exe-file is 298 bytes

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7528
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Re: Novelty value 1k exe.
« Reply #1 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Mikl__

  • Member
  • *****
  • Posts: 1008
Re: Novelty value 1k exe.
« Reply #2 on: August 24, 2016, 03:22:57 PM »
Quote
but its not a legal 64 bit PE file. 2 sections are needed to make a valid 64 bit PE file.
asm-file
Code: [Select]
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
Code: [Select]
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
Code: [Select]
db 'MZ',62 dup(0)
|head|code and data|import|total size
|480|96|92|668 bytes

Raistlin

  • Member
  • ****
  • Posts: 513
Re: Re: Novelty value 1k exe.
« Reply #3 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?
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

Mikl__

  • Member
  • *****
  • Posts: 1008
Re: Re: Novelty value 1k exe.
« Reply #4 on: August 24, 2016, 03:52:28 PM »
Quote
Any 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--

  • Administrator
  • Member
  • ******
  • Posts: 7528
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Re: Novelty value 1k exe.
« Reply #5 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Mikl__

  • Member
  • *****
  • Posts: 1008
Re: Novelty value 1k exe.
« Reply #6 on: August 24, 2016, 04:16:15 PM »
Hi, hutch--!
I used the standard ml64.exe and link.exe and documented options and keys

jj2007

  • Member
  • *****
  • Posts: 10536
  • Assembler is fun ;-)
    • MasmBasic
Re: Re: Novelty value 1k exe.
« Reply #7 on: August 24, 2016, 06:33:33 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: