May 14, 2006

How to bypass the WinSxS for CRT/MFC/ATL DLLs

Starting with VC8, you have two options to distribute the DLL version of the CRT/MFC/ATL with your application:

  1. You can redistribute the DLLs with your application in the same directory and also put a valid manifest for these DLLs into this directory
  2. You can install the redist.exe and the DLL will be installed in the WinSxS folder (on XP and later)

So, if you want to be independed from global DLLs, you might think that you can simply put the DLLs into your applications directory. But this is a false conclusion.
If a DLL is installed in the WinSxS folder, the local DLLs will be ignored. This might be even true, if a newer DLL was installed (for example by security hotfixes). This is possible due to policy redirections of these SxS-DLLs.
In most cases this also makes sense, because you always get the latest (hopefully compatible) version of the DLL.

But there might be some situations in which you might have full control over which DLLs are loaded from where. Now, Andre Stille (an other VC++ MVP), found a very simple solution : just remove the “publicKeyToken” attribute from the manifests!
So an application manifest looks like:

Application.exe.manifest:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.42" processorArchitecture="x86" /> </dependentAssembly> </dependency> </assembly>

You must also set the correct verion-number of the DLL! And remove the “publicKeyToken” attribute.
The manifest the for DLL looks like:

Microsoft.VC80.CRT.Manifest:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.42" processorArchitecture="x86"></assemblyIdentity> <file name="msvcr80.dll"></file> <file name="msvcp80.dll"></file> <file name="msvcm80.dll"></file> </assembly>

Now the CRT DLLs in the WinSxS will be ignored and only the local DLLs will be loaded.

Thanks again to Andre Stille!


Posted 1 year, 7 months ago on May 14, 2006
The trackback url for this post is http://blog.kalmbachnet.de/bblog/trackback.php/80/

Something about a Article you post
>>5/30/2005 10:58:29 AM Re: Detect hardware driven >>mouse event >>Hallo Samme! >>You need to hook the mouse-events via "SetWindowsHookEx" >>and then you >>can see it in the structure "MSLLHOOKSTRUCT" in the >>flags entry >>(LLMHF_INJECTED). >>-- >>Greetings >>Jochen >>My blog about Win32 and .NET >>http://blog.kalmbachnet.de/ Hi, When we try to hook the mouse-events via "SetWindowsHookEx',and check flags entry(LLMHF_INJECTED)with "MSLLHOOKSTRUCT",we can't detect hardware driven mouse event .Both hardward and software mouse event has the same result.Would you tell us how to detect hardware mouse event ? thank you. cch.
Posted 1 year, 7 months ago by cch • • • Reply
Comment Trackback URL : http://blog.kalmbachnet.de/bblog/trackback.php/80/451/

Comments have now been turned off for this post