Changeset 9878 for trunk/src/kernel32/wprocess.cpp
- Timestamp:
- Feb 28, 2003, 12:32:28 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/wprocess.cpp
r9850 r9878 1 /* $Id: wprocess.cpp,v 1.18 2 2003-02-24 17:02:17sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.183 2003-02-28 11:32:28 sandervl Exp $ */ 2 2 3 3 /* … … 1995 1995 } 1996 1996 1997 DWORD Characteristics, SubSystem, fNEExe, fPEExe; 1998 1999 fPEExe = Win32ImageBase::isPEImage(szAppName, &Characteristics, &SubSystem, &fNEExe) == 0; 2000 1997 2001 // open32 does not support DEBUG_ONLY_THIS_PROCESS 1998 2002 if(dwCreationFlags & DEBUG_ONLY_THIS_PROCESS) 1999 2003 dwCreationFlags |= DEBUG_PROCESS; 2000 2004 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, 2002 2009 lpThreadAttributes, bInheritHandles, dwCreationFlags, 2003 2010 lpEnvironment, lpCurrentDirectory, lpStartupInfo, 2004 2011 lpProcessInfo) == TRUE) 2005 {2006 if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)2007 2012 { 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 2045 2033 if(cmdline) 2046 2034 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 } 2049 2054 } 2050 2055 … … 2054 2059 dprintf(("KERNEL32: CreateProcess %s %s", szAppName, lpCommandLine)); 2055 2060 2056 DWORD Characteristics, SubSystem, fNEExe; 2057 if(Win32ImageBase::isPEImage(szAppName, &Characteristics, &SubSystem, &fNEExe) == 0) 2061 if(fPEExe) 2058 2062 { 2059 2063 char *lpszPE; … … 2098 2102 char *newcmdline; 2099 2103 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); 2102 2106 free(cmdline); 2103 2107 cmdline = newcmdline; … … 2106 2110 char *newcmdline; 2107 2111 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); 2110 2114 free(cmdline); 2111 2115 cmdline = newcmdline; … … 2125 2129 char *newcmdline; 2126 2130 2127 newcmdline = (char *)malloc(strlen(szAppName) + strlen(cmdline) + strlen(sz NELoader) + 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); 2130 2134 free(cmdline); 2131 2135 cmdline = newcmdline;
Note:
See TracChangeset
for help on using the changeset viewer.