News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Dave Plummers Smallest Windows App 801 bytes

Started by Shintaro, January 06, 2023, 07:33:18 AM

Previous topic - Next topic

zedd151

Quote from: jj2007 on January 06, 2023, 11:37:32 AM
masm1k is not a function Windows application afaik
Okay, it doesn't meet the criteria from above ...
All it does is display a blank window nothing else. But wait, so does your example.   :tongue:  Seems they are very much alike in some respects.  :biggrin:

hutch--

 :biggrin:

masm1k is a valid Windows 32 bit PE file. It is a bare window without any facilities or accessories but it properly conforms to the system specified ABI (application binary interface) and it will run on any 32 bit or higher Windows OS.

jj2007

Attached another trimmed version. I can't get it under 1,536 bytes, despite some tricks, but there are 400 bytes of zeros at the end.

In contrast, masm1k arrives at 1,024 bytes :rolleyes:

zedd151

Quote from: jj2007 on January 06, 2023, 12:31:46 PM
Attached another trimmed version. I can't get it under 1,536 bytes, despite some tricks, but there are 400 bytes of zeros at the end.
In contrast, masm1k arrives at 1,024 bytes :rolleyes:
Well, what can you do ... ? I originally posted something else here, but thought better of it - and hereby disavow all knowledge of that posts (the original) contents.  :tongue:

hutch--


jj2007

Quote from: hutch-- on January 06, 2023, 05:01:47 PM
Try it with Pelles linker.

Hutch,

That's what I did. It's a question of a few bytes, and apparently your ...

externdef _imp__GetMessageA@16:PTR pr4
GetMessage equ <_imp__GetMessageA@16>

... technique is shorter than my GetProcAddress approach, that's all.

In any case, chasing the Guiness record for the smallest exe is fun but irrelevant for practical purposes. I do try to minimize size where it makes sense, but a minimum window MasmBasic style...
  include \masm32\MasmBasic\Res\MbGui.asm
  GuiEnd

... weighs in at two lines of source and a 59392 byte executable, and the latter is a shame but it's fine for me because it's only 1% of a bloated Hello World QT executable.

Both size and speed matter, but the real problem of Windows is that big pile of crap that builds up over time because most "programmers" don't care at all about size. Actually, they don't even know why their proggies are so bloated. Even the simplest "Hello World, I can translate ounces to grams for you" proggie comes along with a 20MB download. It's ridiculous.

daydreamer

You should check old forum, hitchhiker made 2 1024 bytes dx demos, minimum dx setup + Pixelshader
@JJ not guiness  for smallest .exe is of interest but place for squeeze more Pixelshader instructions in demoscene
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

zedd151


Quote from: jj2007 on January 06, 2023, 08:28:49 PM

externdef _imp__GetMessageA@16:PTR pr4
GetMessage equ <_imp__GetMessageA@16>



... technique is shorter than my GetProcAddress approach ...
Yes, and no import jump table.  :cool:
I always wondered how to do that in masm. I thought it would be a switch that would make that possible. I hadn't really looked at masm1k before.

jj2007

I admire what Oleh Yuschuk has done - he really knows his stuff:
CPU Disasm
Address   Hex dump          Command                       Comments
00401050   .  8D45 B4       lea eax, [ebp-4C]
00401053   .  50            push eax                      ; /pWndclassex
00401054   .  FF15 28114000 call near [<&user32.RegisterC ; \USER32.RegisterClassExA
0040105A   .  68 00000080   push 80000000
0040105F   .  59            pop ecx
00401060   .  57            push edi                      ; /lParam
00401061   .  56            push esi                      ; |hInst
00401062   .  57            push edi                      ; |hMenu
00401063   .  57            push edi                      ; |hParent
00401064   .  57            push edi                      ; |Height
00401065   .  51            push ecx                      ; |Width
00401066   .  57            push edi                      ; |Y
00401067   .  51            push ecx                      ; |X
00401068   .  68 0000CF10   push 10CF0000                 ; |Style = WS_OVERLAPPEDWINDOW|WS_VISIBLE
0040106D   .  53            push ebx                      ; |WindowName
0040106E   .  53            push ebx                      ; |ClassName
0040106F   .  57            push edi                      ; |ExtStyle
00401070   .  FF15 2C114000 call near [<&user32.CreateWin ; \USER32.CreateWindowExA
00401076   .  6A 01         push 1                        ; /Show = SW_SHOWNORMAL
00401078   .  50            push eax                      ; |hWnd
00401079   .  FF15 30114000 call near [<&user32.ShowWindo ; \USER32.ShowWindow
...
CPU Disasm
Address   Hex dump          Command                       Comments
004010BE  |> \FF75 14       push dword ptr [ebp+14]
004010C1  |.  FF75 10       push dword ptr [ebp+10]
004010C4  |.  FF75 0C       push dword ptr [ebp+0C]
004010C7  |.  FF75 08       push dword ptr [ebp+8]
004010CA  |.  FF15 44114000 call near [<&user32.DefWindow
004010D0  |.  5D            pop ebp
004010D1  \.  C2 1000       retn 10
004010D4   .  FC100000      dd 000010FC                   ; Struct 'IMAGE_IMPORT_DESCRIPTOR'
004010D8   .  00000000      dd 00000000
004010DC   .  00000000      dd 00000000
004010E0   .  E2110000      dd 000011E2
004010E4   .  24110000      dd 00001124
004010E8   .  00000000      dd 00000000                   ; Struct 'IMAGE_IMPORT_DESCRIPTOR'
004010EC   .  00000000      dd 00000000
004010F0   .  00000000      dd 00000000
004010F4   .  00000000      dd 00000000
004010F8   .  00000000      dd 00000000
004010FC   .  4C110000      dd 0000114C                   ; Import lookup table for 'user32.dll'
00401100   .  5A110000      dd 0000115A


Note there are no symbols in this 1024 byte executable!

zedd151

#24
Quote from: jj2007 on January 07, 2023, 06:30:55 AM
Note there are no symbols in this 1024 byte executable!
Trimmed a few bytes.  :tongue:  Now 1005 bytes.  :cool:  But I think thats cheating.  :biggrin:
Attachment removed, it has served its purpose

hutch--

 :biggrin:

If it ain't 1024 bytes or bigger, its not a 32 bit PE file but it is a waste o disk space.  :tongue:

If you use driver alignment, you can get the file smaller than 1024 bytes but its still useless.

zedd151

Quote from: hutch-- on January 07, 2023, 07:23:15 AM
If it ain't 1024 bytes or bigger, its not a 32 bit PE file but it is a waste o disk space.  :tongue:
I did say that I cheated.  :tongue: