Ignore:
Timestamp:
Jan 30, 2003, 3:00:47 PM (23 years ago)
Author:
sandervl
Message:

CreateProcess changes for parsing the application name and command line strings

File:
1 edited

Legend:

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

    r9693 r9743  
    1 /* $Id: wprocess.cpp,v 1.176 2003-01-20 10:46:28 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.177 2003-01-30 14:00:47 sandervl Exp $ */
    22
    33/*
     
    18571857    }
    18581858
    1859     // open32 does not support DEBUG_ONLY_THIS_PROCESS
    1860     if(dwCreationFlags & DEBUG_ONLY_THIS_PROCESS)
    1861       dwCreationFlags |= DEBUG_PROCESS;
    1862 
    1863     if(O32_CreateProcess(lpApplicationName, lpCommandLine, lpProcessAttributes,
    1864                          lpThreadAttributes, bInheritHandles, dwCreationFlags,
    1865                          lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    1866                          lpProcessInfo) == TRUE)
    1867     {
    1868       if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)
    1869       {
    1870         if(pThreadDB->o.odin.pidDebuggee != 0)
    1871         {
    1872           // TODO: handle this
    1873           dprintf(("KERNEL32: CreateProcess ERROR: This thread is already a debugger\n"));
    1874         }
    1875         else
    1876         {
    1877           pThreadDB->o.odin.pidDebuggee = lpProcessInfo->dwProcessId;
    1878           OSLibStartDebugger((ULONG*)&pThreadDB->o.odin.pidDebuggee);
    1879         }
    1880       }
    1881       else pThreadDB->o.odin.pidDebuggee = 0;
    1882 
    1883       if(lpProcessInfo)
    1884       {
    1885           lpProcessInfo->dwThreadId = MAKE_THREADID(lpProcessInfo->dwProcessId, lpProcessInfo->dwThreadId);
    1886       }
    1887 
    1888       return(TRUE);
    1889     }
    1890 
    1891     // PH 2001-05-07
    1892     // verify why O32_CreateProcess actually failed.
    1893     // If GetLastError() == 191 (ERROR_INVALID_EXE_SIGNATURE)
    1894     // we can continue to call "PE.EXE".
    1895     // Note: Open32 does not translate ERROR_INVALID_EXE_SIGNATURE,
    1896     // it is also valid in Win32.
    1897     DWORD dwError = GetLastError();
    1898     if (ERROR_INVALID_EXE_SIGNATURE != dwError && ERROR_FILE_NOT_FOUND != dwError && ERROR_ACCESS_DENIED != dwError)
    1899     {
    1900         dprintf(("CreateProcess: O32_CreateProcess failed with rc=%d, not PE-executable !",
    1901                 dwError));
    1902 
    1903         // the current value of GetLastError() is still valid.
    1904 
    1905         return FALSE;
    1906     }
    1907 
    1908     // else ...
    1909 
    1910     //probably a win32 exe, so run it in the pe loader
    19111859    if(lpApplicationName) {
    19121860        if(lpCommandLine) {
     
    19211869            cmdline = (char *)malloc(strlen(lpApplicationName)+strlen(lpCommandLine) + 16);
    19221870            sprintf(cmdline, "%s %s", lpApplicationName, lpCommandLine);
    1923          }
    1924          else {
     1871        }
     1872        else {
    19251873            cmdline = (char *)malloc(strlen(lpApplicationName) + 16);
    19261874            sprintf(cmdline, "%s", lpApplicationName);
     
    19361884    DWORD fileAttr;
    19371885    char *exename = buffer;
    1938     strncpy(buffer, cmdline, sizeof(szAppName));
     1886    strncpy(buffer, cmdline, sizeof(buffer));
    19391887    buffer[MAX_PATH-1] = 0;
    19401888    if(*exename == '"') {
     
    19851933    if(fileAttr == -1 || (fileAttr & FILE_ATTRIBUTE_DIRECTORY)) {
    19861934        dprintf(("CreateProcess: can't find executable!"));
     1935
     1936        if(cmdline)
     1937            free(cmdline);
     1938
    19871939        SetLastError(ERROR_FILE_NOT_FOUND);
    19881940        return FALSE;
    19891941    }
    19901942
     1943    // open32 does not support DEBUG_ONLY_THIS_PROCESS
     1944    if(dwCreationFlags & DEBUG_ONLY_THIS_PROCESS)
     1945      dwCreationFlags |= DEBUG_PROCESS;
     1946
     1947    if(O32_CreateProcess(szAppName, lpCommandLine, lpProcessAttributes,
     1948                         lpThreadAttributes, bInheritHandles, dwCreationFlags,
     1949                         lpEnvironment, lpCurrentDirectory, lpStartupInfo,
     1950                         lpProcessInfo) == TRUE)
     1951    {
     1952      if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)
     1953      {
     1954        if(pThreadDB->o.odin.pidDebuggee != 0)
     1955        {
     1956          // TODO: handle this
     1957          dprintf(("KERNEL32: CreateProcess ERROR: This thread is already a debugger\n"));
     1958        }
     1959        else
     1960        {
     1961          pThreadDB->o.odin.pidDebuggee = lpProcessInfo->dwProcessId;
     1962          OSLibStartDebugger((ULONG*)&pThreadDB->o.odin.pidDebuggee);
     1963        }
     1964      }
     1965      else pThreadDB->o.odin.pidDebuggee = 0;
     1966
     1967      if(lpProcessInfo)
     1968      {
     1969          lpProcessInfo->dwThreadId = MAKE_THREADID(lpProcessInfo->dwProcessId, lpProcessInfo->dwThreadId);
     1970      }
     1971
     1972      if(cmdline)
     1973          free(cmdline);
     1974      return(TRUE);
     1975    }
     1976
     1977    // PH 2001-05-07
     1978    // verify why O32_CreateProcess actually failed.
     1979    // If GetLastError() == 191 (ERROR_INVALID_EXE_SIGNATURE)
     1980    // we can continue to call "PE.EXE".
     1981    // Note: Open32 does not translate ERROR_INVALID_EXE_SIGNATURE,
     1982    // it is also valid in Win32.
     1983    DWORD dwError = GetLastError();
     1984    if (ERROR_INVALID_EXE_SIGNATURE != dwError && ERROR_FILE_NOT_FOUND != dwError && ERROR_ACCESS_DENIED != dwError)
     1985    {
     1986        dprintf(("CreateProcess: O32_CreateProcess failed with rc=%d, not PE-executable !",
     1987                dwError));
     1988
     1989        // the current value of GetLastError() is still valid.
     1990
     1991        if(cmdline)
     1992            free(cmdline);
     1993
     1994        return FALSE;
     1995    }
     1996
     1997    // else ...
     1998
     1999    //probably a win32 exe, so run it in the pe loader
    19912000    dprintf(("KERNEL32: CreateProcess %s %s", szAppName, lpCommandLine));
    19922001
Note: See TracChangeset for help on using the changeset viewer.