- Timestamp:
- Apr 29, 2002, 7:05:30 PM (23 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/directory.cpp
r7935 r8327 1 /* $Id: directory.cpp,v 1.4 5 2002-02-16 18:07:20sandervl Exp $ */1 /* $Id: directory.cpp,v 1.46 2002-04-29 17:05:29 sandervl Exp $ */ 2 2 3 3 /* … … 733 733 LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name ); 734 734 LPSTR extA = HEAP_strdupWtoA( GetProcessHeap(), 0, ext ); 735 735 736 dprintf(("SearchPathA %s %s %s", pathA, nameA, extA)); 736 737 DWORD ret = DIR_SearchPath( pathA, nameA, extA, (LPSTR)full_name ); 737 HeapFree( GetProcessHeap(), 0, extA ); 738 HeapFree( GetProcessHeap(), 0, nameA ); 739 HeapFree( GetProcessHeap(), 0, pathA ); 738 739 if (NULL != extA) 740 HeapFree( GetProcessHeap(), 0, extA ); 741 742 if (NULL != nameA) 743 HeapFree( GetProcessHeap(), 0, nameA ); 744 745 if (NULL != pathA) 746 HeapFree( GetProcessHeap(), 0, pathA ); 747 740 748 if (!ret) return 0; 741 749 -
trunk/src/kernel32/handlenames.cpp
r8216 r8327 1 /* $Id: handlenames.cpp,v 1. 4 2002-04-08 11:22:47 phallerExp $ */1 /* $Id: handlenames.cpp,v 1.5 2002-04-29 17:05:29 sandervl Exp $ */ 2 2 3 3 /* … … 117 117 HandleNames::HandleNames(void) 118 118 { 119 // Note: as handleNameMgr is a static object, the 120 // destructor will never be called, this memory is leaked. 119 121 pSymbolicLinks = new CLinearList(); 120 122 } … … 333 335 rc = FALSE; 334 336 else 337 { 335 338 // 2 - remove the link 336 339 pSymbolicLinks->removeObject(pHandleName); 340 341 if (NULL != pHandleName->pszSymbolicLink ) 342 free( pHandleName->pszSymbolicLink ); 343 344 if (NULL != pHandleName->pszTarget ) 345 free( pHandleName->pszTarget ); 346 347 free( pHandleName ); 348 } 337 349 338 350 mtxHandleNameMgr.leave(); -
trunk/src/kernel32/heap.cpp
r7935 r8327 121 121 122 122 BOOL fResult = curheap->Free(dwFlags, lpMem); 123 124 /* 2002-04-25 PH 125 * Apparently, Win2k does not do this. It does not touch last error, 126 * it does not even return FALSE but just anything != TRUE. 127 * 128 123 129 if (fResult == FALSE) 124 SetLastError(ERROR_INVALID_HANDLE); /// @@@PH possibly wrong return code! 130 SetLastError(ERROR_INVALID_HANDLE); 131 132 */ 125 133 126 134 return fResult; -
trunk/src/kernel32/initkernel32.cpp
r8203 r8327 1 /* $Id: initkernel32.cpp,v 1.1 4 2002-04-07 15:44:10 sandervl Exp $1 /* $Id: initkernel32.cpp,v 1.15 2002-04-29 17:05:30 sandervl Exp $ 2 2 * 3 3 * KERNEL32 DLL entry point … … 229 229 DestroyCodeHeap(); 230 230 231 HMTerminate(); /* shutdown handlemanager */ 232 231 233 #if defined(DEBUG) && defined(__IBMCPP__) && __IBMCPP__ == 300 232 234 ULONG totalmemalloc, nrcalls_malloc, nrcalls_free; … … 238 240 dprintf(("Leaked memory: %d bytes", totalmemalloc)); 239 241 dprintf(("************* KERNEL32 STATISTICS END *****************")); 242 243 _dump_allocated(0); 240 244 #endif 241 245 -
trunk/src/kernel32/registry.cpp
r7846 r8327 1 /* $Id: registry.cpp,v 1.1 3 2002-02-08 15:09:30 sandervl Exp $ */1 /* $Id: registry.cpp,v 1.14 2002-04-29 17:05:30 sandervl Exp $ */ 2 2 3 3 /* … … 158 158 astring, 159 159 phkResult); 160 161 FreeAsciiString(astring); 160 161 if (NULL != astring) 162 FreeAsciiString(astring); 163 162 164 return(rc); 163 165 } … … 237 239 phkResult, 238 240 lpdwDisposition); 239 240 FreeAsciiString(astring1); 241 FreeAsciiString(astring2); 241 242 if (NULL != astring1) 243 FreeAsciiString(astring1); 244 245 if (NULL != astring2) 246 FreeAsciiString(astring2); 247 242 248 return(rc); 243 249 } … … 264 270 rc = O32_RegDeleteKey(ConvertKey(hKey), 265 271 astring); 266 FreeAsciiString(astring); 272 273 if (NULL != astring) 274 FreeAsciiString(astring); 275 267 276 return(rc); 268 277 } … … 326 335 rc = O32_RegDeleteValue(ConvertKey(hKey), 327 336 astring); 328 FreeAsciiString(astring); 337 338 if (NULL != astring) 339 FreeAsciiString(astring); 340 329 341 return(rc); 330 342 } … … 618 630 if(rc) 619 631 *arg3 = 0; 620 621 FreeAsciiString(astring); 632 633 if (NULL != astring) 634 FreeAsciiString(astring); 635 622 636 return(rc); 623 637 } … … 683 697 if(rc) 684 698 *arg5 = 0; 685 686 FreeAsciiString(astring); 699 700 if (NULL != astring) 701 FreeAsciiString(astring); 702 687 703 return(rc); 688 704 } … … 841 857 } 842 858 } 843 FreeAsciiString(astring1); 859 860 if (NULL != astring1) 861 FreeAsciiString(astring1); 862 844 863 return(rc); 845 864 } … … 930 949 } 931 950 } 932 FreeAsciiString(astring); 933 if(akeydata) { 951 952 if (NULL != astring) 953 FreeAsciiString(astring); 954 955 if(akeydata) 934 956 free(akeydata); 935 } 957 936 958 return(rc); 937 959 } … … 1002 1024 1003 1025 rc = RegSetValueA(hkey, astring1, dwType, astring2, cbData); 1004 1005 FreeAsciiString(astring1); 1006 FreeAsciiString(astring2); 1026 1027 if (NULL != astring1) 1028 FreeAsciiString(astring1); 1029 1030 if (NULL != astring2) 1031 FreeAsciiString(astring2); 1032 1007 1033 return(rc); 1008 1034 } … … 1091 1117 } 1092 1118 rc = RegSetValueExA(hkey, astring, dwReserved, fdwType, lpbData, cbData); 1119 1093 1120 if(akeydata) 1094 1121 FreeAsciiString(akeydata); 1095 1096 FreeAsciiString(astring); 1122 1123 if (NULL != astring) 1124 FreeAsciiString(astring); 1125 1097 1126 return(rc); 1098 1127 } -
trunk/src/kernel32/winimagebase.cpp
r7811 r8327 1 /* $Id: winimagebase.cpp,v 1.3 4 2002-02-06 16:33:39sandervl Exp $ */1 /* $Id: winimagebase.cpp,v 1.35 2002-04-29 17:05:30 sandervl Exp $ */ 2 2 3 3 /* … … 322 322 *subsystem = oh.Subsystem; 323 323 } 324 325 free(win32file); 324 326 DosClose(win32handle); 325 327 return ERROR_SUCCESS_W; -
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.