Thursday, April 22, 2010

Visual C++ 2010 Apps Don't Support Windows 2000

One of the rather important things missing in the list of Breaking Changes for Visual C++ in Visual Studio 2010 is that applications generated by VS2010 no longer support Windows 2000.  Usage of W2K has fallen under 0.5%, but that's still a very large number of users. This was pointed out by Martin Richter in the Community Content. However, the actual story is a little more complex.

I built a C++ application to see what functions are actually being called. When examined in DEPENDS under Windows 2000, these are the functions that are undefined:
  • DecodePointer
  • EncodePointer
  • ReleaseActCtx
  • CreateActCtxW
  • ActivateActCtx
  • DeactivateActCtx
The interesting thing is the DecodePointer and EncodePointer are documented as only being available in Windows XP Service Pack 2 or later. This means that the minimum system requirements for an application generated by Visual C++ 2010 is WinXP SP2, or Windows Server 2003 SP1 for server versions of Windows.

In addition, DUMPBIN shows that the required version of Windows has been bumped from 5.00 to 5.01, which is Windows XP.

What's really annoying is that none of these calls are required under Windows 2000. These calls appear to be an artificial limitation purely for the purposes of preventing end-of-life versions of Windows from working properly.

8 comments:

  1. If you're feeling adventurous, you may want to get the KnownDlls wrapper for Windows 2000 from http://www7.atwiki.jp/win2000/pages/17.html

    The wrapper for kernel32.dll that it can install implements all of the functions you listed.

    The OS and subsystem version numbers showing in DUMPBIN are a quick fix in a hex editor, so at least that part is easier to deal with than having to install a kernel wrapper on every PC that will run your applications.

    ReplyDelete
  2. Create a .LIB that implements the missing functionality and link it ahead of KERNEL32.LIB.

    You will need to use the linker option /NODEFAULTLIB:kernel32.lib so that you can put your w2kcompat.lib ahead of kernel32.lib.

    ReplyDelete
  3. The system requirements listed for the Visual C++ redistributable package are: Windows 7; Windows Server 2003 R2 (32-Bit x86); Windows Server 2003 Service Pack 2; Windows Server 2008 R2; Windows Server 2008 Service Pack 2; Windows Vista Service Pack 2; Windows XP Service Pack 3

    ReplyDelete
  4. here's my attempt (statically linked MFC 2010 app on Windows 2000 SP4 + update rollup 1): http://tedwvc.wordpress.com/2010/11/07/how-to-get-visual-c-2010-mfc-applications-to-run-on-windows-2000/

    ReplyDelete
  5. FREE EncodePointerLib provides a library with "stubbed" EncodePointer/DecodePointer functions for Windows 2000

    http://mulder.googlecode.com/svn/!svn/bc/303/trunk/Utils/EncodePointerLib/

    Encode Pointer Library, by LoRd_MuldeR
    =======================================================

    This library was created to allow executables compiled with Visual C++ 2010 to run under Windows 2000.

    If you are not using the Visual C++ 2010 compiler or if you don't care about Windows 2000, then this library is not for you ;-)

    Also note that this is experimental. There is absolutely no guarantee that your program will work properly this way!

    ReplyDelete
  6. I approved the comment from Anonymous about EncodePointerLib because someone might find it helpful, but it's important to note that it's GPL and therefore, if you have a commercial application, don't even waste your time looking at it.

    At three lines of assembly code, this may be the smallest GPL project, ever. What a waste. The project would be much more useful if it were MIT License or Public Domain.

    ReplyDelete
  7. At three lines of assembly code it shouldn't be hard for you to implement a MIT license or public domain implementation of your own if you feel it's such a waste.

    ReplyDelete
    Replies
    1. Sorry, I don't think I made my point clearly. I think the library is very valuable, otherwise I wouldn't have mentioned it on my blog. It may only be three lines, but the research to build it was non-trivial.

      The waste is that the license prevents it from being used by the commercial market, which is where the vast majority of Windows 2000 boxes are located. Enthusiast/open source users are almost certainly not running Windows 2000. Therefore, the author has developed a very handy library, only to use a license that prohibits the people who need it most.

      Delete