Last time around, we were talking about version lie shims for Windows Vista with managed code. Somebody pointed out that they suspected that the same issue might be true for Visual Basic 6 applications, since version lie shims didn’t appear to work there either.
Well, this is not entirely true. We can go through the same process as last time to see if we spot the Visual Basic 6 runtime, but take my word for it – we don’t exclude it. What is actually going on is that we aren’t shimming the Visual Basic virtual machine, by virtue of how it happens to be loaded. Since we don’t have all of the addresses we use sitting in the import table, the shims aren’t applied. Instead, we have to intentionally add the Visual Basic 6 virtual machine, which essentially causes the shim engine to shim up the GetProcAddress API so we can shim a dynamically loaded dll.
To take this for a test drive, I figured I’d go ahead and stick with version lies. I took some sample code for checking versions from here:
Now, if you look at the code, you’ll immediately see an opportunity to update it, since it doesn’t acknowledge the existence of Windows version 6.0. So, I went ahead and added that in, so we could see that this was Windows Vista. (Otherwise, it’s not going to return anything.) If you’re feeling bored, you can also differentiate between 5.1 (XP) and 5.2 (Server 2003).
Compile this code and then try to get a version lie going. You’ll find that, no matter what, it always says Windows Vista. You can do so from the compatibility tab, or from within Compatibility Administrator.
Let’s go in to Compatibility Administrator and fix that up. Select the VB6 exe you just compiled, don’t select a layer/mode, and get to the Compatibility Fixes / Shims page. Select a version lie shim (whichever one you want), and then click on Test Run. It still says Windows Vista. Now, click on the Parameters button for this shim. In the Module Information area, type msvbvm60.dll in the the Module Name text box, then click on Add. Click on OK to dismiss this dialog. Now click on Test Run. Voila! Now, you’re version lie is reaching the application!