4 ms·
I remember the previous record was 97 bytes: https://webserver2.tecgraf.puc-rio.br/~ismael/Cursos/YC++/apostilas/win32_xcoff_pe/tyne-example/Tiny%20PE.htm http
by userbinator 9y ago
I remember the previous record was 97 bytes:
https://webserver2.tecgraf.puc-rio.br/~ismael/Cursos/YC++/apostilas/win32_xcoff_pe/tyne-example/Tiny%20PE.htm https://webserver2.tecgraf.puc-rio.br/~ismael/Cursos/YC++/ap...
But I'm not sure if those will run on anything newer than WinXP.
- ChrisSD 9y agoIt might work on 32bit Windows 10 but I've not tested it. The smallest of the Tiny PE files that runs on 64bit is 296 bytes, which is close to the 268 bytes mentioned in the article. It falls down when removing the data directories so I guess modern 64bit Windows is stricter about that.
- ChrisSD 9y agoAfter some investigation I'm pretty sure 268 bytes is indeed a hard limit for reasons that are mostly explained on the tiny pe page > The PE specification says that the number of data directories is specified in the NumberOfRvaAndSizes header field and the size of the PE optional header is variable. If we set NumberOfRvaAndSizes to 0 and decrease SizeOfOptionalHeader, we can remove the data directories from the file. > Most functions that read the data directories check if NumberOfRvaAndSizes is large enough to avoid accessing invalid memory. The only exception is the Debug directory on Windows XP. If the size of the Debug directory is not 0, regardless of NumberOfRvaAndSizes, the loader will crash with an access violation in ntdll!LdrpCheckForSecuROMImage. We need to ensure that the dword at offset 0x94 from the beginning of the optional header is always 0. In our PE file this address is outside the memory mapped file and is zeroed by the OS. In Windows 10 (and probably Vista & 7) this memory isn't "zeroed by the OS", so we have to set it in the PE file. This appears to be a hard limit on the minimum size.
- jaclaz 9y agoOf course 44 is off by 2 (the answer is actually 42) but apart the program doing nothing actually useful, the blog article is nice. We did something like that with actually some use some time ago (shameless plug): http://reboot.pro/topic/18792-if-anyone-is-up-for-a-challenge/ http://reboot.pro/topic/18792-if-anyone-is-up-for-a-challeng... All the way down to 172, 164 and 148 bytes and even a 97 one which is the bare minimum on XP, same link as already posted on the work by Alexander Sotirov, but more readable: http://www.phreedom.org/research/tinype/ http://www.phreedom.org/research/tinype/ The limit on 64 bit (windows 7 64 bit) has been reported at the time to be 252 bytes, but simply padding with zeroes a smaller program worked to find this limit: http://reboot.pro/topic/18792-if-anyone-is-up-for-a-challenge/?p=176423 http://reboot.pro/topic/18792-if-anyone-is-up-for-a-challeng...