Side-by-side assembly

Last updated

Side-by-side assembly (SxS, or WinSxS on Microsoft Windows) technology is a standard for executable files in Windows 98 Second Edition, Windows 2000, and later versions of Windows that attempts to alleviate problems (collectively known as "DLL Hell") that arise from the use of dynamic-link libraries (DLLs) in Microsoft Windows. Such problems include version conflicts, missing DLLs, duplicate DLLs, and incorrect or missing registration. In side-by-side, Windows stores multiple versions of a DLL in the %systemroot%\WinSxS directory, and loads them on demand. This reduces dependency problems for applications that include a side-by-side manifest.

Contents

Microsoft Visual C++ 2005 and 2008 employ SxS with all C runtime libraries. However, runtime libraries in Visual C++ 2010 no longer use this technology; instead, they include the version number of a DLL in its file name, which means that different versions of one DLL will technically be completely different DLLs now. [1] [2]

SxS is also the technological basis for registration-free COM activation. Only in-process COM servers may be activated this way.

Operation

An application that employs SxS must have a manifest. Manifests are typically a section embedded in the application's executable file but may also be an external file. When the operating system loads the application and detects the presence of a manifest, the operating system DLL loader is directed to the version of the DLL corresponding to that listed in the manifest. If there is no manifest, the DLL loader loads a default version of all DLL dependencies. If the DLL is a COM server, it must have a manifest of its own for registration-free activation to succeed.

On Windows Vista and later, sxstrace.exe can help to diagnose failures in the starting of applications due to SxS misconfiguration.

If a user wishes to override manifest-specified assemblies (for example, in the case of security patches applied to a library), a publisher configuration file can globally redirect assemblies. Digital signatures can ensure the legitimacy of such redirection. [3]

Manifest format

The application manifest is internally represented as XML. The URN associated with SxS manifests is "urn:schemas-microsoft-com:asm.v1".

Several other recent Microsoft technologies such as ClickOnce employ the same manifest format.

Example manifest

The following is an example of a manifest for an application that depends on a C runtime DLL.

<?xml version='1.0' encoding='UTF-8' standalone='yes'?><assemblyxmlns='urn:schemas-microsoft-com:asm.v1'manifestVersion='1.0'><dependency><dependentAssembly><assemblyIdentitytype='win32'name='Microsoft.VC90.CRT'version='9.0.21022.8'processorArchitecture='x86'publicKeyToken='1fc8b3b9a1e18e3b'/></dependentAssembly></dependency></assembly>

Activation contexts

A manifest like the one above is parsed into an activation context by the SxS loader. There is a stack of activation contexts for each thread or fiber. An API allows programmatic manipulation of these contexts. It may be necessary for a library (DLL) to change its activation context, for example if it requires a specific version of another library for its own consumption instead of using the activation context of its caller. This type of issue is sometimes called (activation context) pollution. [4] To prevent polluting its activation context, a DLL can have a manifest embedded as a resource, which is parsed when the DLL is loaded. This manifest must be at resource id 2 in the image file for the loader to find it. [5]

WinSxS (Windows component store)

From Vista onward, the Windows operating system uses WinSxS for its core components. Operating system files in the winsxs directory are hard linked from their usual locations in the Windows directory structure. A file in a subdirectory in winsxs may be linked from multiple locations (e.g. the System32 directory and application directories). Windows Explorer double-counts the disk space occupied by these files. [6] This can be demonstrated using the fsutil command-line program. [7] Some third-party Explorer extensions to show the link count also exist.

However, not all files from winsxs are projected this way to "live" operating system files. For example, after installing some Windows updates, old file versions replaced by the updates are still kept in winsxs although they are no longer linked in the "live" Windows directories. This allows updates to be uninstalled safely. [8]

Because of its elevated importance, from Vista onward the winsxs directory is owned by the Trusted Installer service SID. By default not even administrators can modify its contents (without taking ownership first). Uninstalling applications does not immediately free space in the winsxs directory; space for unused assemblies is garbage-collected over time by the Installer service. [9]

Although not officially documented, the algorithm for generating the directory names residing inside the winsxs directory has been made public on an MSDN Microsoft employee's blog. The algorithm was changed in the transition from XP to Vista. [10]

Windows 7 includes Windows AIK tool Deployment Image Servicing and Management (DISM) which can remove files used by superseded OS updates using the Trusted Installer worker service, without the need to reboot or take down the system; [11] post-SP1 updates add Windows Update cleanup to the Disk Cleanup tool (cleanmgr.exe) [12] and the downloadable System Update Readiness tool (CheckSUR) [13] which can repair components store errors and replace corrupt or missing OS files with known good versions. Windows 8 integrates repair capability to the DISM tool which is now able to copy valid OS files from Windows Update or an offline WIM image, as well as reset the component store to only contain the latest versions of OS components. [14] Windows 10 runs the automatic task to clean up the component store. [15]

