What is the Smallest Possible .EXE?
ฝัง
- เผยแพร่เมื่อ 28 ก.ย. 2024
- To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/... . You’ll also get 20% off an annual premium subscription.
What is the smallest possible EXE that can be run on the Windows Operating System? What about the largest possible EXE? What even is an EXE file? On Windows, EXE files use the Portable Executable file format, which contains the program's code, data, and references to other libraries that can be loaded and run by the OS. It is often referred to as an "Image", the captured state of the program in a form ready to be run by the system.
After testing it was found that the smallest EXE on 64-bit Windows is 268 bytes. This is a system limitation and not a limit with the Portable Executable file format itself. The smallest EXE runnable by other versions of Windows are as follows:
Windows XP: 97 bytes
Windows 2000: 133 bytes
Windows Vista/7 (32-bit): 252 bytes
Windows 7/10/11 (64-bit): 268 bytes
The largest EXE possible is 1,996,488,704 bytes. Again, this size is a limitation with Windows.
GitHub project containing 268 byte EXE, world's smallest game, and world's smallest piano:
github.com/Ink...
About the PE file format:
PE file format: learn.microsof...
PE file diagram: github.com/cor...
Making Small EXE:
Original research into smallest possible EXE: archive.is/w01DO
World's Smallest Windows App (Dave's Garage): • C vs ASM: Making the W...
Tiny PE on Windows 10 (x64): github.com/aya...
More on the 268 byte limit: gist.github.co...
Refined MattKC snake: github.com/Eim...
Low Level Programming:
Kernel32 functions: www.geoffchapp...
Windows Virtual Terminal Sequences: learn.microsof...
MSVC Linker options: learn.microsof...
What is the largest EXE: superuser.com/...
This video is sponsored by Brilliant
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/Inkbox/ . You’ll also get 20% off an annual premium subscription.
3:46
no
How does Brilliant afford to sponsor so many channels, who is paying all that for some information that is already publicly available? And why?
brilliant along with most other sponsors email them a script made to sound better than youtube and stuff which intrigues people
Shove that brilliant up your ass
"I’m not sure typing simulator would become a best seller on Steam."
You'd be surprised what's taking over Steam tops these days...
banana
banana
terracotta
banana click simulator?
@@mjdevlog yeah, it basically just exists to make money off the item trading system on steam
Just to be pedantic, the first file isn't actually 0 bytes. But its contents are!
But the file is nothing but its contents. Unless you're considering the directory entry of the file system part of the file, in which case you would also need to consider the filename and all the files metadata part of it. To my knowledge it isn't though. Directory structure is kept completely separate from file contents
@@HeyImSolaceFiles on your computer are stored with overhead. Some tools will tell you your file has a size of x bytes, and a size on disk of y bytes.
This difference will exist even if the contents are 0bytes, since usually the system reserves a section of disk for it.
This difference is op's 'being pedantic'
O Archon się tu zjawił.
@@mars5train601 I know that this overhead exists, but this overhead is not part of the file. This is like saying a Google search result is part of a Website. It takes up space, but it's not part of the website itself, it merely shows some data of it (Title and a little preview) and points to where it is (its web address).
@HeyImSolace nah, thats the difference in memory vs storage.
The file's metadata in the inode table has a minimum size. In windows ntfs (from googling), the equivalent looks to be the mft record, which clocks in at 1kb or 2 512B ssd sectors.
I remember having an exe file on my Amiga which was only 56 bytes in size: "reboot". This in fact rebooted the Amiga computer when you executed it.
I don't checked size of linux "reboot" program...
@@stalker32041its a symlink to systemctl if on systemd
@@stalker32041 Fifteen characters, 'shutdown -r now' is enough to do that, as root, from the Command Line.
for anyone wondering, the character at 4:06 is "嗯", which (according to Wiktionary) is a Chinese character that can mean doubt, curiosity, surprise, agreement, "pledge", or just onomatopoeia for groaning.
So in general the reaction of the programmer after the program starts and displays the message.
All of that.
If I remember correctly, if you disable ASLR, you can simply jump to Win32 API function addresses. This will eliminate some strings in IMPORTS section of a PE file.
I haven't tried it myself.
Great video! I never considered what the *largest* would be! Now I know :-)
Thanks for giving it a watch, it means a lot coming from you.
I was confused when I saw the video in my feed, thinking it would be basically the same as your video, but I love how this one explains everything visually! Kudos to you both
Nearly 40 years ago, my first Computer was an Amstrad / Schneider CPC 464. I bought a monthly magazine which featured type in programs, back then called listings and there was always the 1kb program section, containing fantastic tools and full games with sound, colour graphics and joystick controls. I remember several Space Invaders clones, Shoot'em Ups, Racing and Puzzle games and an absolutely awesome Fractal generator, everything less than 1kb in Locomotive Basic and less than one page in the magazine.
Back in the day before magazines had download codes. Or DVDs. Or CDs. Or floppies.
No, they printed the code directly and you had to type it in manually.
"What is the largest possible EXE?" (Proceeds to develop an Electron application.)
2:55 - Who knew Plato was a Linux fan?
Maybe an interesting honorable mention: "fr-016c: fuenf (in your face)" by the demo group Farbrausch. It's a COM file that just produces an endless stream of garbage in the terminal, but because sometimes includes ascii bell symbols, it's technically an application with visuals and audio in 5 bytes.
(It also crashes the terminal window)
Back in the day, we called it "Anne See" (like "antsy" with a silent "t"). not "Ay En Ess Eye"
it's the superior way to pronounce it. less syllables and easier to say. I've heard some people say ASCII one letter at a time, one of the worst experiences of my life
@@yourcomputerhasdied you poor soul. Stay strong!
@@yourcomputerhasdied Laugh out loud, what a waste of time.
In fairness, he might have never heard anyone say it 🤷🏻♂️
I pronounce it "ayensi"
You brought me back in time to my computer science days, making games on console applications.
.
Those were the simplest of days.
.
Thank God I still have them.
.
.
I once made an executable a mere 20 bytes in size.
It ran in DOS, was a .com, not a .exe. It's use was to set text resolution to 120x50 characters (if I remember correctly).
I mean, you can make a smaller executable for Windows by taking advantage of the NTVDM and making a COM-file
Yeah, you can get it down to one byte, a single RET instruction.
0:26 sneaking in your mailing list is a genius move lol
I once saw a question on reddit asking why you can't make the same executable file for Linux and Windows.
The answer: see the first half of this video and then one about the ELF format to understand it.
I never expected to see a video game that you can print on a single sheet of paper.
*fun fact:* Registers: EDI, ESP, EBI and EFL could be used to power a RNG with some multiplications and/or additions. Some of them change to a pretty unique value only at start-up and then increment as the program is running, but others could be used to get multiple equally dispersed pseudo-random numbers.
watching videos like these gives me such a desire to c r e a t e something in assembly
but, yknow, then I remember, oh yea, I hate coding in assembly
Sometimes by losing a battle you find a new way to win the war.
Silence bot
15:09 I braced myself for a Rickroll, but was glad that that wasn't the case.
EXE doesn't actually indicate a PE file.
It may contain an early MS-DOS MZ, an MS-DOS 4.0 New Executable or a modern Portable Executable.
and also the LE and LX from Windows VxD services and Microsoft OS/2 2.0
In practical terms, the smallest .exe file you can have is the cluster size the FAT uses on the storage device you're using. Assuming you saved your work that is.
linking an extra dll just for a rng is costing a lot of space. Ok not really a lot but you can do better. It would be smaller to implement a LFSR rng using a seed value from whatever source you can get that you're already have access to. A Console handle is probably good enough to use as a seed for a LFSR. The Handle values are likely going to be unique every time you run the exe though not guaranteed, the chances you'd get repeated Handle values are extremely unlikely. Or you can just go straight to using a cpu random instruction but you lose compatibility with old cpus.
Thank You For Telling Everyone That Small (Functional) Programs Are Indeed Possible And And That You Don't Need A Lot Data To Make A Game Apparently...
what is the smallest possible elf64?
(btw the result turns out to be 45 bytes)
it seems youtube deleted my reply so let's try it again...
even though it's about elf32, I'd highly recommend the famous essay "A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux"
i think using a header someone i know made and assembling asm -> elf64 it was 40 or smth
@@aspectreishauntingeurope that's way smaller than I expected!
...do you have a homemade smartwatch?
We really need Dave on this one
Yes, let's bring in the tone-deaf boomer millionaire. He'll solve our problems.
@@graealex Well, he kinda knows Windows, so he may be a good fit to explain Windows executables
This is not some esoteric boomer multimillionaire knowledge @@Saru-Dono
@@Saru-Dono He knows task manager. There are far more competent people still around in regards to WINAPI.
@@graealexhe developed windows... he made fucking task manager and zip... *_he probably knows a lot about executable files._*
Though not windows PE, the smallest reasonable game that I know of is Shifticida by Rrrola. It's a competitive split screen multiplayer in just 32 bytes COM file for MS-DOS.
with ROP the right jump instruction is turing complete. that's an executable in some scant bytes.
You could fit the entirety of Minecraft into a exe lol
yes? most games can be fit in an exe. in fact that's how games work. they are exes.
@@thewhitefalcon8539 you dont get my point...
@@thewhitefalcon8539 He refers to all the DLLs, libraries, files, external to the Minecraft JAR or EXE file depending on the game edition (Java or Bedrock)
@@thewhitefalcon8539he means the entire game, not just the "executable" portion. (using quotation marks since it's java which is a VM and not a real executable)
Yes, but saves
I appreciated the SID music, I see you like Rob Hubbard :)
would you save some space if you used RDRAND or RDSEED instead for the RNG?
06:43 YOOO GUN NAC OST!!!
But anyways, very impressive
I didn't know they added some ANSI stuff back in, considering how ass BBSes look with MS Telnet Client
In DOS, the smallest EXE that will do something is 2 bytes. If an EXE contains "@e" it will reboot the computer when run.
That sounds more like a COM file. EXE files *must* start with "MZ" to be valid; and then also contain a header (very similar to the one used by EXE files for Windows).
COM files, on the other hand, were literally just something DOS loaded into a page of memory and then jumped to the first byte of. The smallest valid COM file is 1 byte, the encoding of the "RET" instruction (hex code C3). That would just immediately terminate and return control to DOS.
Last time I used DOS/Windows (c. late 1994), you could rename a .COM file to .EXE (and vice versa) with no effect on how it would run.
@@pdr. Back then they do checks for header within the file content instead of fully reliant on file extension.
@@Drysart i know.. but I didn't say it was valid :D I discovered this as a kid who didn't have any compilers, but desperatly wanted to make my own exe. So, as all kids do, I just renamed a BAT to EXE to see what would happen 🤔 the first line was... .@echo off 😀 and the result was that it would restart when I run it. I progressively deleted stuff until I was left with just @e and it would still do the same.
A DOS executable com file with a nop instructions = 1 byte file size.😂
I know once upon a time that virus scanners freaked out over very small EXEs. Did you run into that when working through tis?
nice mix of humor and knowledge, good stuff
0:14
I use DUMMY,EXE files for my GPU's underclocking profiles.
I make sure to TRIPPLE protect them, so only admin accounts can edit or change the exe.
even the folder which they are located in is locked/write protected. and everything is in read only,
even by default they are hidden files. so regular scrapers will overlook them
正津津有味看视频的时候突然蹦出来一个汉字,给我整恍惚了
看起来老哥你是真喜欢简中,关注了,加油!
The fact you put your closing parentheses on its own line to create a ); is almost too perfect, lol.
Why does making the most convoluted GUI in Windows assembly seem simpler and probably more reliable than the simplest installation tutorial for any C++ based GUI library I've seen.
Experience can only be gained by doing not by thinking or dreaming.
How were you calling functions from the windows api? Wondering cause there are some really, really small ways to do it
Ah I assume crinkler is doing the shellcode techniques i'm thinking of
That comment about every Windows executable having the same DOS header isn't true. You could specify an actual MS-DOS application as the header and create a dual-mode application. The same .EXE when run under DOS would run only the DOS "header" portion, while when run from Windows would skip over the DOS header and execute the Windows code.
Many applications used to do this back in the day - and I've even created a few myself!
That's true, and that's why it has an MS-DOS header in the first place. It's just nowadays your standard compiler will fill in the string "This program cannot be run in DOS mode" automatically.
Older compiler uses slightly different string "This program requires Microsoft Windows".
@@rashidisw And certain versions of Delphi had a DOS stub that printed "This program must be run under Win32."
7:54 Seeing as the smallest game I've heard of is 96 bytes, I'm curious how small you're going to be able to get it.
I wish more modern developers thought about such optimisation. At least some optimisation actually
Smallest EXE I wrote was a SOCKS4 proxy coming in at 2Kb. Also, interesting use of old SID tunes.
Patricia found the meaning of life in a bowl of Cheerios.
What kind of bot are you?
I haven't played exe golf in a long time. That was a fun watch...thanks!
I wonder whether there's any significance here, but that "maximum" size is exactly 119(2^24).
I remember in the dos there was an exe compressor which made them small
0 headers filled with 0 and almost impossible to disassemble but it worked without being uncompressed
109kB on Hello World - wait, what?! My whole 3d engine in one's current state is 770kB (version with built-in VR driver, the largest one), 182kB for one's configuration tool (around 110 of which are wasted because I love multi-resolution icons). A tool I wrote to connect a PS VR headset as a monitor and shut it down along with the OS is just 12.5kB. You surely need to check your IDE ;)
You can pronounce ANSI as "ANN-see".
Windows consoles are not "ASCII."
There are people who have money and people who are rich.
Nice intro to the demo scene :)
The title of the video is misleading. I did not expect that you will squish a game inside that smallest file :o
I wonder if it would be cheating to have most of the code in an external file. Like having the exe itself just the minimum to call a much bigger file that has all the code in it.
I mean, I made a program that is 25846 bytes and does nothing but display a 20 character text string in it's window and the header.
Not sure about 268 bytes, but there are boot sector games that fit into a 512 byte floppy boot sector. Those include conversions of Tetris, Pac-Man, Flappy Bird, Space Invaders, Breakout, and even a full on roguelike and a Doom clone.
Hmm, would it be possible to shrink the program by directly coding in CPU internal µops? Because since the mid 90s all x86 CPUs are internally RISC-like and translate x86 instructions into µops.
8:22 what is the code for the program? It's kinda cute and I i want it for myself
Don't Windows EXE's mostly contain a set of code that just piggybacks off of other files? Or am I missing something?
@6:50 ish .... Can we introduce you to the world of 256 byte intros ?
Now that's some witchcraft for sure!
I remember someone handing me a python executable that was only 200-300 bytes, and it loaded a looping 3D 400x400 pixel Animation of white and green boxes tessellating in and out of each-other. In Linux, of course.
In Unix and Linux, except for possibly very old versions, it would be possible to create a script executable with the three characters
#!x
[where the last character, "x" here, is a valid file name, so '.' and NUL would not be possible].
This is kind of cheating, for it would require another executable file ["x" in this case] to be present to actually do anything other than fail to find that file. If "x" were the name of the script executable file, it would incur a recursion failure under Linux at least.
Question: what is the smallest bona fide executable (not a script executable) under Linux? Unix?
Finally an exe without all the bloat
Can you golf it down smaller for Linux/Mac/BSD, or do those platforms end up making the executable larger?
Wow. Really good.
Bonus points for an atla refrence !
So you're a Windows expert? Name every .exe then.
The smallest possible exe is one containing only the phrase "This program cannot be run in DOS mode"
"Error 0x800700E1 an unexpected error is keeping you from deleting the file. file contains a virus or unwanted software" ?????
Still waiting for the 8bit minecraft game
People want to say the MOS 6502 is the first RISC processor, yet it gratuitously waste transistors on BCD (ugh!)
0:25 nice link
It'll still take my internet 5 hours to download.
Love the Links Awakening music ❤️
Kudos for the International Karate music in the background. 8^)
"A-N-S-I" lol
So the thing with the 32-bit address is called PE32, but the thing with the 64-bit address is NOT PE64?
That's because we don't really know ahead of what's coming in computing that's why you have this weird inconsistent naming, go look up the naming of CPU registers for example it's the same story there
According to Microsoft's documentation: "PE32+ images allow for a 64-bit address space while limiting the image size to 2 gigabytes".
It sounds like they decided to keep the "32" in this case because the maximum image size was not increased to 64 bits.
Speaking in an abstract sense (not just related to the PE format), 2GB is the maximum value in 31 bits without also resorting to a more-than-1-byte minimum resolution. If they further extended the PE format in the future to support more than a 2GB image size (which seems like it will be unnecessary for a very long time), then their next logical step is probably to introduce a multiplier of the minimum resolution, instead of jumping straight to 64 bits. If you've got a > 2GB executable, a few wasted bytes of padding at the end is probably not a concern.
Also note that the thing that came before the "PE" format was not "PE16". It was called "NE".
its just microsoft lol
@@rusi6219 8086: al+ah=ax, bl+bh=bx, , cl+ch=cx, dl+dh=dx - low(8b)+high(8b)=extended(16b)
i386: eax, ebx, ecx, edx - extended... uh... extended (32b)
MMX: mm0, mm1... mm6, mm7 - multi-media extension registers, because efficient data handling is surely always going to be multi-media, right?
x86-64: rax, rbx, rcx, rdx, r8, r9... r14, r15 - r for register, finally (64b)
SSE: xmm0, xmm1... xmm14, xmm15 - 'Streaming' SIMD Extensions, EXTENDED multi-media extensions...
AVX: ymm0, ymm1... ymm14, ymm15 - Advanced Vector Extensions, because 'advanced extensions' is a timeless name for sure, and y because it's one after x
AVX-512: zmm0, zmm1... zmm14, zmm15 - AVX but actually saying its bit width in the name, and z because we already started the trend with incrementing
But one of my favorite silly evolutions is a very common instruction:
8086: MOV - move, but without the 'deleting what it was'-par... so actually a copy, yeah, off to a great start...
SSE: MOVDQU - mov, but Double Quad Unaligned, because it goes byte (8b), word (16b), double-word (32b), quad-word (64b), uhh... double-quad-word (128b) instead of octa-word obviously - and U because they mistakenly believed explicit alignment requirements would matter at the time (MOVDQA literally crashes/interrupts if the data crosses cache lines).
AVX: VMOVDQU - V for vector.. which obviously means the size can now be bigger than a DQ, that goes without saying... Better keep the DQ in there just to avoid confu... requiring changing too many letters to adapt, probably.
While my brain stopped working at ~50% of the video, I still was entertained.
But wtf
I would love to see something similar on the linux side of things. Great work btw, fun video!
Ahh Willy Gates, he’s my dude, he’s my connect for that dank sticky icky and Bolivian marching powder.
TH-cam have been recomending this for the last month, finally i surrender, congrats wining the algorithm
goodbye debug table, *and the ASCII art of a shrub*. Jesus why is that in there
*sonic.exe taking notes because he needs too lose weight*
I got onto my friends laptop and quickly processed to find there documents and try to turn them into .exe file
32 byte on a C64... it won't do anything usefull... but it will execute code.
Here's a 256 byte intro for the C64 with "music"... th-cam.com/video/sWblpsLZ-O8/w-d-xo.html
yeah, demoscene is cool. and that with a little bit of research i found a 256 bytes game for ms-dos called q-type:2 on pouet, and that there's a real game for real windows that's like 96KB with 3D and real game mechanics called kkrieger, i recommend you give it a try cuz it's pretty cool
Why is there ASCII/ANSI art of a shrub in the source file
instead of installing a library just for RNG you can roll your own simple algorithm with a hardcoded list of "random numbers"
That would require those numbers to be stored in the program's data section, further increasing the file size
@@InkboxSoftware Check out Wikipedia's article on "xorshift" for super small but effective PRNG.
Basically, start with a seed, then:
x ^= x > 9;
That's it.
It's completely random, but it repeats after a period of 2^64 calls.
Oh, it also won't repeat any number until it completely repeats (if you think about it that makes sense -- same input gives you the same output), but if you aren't using the whole 64-bit numbers you can just modulo (%) your range and get repeat numbers.
Oh, the Computerphile video "Random Numbers with LFSR" is a good watch to see how it works.
@@InkboxSoftware okay i guess i didn't understand the concept of the video then
6:49 Is that the byte of 97??
Congrats on 100K subs! Love the videos.
NOT THE ASCII SHRUB NOOOOOOOOOOO
Great Video!
Now please create an game in assembly that makes real use of all 1,996,488,704 bytes : )
2:07 void main is non-standard
womp womp
windows isn't a standard platform, and this video is about windows, so while the point is accurate, it is also moot
@@blarghblargh C in windows is definitely standard. it’s just not POSIX compliant
(also: void main actually *is* standard in plan 9’s c dialect)
(plan 9 C is very different to ansi c, to be fair)
bro could have literally made a cookie clicker sim
Awesome. Now do the smallest Linux binary. I wonder how small Nibbles could be.
"consoles arent for games" he says as i begin laughing in linux user
The music is so nostalgic ❤
Wait was that that one Chinese governmental song
this guy is good friend with so many things
Next Video, show me how to make the smallest possible .EXE using Python..... I'd love to know how to do that.
we both know brilliant doesn't teach real programming stuff, it only teaches a basic hello word code