The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Dasar on June 26, 2006, 08:04:17 AM

Title: smallest application in masm32 ? how ?
Post by: Dasar on June 26, 2006, 08:04:17 AM
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 ^_^
Title: Re: smallest application in masm32 ? how ?
Post by: hutch-- on June 26, 2006, 08:45:29 AM
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.
Title: Re: smallest application in masm32 ? how ?
Post by: Dasar on June 26, 2006, 09:38:10 AM
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 ^_^
Title: Re: smallest application in masm32 ? how ?
Post by: hutch-- on June 26, 2006, 11:51:22 AM
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.
Title: Re: smallest application in masm32 ? how ?
Post by: 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)
Title: Re: smallest application in masm32 ? how ?
Post by: asmfan on June 26, 2006, 05:26:19 PM
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...
Title: Re: smallest application in masm32 ? how ?
Post by: KSS on June 26, 2006, 06:49:37 PM
P1,
call 32-bit CreateWindow() from .com-file??????? or something else?????! HOW? :eek :eek :eek :eek :eek
Title: Re: smallest application in masm32 ? how ?
Post by: P1 on June 26, 2006, 09:02:33 PM
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.
Title: Re: smallest application in masm32 ? how ?
Post by: Dasar on June 26, 2006, 09:40:23 PM
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 ...
Title: Re: smallest application in masm32 ? how ?
Post by: zooba on June 27, 2006, 01:59:27 AM
The smallest program never does anything useful :lol :wink
Title: Re: smallest application in masm32 ? how ?
Post by: oetriche on June 27, 2006, 07:43:18 AM
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]
Title: Re: smallest application in masm32 ? how ?
Post by: EduardoS on June 27, 2006, 11:11:59 AM
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.
Title: Re: smallest application in masm32 ? how ?
Post by: hutch-- on June 27, 2006, 11:32:48 AM
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.
Title: Re: smallest application in masm32 ? how ?
Post by: P1 on June 27, 2006, 01:55:30 PM
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)
Title: Re: smallest application in masm32 ? how ?
Post by: asmfan on June 27, 2006, 04:21:16 PM
I would answer that "Small is beautiful". And it's always better when smaller and faster (relatively to programs;)
Title: Re: smallest application in masm32 ? how ?
Post by: oetriche on June 27, 2006, 05:26:14 PM
Quote from: EduardoS on June 27, 2006, 11:11:59 AM
oetriche,
both exe crashes here, failed to initialize.
maybe, i doesn't test it on other computers, but in my Windows XP with Service Pack 2 it works
Title: Re: smallest application in masm32 ? how ?
Post by: Faiseur on June 27, 2006, 10:22:25 PM
Quote from: oetriche on June 27, 2006, 05:26:14 PM
Quote from: EduardoS on June 27, 2006, 11:11:59 AM
oetriche,
both exe crashes here, failed to initialize.
maybe, i doesn't test it on other computers, but in my Windows XP with Service Pack 2 it works

Ok in my systems: Windows 2000 sp4, XP sp1 & sp2