VirtualBox

Changeset 95844 in vbox


Ignore:
Timestamp:
Jul 26, 2022 9:43:10 PM (2 years ago)
Author:
vboxsync
Message:

IPRT/nocrt-streams-win.cpp: Fake a little so VBoxService might be happy with us. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/nocrt-streams-win.cpp

    r93115 r95844  
    3535
    3636#include <iprt/ctype.h>
     37#include <iprt/file.h>
    3738#include <iprt/string.h>
    3839
     
    4445typedef struct PRINTFBUF
    4546{
    46     HANDLE  hHandle;
     47    HANDLE  hNative;
    4748    size_t  offBuf;
    4849    char    szBuf[128];
     
    5253{
    5354    int     iStream;
    54     HANDLE  hHandle;
     55    HANDLE  hNative;
     56    RTFILE  hFile;
    5557};
    5658
     
    5961*   Defined Constants And Macros                                                                                                 *
    6062*********************************************************************************************************************************/
     63#define MAKE_SURE_WE_HAVE_HFILE_RETURN(a_pStream) do { \
     64        if ((a_pStream)->hFile != NIL_RTFILE) \
     65            break; \
     66        int rc = RTFileFromNative(&(a_pStream)->hFile, (uintptr_t)(a_pStream)->hNative); \
     67        AssertRCReturn(rc, rc); \
     68    } while (0)
     69
     70
     71/*********************************************************************************************************************************
     72*   Global Variables                                                                                                             *
     73*********************************************************************************************************************************/
    6174RTSTREAM g_aStdStreams[3] =
    6275{
    63     { 0, NULL },
    64     { 1, NULL },
    65     { 2, NULL },
     76    { 0, NULL, NIL_RTFILE },
     77    { 1, NULL, NIL_RTFILE },
     78    { 2, NULL, NIL_RTFILE },
    6679};
    6780
     
    7689    if (pParams)
    7790    {
    78         g_pStdIn->hHandle  = pParams->StandardInput;
    79         g_pStdOut->hHandle = pParams->StandardOutput;
    80         g_pStdErr->hHandle = pParams->StandardError;
     91        g_pStdIn->hNative  = pParams->StandardInput;
     92        g_pStdOut->hNative = pParams->StandardOutput;
     93        g_pStdErr->hNative = pParams->StandardError;
    8194    }
    8295}
     
    88101    {
    89102        DWORD cbWritten = 0;
    90         WriteFile(pBuf->hHandle, pBuf->szBuf, (DWORD)pBuf->offBuf, &cbWritten, NULL);
     103        WriteFile(pBuf->hNative, pBuf->szBuf, (DWORD)pBuf->offBuf, &cbWritten, NULL);
    91104        pBuf->offBuf   = 0;
    92105        pBuf->szBuf[0] = '\0';
     
    127140{
    128141    PRINTFBUF Buf;
    129     Buf.hHandle  = pStream->hHandle;
     142    Buf.hNative  = pStream->hNative;
    130143    Buf.offBuf   = 0;
    131144    Buf.szBuf[0] = '\0';
     
    148161{
    149162    PRINTFBUF Buf;
    150     Buf.hHandle  = g_pStdOut->hHandle;
     163    Buf.hNative  = g_pStdOut->hNative;
    151164    Buf.offBuf   = 0;
    152165    Buf.szBuf[0] = '\0';
     
    165178}
    166179
     180
     181#if 0
     182RTR3DECL(int) RTStrmReadEx(PRTSTREAM pStream, void *pvBuf, size_t cbToRead, size_t *pcbRead)
     183{
     184    MAKE_SURE_WE_HAVE_HFILE_RETURN(pStream);
     185    return RTFileRead(pStream->hFile, pvBuf, cbToRead, pcbRead);
     186}
     187#endif
     188
     189
     190RTR3DECL(int) RTStrmWriteEx(PRTSTREAM pStream, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
     191{
     192    MAKE_SURE_WE_HAVE_HFILE_RETURN(pStream);
     193    return RTFileWrite(pStream->hFile, pvBuf, cbToWrite, pcbWritten);
     194}
     195
     196
     197RTR3DECL(int) RTStrmFlush(PRTSTREAM pStream)
     198{
     199    MAKE_SURE_WE_HAVE_HFILE_RETURN(pStream);
     200    return RTFileFlush(pStream->hFile);
     201}
     202
     203
     204RTR3DECL(int) RTStrmSetMode(PRTSTREAM pStream, int fBinary, int fCurrentCodeSet)
     205{
     206    AssertReturn(fBinary != (int)false, VERR_NOT_IMPLEMENTED);
     207    AssertReturn(fCurrentCodeSet <= (int)false, VERR_NOT_IMPLEMENTED);
     208    RT_NOREF(pStream);
     209    return VINF_SUCCESS;
     210}
     211
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