I recently tried to create the absolutely minimum sized binary in C with VC++.
To accomplish this I removed the C runtime library support in the settings and used this instead of the regular old main with the CRT setup that comes before it.
This is my source file:
int WinMainCRTStartup() {
return 0;
}
I also went around and removed anything that I could find that injected anything inside the outputted binary. There were a few things that I didn't understand why they were there.
This is the output:
MZ..................... @...................... ....................... !..L.!This program cann t be run in DOS mode... $.............d...d...d ..l...d...f...d.Rich..d ....................... PE..L......X.........." ....................... . ....@................ .........0............@ ....................... ....................... ....................... . ..p.................. ....................... ....................... .........text.......... .................... .. .rdata....... ......... ............@..@....... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ................3...... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... .......X........Q...p . p..........X........... . .............X....... @.... .............X... ................RSDS.. ?..N............C:\Users\vlind\Desktop\minimumexe\Release\minimumexe.pd ....................... GCTL.........text$mn... . ..p....rdata..p ..... .rdata$zzzdbg.......... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ....................... ........
I'm really interested in knowing what's exactly inside this executable and why. And what is the purpose of each part. What is .rdata for example? Why is there a path to a .pd file?...
I'll dump the linker flags and compiler flags as well if anyone happens to need them to answer the question.
Compiler:
/GS- /TC /GL /analyze- /W4 /Gy /Zc:wchar_t /Zi /Gm- /O2 /Ob2 /Fd"Release\vc140.pdb" /Zc:inline /fp:fast /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /Fa"Release\" /nologo /Fo"Release\" /C /Fp"Release\minimumexe.pch"
Linker:
/OUT:"C:\Users\vlind\Desktop\minimumexe\Release\minimumexe.exe" /MANIFEST:NO /LTCG:incremental /NXCOMPAT /HEAP:"0"",0" /PDB:"C:\Users\vlind\Desktop\minimumexe\Release\minimumexe.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /LARGEADDRESSAWARE /DEBUG /LTCG:STATUS /MACHINE:X86 /WINMD:NO /OPT:REF /SAFESEH:NO /PGD:"C:\Users\vlind\Desktop\minimumexe\Release\minimumexe.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:NO /OPT:ICF /ERRORREPORT:PROMPT /CLRUNMANAGEDCODECHECK:NO /NOLOGO /VERBOSE /NODEFAULTLIB /TLBID:1