Title: Vista &amp; Windows Side by Side Assemblies
Slug: vista-windows-side-by-side-assemblies
Date: 2007-04-30 18:29:00
Author: Kartones
Lang: en
Tags: Systems-IT, Windows, Troubleshooting
Description: A detailed explanation of Windows Side by Side Assemblies, how they evolved in Windows Vista, and the challenges faced with accessing and modifying the WinSxS folder.

<p>Now almost everyone knows at least what Vista's <acronym title="User Account Control">UAC</acronym> is. But not many people know what <a href="http://msdn2.microsoft.com/en-us/library/aa376307.aspx">Windows Side by Side Assemblies</a> (aka <b>WinSxS</b>) are. </p> <p>Side by Side Assemblies are Microsoft's attempt to evade the DLL hell Windows terror (DLLs currently in use, overriding versions, uninstalling by accident required DLLs...), designed and implemented in <i>Windows XP</i>, and now available too in <i>Windows 2003</i> and <i>Windows Vista</i>.</p> <p>Initially, all DLLs had to go to <font face="Courier New">%Windir%\system32\</font> folder. Since Windows XP, they could be deployed under  <font face="Courier New">%Windir%\WinSxS\YourDLLNameWithAHashCode\YourDLL.dll</font>, and a corresponding manifest in <font face="Courier New">%Windir%\WinSxS\Manifests\</font> folder. Let's see it more clearly with a sample screenshot:</p> <p><img title="Windows SxS folder" alt="Windows SxS folder" src="https://images.kartones.net/posts/screenshots/vista_and_winsxs_001.jpg"></p> <p> The directory name which holds the DLL is an algorithm not published by Microsoft, and so only by using MSI Installer can be created (no more manual installs).</p> <p>When an application tries to use a DLL from WinSxS, Windows searches for the manifest. If found, gets the DLL from it's folder and loads it.</p> <p> </p> <p>All of this sounds great... but with Windows Vista, problems arise.</p> <p>I needed to install <i>Microsoft's RTC Client API 1.3</i> (aprox. from 2005), and UAC detected it was an installation and prompted me for privilege elevation. I accepted, and it was installing , when... surprise!</p> <p><img title="Error trying to instal an assembly" alt="Error trying to instal an assembly" src="https://images.kartones.net/posts/screenshots/vista_and_winsxs_000.png"></p> <p>What? Access denied to a directory? Wasn't I running as administrator the setup?</p> <p>Made some checks, tried some things, and the result was the  same...</p> <p><img title="Reviewing Windows Event Logs" alt="Reviewing Windows Event Logs" src="https://images.kartones.net/posts/screenshots/vista_and_winsxs_003.jpg"></p> <p> </p> <p>Finally, I went to check if the WinSxS folder had some special permissions... and actually it had :)</p> <p><img title="The TrustedInstaller hidden account" alt="The TrustedInstaller hidden account" src="https://images.kartones.net/posts/screenshots/vista_and_winsxs_002.jpg"></p> <p><b>TrustedInstaller</b> user? Well, seems that in Windows Vista, Side by Side Assemblies have evolved to be part of the <b>Windows Resource Protection</b> scheme and so it has ben hardened. <br></p> <p>The WinSxS folder cannot be modified by others than the TrustedInstaller account, <b><u>which is more trusted than any administrator account</u></b>, and so cannot be touched  (admins have only read permissions to the WinSxS folder).</p> <p>So, the only way to access this folder is within installers. No other way. Not even deactivating UAC. You can't give write permissions to an administrator, you can't modify files or manifests, and you can't create by hand DLL folders (because you don't know the  hash algorithm).</p> <p> </p> <p>After some MSI dissasembling, I was able to extract the  DLLs required for the API, and with Visual Studio 2005 I created a new Setup Project, included the files and compiled it. As it's recent, Windows  Vista detects it and installs the DLLs inside WinSxS.</p> <p><img title="Hack worked... at least installed" alt="Hack worked... at least installed" src="https://images.kartones.net/posts/screenshots/vista_and_winsxs_004.jpg"></p> <p> </p> <p>The RTC Client API still doesn't work, but now it may be either a COM problem or that my "custom installer" method doesn't works because my installer creates a different hash code for the DLL folder name.</p> <p>If you want to know more about diagnosing Side by Side problems and errors, check <a href="http://blogs.msdn.com/junfeng/archive/2006/04/14/576314.aspx">this fantastic Junfeng Zhang's post</a>.</p>