Commit 1ce38682 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

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.
parent 1891e137
...@@ -2147,6 +2147,8 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT ...@@ -2147,6 +2147,8 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT
*ppTypeLib = NULL; *ppTypeLib = NULL;
lstrcpynW(pszPath, pszFileName, cchPath);
/* first try loading as a dll and access the typelib as a resource */ /* first try loading as a dll and access the typelib as a resource */
hinstDLL = LoadLibraryExW(pszFileName, 0, DONT_RESOLVE_DLL_REFERENCES | hinstDLL = LoadLibraryExW(pszFileName, 0, DONT_RESOLVE_DLL_REFERENCES |
LOAD_LIBRARY_AS_DATAFILE | LOAD_WITH_ALTERED_SEARCH_PATH); LOAD_LIBRARY_AS_DATAFILE | LOAD_WITH_ALTERED_SEARCH_PATH);
...@@ -2158,8 +2160,6 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT ...@@ -2158,8 +2160,6 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT
if(pIndexStr && pIndexStr != pszFileName && *++pIndexStr != '\0') if(pIndexStr && pIndexStr != pszFileName && *++pIndexStr != '\0')
{ {
index = atoiW(pIndexStr); index = atoiW(pIndexStr);
memcpy(pszPath, pszFileName,
(pIndexStr - pszFileName - 1) * sizeof(WCHAR));
pszPath[pIndexStr - pszFileName - 1] = '\0'; pszPath[pIndexStr - pszFileName - 1] = '\0';
hinstDLL = LoadLibraryExW(pszPath, 0, DONT_RESOLVE_DLL_REFERENCES | hinstDLL = LoadLibraryExW(pszPath, 0, DONT_RESOLVE_DLL_REFERENCES |
...@@ -2168,9 +2168,7 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT ...@@ -2168,9 +2168,7 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT
} }
/* get the path to the specified typelib file */ /* get the path to the specified typelib file */
if (hinstDLL) if (!hinstDLL)
GetModuleFileNameW(hinstDLL, pszPath, cchPath);
else
{ {
/* otherwise, try loading as a regular file */ /* otherwise, try loading as a regular file */
if (!SearchPathW(NULL, pszFileName, NULL, cchPath, pszPath, NULL)) if (!SearchPathW(NULL, pszFileName, NULL, cchPath, pszPath, NULL))
...@@ -2225,7 +2223,7 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT ...@@ -2225,7 +2223,7 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT
} }
else 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) if (INVALID_HANDLE_VALUE != hFile)
{ {
HANDLE hMapping = CreateFileMappingW( hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL ); HANDLE hMapping = CreateFileMappingW( hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL );
...@@ -2255,8 +2253,8 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT ...@@ -2255,8 +2253,8 @@ static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, IT
ITypeLibImpl *impl = (ITypeLibImpl*)*ppTypeLib; ITypeLibImpl *impl = (ITypeLibImpl*)*ppTypeLib;
TRACE("adding to cache\n"); TRACE("adding to cache\n");
impl->path = HeapAlloc(GetProcessHeap(), 0, (strlenW(pszFileName)+1) * sizeof(WCHAR)); impl->path = HeapAlloc(GetProcessHeap(), 0, (strlenW(pszPath)+1) * sizeof(WCHAR));
lstrcpyW(impl->path, pszFileName); lstrcpyW(impl->path, pszPath);
/* We should really canonicalise the path here. */ /* We should really canonicalise the path here. */
impl->index = index; impl->index = index;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment