sven ahlert | charisse dougherty | mustek gsmart mini digital camera | cnn hippo tortoise | cnn on arabsat | sven benkert | george harrison burwell virginia | mustek matador 105 | george hayduke quotes | cnn news nacy grace | ernie ball petrucci | sven blasius | george hawthorn barberton | mustek pvr h140 review | ernicke | charisse bruno | cnn headline news mars | sven br samle | avian dark droppings urine | aviacsa promocion | charisma stille beteiligung | aviador dro nuclear si | joe gepner | mustek scanexpress a3 usb mac | cnn newws | sven altay | charisma steven barnes review | sven and olie jokes | charisma saint cloud mn | bluetick hound behavior | aviad cohen mp3 | erni else | cnn on yellowstone activity | sven alkalaj | bluetooth 5.8 ghz recording phone | avia shenzen | mustek pl510 10 manual | mustel | mustek powermust in vista | george haycock interior designer | joe gilbert golden neese | charismatic influence tactics | joe geraghty and rockford illinois | amoreena tab | charissa kane | sven b cking | blueticks coon hounds | mustek dv 5000 reviews | bluetoot headphones | amorim travel africa | bluetones mp3 | avian adventures mediana bird cage | cnn online survey taker | bluetooth adapter bu-20 instructions | charisse of brigadoon | bluetooth adapter creative zen | mustek wcam 300a | charismatic episcopal church archbishop adler | charisma salon saint cloud mn | bluetongue vaccination | george harrison merchandice | amorgos ferries piraeus to amorgos | sven bollin | amore tanning business forsale | bluetick breeders | cnn pipline | cnn hijackers passport found video | george halasa | mustella nigripes | charismatic and pentecostal churches | charisse carroll | george harnish | avia home theater test dvd | ernie ball musicman guitars | mustek dv 3000 drivers | cnn honeys | cnn preacher and larry flynt | erni relais | charisse peterson | charisse phillips model | sven benninghaus | cnn operation tailwind fired | avia juda | amores translation ovid | cnn lary king | charismatic churches durham nc | amoretti fashion | sven board pthc cgi | george hashway | charisme mp3 | amores estranos laura pousini | charismatic chaos john mcauther | avia tours corporate new york | bluetooth 2.0 wth edr | charisma spa parts | amored core nexus soundtrack | george hannaford elephants | george harrison hitting intruder | charismatic chatroom | joe goddard ancestry | cnn news opra's health | ernie b's reggae | ernie ball silhouette custom | charisma salon in concord california | amore soft romantic sex movie | avia home theater disc | cnn news dallas nhra | charismatic midis download | ernie ball musicman silhouette | george harrison wah wah chords | mustek photo key chain | ernie alloys | cnn news alzheimer love | amori laura lyric pausini strani | mustek pf-a700b wireless | george hawrylak | george harris bridgeville pa | bluetooth advanced audio output driver | george harrisson | sven br cking | charismatic churches in victoria bc | bluetongue deer | erni backplane | charismatic catholic church ghana | charismatic catholic colorado springs | amoret harrington | muster field farm | charisma sale clearance | cnn news sticker shock | mustek nv7 | joe glasier | joe gibbs denomination | ernie ball music man stingray | charisma software pcc | cnn o'brian | charismalife publishers | mustela baby wipes | avia shoe description | cnn investigative reporter robin guess | charismatic missiology | avia journey to the west | muster funeral home mclean | sven bierhoff | bluetooth adapter for midland frs | bluetick coonhound for sale | george harrison genesis lithograph | joe gauthreaux | george haverhill ma | joe giannone | ernie and leilani | charisma properties sioux falls | aviagen vet | cnn hayden protest | ernie ball rps 11 | avian altruism | sven bielfeldt | muster abmahnung runterladen | ernie ball stinray | cnn ofo nov 13th | cnn meteorologist slams al gore | mustek scanners ocr scans | bluetongue order 2003 uk | aviall catalog | amorette robertson | bluetini | cnn hots | charisse bio | ernie barbara bivona | amores dental | cnn mccaffery | ernie ball bass dating | sven altenhoff | bluetiful day | mustek webpag | avian clamydia | ernie ball musicman bass neck | mustek wcam 300a driver download | bluetick decals | mustek gsmart d 50 5mp | joe gibbs press conference | joe gatchell | joe gilling | mustek scanexpress a3 digital color | george hambleton pan american | sven b chi | mustek pl510t | amoria maplestory | avia rice | joe gibney director | mustek keyfoto | charisma tits playboy jokes | sven bielig | bluetongue regulatory impact uk | mustek twainscan ii sp | ernie banks sports magazine cover | sven bbs imgboard | ernie banks home jersey | sven barsch | mustella body products | mustek mp 72 region hack | george harrison psychedelic strat | joe girardi biography | ernie banks sports illustrated | aviacsa reservations | sven balmain football soccer | george handel almira | ernhofer | joe golias | avia hebrew | cnn newscaster meade | ernie ball straplocks | bluetit | chariss | bluetooth adapter for stereo recievers | bluetooth a2dp capabilities | mustela allergic reactions | george hanna major league baseball | bluetip | amori film 1998 | ernie adams ct | joe geeslin | mustek pvr-h140 manual | sven bahnsen | george hale observatory death caltech | bluetights | bluetooth activesync problems | charismatic churches west plains mo | avia women's 239 | george harrison vegetarian | mustek scanmagic 1200 | ernie banks parents | ernie ball compact volume pedal | charisma verlag dusseldorf | bluetick breeder | avia running womens purple | bluetongue disease in magazines | erni bert | avia mid cut shoes | amori a ibiza | bluetooth 8700c owners manual | bluetooth adapter for smartmedia | cnn headline news podcast | mustek gsmart mini 3.1 review | ernie basinger | sven biederer | sven bieber verein | avia runner review | joe gibson suzikie in spartanburg | ernie and shiela koch | sven bbs jp | amored games | sven barnim | george hangleton harry potter | mustek fe1000 | amore twist rita pavone | ernie accorsi | mustek gsmart s55 install | cnn lexxus | bluetick coonhounds personality | bluetoooth drivers | george harper in watervliet michigan | aviaition history | joe gillentine | joe gonzales muay tai vegas | amore uv coating | ernie apodaca | ernie ball 6165 | avia lee roth | aviall aircraft | bluetick coonhound gifts | amorini chocolate hearts | charisma restaurant winnipeg | sven boomgaarden | joe glazer guitars | mustela keratosis pilaris | erni mann switzer financial | erni und bernd | charisse kaylin | ernie ball slinky string | mustek dv8200 | sven bergh user | bluetooh zigbee pic | charissa ramirez | ernie barone | mustela belgique | cnn haron amin | george hartwell bournemouth | charismatic legitimation | bluetick coonhound female picture | mustek mdc830z | bluetick dog hunting sale | george halldin | charisma restaurant salisbury maryland | aviado annie | george hatch appraiser | joe gorski virgin islands | joe gibbs nhra racing | sven baltzer | cnn pomegranate juice | mustek dv4000 pc cam driver | aviadores y sus enfermedades | george hawbaker | george hardie illustrator | aviall pilot headsets | ernie and ricki pruitt | charissa ball | ernie ball earthwood | cnn peoria illinois affiliate | mustek signs | joe gioeli | bluetick beagle kennels | ernie ball custom guitar straps | ernia del disco esercizi | george hatcher band coming home | bluetooth 2c facilities management | sven boot clog | avia scooter | cnn oj simpson poll 2007 | muster blaster | amorgos cyclades blogs | amorea | mustek dv520t | mustelidae how many species | aviall sweden | bluetiful | sven birkner | joe gibbs south carolina | ernie ball rps strings | george hampton ohio comics | mustella baby shampoo | sven allmeroth | joe goldblatt special events | aviadior sunglasses | cnn jarvis segway | cnn nye tape | bluetick training | amores perros music cd | mustek saddle bags | george harriston | bluetooth 2045 driver | cnn nabokov the writer | charismatic churches in smyrna georgia | aviaco | joe gibbs racing web site | george harris lehi city council | mustek mp80b | amored core 4 perfect parts | sven almeroth | amore when you're awake lyrics | charissa ball in kansas | cnn halmark cattle | george harris refugio aransas pass | george halas record | cnn mccarthyism during the | bluetit nest boxes | cnn news noah's ark | mustela sunscreen | charisse ritter | amore today's bridal | bluetooth adapters palm 700 | amored truck | cnn pharmacy school ratings | bluetooth accessories for 6102i | george harvey plane crash france | sven bbs elweb | amorelli giovanni | amored saint lyric | joe giacona | bluetick coonhounds pictures | avia phone answering | amoreena las vedas | joe goodfellas pesci oscar | mustek mdc 3000 | joe gibbs virgin oil analysis | mustek r100a review | george hampton ohio collectible | cnn nicaragua hurricane felxi | george hatchard | charissa escort | bluetick coonhounds in florida | sven bornmann | amored security vehicle m1117 | joe gillich | bluetooth afh | cnn newspersons | ernie alger sr | amorial | ernie barbarash | avia running clothes | charissa marie white | amoretto stone | mustek gsmart mini drivers | joe geremia | amoretti by edmund spenser | george harbaugh morton washington | sven b nemann | bluetinum | amores prohibidos rapidshare | joe gerhart in winters texas | cnn john mcgrady | cnn kenya airways crash | charissa thompson sports | bluetooth adapter for nextel phones | sven blaurock | ernie ball green stingray | cnn kiran chetry age | charisma sheets 310 thread count | charisma stemmed vase | sven berger dresden computer | avia select shoes | charismatic church thunder bay canada | avian brid flu | joe glasby | ernie bach motors ma | ernie ball stage warped tour | charismatic evangelistic ministries ghana | charisse cray | charisse espinosa | mustek scanmagic 1200 usb | george handoko | ernie ball vp jr wiring | amores como el lyric nuestro | ernie barnes lithograph | avian botulism lake erie | ernie avellana | mustek mdc 830z | cnn news branson ripleys | bluetooth 802 11b wireless cards | mustek pvr card recorder | amores perros torrent | joe gillies karate background | charisme carpenter | bluetongue transmission sheep | charismatic prophet church listing tulsa | erni pile | charisma personality trait evaluation | mustek dv5300se accessories | amoretto hells angels | george harrison bootleg 74 | mustek gsmart d50 | amoresse labs | george halworth cle ellum | sven b hm | bluetooth 802.11g mp3 video cooler | joe gorgonio | bluetongue greece | mustek rebate | charisse brooks ohio | mustek ub plus driver | amores perros famous lines | joe giacalone | ernie ball music man evh | cnn news soledad brian | george halson | joe giattina band | joe gladney alabama | ernie ball guitar strap | cnn judy leaving woodruff | bluetooth adapter es-388 windows xp | bluetongue lab | ernie ball stingray replacement pickup | mustek dv4000 digital camcorder | charismatic chiuch knoxville tn | bluetick houds for sale | joe gibbs racinng | george harris karent zent | cnn news santa clarita | erni and burt | cnn hollenbeck | amores imposibles | joe gibbs must go | mustek pl607 car charger | sven and the fabulous lovebirds | ernie ball music man poster | charismatic churches in dominican republic | amorfilial | george harrison brainwashed lyrics | mustek dv4000 digital video camera | joe glasow | avian communications dundee | ernie ball luke dargie | cnn news report on greenies | george harrison wonderwall cassett | mustek pvr-a1 forum | mustek scanner 600 iii | ernie ball axis natural | aviamilano | cnn on amazon rainforest | charismatic church tucson | amoreti | sven bl mle | george hayase | bluetooth accessible headsets | cnn nancy grace rene rockwell | bluetooh chip | ernie barbey | erni c santiago | cnn interview creflo dollar | avia home theater setup | ernie ball 6180 vp jr | joe gibbs to retire | charissa thompson fox | avia workout | sven blome | avian demography unit dtp services | sven balmain football | bluetini recipes | sven birkmann | mustek mp72 review | ernie ball 20th anniversary silhouette | cnn power plant explosion florida | ernie barnes church art 3 | ernie banks sport magazine 1958 | avia womans running shoe | amorim imobiliaria | amoretti and the passionate shepherd | joe gragg texas | sven barkawitz | cnn las vegas debate questions | george harrison faster chords | cnn nibiru | ernie ball clothing | george harrison patch adams soundtrack | cnn headline news mars exploration | bluetooth access nokia 6126 | amores control machete perros | charismatic leadership powerpoint | george halker | george halas trophy | charisma spas jet operations | avian adventures powder coating | joe gatto psu 2007 | cnn michael ware pace wolf | amorim flooring | avian and exotic raleigh | avia special ld | george hagar benson newfoundland | amores perros mexican film | sven bake | ernie ball stingray bass guitar | amorelle | joe girardi yes | mustela dermo pediatrics | george harter genealogy | sven baumwolle | joe gersch winner | amore's spring texas | mustek vcd 300 camera | george hannum 1866 | george harrison burwell carter hall | bluetick hound puppies for sale | ernie banks autograph | george harrison mystical one chords | bluetit nesting behavior | george harrisons friar park estate | george harris refugio 2000 | mustek gsmart mini3 | amorfix | cnn mcmann | sven alexius | mustek pvr h140 40 gb | charisma resin | charisma saeco | avia o americana | charisse holmes | george haw nanaimo music | ernie banks 14 hat | ernie anastas fox | cnn nfc championship game video | charismatic prophecy bill lawrence | sven alstrom | bluetonic | joe gentile utopia | charisma spas parts | cnn hungary baja | mustek gsmart a30 | mustek pl207 service manual | avia wireless router web | amores and west chester | avian and exotics indianapolis | mustek dv3 camcorder | sven angry at smurfs | ernie barnes print | bluetooth advantage and disadvantage | muster e dikson service | aviacsa airplanes | ernie and bert conversations | amoreena sing elton john | amorepacific spa | bluetooth adapter for desk phones | cnn headline news morning express | amorgos bank | george harmon kershaw sc | cnn o'brien shuffle | avia ladies watches | sven br lke | george harlan starr | charismatic fan fiction intricate | charisma patricia jesse oklahoma | cnn linda stouffer

