Jump to content
Tuts 4 You

Reduce your C++ executable size


Zer0Flag

Recommended Posts

Just a heads up with your PDF; the option to choose between Multithreaded-DLL and Multithreaded are not present in Express editions of Visual Studio. This is a non-free feature that is only present in the paid versions.

Link to comment

Your us /O1 or /O2 i see but if your us /Oxs=Full optimation + small code it makes the result are littel bit more smaller.

If your us the command line tools like (cl,link,lib) your can make the result very small.

Her an bsp:


cl /c /Oxs /W3 mrcore.c
cl /c /Oxs /W3 mrarth0.c
cl /c /Oxs /W3 mrarth1.c
cl /c /Oxs /W3 mrarth2.c
cl /c /Oxs /W3 mralloc.c
cl /c /Oxs /W3 mrsmall.c
cl /c /Oxs /W3 mrio1.c
cl /c /Oxs /W3 mrio2.c
cl /c /Oxs /W3 mrgcd.c
cl /c /Oxs /W3 mrjack.c
cl /c /Oxs /W3 mrxgcd.c
cl /c /Oxs /W3 mrarth3.c
cl /c /Oxs /W3 mrbits.c
cl /c /Oxs /W3 mrrand.c
cl /c /Oxs /W3 mrprime.c
cl /c /Oxs /W3 mrcrt.c
cl /c /Oxs /W3 mrscrt.c
cl /c /Oxs /W3 mrmonty.c
cl /c /Oxs /W3 mrpower.c
cl /c /Oxs /W3 mrsroot.c
cl /c /Oxs /W3 mrcurve.c
cl /c /Oxs /W3 mrfast.c
cl /c /Oxs /W3 mrlucas.c
cl /c /Oxs /W3 mrzzn2.c
cl /c /Oxs /W3 mrzzn2b.c
cl /c /Oxs /W3 mrzzn3.c
cl /c /Oxs /W3 mrzzn4.c
cl /c /Oxs /W3 mrshs.c
cl /c /Oxs /W3 mrshs256.c
cl /c /Oxs /W3 mrshs512.c
cl /c /Oxs /W3 mraes.c
cl /c /Oxs /W3 mrgcm.c
cl /c /Oxs /W3 mrstrong.c
cl /c /Oxs /W3 mrbrick.c
cl /c /Oxs /W3 mrebrick.c
cl /c /Oxs /W3 mrgf2m.c
cl /c /Oxs /W3 mrec2m.c
cl /c /Oxs /W3 mrecn2.c
cl /c /Oxs /W3 mrflash.c
cl /c /Oxs /W3 mrfrnd.c
cl /c /Oxs /W3 mrdouble.c
cl /c /Oxs /W3 mrround.c
cl /c /Oxs /W3 mrbuild.c
cl /c /Oxs /W3 mrflsh1.c
cl /c /Oxs /W3 mrpi.c
cl /c /Oxs /W3 mrflsh2.c
cl /c /Oxs /W3 mrflsh3.c
cl /c /Oxs /W3 mrflsh4.c
cl /c /Oxs /W3 mrkcm.c
cl /c /Oxs /W3 mrcomba2.c
copy mrmuldv.w64 mrmuldv.c
cl /c /Oxs /W3 mrmuldv.c

The result for this is about 361kb for the lib.

If your make the same with vc with out the command line tools your get for the same lib this result:

1 - 2 mb

Link to comment

I had been working on a tutorial for this very subject for a couple weeks now, and after seeing your article (which is very good, btw) I decided to finish mine. It is more detailed than yours (I wanted to see how the various options affected the actual disassembly in OllyDBG) and the pictures have been translated to English. Hope you enjoy...


/>http://thelegendofrandom.com/blog/archives/2231

Link to comment

@hmi222

Thanks, no I didnĀ“t test any packer to see if it get even smaller. Since the goal of this was to show how you can decrease the file size using compiler and linker settings. But you can use ASM to shrink it until you reach 92bytes or something. If you are interested in this you should take a look in google for "tiny pe".

~Zer0Flag

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...