Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DLL redirection - working in XP, not in Windows 7

On Windows XP, I'm redirecting user32.dll for a specified application, but with the same setup on Windows 7, user32.dll is not redirected.

The setup is this - a directory containing:

app.exe
app.exe.manifest
user32.dll

app.exe.manifest contains:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    version="0.0.0.0"
    name="Redirection"
    type="win32"
  />

  <file
    name="user32.dll"
  />
</assembly>

On Windows XP, app.exe loads the user32.dll from the application folder. On Windows 7, app.exe loads user32.dll from the system32 folder.

How can I get app.exe to load user32.dll from the application folder on Windows 7? The MSDN docs don't mention any differences between platforms for the way assemblies work, but there must be some difference that's stopping the redirection from working...

Any ideas?

like image 208
parrowdice Avatar asked Oct 15 '25 10:10

parrowdice


1 Answers

So it turns out that Windows platforms from Vista onwards do some activation context caching, i.e. a manifest is looked for the first time the application runs. If a manifest is added or changed after the first run, Windows doesn't bother to look for it to save time loading.

So my scenario does work, but you need to force Windows to re-cache the activation context by modifying the applications binary (e.g. the time-stamp).

I tried that and my user32.dll is loaded in Windows 7 from the application directory.

Refs:
http://blogs.msdn.com/b/vistacompatteam/archive/2006/11/13/manifest-and-the-fusion-cache.aspx
VB6 Manifest not working on Windows 7

like image 159
parrowdice Avatar answered Oct 16 '25 23:10

parrowdice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!