Small Application Wizard

This article was released on www.codeproject.com.

Download Installer and Sources - 488 Kb
Download Demo Projects - 248 Kb

Introduction

This is a Small Application Wizard for Visual Studio .NET, it helps you build small executables with just a few clicks. The downloadable installer was designed for Visual C++ 8, I haven't tested it on earlier versions. If you just want to start using this wizard,  install it and click on Small Application in the Visual Studio's New Project window. Just like this:

 

If you're interested in knowing more details about this little project, just keep reading.

Let's consider this article an update to Matt Pietrek's one about his tiny libc. I never really cared about the size of executables produced by Visual Studio, until I had to build some small ones for work. So, basically, I wrote my own small libc including support for unicode, secure functions, x64 and Itanium. When I was done with that job, I didn't want to leave the files getting old on my hard drive. So, I decided to add some functions to my small libc and create a wizard to make the whole task as easy as possible. As you can imagine this article is not to be taken too seriously.

Small LibC

I won't post the code of the libc since it's useless. These are the supported functions:

Header

Functions

stdio.h Ansi: printf puts scanf gets
Ansi Secure: gets_s

Unicode: wprintf _putws wscanf _getws
Unicode Secure: _getws_s

stdlib.h new delete malloc free calloc realloc
string.h memset memcpy memmove memcmp memchr memcpy_s

Ansi: strlen strcpy strncpy strcat strncat strcmp strncmp _stricmp strupr strlwr strchr strstr strtol strtoul _splitpath
Ansi Secure: strcpy_s strncpy_s strcat_s strncat_s _splitpath_s

Unicode: wcslen wcscpy wcsncpy wcscat wcsncat wcscmp wcsncmp _wcsicmp wcsupr wcslwr wcschr wcsstr wcstol wcstuol _wsplitpath
Unicode Secure: wcscpy_s wcsncpy_s wcscat_s wcsncat_s _wsplitpath_s

For best optimization it's not advisable to use functions like scanf. I just put some stdio functions in my libc to make small console projects work.

Basically, I took half of the string functions from Microsoft's SDK. I believe I took splitpath from wine (I don't remember for sure) and strol / strtoul from somewhere on the web. The other functions I had to write by myself.

A lot of string functions are just wrappers to windows apis.

For Example:

extern "C" size_t __cdecl strlen(const char *str)
{

#ifndef AVOID_IF_POSSIBLE_WINAPI

	return (size_t) lstrlenA(str);

#else

	const char *eos = str;

	while (*eos++) ;

	return (eos - str - 1);

#endif
}

If for whatever reason you don't want to use windows apis whenever possible (it can't be always avoided), just define AVOID_IF_POSSIBLE_WINAPI and no external function will be used. This isn't the best to reduce the executable's size, but it might be useful if you want to make the disassembled code a little bit harder to understand or to avoid simple breakpoints on apis. If you didn't understand what I just said, forget the whole point.

