Search code examples
c#c++cwindows-nt

Intercepting API calls related to getting Windows Verion


I've been playing Homeworld 1, and for it to run you need to run it Windows NT 4 Compatibility mode.

Windows 8 does not have this for some reason, which is quite annoying.

Using Microsoft Application Compatibility Toolkit I discovered that Homeworld does an API call to get the version of Windows, and it seems to stop working unless it is thinking it's running on Windows NT (Using a debugger I can see that it calls for GetVersion and GetVersionEx).

http://technet.microsoft.com/en-us/library/cc749574(v=ws.10).aspx

Using the above with Microsoft Applocation Compat Toolkit fixes this error, but I play this game on a lot of different computers, some which can not use the above method.

Is there any way for me to make some sort of wrapper that intercepts the API calls and returns them with the above links struct so that the program think it is running on NT? I've seen a lot of DLLs that you place in a folder and it can intercept certain calls, though I'm not sure how they work, I assume they are written in C, C++.

The only language I really know any of is C#, which I assume can't do what I want, so if anyone is able to point me in the right direction, help, give me tips on this or point me to where I could get more help that'd be great!


Solution

  • You could use api hooking library, here is a tutorial for the famous easyhook library.

    Hook the GetVersionEx api for you application and return what you want.