Module: wine Branch: refs/heads/master Commit: 1ce38682fb7d4904d4baaf19945881b8730c49d3 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=1ce38682fb7d4904d4baaf19...
Author: Robert Shearman rob@codeweavers.com Date: Tue Feb 14 11:33:40 2006 +0100
oleaut32: Fix returning Typelib file name. We can't use GetModuleFileName on a resource-only module, so the best we can do is to copy the original name we used to find the type library. Fix a couple of places where we were incorrectly using the file name, rather than the path.
---
dlls/oleaut32/typelib.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 6999dfd..317b44c 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -2147,6 +2147,8 @@ static int TLB_ReadTypeLib(LPCWSTR pszFi
*ppTypeLib = NULL;
+ lstrcpynW(pszPath, pszFileName, cchPath); + /* first try loading as a dll and access the typelib as a resource */ hinstDLL = LoadLibraryExW(pszFileName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE | LOAD_WITH_ALTERED_SEARCH_PATH); @@ -2158,8 +2160,6 @@ static int TLB_ReadTypeLib(LPCWSTR pszFi if(pIndexStr && pIndexStr != pszFileName && *++pIndexStr != '\0') { index = atoiW(pIndexStr); - memcpy(pszPath, pszFileName, - (pIndexStr - pszFileName - 1) * sizeof(WCHAR)); pszPath[pIndexStr - pszFileName - 1] = '\0';
hinstDLL = LoadLibraryExW(pszPath, 0, DONT_RESOLVE_DLL_REFERENCES | @@ -2168,9 +2168,7 @@ static int TLB_ReadTypeLib(LPCWSTR pszFi }
/* get the path to the specified typelib file */ - if (hinstDLL) - GetModuleFileNameW(hinstDLL, pszPath, cchPath); - else + if (!hinstDLL) { /* otherwise, try loading as a regular file */ if (!SearchPathW(NULL, pszFileName, NULL, cchPath, pszPath, NULL)) @@ -2225,7 +2223,7 @@ static int TLB_ReadTypeLib(LPCWSTR pszFi } else { - HANDLE hFile = CreateFileW( pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 ); + HANDLE hFile = CreateFileW(pszPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 ); if (INVALID_HANDLE_VALUE != hFile) { HANDLE hMapping = CreateFileMappingW( hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL ); @@ -2255,8 +2253,8 @@ static int TLB_ReadTypeLib(LPCWSTR pszFi ITypeLibImpl *impl = (ITypeLibImpl*)*ppTypeLib;
TRACE("adding to cache\n"); - impl->path = HeapAlloc(GetProcessHeap(), 0, (strlenW(pszFileName)+1) * sizeof(WCHAR)); - lstrcpyW(impl->path, pszFileName); + impl->path = HeapAlloc(GetProcessHeap(), 0, (strlenW(pszPath)+1) * sizeof(WCHAR)); + lstrcpyW(impl->path, pszPath); /* We should really canonicalise the path here. */ impl->index = index;