Stub Code

Windows executables have always a different entrypoint from what you usually see. Three common entrypoints are:

int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow);

BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved);

int _tmain(int argc, _TCHAR* argv[]);
But the actual ones are:
#ifdef UNICODE
extern "C" int WINAPI wWinMainCRTStartup(void)
#else
extern "C" int WINAPI WinMainCRTStartup(void)
#endif

extern "C" BOOL WINAPI _DllMainCRTStartup(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpReserved)

#ifdef UNICODE
extern "C" int WINAPI wmainCRTStartup(void)
#else
extern "C" void __cdecl mainCRTStartup(void)
#endif
In the case of the Win32 Exe and the Console program the actual entrypoint has to get the command line through GetCommandLine and parse it. I used Pietrek's entries, since they were already working, no need to write new ones.

Setting up a Visual Studio Project

C/C++ -> Optimization:

Minimize Size and Favor Small Code are quite easy to understand. What's to say is that I disabled the Whole Program Optimization because it didn't allow me to use my own libc.

C/C++ -> Code Generation:

The Struct Member Alignment is easy to understand. I had to disable the Buffer Security Check in order to use my own libc (and, of course, disabling it reduces size anyway).

Linker -> Input:

Ignore Default Libraries is to ignore the default libc. Additional Dependencies tells the linker to use my small libc. Of course, in case you'll need to compile for x64 or Itanium you've to replace small_libc_x86.lib with small_libc_x64.lib or small_libc_Itanium.lib.

Linker -> Debugging:

I disabled the Debug Info in order to reduce size, but it shouldn't be in a release anyway. It's that information string about the debug info file which is put into your executable:

 Offset    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F   Ascii

00009250  00 00 00 00 00 00 00 00 00 00 00 00 58 AA 40 00  ............X@.
00009260  F0 92 40 00 03 00 00 00 52 53 44 53 87 ED 80 26  @....RSDS&
00009270  95 9A 57 47 8D 75 B2 DA E2 1F F3 4B 02 00 00 00  WGuK...
00009280  63 3A 5C 64 6F 63 75 6D 65 6E 74 73 20 61 6E 64  c:\documents.and
00009290  20 73 65 74 74 69 6E 67 73 5C 6E 74 6F 73 6B 72  .settings\ntoskr
000092A0  6E 6C 5C 64 6F 63 75 6D 65 6E 74 69 5C 76 69 73  nl\documenti\vis
000092B0  75 61 6C 20 73 74 75 64 69 6F 20 70 72 6F 6A 65  ual.studio.proje
000092C0  63 74 73 5C 73 6D 61 6C 6C 20 65 78 65 5C 72 65  cts\small.exe\re
000092D0  6C 65 61 73 65 5C 53 6D 61 6C 6C 20 45 78 65 2E  lease\Small.Exe.
000092E0  70 64 62 00 00 00 00 00 00 00 00 00 00 00 00 00  pdb.............

