Ignore:
Timestamp:
Feb 28, 2003, 12:32:28 PM (22 years ago)
Author:
sandervl
Message:

Fixed CreateProcessA regression (Lotus Notes)

File:
1 edited

Legend:

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

    r9850 r9878  
    1 /* $Id: wprocess.cpp,v 1.182 2003-02-24 17:02:17 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.183 2003-02-28 11:32:28 sandervl Exp $ */
    22
    33/*
     
    19951995    }
    19961996
     1997    DWORD Characteristics, SubSystem, fNEExe, fPEExe;
     1998
     1999    fPEExe = Win32ImageBase::isPEImage(szAppName, &Characteristics, &SubSystem, &fNEExe) == 0;
     2000
    19972001    // open32 does not support DEBUG_ONLY_THIS_PROCESS
    19982002    if(dwCreationFlags & DEBUG_ONLY_THIS_PROCESS)
    19992003      dwCreationFlags |= DEBUG_PROCESS;
    20002004
    2001     if(O32_CreateProcess(szAppName, lpCommandLine, lpProcessAttributes,
     2005    //Only use WGSS to launch the app if it's not PE or PE & win32k loaded
     2006    if(!fPEExe || (fPEExe && fWin32k))
     2007    {
     2008      if(O32_CreateProcess(szAppName, lpCommandLine, lpProcessAttributes,
    20022009                         lpThreadAttributes, bInheritHandles, dwCreationFlags,
    20032010                         lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    20042011                         lpProcessInfo) == TRUE)
    2005     {
    2006       if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)
    20072012      {
    2008         if(pThreadDB->o.odin.pidDebuggee != 0)
    2009         {
    2010           // TODO: handle this
    2011           dprintf(("KERNEL32: CreateProcess ERROR: This thread is already a debugger\n"));
    2012         }
    2013         else
    2014         {
    2015           pThreadDB->o.odin.pidDebuggee = lpProcessInfo->dwProcessId;
    2016           OSLibStartDebugger((ULONG*)&pThreadDB->o.odin.pidDebuggee);
    2017         }
    2018       }
    2019       else pThreadDB->o.odin.pidDebuggee = 0;
    2020 
    2021       if(lpProcessInfo)
    2022       {
    2023           lpProcessInfo->dwThreadId = MAKE_THREADID(lpProcessInfo->dwProcessId, lpProcessInfo->dwThreadId);
    2024       }
    2025 
    2026       if(cmdline)
    2027           free(cmdline);
    2028       return(TRUE);
    2029     }
    2030 
    2031     // PH 2001-05-07
    2032     // verify why O32_CreateProcess actually failed.
    2033     // If GetLastError() == 191 (ERROR_INVALID_EXE_SIGNATURE)
    2034     // we can continue to call "PE.EXE".
    2035     // Note: Open32 does not translate ERROR_INVALID_EXE_SIGNATURE,
    2036     // it is also valid in Win32.
    2037     DWORD dwError = GetLastError();
    2038     if (ERROR_INVALID_EXE_SIGNATURE != dwError && ERROR_FILE_NOT_FOUND != dwError && ERROR_ACCESS_DENIED != dwError)
    2039     {
    2040         dprintf(("CreateProcess: O32_CreateProcess failed with rc=%d, not PE-executable !",
    2041                 dwError));
    2042 
    2043         // the current value of GetLastError() is still valid.
    2044 
     2013        if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)
     2014        {
     2015          if(pThreadDB->o.odin.pidDebuggee != 0)
     2016          {
     2017            // TODO: handle this
     2018            dprintf(("KERNEL32: CreateProcess ERROR: This thread is already a debugger\n"));
     2019          }
     2020          else
     2021          {
     2022            pThreadDB->o.odin.pidDebuggee = lpProcessInfo->dwProcessId;
     2023            OSLibStartDebugger((ULONG*)&pThreadDB->o.odin.pidDebuggee);
     2024          }
     2025        }
     2026        else pThreadDB->o.odin.pidDebuggee = 0;
     2027
     2028        if(lpProcessInfo)
     2029        {
     2030            lpProcessInfo->dwThreadId = MAKE_THREADID(lpProcessInfo->dwProcessId, lpProcessInfo->dwThreadId);
     2031        }
     2032 
    20452033        if(cmdline)
    20462034            free(cmdline);
    2047 
    2048         return FALSE;
     2035        return(TRUE);
     2036      }
     2037 
     2038      // verify why O32_CreateProcess actually failed.
     2039      // If GetLastError() == 191 (ERROR_INVALID_EXE_SIGNATURE)
     2040      // we can continue to call "PE.EXE".
     2041      // Note: Open32 does not translate ERROR_INVALID_EXE_SIGNATURE,
     2042      // it is also valid in Win32.
     2043      DWORD dwError = GetLastError();
     2044      if (ERROR_INVALID_EXE_SIGNATURE != dwError && ERROR_FILE_NOT_FOUND != dwError && ERROR_ACCESS_DENIED != dwError)
     2045      {
     2046          dprintf(("CreateProcess: O32_CreateProcess failed with rc=%d, not PE-executable !", dwError));
     2047
     2048          // the current value of GetLastError() is still valid.
     2049          if(cmdline)
     2050              free(cmdline);
     2051
     2052          return FALSE;
     2053      }
    20492054    }
    20502055
     
    20542059    dprintf(("KERNEL32: CreateProcess %s %s", szAppName, lpCommandLine));
    20552060
    2056     DWORD Characteristics, SubSystem, fNEExe;
    2057     if(Win32ImageBase::isPEImage(szAppName, &Characteristics, &SubSystem, &fNEExe) == 0)
     2061    if(fPEExe)
    20582062    {
    20592063      char *lpszPE;
     
    20982102            char *newcmdline;
    20992103
    2100             newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + iNewCommandLineLength + strlen(lpszPE) + 64);
    2101             sprintf(newcmdline, "%s /OPT:[CURDIR=%s] %s %s", lpszPE, lpCurrentDirectory, szAppName, lpCommandLine);
     2104            newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + iNewCommandLineLength + 64);
     2105            sprintf(newcmdline, " /OPT:[CURDIR=%s] %s %s", lpCurrentDirectory, szAppName, lpCommandLine);
    21022106            free(cmdline);
    21032107            cmdline = newcmdline;
     
    21062110            char *newcmdline;
    21072111
    2108             newcmdline = (char *)malloc(iNewCommandLineLength + strlen(lpszPE) + 16);
    2109             sprintf(newcmdline, "%s %s %s", lpszPE, szAppName, lpCommandLine);
     2112            newcmdline = (char *)malloc(iNewCommandLineLength + 16);
     2113            sprintf(newcmdline, " %s %s", szAppName, lpCommandLine);
    21102114            free(cmdline);
    21112115            cmdline = newcmdline;
     
    21252129        char *newcmdline;
    21262130
    2127         newcmdline = (char *)malloc(strlen(szAppName) + strlen(cmdline) + strlen(szNELoader) + strlen(szPEGUILoader) + strlen(lpCommandLine) + 32);
    2128 
    2129         sprintf(newcmdline, "%s /PELDR=[%s] %s", szNELoader, szPEGUILoader, szAppName, lpCommandLine);
     2131        newcmdline = (char *)malloc(strlen(szAppName) + strlen(cmdline) + strlen(szPEGUILoader) + strlen(lpCommandLine) + 32);
     2132
     2133        sprintf(newcmdline, " /PELDR=[%s] %s", szPEGUILoader, szAppName, lpCommandLine);
    21302134        free(cmdline);
    21312135        cmdline = newcmdline;
Note: See TracChangeset for help on using the changeset viewer.