views:

285

answers:

3

Windows has the capability to apply shims to mis-behaving applications. Shims are used to intercept API calls and change it. For example, shims can be used to:

  • change the incoming paramters
  • lie about the return values
  • change it to call something else

The Application Compatibility Tookit has quite a few existing shims you can apply to your own mis-behaving application. Here's an example of one that ignores your API call and instead calls a completely different API instead:

alt text

i need a shim that isn't one of the hundreds of shims Microsoft already wrote. i need a custom shim.

In my case i want to intercept calls to:

GetSystemMetrics(0x1000)

so that it returns 0. i can't find any information on how to give Windows my own DLL that will have the fix i need. i don't even know if you can create custom shims.

Does Windows support custom shims?

+1  A: 

I'm not aware of any way of someone other than Microsoft implementing an appcompat shim.

You might want to investigate Detours, it might provide the functionality you want.

Larry Osterman
Accepted answer: "No."
Ian Boyd
A: 

You have to think of this from Raymond Chen's point of view. Imagine if it were possible for somebody other than Microsoft to write compatibility shims. Then whenever Microsoft makes a breaking change, in addition to all their other compatibility work they will also have to write shims for the 3rd party shims that did the wrong thing. Maintaining backward compatibility is hard enough as it is.

Luke
i'm just trying to figure out how to fix a problem in software i didn't write. i'm grasping at any options i can find.
Ian Boyd
My next approach would be to use the higly dangerous, and not recommended, api hooking.
Ian Boyd
A: 

you could always use reverse engineering to fix it :), let me know if you need any help with it

Bartosz Wójcik
You mean trace into the assembly, and generate a patch for the executable?
Ian Boyd
that's one of the options, it depends on how do you want it to work, msn me if you want
Bartosz Wójcik