Skip to content

Instantly share code, notes, and snippets.

@shivanshu3
Last active November 20, 2023 03:04
Show Gist options
  • Save shivanshu3/b258e1022777ff2adad92c5f5046f0a1 to your computer and use it in GitHub Desktop.
Save shivanshu3/b258e1022777ff2adad92c5f5046f0a1 to your computer and use it in GitHub Desktop.
Instructions for creating the smallest possible Windows DLL

foo.asm contents:

END

Note: Use the x86 native tools command prompt which comes with Visual Studio for running the following commands:

ml /c /coff foo.asm
link /merge:.rdata=.text /merge:.data=.text /align:16 /subsystem:windows /dll /noentry foo.obj

You can add /debug /pdbstripped to the link command line to generate a .pdb, but that will increase the size of the DLL, so run the 2 commands separately if you want a tiny DLL and PDB. Note that there will be a GUID mismatch, so you will have to tell your debugger to not care about matching PDB GUIDs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment