Changeset 4486 for trunk/src/kernel32/wprocess.cpp
- Timestamp:
- Oct 16, 2000, 1:05:15 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/wprocess.cpp
r4474 r4486 1 /* $Id: wprocess.cpp,v 1.10 3 2000-10-10 17:14:09sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.104 2000-10-16 11:05:15 sandervl Exp $ */ 2 2 3 3 /* … … 679 679 ULONG fPE; /* isPEImage return value. */ 680 680 DWORD Characteristics; //file header's Characteristics 681 BOOL fDllModule; //file type 681 682 682 683 /** @sketch … … 708 709 /** @sketch 709 710 * First we'll see if the module is allready loaded - either as the EXE or as DLL. 710 * IF Executable present AND libfile matches the modname of the executable THEN711 * IF NOT dll AND Executable present AND libfile matches the modname of the executable THEN 711 712 * RETURN instance handle of executable. 712 713 * Endif … … 720 721 * Endif 721 722 */ 722 if (WinExe != NULL && WinExe->matchModName(lpszLibFile)) 723 if(strstr(lpszLibFile, ".DLL")) { 724 fDllModule = TRUE; 725 } 726 else { 727 if(!strstr(lpszLibFile, ".")) { 728 //if there's no extension or trainling dot, we 729 //assume it's a dll (see Win32 SDK docs) 730 fDllModule = TRUE; 731 } 732 } 733 734 //todo: the entire exe name probably needs to be identical (path + extension) 735 // -> check in NT 736 if (!fDllModule && WinExe != NULL && WinExe->matchModName(lpszLibFile)) 723 737 return WinExe->getInstanceHandle(); 724 738 … … 790 804 if(pModule->isLxDll()) 791 805 { 792 793 if(fPeLoader)794 795 796 797 798 799 800 806 ((Win32LxDll *)pModule)->setDllHandleOS2(hDll); 807 if(fPeLoader) 808 { 809 if(pModule->AddRef() == -1) {//-1 -> load failed (attachProcess) 810 dprintf(("Dll %s refused to be loaded; aborting", szModname)); 811 delete pModule; 812 return 0; 813 } 814 } 801 815 } 802 816 pModule->incDynamicLib(); … … 851 865 * Process dwFlags 852 866 */ 853 if (dwFlags & LOAD_LIBRARY_AS_DATAFILE) 867 if (dwFlags & LOAD_LIBRARY_AS_DATAFILE) 854 868 { 855 869 dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): LOAD_LIBRARY_AS_DATAFILE", 856 870 lpszLibFile, hFile, dwFlags)); 857 871 peldrDll->setLoadAsDataFile(); 858 872 peldrDll->disableLibraryCalls(); 859 873 } 860 874 if (dwFlags & DONT_RESOLVE_DLL_REFERENCES) … … 862 876 dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): DONT_RESOLVE_DLL_REFERENCES", 863 877 lpszLibFile, hFile, dwFlags)); 864 878 peldrDll->disableLibraryCalls(); 865 879 peldrDll->disableImportHandling(); 866 880 } … … 910 924 SetLastError(ERROR_DLL_INIT_FAILED); 911 925 delete peldrDll; 912 926 return NULL; 913 927 } 914 928 } … … 919 933 SetLastError(ERROR_INVALID_EXE_SIGNATURE); 920 934 delete peldrDll; 921 935 return NULL; 922 936 } 923 937 } … … 927 941 lpszLibFile, hFile, dwFlags, szModname, fPE)); 928 942 SetLastError(fPE); 929 943 return NULL; 930 944 } 931 945 … … 1111 1125 return ERROR_NOT_ENOUGH_MEMORY; 1112 1126 } 1113 1114 1127 strcpy((char *)pszCmdLineA, pszPeExe); 1128 1115 1129 rc = NO_ERROR; 1116 1130 } … … 1473 1487 if(!strstr(szModule, ".")) { 1474 1488 //if there's no extension or trainling dot, we 1475 1489 //assume it's a dll (see Win32 SDK docs) 1476 1490 fDllModule = TRUE; 1477 1491 } … … 1481 1495 *dot = 0; 1482 1496 1483 if(!fDllModule && WinExe && !strcmpi(szModule, WinExe->getModuleName())) {1497 if(!fDllModule && WinExe && WinExe->matchModName(szModule)) { 1484 1498 hMod = WinExe->getInstanceHandle(); 1485 1499 } … … 1591 1605 } 1592 1606 if(szAppName[0] == '"') { 1593 1607 exename = &szAppName[1]; 1594 1608 } 1595 1609 else exename = szAppName; 1596 1610 1597 if(GetFileAttributesA(exename) == -1) { 1598 1599 1600 1601 } 1611 if(GetFileAttributesA(exename) == -1) { 1612 dprintf(("CreateProcess: can't find executable!")); 1613 SetLastError(ERROR_FILE_NOT_FOUND); 1614 return FALSE; 1615 } 1602 1616 dprintf(("KERNEL32: CreateProcess %s\n", cmdline)); 1603 1617 1604 //SvL: Allright. Before we call O32_CreateProcess, we must take care of 1618 //SvL: Allright. Before we call O32_CreateProcess, we must take care of 1605 1619 // lpCurrentDirectory ourselves. (Open32 ignores it!) 1606 1620 if(lpCurrentDirectory) { 1607 1608 1609 1610 1611 1612 1621 char *newcmdline; 1622 1623 newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + strlen(cmdline) + 32); 1624 sprintf(newcmdline, "PE.EXE /OPT:[CURDIR=%s] %s", lpCurrentDirectory, cmdline); 1625 free(cmdline); 1626 cmdline = newcmdline; 1613 1627 } 1614 1628 else { 1615 1616 1617 1618 1619 1620 1629 char *newcmdline; 1630 1631 newcmdline = (char *)malloc(strlen(cmdline) + 16); 1632 sprintf(newcmdline, "PE.EXE %s", cmdline); 1633 free(cmdline); 1634 cmdline = newcmdline; 1621 1635 } 1622 1636 rc = O32_CreateProcess("PE.EXE", (LPCSTR)cmdline,lpProcessAttributes, … … 1624 1638 lpEnvironment, lpCurrentDirectory, lpStartupInfo, 1625 1639 lpProcessInfo); 1626 if(rc == TRUE) 1640 if(rc == TRUE) 1627 1641 { 1628 1642 if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL) … … 1701 1715 rc = O32_WaitForInputIdle(procinfo.hProcess, 15000); 1702 1716 if(rc != 0) { 1703 1717 dprintf(("WinExec: WaitForInputIdle %x returned %x", procinfo.hProcess, rc)); 1704 1718 } 1705 1719 return procinfo.hProcess; //correct? … … 1712 1726 * Copyright 1995 Alexandre Julliard 1713 1727 */ 1714 HINSTANCE WINAPI LoadModule( LPCSTR name, LPVOID paramBlock ) 1728 HINSTANCE WINAPI LoadModule( LPCSTR name, LPVOID paramBlock ) 1715 1729 { 1716 1730 LOADPARAMS *params = (LOADPARAMS *)paramBlock; … … 1747 1761 startup.wShowWindow = params->lpCmdShow[1]; 1748 1762 } 1749 1763 1750 1764 if (CreateProcessA( filename, cmdline, NULL, NULL, FALSE, 0, 1751 1765 params->lpEnvAddress, NULL, &startup, &info )) 1752 1766 { 1753 1767 /* Give 15 seconds to the app to come up */ 1754 if ( O32_WaitForInputIdle ( info.hProcess, 15000 ) == 0xFFFFFFFF ) 1768 if ( O32_WaitForInputIdle ( info.hProcess, 15000 ) == 0xFFFFFFFF ) 1755 1769 dprintf(("ERROR: WaitForInputIdle failed: Error %ld\n", GetLastError() )); 1756 1770 hInstance = 33; … … 1817 1831 dprintf(("GetVersionStruct of module %s %x %d", lpszModName, verstruct, bufLength)); 1818 1832 if(verstruct == NULL) { 1819 1820 1833 SetLastError(ERROR_INVALID_PARAMETER); 1834 return FALSE; 1821 1835 } 1822 if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) 1836 if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) 1823 1837 { 1824 1838 winimage = (Win32ImageBase *)WinExe; 1825 1839 } 1826 else 1840 else 1827 1841 { 1828 1842 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); … … 1848 1862 return winimage->getVersionStruct(verstruct, bufLength); 1849 1863 } 1850 1864 dprintf(("GetVersionStruct; just loaded dll %s, but can't find it now!", modname)); 1851 1865 return 0; 1852 1866 } … … 1859 1873 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); 1860 1874 if(winimage != NULL) { 1861 1862 1863 else 1864 1875 rc = winimage->getVersionStruct(verstruct, bufLength); 1876 } 1877 else dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName)); 1878 FreeLibrary(hDll); 1865 1879 return rc; 1866 1880 } … … 1903 1917 return winimage->getVersionSize(); 1904 1918 } 1905 1919 dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", modname)); 1906 1920 return 0; 1907 1921 } … … 1914 1928 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); 1915 1929 if(winimage != NULL) { 1916 1917 1918 else 1919 1930 size = winimage->getVersionSize(); 1931 } 1932 else dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName)); 1933 FreeLibrary(hDll); 1920 1934 return size; 1921 1935 }
Note:
See TracChangeset
for help on using the changeset viewer.