I am trying to perform DLL redirection on a Windows 7 x64 machine. I have a 3rd party application say App.exe
which is located in %PROGRAMFILES%\SomeApp\App.exe
. App.exe is a native unmanaged Windows application and depends on an unmanaged native DLL, say foo.dll
which is present within C:\Windows\System32
Now I have my own version of foo.dll
which I want App.exe
to load instead of the one present within C:\Windows\System32
.
Here is what I tried and works well on XP:
App.exe.manifest
foo.dll
within %PROGRAMFILES%\SomeApp
. This is the same directory where App.exe
resides.<file name="foo.dll">
However, this does not work on Windows 7.
I googled around and my research led me to this MSDN discussion. Here the answer talks about creating assemblies and also providing configuration files (e.g. App.exe.config
). MSDN does not talk about this. Hence my first question:
Is it mandatory to have our unmanaged DLL wrapped into an assembly as mentioned in the above link and is it also mandated to have an application config file for DLL redirection to take place?
In addition I referred to some of the application manifests present within the WinSxS
folder in Windows 7 and found some manifest files containing the <file>
element entry as below:
<file hash="6bd4c0b867d2ec23a03fc1b290abc62a7d7d0908"
hashalg="SHA1"
name="aspnet_regiis.exe"
destinationPath="$(runtime.windows)\Microsoft.NET\Framework64\v2.0.50727\"
sourceName="aspnet_regiis.exe"
sourcePath="Win\Microsoft.NET\Framework\URTInstallPath\"
importPath="$(build.nttree)\netfx\Win\Microsoft.NET\Framework\URTInstallPath\">
Hence my second question:
What do the attributes destinationPath
, sourceName
, sourcePath
and importPath
stand for? These are not documented within the Assembly Manifest or Application Manifest MSDN documentation.
And my third question (implied by the first and second):
What is the correct <file>
tag entry that must be specified within the App.exe.manifest so that my version of foo.dll is picked up?
Any other pointers to achieve DLL redirection on Windows 7 are welcome.
Try to avoid DLL redirection if at all possible. Put all your DLLs int the same folder as the EXE. This can only not be avoided for the MSVC DLLs themselves. Installing the redist as a dependency in your installer normally fixes these.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With