1

This blog post mentions how to create your own shims.

What I don't understand is:

When a newer version of a DLL comes out (with more exported functions), wouldn't this technique break?

i.e. If you completely override the target DLL with a shim DLL, then what do you do about functions that you didn't/couldn't implement a redirection for?

user541686
  • 205,094
  • 128
  • 528
  • 886
  • Yes, I would expect it to break when a newer version of the DLL comes out. What gave you a different impression? – Cody Gray - on strike Feb 29 '12 at 17:28
  • @CodyGray: Hmm... I expected it to be a more transparent kind of hook, otherwise you might need a new shim for every new version of a DLL (which sounds unscalable). – user541686 Feb 29 '12 at 17:39
  • 2
    The shim that article creates is not an application compatibility shim. It is, as you noted, hard-coded to a specific version of the target DLL. – Raymond Chen Feb 29 '12 at 22:14
  • @RaymondChen: Oh huh, interesting... but then how are application compatibility shims created? (Or rather, what *are* they in the first place? DLLs, or something else?) – user541686 Mar 01 '12 at 02:54
  • 1
    There is no way for third parties to create new compatibility shims. The Windows Application Compatibility team creates the shims. – Raymond Chen Mar 01 '12 at 22:17
  • @RaymondChen: Oh wow, okay, thanks. (Feel free to post it as an answer so I can accept it!) – user541686 Mar 01 '12 at 22:23
  • You really don't *need* to create your own compatibility shim, you can download the [Application Compatibility Toolkit](http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7352) and piece together the functionality you need from the shims the appcompat team has already written. Like all such things, shims are designed for the user, not the programmer since she can just fix her buggy code at the source. Of course, as you alluded to, you could hook individual APIs and modify the behavior, but I wouldn't recommend it... – Cody Gray - on strike Mar 02 '12 at 07:43

1 Answers1

0

This isn't the only way to do it.

The easiest solution is probably to use Detours, though the free version is 32-bit only and for non-commercial use, and the paid version is seriously expensive.

This article describes a bunch of methods of doing it yourself.

arx
  • 16,686
  • 2
  • 44
  • 61