What is the Smallest Possible .EXE?
Вставка
- Опубліковано 26 чер 2024
- 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.
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/InkboxSoftware/sma...
About the PE file format:
PE file format: learn.microsoft.com/en-us/win...
PE file diagram: github.com/corkami/pics/blob/...
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/ayaka14732/TinyPE-...
More on the 268 byte limit: gist.github.com/kajott/063dfc...
Refined MattKC snake: github.com/EimaMei/snake-qr
Low Level Programming:
Kernel32 functions: www.geoffchappell.com/studies...
Windows Virtual Terminal Sequences: learn.microsoft.com/en-us/win...
MSVC Linker options: learn.microsoft.com/en-us/cpp...
What is the largest EXE: superuser.com/questions/66759...
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
When I started watching, I somehow only expected the usual "overlapping the DOS and PE headers" and hello world message box, didn't expect you to enter the
Clearly the video failed hugely on its stated objective to create smallest possible .EXE. Have to give a grade of F for that reason.
1:15 nice integer overflow lmao
17:46 bad video for security. Now the number of executables is finite and we can brute force through all of the 2^2^34 executables to find all of the penetration vectors.
only for windows. unix/linux-based systems are still safe (but for how long?)
huh?
Good idea. I'm sure this calculation will complete before the heat death of the universe
While you're at it, you can figure out all the valid versions of Doom are in there ^^
@@samuelthecamel Well, it probably would. As technological advancements are constantly happening, once we have, per say, consumer-grade quantum computers, we just write the program, sit back, and enjoy.
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 was exspecting this to just be a deep dive in to how small an exe can be, then he just made a game, this is amazing
Anticlickbait
@@egarcia1360 Yeah!!
@@SomethingCatchy2_is that twitter meme
@@NolanHOfficial ?
@@SomethingCatchy2_ "Yeah!!! 👍"
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"
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.
5:17 wait a sec, wait a sec, does every windows executable really contain ASCII art of a shrub by default? I'm tempted to assume that was a joke so you would have something to rhyme, but honestly I'm hoping that it's true because that would be a hilarious and genuinely beautiful absurdity.
10:56 those aren't actually ASCII characters (except for the @)
ASCII is only a 7-bit encoding, and thus only contains 127 characters. anything beyond that into the 8-bit realm is a vendor-specific extension beyond ASCII
Demoscene members being chads as always. Crinkler is one of my favorite tools, so cursed yet so elegant.
Another demoscene-friendly language is JS. In my experience, it's quite versatile. Stuff like fitting a game that was 30,000 bytes into 3,081 bytes. People have also made 140-character JS programs back in the olden days of X/Twitter when there was a hard 140 character limit.
@@stgigamovement sounds more like code golf.
does the demoscene want or care about JS?
@@blarghblargh there's a section on Demozoo and Pouet for Javascript demoscene works, which I've used.
@@stgigamovement i mean you need the runtime to go with it lol so not really demosccene
@@stgigamovementThat’s code golf, you still need an interpreter for JS
Dude... Dealing with microsoft's documentation practoces, that's the challenge I saw. Amazing work of art
ANSI you can just say "an-see"
Un-see🙈
I've got ANSI in my pantsi
5:15 the what now?
Essential code, the ASCII Art Of A Shrub (TM) stabilizes the program, protects against any form of cyberattack, and automatically generates cryptocurrency. It's the sequel to Sun Tzu's The Art Of War, even being more practical on the field of battle.
I've played DOS games with entire open worlds that were less than 64 kilobytes
11:59 I laughed more than i should have on this part lol. Amazing video
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 just wonder why you used the song "There is no new China if there is no Chinese Communist Party" as the BGM for the (allegedly) Microsoft footage
♪mayor gone cheddar though mayor syndrome gore
♪mayor gone cheddar though mayor syndrome gore
♪gone cheddar, ...
It could be the Taiwanese version, "Only Without the Communist Party, Will There Be a New China!".
Maybe to avoid problems for using copyrighted music?
With the parameters now all in place, we can build Jorge Luis Borges' library of Babel, but for exe files. Since there's a limit to the number of bytes that can go in an exe and a finite number of values each byte can have, we can imagine a filesystem the contains every possible exe file. But it couldn't be a Windows filesystem.
Here you go: github.com/InkboxSoftware/DatabaseOfDamascus
I mean, you can make a smaller executable for Windows by taking advantage of the NTVDM and making a COM-file
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!
Not sure if you already know about this, but you might be interested in Cosmopolitan libc, a project to compile c code to a polyglot binary running natively on Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD and even in BIOS
0:26 sneaking in your mailing list is a genius move lol
You could fit the entirety of Minecraft into a exe lol
that 嗯 got me laughing so hard in the binary selection part
I have fond recollections of the smallest executable I ever wrote. It changed foreground and background colors on the display and was all of 47 bytes long. No lie. You could do wonders with assembly back then...
You can pronounce ANSI as "ANN-see".
Windows consoles are not "ASCII."
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.
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 think this is the first time I've ever heard anyone say "ay en ess eye" instead of "an-see"
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
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._*
I haven't played exe golf in a long time. That was a fun watch...thanks!
*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.
Sorry you had to look up the minimum file size of Portable Executables on different operating systems.
Checking the minimum file system cluster size would have sufficed...
For example a FAT sector is 512 bytes or more.
this game with 825 is very small. Even NES Super Mario Bros. is 32 000 Bytes or 32 KB
Imagine using those skills to write the most advance malware ever. OMG it sounds orgasmic!
NO DONT DO THAT.
Writing small programs under an OS is fun. Try writing a bootable game :) People managed to pack whole simulations or games into the bootsector of a floppy. A sector has 512 bytes but the last 2 bytes are required or the BIOS won't recognise it as bootable (55AA in hex). Though the bootsector (depending on the medium) also contains some volume information. That only leaves a little bit left for the program. People have written bootsector games or simulations and still have the disk to work properly under DOS or windows. Also there are no sys calls to any OS function since we ARE the OS if we boot from this medium. All we have are the BIOS interrupts and direct memory access. The BIOS only loads the first sector (boot sector) of the medium which usually just contains code to load the actual OS boot loader from other sectors.
2:55 - Who knew Plato was a Linux fan?
nice mix of humor and knowledge, good stuff
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.
The Game .kkrieger should be a honorable mention. It's a 3D ego shooter in 96k! That's a lot bigger than your game, but with a lot more features. Maybe have a look :)
I appreciated the SID music, I see you like Rob Hubbard :)
I never expected to see a video game that you can print on a single sheet of paper.
That hotel light smash video is a real blast from the past
Kevin watch the light!
The smallest windows .exe, that does something meaningful, that I've seen, was a demo project in macro assembler and was just under 900 bytes. It created a window/form with some inputs and buttons and then executed a command when clicked. Basic demo, but still impressive.
Cool. Next time do a boot sector program so that way you don’t need the pesky bloat of an OS to execute.
11:00 none of those characters are a part of ASCII... 😄
If memory serves, isn't this CP437?
@@timseguine2To my knolwedge with ANSI art, yes
The "@" sign isn't part of ASCII-7?
@ is ASCII at least
MattKC did a similar fitting a game to a QR code, but good on job on making this video your own!
'William Gates' actually threw me for a second.
And this, ladies and gentlemen, is how games were made in the 80s.
Just discovered your channel. At first wasn't sure if I was watching clickbait. Then at 1:00 - 1:15 I knew you were the real deal!
Back in the days of DOS, we (Crescent Software) sold a library for BASIC (called PDQ) which would allow for the quick compilation & linking of EXEs less then 512 Bytes. Why 'so big' (LOL)? Because that was the size of *ONE* sector on a *FLOPPY DISK*. Anything less was moot.
It could also create TSR (Terminate & Stay Resident) programs, which were available with a keystroke or interrupt. And we could shove them up into Extended, or of you remember it, "Expanded" memory.
Since this was in the days prior to math coprocessors, I wrote the 8087 emulator for the product.
Thanks for the nostalgic trip down memory lane.
Chrome turning into Pac-Man and eating all the ram is too accurate 💀
Congrats on 100K subs! Love the videos.
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.
Next step: waste money to make the smallest digitally signed executable
I would love to see something similar on the linux side of things. Great work btw, fun video!
I wonder whether there's any significance here, but that "maximum" size is exactly 119(2^24).
we both know brilliant doesn't teach real programming stuff, it only teaches a basic hello word code
would you save some space if you used RDRAND or RDSEED instead for the RNG?
Most copies of Win XP are 32-bit, still able to run 16-bit programs, so you can just use the DEBUG command to create an EXE of: MOV AH, 4C INT 21 I think that'd be less than ten bytes
Major-key ass Tetris lmao
The smallest possible exe is one containing only the phrase "This program cannot be run in DOS mode"
8:14 you just offended a whole generation of people that played DOS games on Windows 9x lol
I want to practice a bit assembly. I chose at first old versions Z80 and MS-DOS. So I made my first empty exe file under DOS with TASM assembler and it weights 500 bytes.
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
Congrats on 100k subs!
Time to get a new mic :)
Maybe the real EXE was the friends we made along the way
A colleague and I once created a small Amiga Hello World executable. I think we got it down to 33 bytes or smaller.
Kinda funny that some of the smallest Windows executables are larger than the entirety of DOS nowadays.
Actually the smallest possible .EXE is 97 bytes.
with ROP the right jump instruction is turing complete. that's an executable in some scant bytes.
Just as a comment here, you don't want to do things like cmp al, 0. The reason is simple. You're comparing an immediate value and that value has to be stored in the instruction. Since you're only interested in the flags, you should test al, al whereby the assembly doesn't need to store the immediate value and it will set the flags for you to branch against.
Thanks, I had forgot about TEST, looks like I can shave off a few more bytes
@@InkboxSoftware Well when you've done as much assembly as I have and enter 4k/64k demo competitions at Revision and other parties, every byte does indeed matter!
Good video though.
So - Why didn't you show you running those two programs at the end?
I saw that you developed them, but it would have been fun and rewarding seeing the two files actually in your explorer and you comparing their sizes and clicking on them to play the game. That's, like, one minute max
The installer for Davinci Resolve 18.6.4 is 2 156 754 704 bytes. They finally had to separate it into a small exe and an external dat file for 18.6.5.
"A-N-S-I" lol
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
15:08 I love the piano.exe😆
100k subs?! Congrats!
Dude, absolutely awesome video, your editing is next-level
Ahh Willy Gates, he’s my dude, he’s my connect for that dank sticky icky and Bolivian marching powder.
I wasn't expecting Ibai to be in this video @ 1:43
7:15 you wont believe whats the 2nd-3rd most popular game on steam
idk if ive every subscribed to a channel based off 1 video faster than the 40 seconds this took
so uh it's 3:14 in the morning already
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.😂
smallest code i was thinking of while watching was a asm register input adder and syscall to quit
Great Video!
Now please create an game in assembly that makes real use of all 1,996,488,704 bytes : )
I want a 5 minnute apology for pronouncing ANSI as A N S I and a reupload with it pronounced correctly
exe has already been used in DOS - please consider that!
Grats on 100k in advance!
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.
It's possible to set a flag that allows the exe to be 4GB.
Some games can weight 128gb+, but still can be opened (with one modified thing)
this guy is good friend with so many things
Yeah that's definitely one of the CISC instructions of all time
Wait, there's XP compatibility mode on Windows 10...
what is the smallest possible program on Linux?
the asmutils are mostly way below 1 kByte.