It doesn't respect the programmer's privacy as well (be aware: it's put by default into all your executables, even .NET ones).

Optimization Results

Here's a small table to compare sizes between minimal exes produced by defualt linking and the ones produced with this wizard:

Project Type Win32 Exe Win32 Dll Console
Default x86 48,00 KB 52,00 KB 48,00 KB
Small x86 2,50 KB 2,00 KB 2,50 KB
Default x64 44,00 KB 45,50 KB 44,00 KB
Small x64 3,00 KB 2,00 KB 3,00 KB
Default Itanium 90,50 KB 95,00 KB 90,00 KB
Small Itanium 4,00 KB 3,50 KB 5,00 KB

This seems pretty acceptable, doesn't it?

The Wizard

This is the J# code of the wizard:


function OnFinish(selProj, selObj)
{
	try
	{
		var strProjectPath = wizard.FindSymbol('PROJECT_PATH');
		var strProjectName = wizard.FindSymbol('PROJECT_NAME');

		selProj = CreateCustomProject(strProjectName, strProjectPath);
		AddConfig(selProj, strProjectName);
		AddFilters(selProj);

		var InfFile = CreateCustomInfFile();
		AddFilesToCustomProj(selProj, strProjectName, strProjectPath, InfFile);
		PchSettings(selProj);
		InfFile.Delete();

		selProj.Object.Save();
	}
	catch(e)
	{
		if (e.description.length != 0)
			SetErrorInfo(e);
		return e.number
	}
}

function CreateCustomProject(strProjectName, strProjectPath)
{
	try
	{
		var strProjTemplatePath = wizard.FindSymbol('PROJECT_TEMPLATE_PATH');
		var strProjTemplate = '';
		strProjTemplate = strProjTemplatePath + '\\default.vcproj';

		var Solution = dte.Solution;
		var strSolutionName = "";
		if (wizard.FindSymbol("CLOSE_SOLUTION"))
		{
			Solution.Close();
			strSolutionName = wizard.FindSymbol("VS_SOLUTION_NAME");
			if (strSolutionName.length)
			{
				var strSolutionPath = strProjectPath.substr(0, strProjectPath.length - strProjectName.length);
				Solution.Create(strSolutionPath, strSolutionName);
			}
		}

		var strProjectNameWithExt = '';
		strProjectNameWithExt = strProjectName + '.vcproj';

		var oTarget = wizard.FindSymbol("TARGET");
		var prj;
		if (wizard.FindSymbol("WIZARD_TYPE") == vsWizardAddSubProject)  // vsWizardAddSubProject
		{
			var prjItem = oTarget.AddFromTemplate(strProjTemplate, strProjectNameWithExt);
			prj = prjItem.SubProject;
		}
		else
		{
			prj = oTarget.AddFromTemplate(strProjTemplate, strProjectPath, strProjectNameWithExt);
		}
		return prj;
	}
	catch(e)
	{
		throw e;
	}
}

function AddFilters(proj)
{
	try
	{
		// Add the folders to your project
		var strSrcFilter = wizard.FindSymbol('SOURCE_FILTER');
		var group = proj.Object.AddFilter('Source Files');
		group.Filter = strSrcFilter;
	}
	catch(e)
	{
		throw e;
	}
}

function AddConfig(proj, strProjectName)
{
	try
	{   
	    var ProjType = wizard.FindSymbol('LST_PROJECT');
	    var bUseUnicode = wizard.FindSymbol('RB_UNICODE');
	    
	    //
		// Debug (x86)
		//
	    
		var config = proj.Object.Configurations('Debug');
		
		config.IntermediateDirectory = '$(ConfigurationName)';
		config.OutputDirectory = '$(ConfigurationName)';
		
		if (ProjType != 'Win32Dll')
		    config.ConfigurationType = 1; // exe
		else
		    config.ConfigurationType = 2; // dll
				
		if (bUseUnicode == true)
		    config.CharacterSet = 1; // unicode
		else
		    config.CharacterSet = 0; // ascii

		var CLTool = config.Tools('VCCLCompilerTool');
		
		CLTool.Optimization = 0;
		CLTool.MinimalRebuild = true;
		CLTool.BasicRuntimeChecks = 3;
		CLTool.RuntimeLibrary = 0;
		CLTool.UsePrecompiledHeader = 0;
		CLTool.WarningLevel = 3;
		CLTool.Detect64BitPortabilityProblems = true;
		CLTool.DebugInformationFormat = 4;
				
		if (ProjType == 'Win32Exe')
		    CLTool.PreprocessorDefinitions = 'WIN32;_DEBUG;_WINDOWS';
		else if (ProjType == 'Console')
		    CLTool.PreprocessorDefinitions = 'WIN32;_DEBUG;_CONSOLE';
		 else 
		    CLTool.PreprocessorDefinitions = 'WIN32;_DEBUG;_WINDOWS;_USRDLL';

		var LinkTool = config.Tools('VCLinkerTool');
		
		LinkTool.LinkIncremental = 2;
		LinkTool.GenerateDebugInformation = true;
		
		if (ProjType != 'Console')
		    LinkTool.SubSystem = 2; // win32
		else
		    LinkTool.SubSystem = 1; // console
		    
		LinkTool.TargetMachine = 1;
		
		//
		// Release (x86)
		//

		config = proj.Object.Configurations('Release');
		
		config.IntermediateDirectory = '$(ConfigurationName)';
		config.OutputDirectory = '$(ConfigurationName)';
		
		if (ProjType != 'Win32Dll')
		    config.ConfigurationType = 1; // exe
		else
		    config.ConfigurationType = 2; // dll
		
		if (bUseUnicode == true)
		    config.CharacterSet = 1; // unicode
		else
		    config.CharacterSet = 0; // ascii
		    
		var CLTool = config.Tools('VCCLCompilerTool');
		
		CLTool.Optimization = 1;
		CLTool.FavorSizeOrSpeed = 2;
		CLTool.WholeProgramOptimization = false;
		CLTool.RuntimeLibrary = 0;
		CLTool.StructMemberAlignment = 1;
		CLTool.BufferSecurityCheck = false;
		CLTool.UsePrecompiledHeader = 0;
		CLTool.WarningLevel = 3;
		CLTool.Detect64BitPortabilityProblems = true;
		CLTool.DebugInformationFormat = 3;
		
		if (ProjType == 'Win32Exe')
		    CLTool.PreprocessorDefinitions = 'WIN32;NDEBUG;_WINDOWS';
		else if (ProjType == 'Console')
		    CLTool.PreprocessorDefinitions = 'WIN32;NDEBUG;_CONSOLE';
		 else 
		    CLTool.PreprocessorDefinitions = 'WIN32;NDEBUG;_WINDOWS;_USRDLL';
		    
		var LinkTool = config.Tools('VCLinkerTool');
		
		LinkTool.AdditionalDependencies = 'small_libc_x86.lib';
		LinkTool.LinkIncremental = 1;
		LinkTool.IgnoreAllDefaultLibraries = true;
		LinkTool.GenerateDebugInformation = false;
		
		if (ProjType != 'Console')
		    LinkTool.SubSystem = 2; // win32
		else
		    LinkTool.SubSystem = 1; // console
		
		LinkTool.OptimizeReferences = 2;
		LinkTool.EnableCOMDATFolding = 2;
		LinkTool.TargetMachine = 1;
	}
	catch(e)
	{
		throw e;
	}
}

function PchSettings(proj)
{
	// TODO: specify pch settings
}

function DelFile(fso, strWizTempFile)
{
	try
	{
		if (fso.FileExists(strWizTempFile))
		{
			var tmpFile = fso.GetFile(strWizTempFile);
			tmpFile.Delete();
		}
	}
	catch(e)
	{
		throw e;
	}
}

function CreateCustomInfFile()
{
	try
	{
		var fso, TemplatesFolder, TemplateFiles, strTemplate;
		fso = new ActiveXObject('Scripting.FileSystemObject');

		var TemporaryFolder = 2;
		var tfolder = fso.GetSpecialFolder(TemporaryFolder);
		var strTempFolder = tfolder.Drive + '\\' + tfolder.Name;

		var strWizTempFile = strTempFolder + "\\" + fso.GetTempName();

		var strTemplatePath = wizard.FindSymbol('TEMPLATES_PATH');
		var strInfFile = strTemplatePath + '\\Templates.inf';
		wizard.RenderTemplate(strInfFile, strWizTempFile);

		var WizTempFile = fso.GetFile(strWizTempFile);
		return WizTempFile;
	}
	catch(e)
	{
		throw e;
	}
}

function GetTargetName(strName, strProjectName)
{
	try
	{
		// TODO: set the name of the rendered file based on the template filename
		var strTarget = strName;

		if (strName == 'readme.txt')
			strTarget = 'ReadMe.txt';
			
		if (strName == 'main.h')
		    strTarget = strProjectName + '.h';
		    
		if (strName == 'main.cpp')
		    strTarget = strProjectName + '.cpp';
		    
		if (strName == 'crt.cpp')
		    strTarget = strProjectName + ' CRT.cpp';
		    
		return strTarget; 
	}
	catch(e)
	{
		throw e;
	}
}

function AddFilesToCustomProj(proj, strProjectName, strProjectPath, InfFile)
{
	try
	{
		var projItems = proj.ProjectItems

		var strTemplatePath = wizard.FindSymbol('TEMPLATES_PATH');

		var strTpl = '';
		var strName = '';

		var strTextStream = InfFile.OpenAsTextStream(1, -2);
		while (!strTextStream.AtEndOfStream)
		{
			strTpl = strTextStream.ReadLine();
			if (strTpl != '')
			{
				strName = strTpl;
				var strTarget = GetTargetName(strName, strProjectName);
				var strTemplate = strTemplatePath + '\\' + strTpl;
				var strFile = strProjectPath + '\\' + strTarget;

				var bCopyOnly = false;  
				var strExt = strName.substr(strName.lastIndexOf("."));
				if(strExt==".bmp" || strExt==".ico" || strExt==".gif" || strExt==".rtf" 
				   || strExt==".css" || strExt==".lib")
					bCopyOnly = true;
				wizard.RenderTemplate(strTemplate, strFile, bCopyOnly);
				
				if (strExt != ".lib")
				    proj.Object.AddFile(strFile);
			}
		}
		strTextStream.Close();
	}
	catch(e)
	{
		throw e;
	}
}
There are already a lot of articles on how to make a Custom Wizard for Visual Studio, so any further explanation is quite useless. I just put the code in the article to let it be ridden by someone who's not interested in downloading the attachment.

The installer just puts all the files in the right directories, there's nothing unusual in the whole process.

Final Considerations

More Optimization can be still reached. I was thinking about a post-build PE optimizer...

I'd like to say a last thing about this whole subject. Reducing executables size isn't that important, most of the times it's just playing around. The default libc makes executables very big, but the added code is not useless code. Reduce your executables size only if necessary.

Goodbye!

Daniel Pistelli