Advantages

Disadvantages

Disk space

While the winsxs directory is extremely large and contains multiple versions of many files, there are some files elsewhere in the Windows folder (e.g. System32) that are hardlinks to files in the winsxs directory. [17] Thus, programs estimating the size of the Windows folder must be careful not to add the size of additional hard links to a file after one has already been counted. [18]

DIR and Explorer fail to check for hard links, and so may count the same file multiple times, adding incorrectly to the perceived disk usage. The disk usage reported by these two programs is as if each hard link is an actual file. [19]

Since Windows 8.1, the DISM tool can be used to analyze the component store and report its actual size. [20]

Related Research Articles

In computing, DLL Hell is a term for the complications that arise when one works with dynamic-link libraries (DLLs) used with Microsoft Windows operating systems, particularly legacy 16-bit editions, which all run in a single memory space.

<span class="mw-page-title-main">Windows API</span> Microsofts core set of application programming interfaces on Windows

The Windows API, informally WinAPI, is the foundational application programming interface (API) that allows a computer program to access the features of the Microsoft Windows operating system in which the program is running.

NTLDR is the boot loader for all releases of Windows NT operating system from 1993 with the release of Windows NT 3.1 up until Windows XP and Windows Server 2003. From Windows Vista onwards it was replaced by the BOOTMGR bootloader. NTLDR is typically run from the primary storage device, but it can also run from portable storage devices such as a CD-ROM, USB flash drive, or floppy disk. NTLDR can also load a non NT-based operating system given the appropriate boot sector in a file.

<span class="mw-page-title-main">Windows XP Professional x64 Edition</span> Edition of Windows XP for x86-64 computers, released in 2005

Microsoft Windows XP Professional x64 Edition is an edition of Windows XP for x86-64 personal computers. It was released on April 25, 2005, around the same time as with the x86-64 versions of Windows Server 2003. It is designed to use the expanded 64-bit memory address space provided by the x86-64 architecture.

<span class="mw-page-title-main">Control Panel (Windows)</span> Component of Microsoft Windows and Windows Server

Control Panel is a component of Microsoft Windows that provides the ability to view and change system settings. It consists of a set of applets that include adding or removing hardware and software, controlling user accounts, changing accessibility options, and accessing networking settings. Additional applets are provided by third parties, such as audio and video drivers, VPN tools, input devices, and networking tools.

Windows USER is a component of the Microsoft Windows operating system that provides core functionality for building simple user interfaces. The component has existed in all versions of Windows, and includes functionality for window management, message passing, input processing and standard controls.

<span class="mw-page-title-main">System Restore</span> System recovery feature in Microsoft Windows

System Restore is a feature in Microsoft Windows that allows the user to revert their computer's state to that of a previous point in time, which can be used to recover from system malfunctions or other problems. First included in Windows Me, it has been included in all following desktop versions of Windows released since, excluding Windows Server. In Windows 10, System Restore is turned off by default and must be enabled by users in order to function. This does not affect personal files such as documents, music, pictures, and videos.

Dependency Walker or depends.exe is a free program for Microsoft Windows used to list the imported and exported functions of a portable executable file. It also displays a recursive tree of all the dependencies of the executable file. Dependency Walker was included in Microsoft Visual Studio until Visual Studio 2005 and Windows XP SP2 support tools. The latest version v2.2.10011 is not available on dependencywalker.com website but is included in the Windows Driver Kit v10.

Microsoft Plus! is a discontinued commercial operating system enhancement product by Microsoft. The last edition is the Plus! SuperPack, which includes an assortment of screensavers, themes, and games, as well as multimedia applications. The Microsoft Plus! product was first announced on January 31, 1994, under the internal codename "Frosting". The first edition was an enhancement for Windows 95, Windows 95 Plus!

System File Checker (SFC) is a utility in Microsoft Windows that allows users to scan for and restore corrupted Windows system files.

As the next version of Windows NT after Windows 2000, as well as the successor to Windows Me, Windows XP introduced many new features but it also removed some others.

Compared with previous versions of Microsoft Windows, features new to Windows Vista are very numerous, covering most aspects of the operating system, including additional management features, new aspects of security and safety, new I/O technologies, new networking features, and new technical features. Windows Vista also removed some others.

<span class="mw-page-title-main">Microsoft Management Console</span> Component of Microsoft Windows

Microsoft Management Console (MMC) is a component of Microsoft Windows that provides system administrators and advanced users an interface for configuring and monitoring the system. It was first introduced in 1998 with the Option Pack for Windows NT 4.0 and later came pre-bundled with Windows 2000 and its successors.

<span class="mw-page-title-main">User Account Control</span> Security software

