News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

smallest application in masm32 ? how ?

Started by Dasar, June 26, 2006, 08:04:17 AM

Previous topic - Next topic

Dasar

hi all

i just want to ask, what is the smallest program may be written in masm32 ? as i know the smallest one is 1.5 kb, and this application does nothing, it just call ExitProcess, but i think there are  programs  smaller than this in masm32, right ?

hint:  i think in assembler and linker params, but i'm not sure


could you please give me any info about this  "to reduce my programs size" ?


thank you in advance ^_^

hutch--

Dasar,

Look in the masm32 example code and you will find a 1k window that works. That is technically the smallest specification PE file that can be built. It amounts to the MZ, PE and section headers at 512 bytes and one section for the rest at 512 bytes. There have been smaller that run on some 32 bit windws versions but they do not conform to the PE specification and don't run on all versions.

For small code, write it efficiently and don't use un-necessary resources like image data when you don't need it and you will get them small enough.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Dasar

#2
thank you alot hutch : )

but i didn't understand

QuoteFor small code, write it efficiently and don't use un-necessary resources like image data when you don't need it

i don't know what is image data ( is it a member of PE ?  ) !!   :' (  , and don't know how to exclude it...

i want also to know if there some params i have to put in the assmebler\linker to make the output file size smaller...

and i'll see the example you mentioned :)


any other hints is very appreciated ^_^

hutch--

Image data is things like icons and bitmaps. These are usually larger than the code you write so you need to use them carefully if size is the factor you are after.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

P1

The shortest working MASM program is a .com file ( They still work in XP. ) with a return in it.

Regards,  P1  :8)

asmfan

Speaking on PE EXE i made some time ago manually an 6xx bytes exe by removing redundant space padding for the last (frankly speaking the only one:) section. Exe contain 1 merged section import and code together. With HEX editor manually truncated it and corrected the header...
Russia is a weird place

KSS

P1,
call 32-bit CreateWindow() from .com-file??????? or something else?????! HOW? :eek :eek :eek :eek :eek

P1

Quote from: KSS on June 26, 2006, 06:49:37 PMcall 32-bit CreateWindow() from .com-file??????? or something else?????! HOW? :eek :eek :eek :eek :eek
Me scalp 'em you, Thunk head.   :dazzled:

Regards,  P1  :8)

PS:  In case you missed it because of the humor.  I gave you the answer.  Hint:  There are no misspellings.

Dasar

hi, thank you all for your replies


Quote from: P1 on June 26, 2006, 01:45:17 PM
The shortest working MASM program is a .com file ( They still work in XP. ) with a return in it.

Regards,  P1  :8)

i was talking about .EXE applictions, and thank you for the hint ...

zooba

The smallest program never does anything useful :lol :wink

oetriche

Smallest PE with ExitProcess i write in 444 bytes
but it is necessary to use elink from ElicZ's eliasm, some linker options and stub

[attachment deleted by admin]

EduardoS

Quote from: P1 on June 26, 2006, 01:45:17 PM
The shortest working MASM program is a .com file ( They still work in XP. ) with a return in it.

Regards,  P1  :8)
You don't need masm for it, open note pad type Í(space) and save as a .com, a good 2 byte program that don't do anything :8)

oetriche,
both exe crashes here, failed to initialize.

hutch--

For a DOS COM file here is the 2 byte version that works on a dos box.


com_seg segment byte public         ; define the ONLY segment

    assume cs:com_seg, ds:com_seg   ; both code & data in same segment.
    org 100h                        ; go to start adress in memory.

start:                              ; code execution extry point

    int 19h                         ; reboot

com_seg ends                        ; define the end of the segment.

    end start


For a 32 bit file to be a PE file, it requires 2 sections which make it 1024 bytes.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

P1

Quote from: zooba on June 27, 2006, 01:59:27 AMThe smallest program never does anything useful :lol :wink
I'll bet a few virus writers could take you to task on that statement.  :lol :wink  And some Identity Thief trojan writers.  And SPAMmers can be included.   :dazzled:

Now, that's been brought up as a side note:  Have you read the rules yet?    :naughty:

Dasar,  What are you trying to accomphish here?   What is the goal of a small footprint, got to do with your goal?

Regards,  P1  :8)

asmfan

I would answer that "Small is beautiful". And it's always better when smaller and faster (relatively to programs;)
Russia is a weird place