Changeset 21302 for trunk/src/kernel32/wprocess.cpp
- Timestamp:
- Jun 18, 2009, 11:53:26 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/wprocess.cpp
r10481 r21302 67 67 ODINDEBUGCHANNEL(KERNEL32-WPROCESS) 68 68 69 70 //environ.cpp 71 char *CreateNewEnvironment(char *lpEnvironment); 69 72 70 73 /******************************************************************************* … … 1906 1909 STARTUPINFOA startinfo; 1907 1910 TEB *pThreadDB = (TEB*)GetThreadTEB(); 1908 char *cmdline = NULL, *newenv = NULL ;1911 char *cmdline = NULL, *newenv = NULL, *oldlibpath = NULL; 1909 1912 BOOL rc; 1910 1913 … … 1939 1942 1940 1943 memcpy(&startinfo, lpStartupInfo, sizeof(startinfo)); 1944 if(lpStartupInfo->hStdInput) { 1941 1945 retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdInput, &startinfo.hStdInput); 1946 } 1947 if(lpStartupInfo->hStdOutput) { 1942 1948 retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdOutput, &startinfo.hStdOutput); 1949 } 1950 if(lpStartupInfo->hStdError) { 1943 1951 retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdError, &startinfo.hStdError); 1952 } 1944 1953 1945 1954 if(retcode) { … … 2019 2028 break; 2020 2029 } 2021 2030 else 2031 {//maybe it's a short name 2032 if(GetLongPathNameA(buffer, szAppName, sizeof(szAppName))) 2033 { 2034 if(fTerminate) exename++; 2035 break; 2036 } 2037 } 2022 2038 if(fTerminate) { 2023 2039 *exename = ' '; … … 2039 2055 } 2040 2056 2057 if(lpEnvironment) { 2058 newenv = CreateNewEnvironment((char *)lpEnvironment); 2059 if(newenv == NULL) { 2060 SetLastError(ERROR_NOT_ENOUGH_MEMORY); 2061 rc = FALSE; 2062 goto finished; 2063 } 2064 lpEnvironment = newenv; 2065 } 2066 2041 2067 DWORD Characteristics, SubSystem, fNEExe, fPEExe; 2042 2068 … … 2050 2076 if(!fPEExe || (fPEExe && fWin32k)) 2051 2077 { 2078 2079 trylaunchagain: 2052 2080 if(O32_CreateProcess(szAppName, lpCommandLine, lpProcessAttributes, 2053 2081 lpThreadAttributes, bInheritHandles, dwCreationFlags, … … 2078 2106 goto finished; 2079 2107 } 2080 2108 else 2109 if(!oldlibpath) 2110 {//might have failed because it wants to load dlls in its current directory 2111 // Add the application directory to the ENDLIBPATH, so dlls can be found there 2112 // Only necessary for OS/2 applications 2113 oldlibpath = (char *)calloc(4096, 1); 2114 if(oldlibpath) 2115 { 2116 OSLibQueryBeginLibpath(oldlibpath, 4096); 2117 2118 char *tmp = strrchr(szAppName, '\\'); 2119 if(tmp) *tmp = 0; 2120 2121 OSLibSetBeginLibpath(szAppName); 2122 if(tmp) *tmp = '\\'; 2123 2124 goto trylaunchagain; 2125 } 2126 2127 } 2081 2128 // verify why O32_CreateProcess actually failed. 2082 2129 // If GetLastError() == 191 (ERROR_INVALID_EXE_SIGNATURE) … … 2102 2149 if(fPEExe) 2103 2150 { 2104 char *lpszPE; 2105 char *lpszExecutable; 2151 LPCSTR lpszExecutable; 2106 2152 int iNewCommandLineLength; 2107 2153 … … 2110 2156 2111 2157 if(SubSystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) 2112 lpszExecutable = (LPSTR)szPECmdLoader;2158 lpszExecutable = szPECmdLoader; 2113 2159 else 2114 lpszExecutable = (LPSTR)szPEGUILoader; 2115 2116 lpszPE = lpszExecutable; 2160 lpszExecutable = szPEGUILoader; 2117 2161 2118 2162 // 2002-04-24 PH 2119 2163 // set the ODIN32.DEBUG_CHILD environment variable to start new PE processes 2120 2164 // under a new instance of the (IPMD) debugger. 2165 const char *pszDebugChildArg = ""; 2121 2166 #ifdef DEBUG 2122 CHAR debug_szPE[ 512];2123 PSZ debug_pszOS2Debugger= getenv("ODIN32.DEBUG_CHILD");2124 if ( NULL != debug_pszOS2Debugger)2167 char szDebugChild[512]; 2168 const char *pszChildDebugger = getenv("ODIN32.DEBUG_CHILD"); 2169 if (pszChildDebugger) 2125 2170 { 2126 // build new start command 2127 strcpy(debug_szPE, debug_pszOS2Debugger); 2128 strcat(debug_szPE, " "); 2129 strcat(debug_szPE, lpszExecutable); 2130 2131 // we require more space in the new command line 2132 iNewCommandLineLength += strlen( debug_szPE ); 2133 2134 // only launch the specified executable (ICSDEBUG.EXE) 2135 lpszPE = debug_szPE; 2136 lpszExecutable = debug_pszOS2Debugger; 2171 /* 2172 * Change the executable to the debugger (icsdebug.exe) and 2173 * move the previous executable onto the commandline. 2174 */ 2175 szDebugChild[0] = ' '; 2176 strcpy(&szDebugChild[1], lpszExecutable); 2177 iNewCommandLineLength += strlen(&szDebugChild[0]); 2178 2179 pszDebugChildArg = &szDebugChild[0]; 2180 lpszExecutable = pszChildDebugger; 2137 2181 } 2138 2182 #endif … … 2144 2188 2145 2189 newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + iNewCommandLineLength + 64); 2146 sprintf(newcmdline, " /OPT:[CURDIR=%s] %s %s", lpCurrentDirectory, szAppName, lpCommandLine);2190 sprintf(newcmdline, "%s /OPT:[CURDIR=%s] %s %s", pszDebugChildArg, lpCurrentDirectory, szAppName, lpCommandLine); 2147 2191 free(cmdline); 2148 2192 cmdline = newcmdline; … … 2152 2196 2153 2197 newcmdline = (char *)malloc(iNewCommandLineLength + 16); 2154 sprintf(newcmdline, " %s %s", szAppName, lpCommandLine);2198 sprintf(newcmdline, "%s %s %s", pszDebugChildArg, szAppName, lpCommandLine); 2155 2199 free(cmdline); 2156 2200 cmdline = newcmdline; … … 2192 2236 lpProcessInfo); 2193 2237 } 2238 if(!lpEnvironment) { 2239 // Restore old ENDLIBPATH variable 2240 // TODO: 2241 } 2242 2194 2243 if(rc == TRUE) 2195 2244 { … … 2222 2271 finished: 2223 2272 2273 if(oldlibpath) { 2274 OSLibSetBeginLibpath(oldlibpath); 2275 free(oldlibpath); 2276 } 2224 2277 if(cmdline) free(cmdline); 2225 2278 if(newenv) free(newenv);
Note:
See TracChangeset
for help on using the changeset viewer.