Changeset 4474 for trunk/src/kernel32/wprocess.cpp
- Timestamp:
- Oct 10, 2000, 7:14:09 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/wprocess.cpp
r4445 r4474 1 /* $Id: wprocess.cpp,v 1.10 2 2000-10-06 15:16:07sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.103 2000-10-10 17:14:09 sandervl Exp $ */ 2 2 3 3 /* … … 9 9 * NOTE: Even though Odin32 OS/2 apps don't switch FS selectors, 10 10 * we still allocate a TEB to store misc information. 11 * 12 * TODO: What happens when a dll is first loaded as LOAD_LIBRARY_AS_DATAFILE 13 * and then for real? (first one not freed of course) 11 14 * 12 15 * Project Odin Software License can be found in LICENSE.TXT … … 25 28 #include "windllpeldr.h" 26 29 #include "winexepeldr.h" 27 #include "winfakepeldr.h"28 30 #include "windlllx.h" 29 31 #include <vmutex.h> … … 443 445 BOOL rc; 444 446 447 SetLastError(ERROR_SUCCESS); 445 448 //SvL: Ignore FreeLibary for executable 446 449 if(WinExe && hinstance == WinExe->getInstanceHandle()) { … … 633 636 * by the module). 634 637 * 635 * partially implemented yet - imports are resolved it seems.636 638 * 637 639 * LOAD_LIBRARY_AS_DATAFILE … … 648 650 * LoadCursor, LoadIcon, LoadImage, LoadMenu.) 649 651 * 650 * not implemented yet.651 652 * 652 653 * LOAD_WITH_ALTERED_SEARCH_PATH … … 677 678 /* lpszLibFile contains a path. */ 678 679 ULONG fPE; /* isPEImage return value. */ 680 DWORD Characteristics; //file header's Characteristics 679 681 680 682 /** @sketch … … 720 722 if (WinExe != NULL && WinExe->matchModName(lpszLibFile)) 721 723 return WinExe->getInstanceHandle(); 724 722 725 pModule = Win32DllBase::findModule((LPSTR)lpszLibFile); 723 726 if (pModule) … … 760 763 761 764 //test if dll is in PE or LX format 762 fPE = Win32ImageBase::isPEImage(szModname );765 fPE = Win32ImageBase::isPEImage(szModname, &Characteristics); 763 766 764 767 /** @sketch … … 785 788 if(pModule) 786 789 { 787 788 790 if(pModule->isLxDll()) 789 791 { … … 829 831 if(fPE == ERROR_SUCCESS) 830 832 { 831 Win32PeLdrDll * peldrDll; 832 /* TODO! 833 * We might use the fake loader class to do the LOAD_LIBRARY_AS_DATAFILE and 834 * executable image loading. These are both loaded for accessing resource. 835 * But this requires that they behaves like Dlls... 836 if (dwFlags & LOAD_LIBRARY_AS_DATAFILE || fPE == 2) 837 { 838 peldrDll = new Win32PeLdrRsrcImg(szModname); 839 } 840 else 841 */ 833 Win32PeLdrDll *peldrDll; 834 835 //SvL: If executable -> load as data file (only resources) 836 if(!(Characteristics & IMAGE_FILE_DLL)) 837 { 838 dwFlags |= (LOAD_LIBRARY_AS_DATAFILE | DONT_RESOLVE_DLL_REFERENCES); 839 } 842 840 843 841 peldrDll = new Win32PeLdrDll(szModname); … … 853 851 * Process dwFlags 854 852 */ 855 if (dwFlags & (DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE)) 856 { 857 peldrDll->disableThreadLibraryCalls(); 858 //peldrDll->setDontProcessImports(); not implemented? 853 if (dwFlags & LOAD_LIBRARY_AS_DATAFILE) 854 { 855 dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): LOAD_LIBRARY_AS_DATAFILE", 856 lpszLibFile, hFile, dwFlags)); 857 peldrDll->setLoadAsDataFile(); 858 peldrDll->disableLibraryCalls(); 859 } 860 if (dwFlags & DONT_RESOLVE_DLL_REFERENCES) 861 { 862 dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): DONT_RESOLVE_DLL_REFERENCES", 863 lpszLibFile, hFile, dwFlags)); 864 peldrDll->disableLibraryCalls(); 865 peldrDll->disableImportHandling(); 859 866 } 860 867 if (dwFlags & LOAD_WITH_ALTERED_SEARCH_PATH) … … 863 870 lpszLibFile, hFile, dwFlags)); 864 871 //peldrDll->setLoadWithAlteredSearchPath(); 865 }866 if (dwFlags & LOAD_LIBRARY_AS_DATAFILE)867 {868 dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): Warning dwFlags LOAD_LIBRARY_AS_DATAFILE is not implemented.",869 lpszLibFile, hFile, dwFlags));870 //peldrDll->setLoadAsDatafile();871 872 } 872 873 … … 918 919 SetLastError(ERROR_INVALID_EXE_SIGNATURE); 919 920 delete peldrDll; 920 921 return NULL; 921 922 } 922 923 } … … 1812 1813 { 1813 1814 Win32ImageBase *winimage; 1814 Win32PeLdrRsrcImg *rsrcimg; 1815 1816 dprintf(("GetVersionStruct of module %s", lpszModName)); 1815 HINSTANCE hDll; 1816 1817 dprintf(("GetVersionStruct of module %s %x %d", lpszModName, verstruct, bufLength)); 1818 if(verstruct == NULL) { 1819 SetLastError(ERROR_INVALID_PARAMETER); 1820 return FALSE; 1821 } 1822 if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) 1823 { 1824 winimage = (Win32ImageBase *)WinExe; 1825 } 1826 else 1827 { 1828 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); 1829 if(winimage == NULL) 1830 { 1831 char modname[CCHMAXPATH]; 1832 1833 strcpy(modname, lpszModName); 1834 //rename dll if necessary (i.e. OLE32 -> OLE32OS2) 1835 Win32DllBase::renameDll(modname); 1836 1837 if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS) 1838 { 1839 HINSTANCE hInstance; 1840 1841 //must be an LX dll, just load it (app will probably load it anyway) 1842 hInstance = LoadLibraryA(modname); 1843 if(hInstance == 0) 1844 return 0; 1845 1846 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance); 1847 if(winimage) { 1848 return winimage->getVersionStruct(verstruct, bufLength); 1849 } 1850 dprintf(("GetVersionStruct; just loaded dll %s, but can't find it now!", modname)); 1851 return 0; 1852 } 1853 BOOL rc = FALSE; 1854 1855 hDll = LoadLibraryExA(lpszModName, 0, LOAD_LIBRARY_AS_DATAFILE); 1856 if(hDll == 0) 1857 return 0; 1858 1859 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); 1860 if(winimage != NULL) { 1861 rc = winimage->getVersionStruct(verstruct, bufLength); 1862 } 1863 else dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName)); 1864 FreeLibrary(hDll); 1865 return rc; 1866 } 1867 } 1868 return winimage->getVersionStruct(verstruct, bufLength); 1869 } 1870 //****************************************************************************** 1871 //****************************************************************************** 1872 ULONG SYSTEM GetVersionSize(char *lpszModName) 1873 { 1874 Win32ImageBase *winimage; 1875 HINSTANCE hDll; 1876 1877 dprintf(("GetVersionSize of %s\n", lpszModName)); 1878 1817 1879 if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) { 1818 1880 winimage = (Win32ImageBase *)WinExe; … … 1822 1884 if(winimage == NULL) 1823 1885 { 1824 char modname[CCHMAXPATH];1825 1826 strcpy(modname, lpszModName);1827 //rename dll if necessary (i.e. OLE32 -> OLE32OS2)1828 Win32DllBase::renameDll(modname);1829 1830 if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)1831 {1832 HINSTANCE hInstance;1886 char modname[CCHMAXPATH]; 1887 1888 strcpy(modname, lpszModName); 1889 //rename dll if necessary (i.e. OLE32 -> OLE32OS2) 1890 Win32DllBase::renameDll(modname); 1891 1892 if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS) 1893 { 1894 HINSTANCE hInstance; 1833 1895 1834 1896 //must be an LX dll, just load it (app will probably load it anyway) … … 1836 1898 if(hInstance == 0) 1837 1899 return 0; 1838 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance); 1839 if(winimage) { 1840 return winimage->getVersionStruct(verstruct, bufLength); 1841 } 1842 return 0; 1843 } 1844 //SvL: Try to load it 1845 rsrcimg = new Win32PeLdrRsrcImg(modname); 1846 if(rsrcimg == NULL) 1847 return 0; 1848 1849 rsrcimg->init(0); 1850 if(rsrcimg->getError() != NO_ERROR) 1851 { 1852 dprintf(("GetVersionStruct can't load %s\n", modname)); 1853 delete rsrcimg; 1854 return(FALSE); 1855 } 1856 BOOL rc = rsrcimg->getVersionStruct(verstruct, bufLength); 1857 delete rsrcimg; 1858 return rc; 1859 } 1860 } 1861 return winimage->getVersionStruct(verstruct, bufLength); 1862 } 1863 //****************************************************************************** 1864 //****************************************************************************** 1865 ULONG SYSTEM GetVersionSize(char *lpszModName) 1866 { 1867 Win32ImageBase *winimage; 1868 Win32PeLdrRsrcImg *rsrcimg; 1869 1870 dprintf(("GetVersionSize of %s\n", lpszModName)); 1871 1872 if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) { 1873 winimage = (Win32ImageBase *)WinExe; 1874 } 1875 else { 1876 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); 1877 if(winimage == NULL) 1878 { 1879 char modname[CCHMAXPATH]; 1880 1881 strcpy(modname, lpszModName); 1882 //rename dll if necessary (i.e. OLE32 -> OLE32OS2) 1883 Win32DllBase::renameDll(modname); 1884 1885 if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS) 1886 { 1887 HINSTANCE hInstance; 1888 1889 //must be an LX dll, just load it (app will probably load it anyway) 1890 hInstance = LoadLibraryA(modname); 1891 if(hInstance == 0) 1892 return 0; 1893 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance); 1894 if(winimage) { 1900 1901 winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance); 1902 if(winimage) { 1895 1903 return winimage->getVersionSize(); 1896 1904 } 1905 dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", modname)); 1897 1906 return 0; 1898 1907 } 1899 1900 //SvL: Try to load it 1901 rsrcimg = new Win32PeLdrRsrcImg(modname);1902 if( rsrcimg == NULL)1908 int size = 0; 1909 1910 hDll = LoadLibraryExA(lpszModName, 0, LOAD_LIBRARY_AS_DATAFILE); 1911 if(hDll == 0) 1903 1912 return 0; 1904 1913 1905 rsrcimg->init(0); 1906 if(rsrcimg->getError() != NO_ERROR) 1907 { 1908 dprintf(("GetVersionSize can't load %s\n", modname)); 1909 delete rsrcimg; 1910 return(FALSE); 1911 } 1912 int size = rsrcimg->getVersionSize(); 1913 delete rsrcimg; 1914 winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName); 1915 if(winimage != NULL) { 1916 size = winimage->getVersionSize(); 1917 } 1918 else dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName)); 1919 FreeLibrary(hDll); 1914 1920 return size; 1915 1921 } 1916 1922 } 1917 1923 return winimage->getVersionSize(); 1918 1924 } 1919 1925 //****************************************************************************** 1920 //TODO:What does this do exactly??1921 1926 //****************************************************************************** 1922 1927 ODINFUNCTION1(BOOL,DisableThreadLibraryCalls,HMODULE,hModule)
Note:
See TracChangeset
for help on using the changeset viewer.