You can create an executable with the text section (i.e. the section that has the executable code in it) of less than 100 bytes for a hello world
console output, but the .EXE file size will be larger because it needs to have a valid PE format structure, and that format requires quite a bit of padding. /NODEFAULT
will of course give you errors. You'll then have to reimplement whatever's missing, usually making things no-op, and you'll need to use link-time code generation so that all the calls to the empty functions get removed (as well as the functions themselves). You'll also need to find compiler flags that disable all "cool" features. E.g. to make the compiler stop emitting buffer security checks (__security_check_cookie
& al.), provide the /GS-
option.
You'll probably need to use a custom tool to completely strip the .EXE file from unnecessary PE cruft that VS linker emits. And your executable will still be runtime-linked with at least KERNEL32.DLL, since without that you won't be able to do anything useful. If you're brave, you could use NTDLL.DLL (i.e. the native API) directly, but that will probably need more than 100 bytes of code to.
Your executable will also need to be targeting the 32 bit architecture; 64-bit one will be about 25% larger (at such small section sizes to start with).
It's a nice challenge.