Index: trunk/src/VBox/Runtime/r3/win/RTHandleGetStandard-win.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/win/RTHandleGetStandard-win.cpp	(revision 96448)
+++ trunk/src/VBox/Runtime/r3/win/RTHandleGetStandard-win.cpp	(revision 96475)
@@ -51,4 +51,5 @@
 
 #include "internal/socket.h"            /* (Needs Windows.h.) */
+#include "internal-r3-win.h"            /* (Needs Windows.h.) */
 
 
@@ -77,15 +78,19 @@
         return RTErrConvertFromWin32(GetLastError());
 
-    DWORD dwInfo;
-    if (!GetHandleInformation(hNative, &dwInfo))
+    DWORD dwInfo = 0;
+    if (g_pfnGetHandleInformation && !g_pfnGetHandleInformation(hNative, &dwInfo))
         return RTErrConvertFromWin32(GetLastError());
     bool const fInherit = RT_BOOL(dwInfo & HANDLE_FLAG_INHERIT);
 
+    SetLastError(NO_ERROR);
     RTHANDLE h;
     DWORD    dwType = GetFileType(hNative);
     switch (dwType & ~FILE_TYPE_REMOTE)
     {
+        case FILE_TYPE_UNKNOWN:
+            if (GetLastError() != NO_ERROR)
+                return RTErrConvertFromWin32(GetLastError());
+            RT_FALL_THROUGH();
         default:
-        case FILE_TYPE_UNKNOWN:
         case FILE_TYPE_CHAR:
         case FILE_TYPE_DISK:
Index: trunk/src/VBox/Runtime/r3/win/init-win.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/win/init-win.cpp	(revision 96448)
+++ trunk/src/VBox/Runtime/r3/win/init-win.cpp	(revision 96475)
@@ -87,7 +87,9 @@
 static LPTOP_LEVEL_EXCEPTION_FILTER             g_pfnUnhandledXcptFilter = NULL;
 /** SystemTimeToTzSpecificLocalTime. */
-DECL_HIDDEN_DATA(decltype(SystemTimeToTzSpecificLocalTime) *) g_pfnSystemTimeToTzSpecificLocalTime = NULL;
+DECL_HIDDEN_DATA(decltype(SystemTimeToTzSpecificLocalTime) *)   g_pfnSystemTimeToTzSpecificLocalTime = NULL;
 /** CreateWaitableTimerEx . */
-DECL_HIDDEN_DATA(PFNCREATEWAITABLETIMEREX)      g_pfnCreateWaitableTimerExW = NULL;
+DECL_HIDDEN_DATA(PFNCREATEWAITABLETIMEREX)                      g_pfnCreateWaitableTimerExW = NULL;
+DECL_HIDDEN_DATA(decltype(GetHandleInformation) *)              g_pfnGetHandleInformation = NULL;
+DECL_HIDDEN_DATA(decltype(SetHandleInformation) *)              g_pfnSetHandleInformation = NULL;
 
 /** The native ntdll.dll handle. */
@@ -122,6 +124,8 @@
 /** WSAEnumNetworkEvents */
 DECL_HIDDEN_DATA(PFNWSAENUMNETWORKEVENTS)       g_pfnWSAEnumNetworkEvents = NULL;
+/** WSASocketW */
+DECL_HIDDEN_DATA(PFNWSASOCKETW)                 g_pfnWSASocketW = NULL;
 /** WSASend */
-DECL_HIDDEN_DATA(PFNWSASend)                    g_pfnWSASend = NULL;
+DECL_HIDDEN_DATA(PFNWSASEND)                    g_pfnWSASend = NULL;
 /** socket */
 DECL_HIDDEN_DATA(PFNWINSOCKSOCKET)              g_pfnsocket = NULL;
@@ -311,6 +315,6 @@
 
     /*
-     * Use the NT version of GetVersionExW so we don't get fooled by
-     * compatability shims.
+     * Use the NT version of RtlGetVersion (since w2k) so we don't get fooled
+     * by compatability shims.
      */
     RT_ZERO(g_WinOsInfoEx);
@@ -326,8 +330,13 @@
         /*
          * Couldn't find it or it failed, try the windows version of the API.
+         * The GetVersionExW API was added in NT 3.51.
          */
         RT_ZERO(g_WinOsInfoEx);
         g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
-        if (!GetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
+
+        BOOL (__stdcall *pfnGetVersionExW)(OSVERSIONINFOW *);
+        *(FARPROC *)&pfnGetVersionExW = GetProcAddress(g_hModKernel32, "GetVersionExW");
+
+        if (!pfnGetVersionExW || !pfnGetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
         {
             /*
@@ -336,10 +345,31 @@
             RT_ZERO(g_WinOsInfoEx);
             g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
-            if (GetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
+            if (!pfnGetVersionExW || !pfnGetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
                 Assert(g_WinOsInfoEx.dwPlatformId != VER_PLATFORM_WIN32_NT || g_WinOsInfoEx.dwMajorVersion < 5);
             else
             {
+                /*
+                 * Okay, nothing worked, so use GetVersion.
+                 * This should only happen if we're on NT 3.1 or NT 3.50.
+                 * It should never happen for 64-bit builds.
+                 */
+#ifdef RT_ARCH_X86
+                RT_ZERO(g_WinOsInfoEx);
+                DWORD const dwVersion = GetVersion();
+
+                /* Common fields: */
+                g_WinOsInfoEx.dwMajorVersion    = dwVersion & 0xff;
+                g_WinOsInfoEx.dwMinorVersion    = (dwVersion >> 8) & 0xff;
+                if (!(dwVersion & RT_BIT_32(31)))
+                    g_WinOsInfoEx.dwBuildNumber = dwVersion >> 16;
+                else
+                    g_WinOsInfoEx.dwBuildNumber = 511;
+                g_WinOsInfoEx.dwPlatformId      = VER_PLATFORM_WIN32_NT;
+                g_WinOsInfoEx.wProductType      = VER_NT_WORKSTATION;
+                /** @todo get CSD from registry. */
+#else
                 AssertBreakpoint();
                 RT_ZERO(g_WinOsInfoEx);
+#endif
             }
         }
@@ -389,4 +419,5 @@
     g_pfnWSAEventSelect       = (decltype(g_pfnWSAEventSelect))     GetProcAddress(g_hModWinSock, "WSAEventSelect");
     g_pfnWSAEnumNetworkEvents = (decltype(g_pfnWSAEnumNetworkEvents))GetProcAddress(g_hModWinSock,"WSAEnumNetworkEvents");
+    g_pfnWSASocketW           = (decltype(g_pfnWSASocketW))         GetProcAddress(g_hModWinSock, "WSASocketW");
     g_pfnWSASend              = (decltype(g_pfnWSASend))            GetProcAddress(g_hModWinSock, "WSASend");
     g_pfnsocket               = (decltype(g_pfnsocket))             GetProcAddress(g_hModWinSock, "socket");
@@ -419,4 +450,5 @@
     Assert(g_pfnWSAEventSelect       || g_fOldWinSock);
     Assert(g_pfnWSAEnumNetworkEvents || g_fOldWinSock);
+    Assert(g_pfnWSASocketW           || g_fOldWinSock);
     Assert(g_pfnWSASend              || g_fOldWinSock);
     Assert(g_pfnsocket);
@@ -530,16 +562,20 @@
      * present in older windows versions.
      */
-    g_pfnGetSystemWindowsDirectoryW = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetSystemWindowsDirectoryW");
+    g_pfnGetSystemWindowsDirectoryW      = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetSystemWindowsDirectoryW");
     if (g_pfnGetSystemWindowsDirectoryW)
-        g_pfnGetSystemWindowsDirectoryW = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetWindowsDirectoryW");
+        g_pfnGetSystemWindowsDirectoryW  = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetWindowsDirectoryW");
     g_pfnSystemTimeToTzSpecificLocalTime = (decltype(SystemTimeToTzSpecificLocalTime) *)GetProcAddress(g_hModKernel32, "SystemTimeToTzSpecificLocalTime");
-    g_pfnCreateWaitableTimerExW = (PFNCREATEWAITABLETIMEREX)GetProcAddress(g_hModKernel32, "CreateWaitableTimerExW");
+    g_pfnCreateWaitableTimerExW     = (PFNCREATEWAITABLETIMEREX)        GetProcAddress(g_hModKernel32, "CreateWaitableTimerExW");
+    g_pfnGetHandleInformation       = (decltype(GetHandleInformation) *)GetProcAddress(g_hModKernel32, "GetHandleInformation");
+    g_pfnSetHandleInformation       = (decltype(SetHandleInformation) *)GetProcAddress(g_hModKernel32, "SetHandleInformation");
+    Assert(g_pfnSetHandleInformation || g_enmWinVer < kRTWinOSType_NT351);
+    Assert(g_pfnGetHandleInformation || g_enmWinVer < kRTWinOSType_NT351);
 
     /*
      * Resolve some ntdll.dll APIs that weren't there in early NT versions.
      */
-    g_pfnNtQueryFullAttributesFile = (PFNNTQUERYFULLATTRIBUTESFILE)GetProcAddress(g_hModNtDll, "NtQueryFullAttributesFile");
-    g_pfnNtDuplicateToken          = (PFNNTDUPLICATETOKEN)GetProcAddress(         g_hModNtDll, "NtDuplicateToken");
-    g_pfnNtAlertThread             = (decltype(NtAlertThread) *)GetProcAddress(   g_hModNtDll, "NtAlertThread");
+    g_pfnNtQueryFullAttributesFile  = (PFNNTQUERYFULLATTRIBUTESFILE)GetProcAddress(g_hModNtDll, "NtQueryFullAttributesFile");
+    g_pfnNtDuplicateToken           = (PFNNTDUPLICATETOKEN)GetProcAddress(         g_hModNtDll, "NtDuplicateToken");
+    g_pfnNtAlertThread              = (decltype(NtAlertThread) *)GetProcAddress(   g_hModNtDll, "NtAlertThread");
 
     /*
Index: trunk/src/VBox/Runtime/r3/win/internal-r3-win.h
===================================================================
--- trunk/src/VBox/Runtime/r3/win/internal-r3-win.h	(revision 96448)
+++ trunk/src/VBox/Runtime/r3/win/internal-r3-win.h	(revision 96475)
@@ -117,7 +117,12 @@
 typedef UINT (WINAPI *PFNGETWINSYSDIR)(LPWSTR,UINT);
 extern DECL_HIDDEN_DATA(PFNGETWINSYSDIR)                g_pfnGetSystemWindowsDirectoryW;
-extern DECL_HIDDEN_DATA(decltype(SystemTimeToTzSpecificLocalTime) *) g_pfnSystemTimeToTzSpecificLocalTime;
+extern DECL_HIDDEN_DATA(decltype(SystemTimeToTzSpecificLocalTime) *)    g_pfnSystemTimeToTzSpecificLocalTime;
 typedef HANDLE (WINAPI *PFNCREATEWAITABLETIMEREX)(LPSECURITY_ATTRIBUTES, LPCWSTR, DWORD, DWORD);
 extern DECL_HIDDEN_DATA(PFNCREATEWAITABLETIMEREX)       g_pfnCreateWaitableTimerExW;
+extern DECL_HIDDEN_DATA(decltype(GetHandleInformation) *)               g_pfnGetHandleInformation;
+extern DECL_HIDDEN_DATA(decltype(SetHandleInformation) *)               g_pfnSetHandleInformation;
+typedef UINT (WINAPI *PFNGETWINSYSDIR)(LPWSTR,UINT);
+extern DECL_HIDDEN_DATA(PFNGETWINSYSDIR)                g_pfnGetSystemWindowsDirectoryW;
+
 
 extern DECL_HIDDEN_DATA(HMODULE)                        g_hModNtDll;
@@ -150,6 +155,9 @@
 /** WSAEnumNetworkEvents */
 typedef int             (WINAPI *PFNWSAENUMNETWORKEVENTS)(UINT_PTR, HANDLE, struct _WSANETWORKEVENTS *);
+/** WSASocketW */
+typedef UINT_PTR        (WINAPI *PFNWSASOCKETW)(int, int, int, struct _WSAPROTOCOL_INFOW *, unsigned, DWORD);
 /** WSASend */
-typedef int             (WINAPI *PFNWSASend)(UINT_PTR, struct _WSABUF *, DWORD, LPDWORD, DWORD dwFlags, struct _OVERLAPPED *, uintptr_t /*LPWSAOVERLAPPED_COMPLETION_ROUTINE*/);
+typedef int             (WINAPI *PFNWSASEND)(UINT_PTR, struct _WSABUF *, DWORD, LPDWORD, DWORD dwFlags,
+                                             struct _OVERLAPPED *, uintptr_t /*LPWSAOVERLAPPED_COMPLETION_ROUTINE*/);
 
 /** socket */
@@ -201,5 +209,6 @@
 extern DECL_HIDDEN_DATA(PFNWSAEVENTSELECT)               g_pfnWSAEventSelect;
 extern DECL_HIDDEN_DATA(PFNWSAENUMNETWORKEVENTS)         g_pfnWSAEnumNetworkEvents;
-extern DECL_HIDDEN_DATA(PFNWSASend)                      g_pfnWSASend;
+extern DECL_HIDDEN_DATA(PFNWSASOCKETW)                   g_pfnWSASocketW;
+extern DECL_HIDDEN_DATA(PFNWSASEND)                      g_pfnWSASend;
 extern DECL_HIDDEN_DATA(PFNWINSOCKSOCKET)                g_pfnsocket;
 extern DECL_HIDDEN_DATA(PFNWINSOCKCLOSESOCKET)           g_pfnclosesocket;
Index: trunk/src/VBox/Runtime/r3/win/pipe-win.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/win/pipe-win.cpp	(revision 96448)
+++ trunk/src/VBox/Runtime/r3/win/pipe-win.cpp	(revision 96475)
@@ -520,5 +520,5 @@
             FILE_PIPE_LOCAL_INFORMATION Info;
             RT_ZERO(Info);
-            if (   g_enmWinVer != kRTWinOSType_NT310
+            if (   g_pfnSetHandleInformation
                 && rtPipeQueryNtInfo(pThis, &Info))
                 rc = VINF_SUCCESS;
@@ -563,7 +563,7 @@
                 if (   RT_SUCCESS(rc)
                     && hNative2 == INVALID_HANDLE_VALUE
-                    && !SetHandleInformation(hNative,
-                                             HANDLE_FLAG_INHERIT /*dwMask*/,
-                                             fFlags & RTPIPE_N_INHERIT ? HANDLE_FLAG_INHERIT : 0))
+                    && !g_pfnSetHandleInformation(hNative,
+                                                  HANDLE_FLAG_INHERIT /*dwMask*/,
+                                                  fFlags & RTPIPE_N_INHERIT ? HANDLE_FLAG_INHERIT : 0))
                 {
                     rc = RTErrConvertFromWin32(GetLastError());
Index: trunk/src/VBox/Runtime/r3/win/process-win.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/win/process-win.cpp	(revision 96448)
+++ trunk/src/VBox/Runtime/r3/win/process-win.cpp	(revision 96475)
@@ -2380,7 +2380,7 @@
             if (*aphStds[i] != INVALID_HANDLE_VALUE)
             {
-                if (g_enmWinVer == kRTWinOSType_NT310)
+                if (!g_pfnGetHandleInformation)
                     afInhStds[i] = 0; /* No handle info on NT 3.1, so ASSUME it is not inheritable. */
-                else if (!GetHandleInformation(*aphStds[i], &afInhStds[i]))
+                else if (!g_pfnGetHandleInformation(*aphStds[i], &afInhStds[i]))
                 {
                     rc = RTErrConvertFromWin32(GetLastError());
@@ -2404,5 +2404,5 @@
             && !(afInhStds[i] & HANDLE_FLAG_INHERIT))
         {
-            if (g_enmWinVer == kRTWinOSType_NT310)
+            if (!g_pfnSetHandleInformation)
             {
                 if (DuplicateHandle(GetCurrentProcess(), *aphStds[i], GetCurrentProcess(), &ahStdDups[i],
@@ -2415,5 +2415,5 @@
                 }
             }
-            else if (!SetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
+            else if (!g_pfnSetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
             {
                 rc = RTErrConvertFromWin32(GetLastError());
@@ -2529,5 +2529,5 @@
     }
 
-    if (g_enmWinVer != kRTWinOSType_NT310)
+    if (g_pfnSetHandleInformation)
     {
         /* Undo any handle inherit changes. */
@@ -2536,5 +2536,5 @@
                 && !(afInhStds[i] & HANDLE_FLAG_INHERIT))
             {
-                if (   !SetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, 0)
+                if (   !g_pfnSetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, 0)
                     && (   GetLastError() != ERROR_INVALID_FUNCTION
                         || g_enmWinVer != kRTWinOSType_NT310) )
