A way to creating small executables with Microsoft Visual Studio, without import directory
, remove the C runtime
library initialization code, but can dynamic call C standard library
from msvcrt.dll
.
All windows API
and C API
dynamic load from DLL
, include Loadlibrary
, so we can build an EXE
without import directory
.
- Get
kernel32.dll
base from PEB - Get
LoadLibraryA
, ... API address fromkernel32.dll
base - Load
user32.dll
andmsvcrt.dll
- Get others
API
by loaded mod's export table - Spec our entry point, do not link default
C run time
(/NODEFAULTLIB)
Realize mainCRTstartup
function, by miniCRT
Use Cmake-GUI
or console version if u want.
On my PC, size of EXE only 2560Bytes(2.5 KB), it could be smaller, no run time dependence, all DLLs are windows original.
x86
x64