User Account Control (UAC) is a mandatory access control enforcement feature introduced with Microsoft's Windows Vista and Windows Server 2008 operating systems, with a more relaxed version also present in Windows 7, Windows Server 2008 R2, Windows 8, Windows Server 2012, Windows 8.1, Windows Server 2012 R2, Windows 10, and Windows 11. It aims to improve the security of Microsoft Windows by limiting application software to standard user privileges until an administrator authorises an increase or elevation. In this way, only applications trusted by the user may receive administrative privileges and malware are kept from compromising the operating system. In other words, a user account may have administrator privileges assigned to it, but applications that the user runs do not inherit those privileges unless they are approved beforehand or the user explicitly authorises it.

Windows Vista introduced a number of new I/O functions to the Microsoft Windows line of operating systems. They are intended to shorten the time taken to boot the system, improve the responsiveness of the system, and improve the reliability of data storage.

The NTFS file system defines various ways to redirect files and folders, e.g., to make a file point to another file or its contents without making a copy of it. The object being pointed to is called the target. Such file is called a hard or symbolic link depending on a way it's stored on the filesystem.

Windows Vista contains a range of new technologies and features that are intended to help network administrators and power users better manage their systems. Notable changes include a complete replacement of both the Windows Setup and the Windows startup processes, completely rewritten deployment mechanisms, new diagnostic and health monitoring tools such as random access memory diagnostic program, support for per-application Remote Desktop sessions, a completely new Task Scheduler, and a range of new Group Policy settings covering many of the features new to Windows Vista. Subsystem for UNIX Applications, which provides a POSIX-compatible environment is also introduced.

In computing, a manifest file is a file containing metadata for a group of accompanying files that are part of a set or coherent unit. For example, the files of a computer program may have a manifest describing the name, version number, license and the constituent files of the program.

In computing on Microsoft platforms, WoW64 is a subsystem of the Windows operating system capable of running 32-bit applications on 64-bit Windows. It is included in all 64-bit versions of Windows, except in Windows Server Server Core where it is an optional component, and Windows Nano Server where it is not included. WoW64 aims to take care of many of the differences between 32-bit Windows and 64-bit Windows, particularly involving structural changes to Windows itself.

References

  1. Section "Visual C++ Libraries" in Breaking Changes in Visual C++. Retrieved on 2010-09-10.
  2. See section "Differences between Visual C++ 2008 and Visual C++ 2010" in "Deployment in Visual C++ 2010". Retrieved on 2010-09-10.
  3. Publisher Configuration (Windows)
  4. Wiswall, Jon (2006-01-07). "Fixing Activation Context Pollution". Nothing ventured, nothing gained. Microsoft.
  5. Wiswall, Jon (2006-01-17). "DLLs and resource ID 2 manifests". Nothing ventured, nothing gained. Microsoft.
  6. "KB 2592038: How to Alleviate Disk Space Pressure Caused By a Large Windows Component Store (WinSxS) Directory". support.microsoft.com. Archived from the original on 2012-10-14.
  7. joscon (2010-08-06). "Should you delete files in the \WinSXS directory? And what's the deal with VSS?". The Windows Servicing Guy.
  8. 1 2 Huges, Jeff (2008-09-17). "What is the WINSXS directory in Windows 2008 and Windows Vista and why is it so large?". Microsoft Corporation. Retrieved 15 March 2011.
  9. Wiswall, Jon (2007-01-02). "Deleting from the WinSxS Directory". Nothing ventured, nothing gained. Microsoft.
  10. Wiswall, Jon (2005-12-28). "What's that Awful Directory Name Under Windows\WinSxS?". Nothing ventured, nothing gained. Microsoft.
  11. Microsoft TechNet: What Is Deployment Image Servicing and Management?
  12. Shelbourne, Charity (2013-10-08). "Breaking News! Reduce the size of the WinSxS Directory and Free up Disk Space with a New Update for Windows 7 SP1 Clients". Ask Premier Field Engineering (PFE) Platforms. Microsoft.
  13. Microsoft TechNet: Advanced guidelines for diagnosing and fixing servicing corruption
  14. "DISM – Repair a Windows Image". TechNet. Microsoft.
  15. "Clean Up the WinSxS Folder". Docs.Microsoft.com. 2017-05-02.
  16. "KB 943232: An application that uses the Sxs.dll file crashes when you run the application on a Windows XP-based computer". support.microsoft.com. Archived from the original on 2012-10-27.
  17. "Manage the Component Store". TechNet. Microsoft.
  18. joscon (2011-01-06). "How hard links work". The Windows Servicing Guy.
  19. Sinofsky, Steven (2008-11-19). "Disk Space". Engineering Windows 7. Microsoft.
  20. "Determine the Actual Size of the WinSxS Folder". TechNet. Microsoft.