VirtualBox

Changeset 96475 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Aug 25, 2022 2:27:54 AM (2 years ago)
Author:
vboxsync
Message:

IPRT: Resolve SetHandleInformation and GetHandleInformation dynamically and let the affected code deal with it specifically. Refactored the rtSocketCreate function to combine with setting inheritance, so we can use the WSA_FLAG_NO_HANDLE_INHERIT when available to avoid explicitly setting inheritance. Made RTSocketSetInheritance check the status before trying to set it, returning VERR_NET_NOT_UNSUPPORTED if tool old windows version. Also made GetVersionExW go via a function pointer since it wasn't there in NT 3.1. bugref:10261

Location:
trunk/src/VBox/Runtime/r3
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/localipc-posix.cpp

    r96407 r96475  
    242242                 * Create the local (unix) socket and bind to it.
    243243                 */
    244                 rc = rtSocketCreate(&pThis->hSocket, AF_LOCAL, SOCK_STREAM, 0 /*iProtocol*/);
     244                rc = rtSocketCreate(&pThis->hSocket, AF_LOCAL, SOCK_STREAM, 0 /*iProtocol*/, false /*fInheritable*/);
    245245                if (RT_SUCCESS(rc))
    246246                {
    247                     RTSocketSetInheritance(pThis->hSocket, false /*fInheritable*/);
    248247                    signal(SIGPIPE, SIG_IGN); /* Required on solaris, at least. */
    249248
     
    561560                 * Create the local (unix) socket and try connect to the server.
    562561                 */
    563                 rc = rtSocketCreate(&pThis->hSocket, AF_LOCAL, SOCK_STREAM, 0 /*iProtocol*/);
     562                rc = rtSocketCreate(&pThis->hSocket, AF_LOCAL, SOCK_STREAM, 0 /*iProtocol*/, false /*fInheritable*/);
    564563                if (RT_SUCCESS(rc))
    565564                {
    566                     RTSocketSetInheritance(pThis->hSocket, false /*fInheritable*/);
    567565                    signal(SIGPIPE, SIG_IGN); /* Required on solaris, at least. */
    568566
  • trunk/src/VBox/Runtime/r3/socket.cpp

    r96407 r96475  
    572572 * @param   iType               The socket type (SOCK_XXX).
    573573 * @param   iProtocol           Socket parameter, usually 0.
    574  */
    575 DECLHIDDEN(int) rtSocketCreate(PRTSOCKET phSocket, int iDomain, int iType, int iProtocol)
     574 * @param   fInheritable        Set to true if the socket should be inherted by
     575 *                              child processes, false if not inheritable.
     576 */
     577DECLHIDDEN(int) rtSocketCreate(PRTSOCKET phSocket, int iDomain, int iType, int iProtocol, bool fInheritable)
    576578{
    577579#ifdef RT_OS_WINDOWS
     
    587589    /*
    588590     * Create the socket.
    589      */
    590 #ifdef RT_OS_WINDOWS
    591     RTSOCKETNATIVE hNative = g_pfnsocket(iDomain, iType, iProtocol);
     591     *
     592     * The RTSocketSetInheritance operation isn't necessarily reliable on windows,
     593     * so try use WSA_FLAG_NO_HANDLE_INHERIT with WSASocketW when possible.
     594     */
     595#ifdef RT_OS_WINDOWS
     596    bool           fCallSetInheritance = true;
     597    RTSOCKETNATIVE hNative;
     598    if (g_pfnWSASocketW)
     599    {
     600        DWORD fWsaFlags = WSA_FLAG_OVERLAPPED | (!fInheritable ? WSA_FLAG_NO_HANDLE_INHERIT : 0);
     601        hNative = g_pfnWSASocketW(iDomain, iType, iProtocol, NULL, 0 /*Group*/, fWsaFlags);
     602        if (hNative != NIL_RTSOCKETNATIVE)
     603            fCallSetInheritance = false;
     604        else
     605        {
     606            if (!fInheritable)
     607                hNative = g_pfnsocket(iDomain, iType, iProtocol);
     608            if (hNative == NIL_RTSOCKETNATIVE)
     609                return rtSocketError();
     610        }
     611    }
     612    else
     613    {
     614        hNative = g_pfnsocket(iDomain, iType, iProtocol);
     615        if (hNative == NIL_RTSOCKETNATIVE)
     616            return rtSocketError();
     617    }
    592618#else
    593619    RTSOCKETNATIVE hNative = socket(iDomain, iType, iProtocol);
    594 #endif
    595620    if (hNative == NIL_RTSOCKETNATIVE)
    596621        return rtSocketError();
     622#endif
    597623
    598624    /*
     
    600626     */
    601627    int rc = rtSocketCreateForNative(phSocket, hNative, false /*fLeaveOpen*/);
    602     if (RT_FAILURE(rc))
     628    if (RT_SUCCESS(rc))
     629    {
     630#ifdef RT_OS_WINDOWS
     631        if (fCallSetInheritance)
     632#endif
     633            RTSocketSetInheritance(*phSocket, fInheritable);
     634    }
     635    else
    603636    {
    604637#ifdef RT_OS_WINDOWS
     
    943976    AssertReturn(RTMemPoolRefCount(pThis) >= (pThis->cUsers ? 2U : 1U), VERR_CALLER_NO_REFERENCE);
    944977
    945     int rc = VINF_SUCCESS;
    946 #ifdef RT_OS_WINDOWS
    947     if (!SetHandleInformation((HANDLE)pThis->hNative, HANDLE_FLAG_INHERIT, fInheritable ? HANDLE_FLAG_INHERIT : 0))
    948         rc = RTErrConvertFromWin32(GetLastError());
     978#ifndef RT_OS_WINDOWS
     979    if (fcntl(pThis->hNative, F_SETFD, fInheritable ? 0 : FD_CLOEXEC) < 0)
     980        return RTErrConvertFromErrno(errno);
     981    return VINF_SUCCESS;
    949982#else
    950     if (fcntl(pThis->hNative, F_SETFD, fInheritable ? 0 : FD_CLOEXEC) < 0)
    951         rc = RTErrConvertFromErrno(errno);
    952 #endif
    953 
    954     return rc;
     983    /* Windows is more complicated as sockets are complicated wrt inheritance
     984       (see stackoverflow for details).  In general, though we cannot hope to
     985       make a socket really non-inheritable before vista as other layers in
     986       the winsock maze may have additional handles associated with the socket. */
     987    if (g_pfnGetHandleInformation)
     988    {
     989        /* Check if the handle is already in what seems to be the right state
     990           before we try doing anything. */
     991        DWORD fFlags;
     992        if (g_pfnGetHandleInformation((HANDLE)pThis->hNative, &fFlags))
     993        {
     994            if (RT_BOOL(fFlags & HANDLE_FLAG_INHERIT) == fInheritable)
     995                return VINF_SUCCESS;
     996        }
     997    }
     998
     999    if (!g_pfnSetHandleInformation)
     1000        return VERR_NET_NOT_UNSUPPORTED;
     1001
     1002    if (!g_pfnSetHandleInformation((HANDLE)pThis->hNative, HANDLE_FLAG_INHERIT, fInheritable ? HANDLE_FLAG_INHERIT : 0))
     1003        return RTErrConvertFromWin32(GetLastError());
     1004    /** @todo Need we do something related to WS_SIO_ASSOCIATE_HANDLE or
     1005     *        WS_SIO_TRANSLATE_HANDLE? Or what  other handles could be associated
     1006     *        with the socket? that we need to modify? */
     1007
     1008    return VINF_SUCCESS;
     1009#endif
    9551010}
    9561011
  • trunk/src/VBox/Runtime/r3/tcp.cpp

    r96407 r96475  
    332332     */
    333333    RTSOCKET WaitSock;
    334     rc = rtSocketCreate(&WaitSock, AF_INET, SOCK_STREAM, IPPROTO_TCP);
     334    rc = rtSocketCreate(&WaitSock, AF_INET, SOCK_STREAM, IPPROTO_TCP, false /*fInheritable*/);
    335335    if (RT_SUCCESS(rc))
    336336    {
    337         RTSocketSetInheritance(WaitSock, false /*fInheritable*/);
    338 
    339337        /*
    340338         * Set socket options.
     
    343341        if (!rtSocketSetOpt(WaitSock, SOL_SOCKET, SO_REUSEADDR, &fFlag, sizeof(fFlag)))
    344342        {
    345 
    346343            /*
    347344             * Bind a name to a socket and set it listening for connections.
     
    842839     */
    843840    RTSOCKET Sock;
    844     rc = rtSocketCreate(&Sock, PF_INET, SOCK_STREAM, 0);
     841    rc = rtSocketCreate(&Sock, PF_INET, SOCK_STREAM, 0, false /*fInheritable*/);
    845842    if (RT_SUCCESS(rc))
    846843    {
    847         RTSocketSetInheritance(Sock, false /*fInheritable*/);
    848 
    849844        if (!ppCancelCookie)
    850845            rc = rtSocketConnect(Sock, &Addr, cMillies);
  • trunk/src/VBox/Runtime/r3/udp.cpp

    r96407 r96475  
    303303     */
    304304    RTSOCKET Sock;
    305     rc = rtSocketCreate(&Sock, AF_INET, SOCK_DGRAM, IPPROTO_UDP);
     305    rc = rtSocketCreate(&Sock, AF_INET, SOCK_DGRAM, IPPROTO_UDP, false /*fInheritable*/);
    306306    if (RT_SUCCESS(rc))
    307307    {
    308         RTSocketSetInheritance(Sock, false /*fInheritable*/);
    309 
    310308        /*
    311309         * Set socket options.
     
    719717     */
    720718    RTSOCKET Sock;
    721     rc = rtSocketCreate(&Sock, AF_INET, SOCK_DGRAM, 0);
     719    rc = rtSocketCreate(&Sock, AF_INET, SOCK_DGRAM, 0, false /*fInheritable*/);
    722720    if (RT_SUCCESS(rc))
    723721    {
    724         RTSocketSetInheritance(Sock, false /* fInheritable */);
    725722        if (pLocalAddr)
    726723            rc = rtSocketBind(Sock, pLocalAddr);
  • trunk/src/VBox/Runtime/r3/win/RTHandleGetStandard-win.cpp

    r96407 r96475  
    5151
    5252#include "internal/socket.h"            /* (Needs Windows.h.) */
     53#include "internal-r3-win.h"            /* (Needs Windows.h.) */
    5354
    5455
     
    7778        return RTErrConvertFromWin32(GetLastError());
    7879
    79     DWORD dwInfo;
    80     if (!GetHandleInformation(hNative, &dwInfo))
     80    DWORD dwInfo = 0;
     81    if (g_pfnGetHandleInformation && !g_pfnGetHandleInformation(hNative, &dwInfo))
    8182        return RTErrConvertFromWin32(GetLastError());
    8283    bool const fInherit = RT_BOOL(dwInfo & HANDLE_FLAG_INHERIT);
    8384
     85    SetLastError(NO_ERROR);
    8486    RTHANDLE h;
    8587    DWORD    dwType = GetFileType(hNative);
    8688    switch (dwType & ~FILE_TYPE_REMOTE)
    8789    {
     90        case FILE_TYPE_UNKNOWN:
     91            if (GetLastError() != NO_ERROR)
     92                return RTErrConvertFromWin32(GetLastError());
     93            RT_FALL_THROUGH();
    8894        default:
    89         case FILE_TYPE_UNKNOWN:
    9095        case FILE_TYPE_CHAR:
    9196        case FILE_TYPE_DISK:
  • trunk/src/VBox/Runtime/r3/win/init-win.cpp

    r96448 r96475  
    8787static LPTOP_LEVEL_EXCEPTION_FILTER             g_pfnUnhandledXcptFilter = NULL;
    8888/** SystemTimeToTzSpecificLocalTime. */
    89 DECL_HIDDEN_DATA(decltype(SystemTimeToTzSpecificLocalTime) *) g_pfnSystemTimeToTzSpecificLocalTime = NULL;
     89DECL_HIDDEN_DATA(decltype(SystemTimeToTzSpecificLocalTime) *)   g_pfnSystemTimeToTzSpecificLocalTime = NULL;
    9090/** CreateWaitableTimerEx . */
    91 DECL_HIDDEN_DATA(PFNCREATEWAITABLETIMEREX)      g_pfnCreateWaitableTimerExW = NULL;
     91DECL_HIDDEN_DATA(PFNCREATEWAITABLETIMEREX)                      g_pfnCreateWaitableTimerExW = NULL;
     92DECL_HIDDEN_DATA(decltype(GetHandleInformation) *)              g_pfnGetHandleInformation = NULL;
     93DECL_HIDDEN_DATA(decltype(SetHandleInformation) *)              g_pfnSetHandleInformation = NULL;
    9294
    9395/** The native ntdll.dll handle. */
     
    122124/** WSAEnumNetworkEvents */
    123125DECL_HIDDEN_DATA(PFNWSAENUMNETWORKEVENTS)       g_pfnWSAEnumNetworkEvents = NULL;
     126/** WSASocketW */
     127DECL_HIDDEN_DATA(PFNWSASOCKETW)                 g_pfnWSASocketW = NULL;
    124128/** WSASend */
    125 DECL_HIDDEN_DATA(PFNWSASend)                    g_pfnWSASend = NULL;
     129DECL_HIDDEN_DATA(PFNWSASEND)                    g_pfnWSASend = NULL;
    126130/** socket */
    127131DECL_HIDDEN_DATA(PFNWINSOCKSOCKET)              g_pfnsocket = NULL;
     
    311315
    312316    /*
    313      * Use the NT version of GetVersionExW so we don't get fooled by
    314      * compatability shims.
     317     * Use the NT version of RtlGetVersion (since w2k) so we don't get fooled
     318     * by compatability shims.
    315319     */
    316320    RT_ZERO(g_WinOsInfoEx);
     
    326330        /*
    327331         * Couldn't find it or it failed, try the windows version of the API.
     332         * The GetVersionExW API was added in NT 3.51.
    328333         */
    329334        RT_ZERO(g_WinOsInfoEx);
    330335        g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
    331         if (!GetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
     336
     337        BOOL (__stdcall *pfnGetVersionExW)(OSVERSIONINFOW *);
     338        *(FARPROC *)&pfnGetVersionExW = GetProcAddress(g_hModKernel32, "GetVersionExW");
     339
     340        if (!pfnGetVersionExW || !pfnGetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
    332341        {
    333342            /*
     
    336345            RT_ZERO(g_WinOsInfoEx);
    337346            g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
    338             if (GetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
     347            if (!pfnGetVersionExW || !pfnGetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
    339348                Assert(g_WinOsInfoEx.dwPlatformId != VER_PLATFORM_WIN32_NT || g_WinOsInfoEx.dwMajorVersion < 5);
    340349            else
    341350            {
     351                /*
     352                 * Okay, nothing worked, so use GetVersion.
     353                 * This should only happen if we're on NT 3.1 or NT 3.50.
     354                 * It should never happen for 64-bit builds.
     355                 */
     356#ifdef RT_ARCH_X86
     357                RT_ZERO(g_WinOsInfoEx);
     358                DWORD const dwVersion = GetVersion();
     359
     360                /* Common fields: */
     361                g_WinOsInfoEx.dwMajorVersion    = dwVersion & 0xff;
     362                g_WinOsInfoEx.dwMinorVersion    = (dwVersion >> 8) & 0xff;
     363                if (!(dwVersion & RT_BIT_32(31)))
     364                    g_WinOsInfoEx.dwBuildNumber = dwVersion >> 16;
     365                else
     366                    g_WinOsInfoEx.dwBuildNumber = 511;
     367                g_WinOsInfoEx.dwPlatformId      = VER_PLATFORM_WIN32_NT;
     368                g_WinOsInfoEx.wProductType      = VER_NT_WORKSTATION;
     369                /** @todo get CSD from registry. */
     370#else
    342371                AssertBreakpoint();
    343372                RT_ZERO(g_WinOsInfoEx);
     373#endif
    344374            }
    345375        }
     
    389419    g_pfnWSAEventSelect       = (decltype(g_pfnWSAEventSelect))     GetProcAddress(g_hModWinSock, "WSAEventSelect");
    390420    g_pfnWSAEnumNetworkEvents = (decltype(g_pfnWSAEnumNetworkEvents))GetProcAddress(g_hModWinSock,"WSAEnumNetworkEvents");
     421    g_pfnWSASocketW           = (decltype(g_pfnWSASocketW))         GetProcAddress(g_hModWinSock, "WSASocketW");
    391422    g_pfnWSASend              = (decltype(g_pfnWSASend))            GetProcAddress(g_hModWinSock, "WSASend");
    392423    g_pfnsocket               = (decltype(g_pfnsocket))             GetProcAddress(g_hModWinSock, "socket");
     
    419450    Assert(g_pfnWSAEventSelect       || g_fOldWinSock);
    420451    Assert(g_pfnWSAEnumNetworkEvents || g_fOldWinSock);
     452    Assert(g_pfnWSASocketW           || g_fOldWinSock);
    421453    Assert(g_pfnWSASend              || g_fOldWinSock);
    422454    Assert(g_pfnsocket);
     
    530562     * present in older windows versions.
    531563     */
    532     g_pfnGetSystemWindowsDirectoryW = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetSystemWindowsDirectoryW");
     564    g_pfnGetSystemWindowsDirectoryW      = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetSystemWindowsDirectoryW");
    533565    if (g_pfnGetSystemWindowsDirectoryW)
    534         g_pfnGetSystemWindowsDirectoryW = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetWindowsDirectoryW");
     566        g_pfnGetSystemWindowsDirectoryW  = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetWindowsDirectoryW");
    535567    g_pfnSystemTimeToTzSpecificLocalTime = (decltype(SystemTimeToTzSpecificLocalTime) *)GetProcAddress(g_hModKernel32, "SystemTimeToTzSpecificLocalTime");
    536     g_pfnCreateWaitableTimerExW = (PFNCREATEWAITABLETIMEREX)GetProcAddress(g_hModKernel32, "CreateWaitableTimerExW");
     568    g_pfnCreateWaitableTimerExW     = (PFNCREATEWAITABLETIMEREX)        GetProcAddress(g_hModKernel32, "CreateWaitableTimerExW");
     569    g_pfnGetHandleInformation       = (decltype(GetHandleInformation) *)GetProcAddress(g_hModKernel32, "GetHandleInformation");
     570    g_pfnSetHandleInformation       = (decltype(SetHandleInformation) *)GetProcAddress(g_hModKernel32, "SetHandleInformation");
     571    Assert(g_pfnSetHandleInformation || g_enmWinVer < kRTWinOSType_NT351);
     572    Assert(g_pfnGetHandleInformation || g_enmWinVer < kRTWinOSType_NT351);
    537573
    538574    /*
    539575     * Resolve some ntdll.dll APIs that weren't there in early NT versions.
    540576     */
    541     g_pfnNtQueryFullAttributesFile = (PFNNTQUERYFULLATTRIBUTESFILE)GetProcAddress(g_hModNtDll, "NtQueryFullAttributesFile");
    542     g_pfnNtDuplicateToken          = (PFNNTDUPLICATETOKEN)GetProcAddress(         g_hModNtDll, "NtDuplicateToken");
    543     g_pfnNtAlertThread             = (decltype(NtAlertThread) *)GetProcAddress(   g_hModNtDll, "NtAlertThread");
     577    g_pfnNtQueryFullAttributesFile  = (PFNNTQUERYFULLATTRIBUTESFILE)GetProcAddress(g_hModNtDll, "NtQueryFullAttributesFile");
     578    g_pfnNtDuplicateToken           = (PFNNTDUPLICATETOKEN)GetProcAddress(         g_hModNtDll, "NtDuplicateToken");
     579    g_pfnNtAlertThread              = (decltype(NtAlertThread) *)GetProcAddress(   g_hModNtDll, "NtAlertThread");
    544580
    545581    /*
  • trunk/src/VBox/Runtime/r3/win/internal-r3-win.h

    r96407 r96475  
    117117typedef UINT (WINAPI *PFNGETWINSYSDIR)(LPWSTR,UINT);
    118118extern DECL_HIDDEN_DATA(PFNGETWINSYSDIR)                g_pfnGetSystemWindowsDirectoryW;
    119 extern DECL_HIDDEN_DATA(decltype(SystemTimeToTzSpecificLocalTime) *) g_pfnSystemTimeToTzSpecificLocalTime;
     119extern DECL_HIDDEN_DATA(decltype(SystemTimeToTzSpecificLocalTime) *)    g_pfnSystemTimeToTzSpecificLocalTime;
    120120typedef HANDLE (WINAPI *PFNCREATEWAITABLETIMEREX)(LPSECURITY_ATTRIBUTES, LPCWSTR, DWORD, DWORD);
    121121extern DECL_HIDDEN_DATA(PFNCREATEWAITABLETIMEREX)       g_pfnCreateWaitableTimerExW;
     122extern DECL_HIDDEN_DATA(decltype(GetHandleInformation) *)               g_pfnGetHandleInformation;
     123extern DECL_HIDDEN_DATA(decltype(SetHandleInformation) *)               g_pfnSetHandleInformation;
     124typedef UINT (WINAPI *PFNGETWINSYSDIR)(LPWSTR,UINT);
     125extern DECL_HIDDEN_DATA(PFNGETWINSYSDIR)                g_pfnGetSystemWindowsDirectoryW;
     126
    122127
    123128extern DECL_HIDDEN_DATA(HMODULE)                        g_hModNtDll;
     
    150155/** WSAEnumNetworkEvents */
    151156typedef int             (WINAPI *PFNWSAENUMNETWORKEVENTS)(UINT_PTR, HANDLE, struct _WSANETWORKEVENTS *);
     157/** WSASocketW */
     158typedef UINT_PTR        (WINAPI *PFNWSASOCKETW)(int, int, int, struct _WSAPROTOCOL_INFOW *, unsigned, DWORD);
    152159/** WSASend */
    153 typedef int             (WINAPI *PFNWSASend)(UINT_PTR, struct _WSABUF *, DWORD, LPDWORD, DWORD dwFlags, struct _OVERLAPPED *, uintptr_t /*LPWSAOVERLAPPED_COMPLETION_ROUTINE*/);
     160typedef int             (WINAPI *PFNWSASEND)(UINT_PTR, struct _WSABUF *, DWORD, LPDWORD, DWORD dwFlags,
     161                                             struct _OVERLAPPED *, uintptr_t /*LPWSAOVERLAPPED_COMPLETION_ROUTINE*/);
    154162
    155163/** socket */
     
    201209extern DECL_HIDDEN_DATA(PFNWSAEVENTSELECT)               g_pfnWSAEventSelect;
    202210extern DECL_HIDDEN_DATA(PFNWSAENUMNETWORKEVENTS)         g_pfnWSAEnumNetworkEvents;
    203 extern DECL_HIDDEN_DATA(PFNWSASend)                      g_pfnWSASend;
     211extern DECL_HIDDEN_DATA(PFNWSASOCKETW)                   g_pfnWSASocketW;
     212extern DECL_HIDDEN_DATA(PFNWSASEND)                      g_pfnWSASend;
    204213extern DECL_HIDDEN_DATA(PFNWINSOCKSOCKET)                g_pfnsocket;
    205214extern DECL_HIDDEN_DATA(PFNWINSOCKCLOSESOCKET)           g_pfnclosesocket;
  • trunk/src/VBox/Runtime/r3/win/pipe-win.cpp

    r96407 r96475  
    520520            FILE_PIPE_LOCAL_INFORMATION Info;
    521521            RT_ZERO(Info);
    522             if (   g_enmWinVer != kRTWinOSType_NT310
     522            if (   g_pfnSetHandleInformation
    523523                && rtPipeQueryNtInfo(pThis, &Info))
    524524                rc = VINF_SUCCESS;
     
    563563                if (   RT_SUCCESS(rc)
    564564                    && hNative2 == INVALID_HANDLE_VALUE
    565                     && !SetHandleInformation(hNative,
    566                                              HANDLE_FLAG_INHERIT /*dwMask*/,
    567                                              fFlags & RTPIPE_N_INHERIT ? HANDLE_FLAG_INHERIT : 0))
     565                    && !g_pfnSetHandleInformation(hNative,
     566                                                  HANDLE_FLAG_INHERIT /*dwMask*/,
     567                                                  fFlags & RTPIPE_N_INHERIT ? HANDLE_FLAG_INHERIT : 0))
    568568                {
    569569                    rc = RTErrConvertFromWin32(GetLastError());
  • trunk/src/VBox/Runtime/r3/win/process-win.cpp

    r96407 r96475  
    23802380            if (*aphStds[i] != INVALID_HANDLE_VALUE)
    23812381            {
    2382                 if (g_enmWinVer == kRTWinOSType_NT310)
     2382                if (!g_pfnGetHandleInformation)
    23832383                    afInhStds[i] = 0; /* No handle info on NT 3.1, so ASSUME it is not inheritable. */
    2384                 else if (!GetHandleInformation(*aphStds[i], &afInhStds[i]))
     2384                else if (!g_pfnGetHandleInformation(*aphStds[i], &afInhStds[i]))
    23852385                {
    23862386                    rc = RTErrConvertFromWin32(GetLastError());
     
    24042404            && !(afInhStds[i] & HANDLE_FLAG_INHERIT))
    24052405        {
    2406             if (g_enmWinVer == kRTWinOSType_NT310)
     2406            if (!g_pfnSetHandleInformation)
    24072407            {
    24082408                if (DuplicateHandle(GetCurrentProcess(), *aphStds[i], GetCurrentProcess(), &ahStdDups[i],
     
    24152415                }
    24162416            }
    2417             else if (!SetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
     2417            else if (!g_pfnSetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
    24182418            {
    24192419                rc = RTErrConvertFromWin32(GetLastError());
     
    25292529    }
    25302530
    2531     if (g_enmWinVer != kRTWinOSType_NT310)
     2531    if (g_pfnSetHandleInformation)
    25322532    {
    25332533        /* Undo any handle inherit changes. */
     
    25362536                && !(afInhStds[i] & HANDLE_FLAG_INHERIT))
    25372537            {
    2538                 if (   !SetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, 0)
     2538                if (   !g_pfnSetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, 0)
    25392539                    && (   GetLastError() != ERROR_INVALID_FUNCTION
    25402540                        || g_enmWinVer != kRTWinOSType_NT310) )
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette