News:

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

Tiny Executable

Started by Queue, June 27, 2010, 04:26:04 AM

Previous topic - Next topic

Queue

I know, this topic's been beaten to death, and there are a jillion ways to do it. That doesn't mean it's not a fun exercise though, so here's my stab at it.

One ASM file; it generates both the DOS Stub and the EXE output file. Notes on assembler and linker options are listed at the top of the ASM file as well as the two changes that need to be made (after linking) using a hex editor. The 16-bit MASM LINK.EXE and POLINK.EXE are assumed for linkers. I personally used ML.EXE 6.15; 6.14 will work too.

My goal was a 512 byte EXE that runs on all 32-bit versions of Windows, and DOS, and returns an exit code of 1. I've tested it on 98SE, XP, Vista, DOS 6.22 and DOSBox. It should work, based on those results, on ME and 7, but I don't know about NT or 2000.

Queue

Edit - Use this download, attached farther down in the thread, instead:
http://www.masm32.com/board/index.php?action=dlattach;topic=14285.0;id=7740

TmX

Quote from: Queue on June 27, 2010, 04:26:04 AM
It should work, based on those results, on ME and 7, but I don't know about NT or 2000.

Queue

No, doesn't work on Win 7.

Queue

Quote from: TmX on June 27, 2010, 05:05:07 AM
Quote from: Queue on June 27, 2010, 04:26:04 AM
It should work, based on those results, on ME and 7, but I don't know about NT or 2000.

Queue

No, doesn't work on Win 7.
Well now I know. What sort of error does it give? This is not a valid executable? I'm kinda surprised since it worked on Vista.

Queue

Edit - Attached a batch file to make testing really easy.

FORTRANS

Hi,

   Says "G:\WORK\TINYE9XE.EXE is not a valid Win32 application."
and then "Access is denied."

Microsoft Windows 2000 [Version 5.00.2195]

HTH,

Steve N.

TmX

Quote from: Queue on June 27, 2010, 05:14:42 AM
Well now I know. What sort of error does it give? This is not a valid executable? I'm kinda surprised since it worked on Vista.

Yes, "not a valid Win32 application", then "access is denied"

jj2007


Queue

Hm... I messed something up preparing this example to upload. How embarrassing.

I'll return once I fix and properly test it. My point was that a valid 1 block PE executable can be made mostly with an assembler and linker, and that it can adhere to PE specs, but I shot myself in the foot by not providing that.

Queue

Queue

This version's a little less impressive but was the other variant I was working on. The smallest Windows executable with an icon. All code and imports are contained in the first 512 byte block. The icon fits in the second. In this case, while it's important to see if the program runs, it's equally important that the program has a visible custom icon.

Queue

FORTRANS

Hi,

   No message and just returns to prompt.

Steve N.

Queue

Good, that means it works; there is no message as it simply exits with an exit code of 1. Failure means a dialog box pops up telling you it's not a valid executable. Did you try the included tinytest.bat file? It checks for the proper exit code.

Queue

FORTRANS

Hi,

   Tinytest works as you state.  Returns 1.

Regards,

Steve