Changeset 8327 for trunk/src/kernel32/wprocess.cpp
- Timestamp:
- Apr 29, 2002, 7:05:30 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/wprocess.cpp
r8015 r8327 1 /* $Id: wprocess.cpp,v 1.1 49 2002-02-26 11:11:17sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.150 2002-04-29 17:05:30 sandervl Exp $ */ 2 2 3 3 /* … … 340 340 } 341 341 threadListMutex.leave(); 342 342 343 // PH 2002-04-11 344 // free allocated memory 345 free( winteb->o.odin.threadinfo.pTokenGroups ); 346 347 #ifdef DEBUG 348 if (winteb->o.odin.arrstrCallStack != NULL) 349 free( winteb->o.odin.arrstrCallStack ); 350 #endif 351 343 352 //Restore our original FS selector 344 353 SetFS(orgtibsel); … … 1203 1212 */ 1204 1213 cch = strlen(pszPeExe)+1; 1214 1215 // PH 2002-04-11 1216 // Note: intentional memory leak, pszCmdLineW will not be freed 1217 // or allocated after process startup 1205 1218 pszCmdLineA = psz = (PSZ)malloc(cch); 1206 1219 if (psz == NULL) … … 1304 1317 if (rc == NO_ERROR) 1305 1318 { 1319 // PH 2002-04-11 1320 // Note: intentional memory leak, pszCmdLineW will not be freed 1321 // or allocated after process startup 1306 1322 pszCmdLineW = (WCHAR*)malloc(cch * 2); 1307 1323 if (pszCmdLineW != NULL) … … 1402 1418 * terminating '\0'. 1403 1419 * On error 0 is returned. Last error is set. 1420 * 1421 * 2002-04-25 PH 1422 * Q - Do we set ERROR_BUFFER_OVERFLOW when cch > cchPath? 1423 * Q - Does NT really set the last error? 1424 * A > Win2k does not set LastError here, remains OK 1425 * 1426 * While GetModuleFileName does add a trailing termination zero 1427 * if there is enough room, the returned number of characters 1428 * *MUST NOT* include the zero character! 1429 * (Notes R6 Installer on Win2kSP6, verified Testcase) 1430 * 1404 1431 * @param hModule Handle to the module you like to get the file name to. 1405 1432 * @param lpszPath Output buffer for full path and file name. … … 1421 1448 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 1422 1449 * Sander van Leeuwen (sandervl@xs4all.nl) 1450 * Patrick Haller (patrick.haller@innotek.de) 1423 1451 * @remark - Do we still have to call Open32? 1424 * - Do we set ERROR_BUFFER_OVERFLOW when cch > cchPath?1425 * - Does NT really set the last error?1426 1452 */ 1427 1453 DWORD WIN32API GetModuleFileNameA(HMODULE hModule, LPTSTR lpszPath, DWORD cchPath) 1428 1454 { 1429 1455 Win32ImageBase * pMod; /* Pointer to the module object. */ 1430 DWORD cch; /* Length of the */ 1431 1456 DWORD cch = 0; /* Length of the */ 1457 1458 // PH 2002-04-24 Note: 1459 // WIN2k just crashes in NTDLL if lpszPath is invalid! 1432 1460 if (!VALID_PSZ(lpszPath)) 1433 1461 { … … 1444 1472 if (pszFn) 1445 1473 { 1446 cch = strlen(pszFn) + 1; 1447 if (cch > cchPath) 1448 cch = cchPath; 1474 cch = strlen(pszFn); 1475 if (cch >= cchPath) 1476 cch = cchPath; 1477 else 1478 // if there is sufficient room for the zero termination, 1479 // write it additionally, uncounted 1480 lpszPath[cch] = '\0'; 1481 1449 1482 memcpy(lpszPath, pszFn, cch); 1450 lpszPath[cch - 1] = '\0';1451 1483 } 1452 1484 else … … 1463 1495 //(console init only it seems...) 1464 1496 cch = OSLibDosGetModuleFileName(hModule, lpszPath, cchPath); 1465 if (cch > 0) cch++; /* Open32 doesn't count the terminator. */1466 1497 } 1467 1498 … … 1794 1825 1795 1826 DWORD Characteristics, SubSystem, fNEExe; 1796 if(Win32ImageBase::isPEImage(szAppName, &Characteristics, &SubSystem, &fNEExe) == 0) { 1797 char *lpszPE; 1798 if(SubSystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) { 1799 lpszPE = "PEC.EXE"; 1800 } 1801 else lpszPE = "PE.EXE"; 1802 1827 if(Win32ImageBase::isPEImage(szAppName, &Characteristics, &SubSystem, &fNEExe) == 0) 1828 { 1829 char *lpszPE; 1830 char *lpszExecutable; 1831 int iNewCommandLineLength; 1832 1833 // calculate base length for the new command line 1834 iNewCommandLineLength = strlen(szAppName) + strlen(lpCommandLine); 1835 1836 if(SubSystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) 1837 lpszExecutable = "PEC.EXE"; 1838 else 1839 lpszExecutable = "PE.EXE"; 1840 1841 lpszPE = lpszExecutable; 1842 1843 // 2002-04-24 PH 1844 // set the ODIN32.DEBUG_CHILD environment variable to start new PE processes 1845 // under a new instance of the (IPMD) debugger. 1846 #ifdef DEBUG 1847 CHAR debug_szPE[ 512 ]; 1848 PSZ debug_pszOS2Debugger = getenv("ODIN32.DEBUG_CHILD"); 1849 if (NULL != debug_pszOS2Debugger) 1850 { 1851 // build new start command 1852 strcpy(debug_szPE, debug_pszOS2Debugger); 1853 strcat(debug_szPE, " "); 1854 strcat(debug_szPE, lpszExecutable); 1855 1856 // we require more space in the new command line 1857 iNewCommandLineLength += strlen( debug_szPE ); 1858 1859 // only launch the specified executable (ICSDEBUG.EXE) 1860 lpszPE = debug_szPE; 1861 lpszExecutable = debug_pszOS2Debugger; 1862 } 1863 #endif 1864 1803 1865 //SvL: Allright. Before we call O32_CreateProcess, we must take care of 1804 1866 // lpCurrentDirectory ourselves. (Open32 ignores it!) … … 1806 1868 char *newcmdline; 1807 1869 1808 newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + strlen(szAppName) + strlen(lpCommandLine)+ 32);1870 newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + iNewCommandLineLength + 32); 1809 1871 sprintf(newcmdline, "%s /OPT:[CURDIR=%s] %s %s", lpszPE, lpCurrentDirectory, szAppName, lpCommandLine); 1810 1872 free(cmdline); … … 1814 1876 char *newcmdline; 1815 1877 1816 newcmdline = (char *)malloc( strlen(szAppName) + strlen(lpCommandLine)+ 16);1878 newcmdline = (char *)malloc(iNewCommandLineLength + 16); 1817 1879 sprintf(newcmdline, "%s %s %s", lpszPE, szAppName, lpCommandLine); 1818 1880 free(cmdline); 1819 1881 cmdline = newcmdline; 1820 1882 } 1821 rc = O32_CreateProcess(lpszPE, (LPCSTR)cmdline,lpProcessAttributes, 1883 1884 dprintf(("KERNEL32: CreateProcess starting [%s],[%s]", 1885 lpszExecutable, 1886 cmdline)); 1887 1888 rc = O32_CreateProcess(lpszExecutable, (LPCSTR)cmdline,lpProcessAttributes, 1822 1889 lpThreadAttributes, bInheritHandles, dwCreationFlags, 1823 1890 lpEnvironment, lpCurrentDirectory, lpStartupInfo,
Note:
See TracChangeset
for help on using the changeset viewer.