Changeset 9660 for trunk/src


Ignore:
Timestamp:
Jan 10, 2003, 4:19:54 PM (23 years ago)
Author:
sandervl
Message:

changes for inheritance (check security structure); workaround for PeekNamedPipe with unnamed pipes; support input/output redirection for child processes

Location:
trunk/src/kernel32
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/HandleManager.cpp

    r9653 r9660  
    1 /* $Id: HandleManager.cpp,v 1.92 2003-01-10 12:57:11 sandervl Exp $ */
     1/* $Id: HandleManager.cpp,v 1.93 2003-01-10 15:19:53 sandervl Exp $ */
    22
    33/*
     
    11211121  else
    11221122  {
    1123     SetLastError(ERROR_SUCCESS); //@@@PH 1999/10/27 rc5desg requires this?
    1124 
    1125              /* copy data fields that might have been modified by CreateFile */
     1123    /* copy data fields that might have been modified by CreateFile */
    11261124    memcpy(&TabWin32Handles[iIndexNew].hmHandleData,
    11271125           &HMHandleTemp,
    11281126           sizeof(HMHANDLEDATA));
     1127
     1128    if(lpSecurityAttributes && lpSecurityAttributes->bInheritHandle) {
     1129        dprintf(("Set inheritance for child processes"));
     1130        HMSetHandleInformation(iIndexNew, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
     1131    }
     1132
     1133    SetLastError(ERROR_SUCCESS); //@@@PH 1999/10/27 rc5desg requires this?
    11291134  }
    11301135
     
    45134518  }
    45144519
     4520  dprintf(("Named pipe %x", iIndexNew));
     4521  if(lpSecurityAttributes && lpSecurityAttributes->bInheritHandle) {
     4522      dprintf(("Set inheritance for child processes"));
     4523      HMSetHandleInformation(iIndexNew, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
     4524  }
     4525
    45154526  return iIndexNew;
    45164527}
     
    47604771 *****************************************************************************/
    47614772BOOL HMCreatePipe(PHANDLE phRead,
    4762                 PHANDLE phWrite,
    4763                 LPSECURITY_ATTRIBUTES lpsa,
    4764                 DWORD                 cbPipe)
     4773                  PHANDLE phWrite,
     4774                  LPSECURITY_ATTRIBUTES lpsa,
     4775                  DWORD                 cbPipe)
    47654776{
    47664777  int             iIndex;                     /* index into the handle table */
     
    48344845  }
    48354846
     4847  dprintf(("Read pipe %x, Write pipe %x", iIndexNewRead, iIndexNewWrite));
     4848  if(lpsa && lpsa->bInheritHandle) {
     4849      dprintf(("Set inheritance for child processes"));
     4850      HMSetHandleInformation(iIndexNewRead, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
     4851      HMSetHandleInformation(iIndexNewWrite, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
     4852  }
     4853
    48364854  *phRead  = iIndexNewRead;
    48374855  *phWrite = iIndexNewWrite;
  • trunk/src/kernel32/hmnpipe.cpp

    r7929 r9660  
    1 /* $Id: hmnpipe.cpp,v 1.9 2002-02-15 20:15:55 sandervl Exp $ */
     1/* $Id: hmnpipe.cpp,v 1.10 2003-01-10 15:19:53 sandervl Exp $ */
    22/*
    33 * Project Odin Software License can be found in LICENSE.TXT
     
    201201                         lpsa,
    202202                         cbPipe))
    203     return TRUE;
     203  {
     204     return TRUE;
     205  }
    204206  else
    205     return(FALSE);
     207     return FALSE;
    206208}
    207209//******************************************************************************
    208210//******************************************************************************
    209211BOOL HMDeviceNamedPipeClass::ConnectNamedPipe( PHMHANDLEDATA pHMHandleData,
    210                                           LPOVERLAPPED lpOverlapped)
     212                                               LPOVERLAPPED lpOverlapped)
    211213{
    212214  dprintfl(("KERNEL32: HMDeviceNamedPipeClass::ConnectNamedPipe %s(%08x) [%08x]\n",
  • trunk/src/kernel32/oslibdos.cpp

    r9653 r9660  
    1 /* $Id: oslibdos.cpp,v 1.111 2003-01-10 12:57:13 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.112 2003-01-10 15:19:54 sandervl Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    18401840//******************************************************************************
    18411841BOOL OSLibDosPeekNamedPipe(DWORD   hPipe,
    1842                         LPVOID  lpvBuffer,
    1843                         DWORD   cbBuffer,
    1844                         LPDWORD lpcbRead,
    1845                         LPDWORD lpcbAvail,
    1846                         LPDWORD lpcbMessage)
     1842                           LPVOID  lpvBuffer,
     1843                           DWORD   cbBuffer,
     1844                           LPDWORD lpcbRead,
     1845                           LPDWORD lpcbAvail,
     1846                           LPDWORD lpcbMessage)
    18471847{
    18481848  DWORD     rc;
    18491849  AVAILDATA availData ={0};
    1850   ULONG     ulDummy;
    1851 
    1852   rc=DosPeekNPipe(hPipe,lpvBuffer,cbBuffer,lpcbRead,&availData,&ulDummy);
     1850  ULONG     ulState, ulRead, ulMessage;
     1851  char      buffer;
     1852
     1853  if(lpcbRead == NULL) {
     1854      lpcbRead = &ulRead;
     1855  }
     1856  if(lpcbMessage == NULL) {
     1857      lpcbMessage = &ulMessage;
     1858  }
     1859  if(lpvBuffer == NULL) {
     1860      lpvBuffer = &buffer;
     1861      cbBuffer = 0;
     1862  }
     1863
     1864  rc = DosPeekNPipe(hPipe,lpvBuffer,cbBuffer,lpcbRead,&availData,&ulState);
    18531865
    18541866  dprintf(("DosPeekNPipe returned rc=%d",rc));
    18551867
    1856   if (!rc)
    1857   {
    1858     *lpcbAvail   = availData.cbpipe;
    1859     *lpcbMessage = availData.cbmessage;
     1868  //OS/2 doesn't support DosPeekNPipe for unnamed pipes; win32 does
     1869  if (rc == 1) {
     1870     dprintf(("WARNING: Pretend broken pipe for PeekNamedPipe with unnamed pipe handle"));
     1871     SetLastError(ERROR_BROKEN_PIPE_W);
     1872     return FALSE;
     1873  }
     1874  if (rc == NO_ERROR)
     1875  {
     1876    if(lpcbAvail) {
     1877        *lpcbAvail   = availData.cbpipe;
     1878    }
     1879    if(lpcbMessage) {
     1880        *lpcbMessage = availData.cbmessage;
     1881    }
    18601882    SetLastError(ERROR_SUCCESS_W);
    18611883    return (TRUE);
  • trunk/src/kernel32/wprocess.cpp

    r9634 r9660  
    1 /* $Id: wprocess.cpp,v 1.170 2003-01-06 14:43:51 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.171 2003-01-10 15:19:54 sandervl Exp $ */
    22
    33/*
     
    18081808                            LPPROCESS_INFORMATION lpProcessInfo )
    18091809{
     1810 STARTUPINFOA startinfo;
    18101811 TEB *pThreadDB = (TEB*)GetThreadTEB();
    18111812 char *cmdline = NULL;
     
    18181819#ifdef DEBUG
    18191820    if(lpStartupInfo) {
    1820     dprintf(("lpStartupInfo->lpReserved %x", lpStartupInfo->lpReserved));
    1821     dprintf(("lpStartupInfo->lpDesktop %x", lpStartupInfo->lpDesktop));
    1822     dprintf(("lpStartupInfo->lpTitle %s", lpStartupInfo->lpTitle));
    1823     dprintf(("lpStartupInfo->dwX %x", lpStartupInfo->dwX));
    1824     dprintf(("lpStartupInfo->dwY %x", lpStartupInfo->dwY));
    1825     dprintf(("lpStartupInfo->dwXSize %x", lpStartupInfo->dwXSize));
    1826     dprintf(("lpStartupInfo->dwYSize %x", lpStartupInfo->dwYSize));
    1827     dprintf(("lpStartupInfo->dwXCountChars %x", lpStartupInfo->dwXCountChars));
    1828     dprintf(("lpStartupInfo->dwYCountChars %x", lpStartupInfo->dwYCountChars));
    1829     dprintf(("lpStartupInfo->dwFillAttribute %x", lpStartupInfo->dwFillAttribute));
    1830     dprintf(("lpStartupInfo->dwFlags %x", lpStartupInfo->dwFlags));
    1831     dprintf(("lpStartupInfo->wShowWindow %x", lpStartupInfo->wShowWindow));
    1832     dprintf(("lpStartupInfo->hStdInput %x", lpStartupInfo->hStdInput));
    1833     dprintf(("lpStartupInfo->hStdOutput %x", lpStartupInfo->hStdOutput));
    1834     dprintf(("lpStartupInfo->hStdError %x", lpStartupInfo->hStdError));
     1821        dprintf(("lpStartupInfo->lpReserved %x", lpStartupInfo->lpReserved));
     1822        dprintf(("lpStartupInfo->lpDesktop %x", lpStartupInfo->lpDesktop));
     1823        dprintf(("lpStartupInfo->lpTitle %s", lpStartupInfo->lpTitle));
     1824        dprintf(("lpStartupInfo->dwX %x", lpStartupInfo->dwX));
     1825        dprintf(("lpStartupInfo->dwY %x", lpStartupInfo->dwY));
     1826        dprintf(("lpStartupInfo->dwXSize %x", lpStartupInfo->dwXSize));
     1827        dprintf(("lpStartupInfo->dwYSize %x", lpStartupInfo->dwYSize));
     1828        dprintf(("lpStartupInfo->dwXCountChars %x", lpStartupInfo->dwXCountChars));
     1829        dprintf(("lpStartupInfo->dwYCountChars %x", lpStartupInfo->dwYCountChars));
     1830        dprintf(("lpStartupInfo->dwFillAttribute %x", lpStartupInfo->dwFillAttribute));
     1831        dprintf(("lpStartupInfo->dwFlags %x", lpStartupInfo->dwFlags));
     1832        dprintf(("lpStartupInfo->wShowWindow %x", lpStartupInfo->wShowWindow));
     1833        dprintf(("lpStartupInfo->hStdInput %x", lpStartupInfo->hStdInput));
     1834        dprintf(("lpStartupInfo->hStdOutput %x", lpStartupInfo->hStdOutput));
     1835        dprintf(("lpStartupInfo->hStdError %x", lpStartupInfo->hStdError));
    18351836    }
    18361837#endif
     1838
     1839    if(bInheritHandles && lpStartupInfo->dwFlags & STARTF_USESTDHANDLES)
     1840    {
     1841        //Translate standard handles if the child needs to inherit them
     1842        int retcode = 0;
     1843
     1844        memcpy(&startinfo, lpStartupInfo, sizeof(startinfo));
     1845        retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdInput, &startinfo.hStdInput);
     1846        retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdOutput, &startinfo.hStdOutput);
     1847        retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdError, &startinfo.hStdError);
     1848
     1849        if(retcode) { 
     1850            SetLastError(ERROR_INVALID_HANDLE);
     1851            return FALSE;
     1852        }
     1853
     1854        lpStartupInfo = &startinfo;
     1855    }
    18371856
    18381857    // open32 does not support DEBUG_ONLY_THIS_PROCESS
Note: See TracChangeset for help on using the changeset viewer.