Robert Shearman : oleaut:
Move the call to SearchPath inside of TLB_ReadTypeLib.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Feb 9 05:47:37 CST 2006
Module: wine
Branch: refs/heads/master
Commit: 19b6046e2186fc11d709a64ff39053599d72e0c9
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=19b6046e2186fc11d709a64ff39053599d72e0c9
Author: Robert Shearman <rob at codeweavers.com>
Date: Thu Feb 9 12:11:01 2006 +0100
oleaut: Move the call to SearchPath inside of TLB_ReadTypeLib.
---
dlls/oleaut32/typelib.c | 59 ++++++++++++++++++++++-------------------------
1 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 8cface4..77f1f5f 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -196,7 +196,7 @@ static WCHAR *get_lcid_subkey( LCID lcid
return buffer;
}
-int TLB_ReadTypeLib(LPCWSTR file, INT index, ITypeLib2 **ppTypelib);
+static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, ITypeLib2 **ppTypeLib);
/****************************************************************************
@@ -333,38 +333,14 @@ HRESULT WINAPI LoadTypeLibEx(
REGKIND regkind, /* [in] Specify kind of registration */
ITypeLib **pptLib) /* [out] Pointer to pointer to loaded type library */
{
- WCHAR szPath[MAX_PATH+1], szFileCopy[MAX_PATH+1];
- WCHAR *pIndexStr;
+ WCHAR szPath[MAX_PATH+1];
HRESULT res;
- INT index = 1;
TRACE("(%s,%d,%p)\n",debugstr_w(szFile), regkind, pptLib);
- /* by default try and load using LoadLibrary (for builtin stdole32.tlb) */
- memcpy(szPath, szFile, (strlenW(szFile)+1)*sizeof(WCHAR));
-
*pptLib = NULL;
- if(!SearchPathW(NULL,szFile,NULL,sizeof(szPath)/sizeof(WCHAR),szPath,
- NULL)) {
-
- /* Look for a trailing '\\' followed by an index */
- pIndexStr = strrchrW(szFile, '\\');
- if(pIndexStr && pIndexStr != szFile && *++pIndexStr != '\0') {
- index = atoiW(pIndexStr);
- memcpy(szFileCopy, szFile,
- (pIndexStr - szFile - 1) * sizeof(WCHAR));
- szFileCopy[pIndexStr - szFile - 1] = '\0';
- if(!SearchPathW(NULL,szFileCopy,NULL,sizeof(szPath)/sizeof(WCHAR),
- szPath,NULL))
- return TYPE_E_CANTLOADLIBRARY;
- if (GetFileAttributesW(szFileCopy) & FILE_ATTRIBUTE_DIRECTORY)
- return TYPE_E_CANTLOADLIBRARY;
- }
- }
- TRACE("File %s index %d\n", debugstr_w(szPath), index);
-
- res = TLB_ReadTypeLib(szPath, index, (ITypeLib2**)pptLib);
+ res = TLB_ReadTypeLib(szFile, szPath, MAX_PATH + 1, (ITypeLib2**)pptLib);
if (SUCCEEDED(res))
switch(regkind)
@@ -2188,17 +2164,36 @@ static CRITICAL_SECTION cache_section =
*/
#define MSFT_SIGNATURE 0x5446534D /* "MSFT" */
#define SLTG_SIGNATURE 0x47544c53 /* "SLTG" */
-int TLB_ReadTypeLib(LPCWSTR pszFileName, INT index, ITypeLib2 **ppTypeLib)
+static int TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath, ITypeLib2 **ppTypeLib)
{
ITypeLibImpl *entry;
int ret = TYPE_E_CANTLOADLIBRARY;
DWORD dwSignature = 0;
HANDLE hFile;
-
- TRACE_(typelib)("%s:%d\n", debugstr_w(pszFileName), index);
+ INT index = 1;
*ppTypeLib = NULL;
+ if (!SearchPathW(NULL, pszFileName, NULL, cchPath, pszPath, NULL))
+ {
+ WCHAR szFileCopy[MAX_PATH+1];
+ /* Look for a trailing '\\' followed by an index */
+ WCHAR *pIndexStr = strrchrW(pszFileName, '\\');
+ if(pIndexStr && pIndexStr != pszFileName && *++pIndexStr != '\0')
+ {
+ index = atoiW(pIndexStr);
+ memcpy(szFileCopy, pszFileName,
+ (pIndexStr - pszFileName - 1) * sizeof(WCHAR));
+ szFileCopy[pIndexStr - pszFileName - 1] = '\0';
+ if (!SearchPathW(NULL, szFileCopy, NULL, cchPath, pszPath, NULL))
+ return TYPE_E_CANTLOADLIBRARY;
+ if (GetFileAttributesW(szFileCopy) & FILE_ATTRIBUTE_DIRECTORY)
+ return TYPE_E_CANTLOADLIBRARY;
+ }
+ }
+
+ TRACE_(typelib)("File %s index %d\n", debugstr_w(pszPath), index);
+
/* We look the path up in the typelib cache. If found, we just addref it, and return the pointer. */
EnterCriticalSection(&cache_section);
for (entry = tlb_cache_first; entry != NULL; entry = entry->next)
@@ -2215,7 +2210,7 @@ int TLB_ReadTypeLib(LPCWSTR pszFileName,
LeaveCriticalSection(&cache_section);
/* check the signature of the file */
- hFile = CreateFileW( pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
+ 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 );
@@ -2252,7 +2247,7 @@ int TLB_ReadTypeLib(LPCWSTR pszFileName,
if (((WORD)dwSignature == IMAGE_DOS_SIGNATURE) || (dwSignature == 0))
{
/* find the typelibrary resource*/
- HINSTANCE hinstDLL = LoadLibraryExW(pszFileName, 0, DONT_RESOLVE_DLL_REFERENCES|
+ HINSTANCE hinstDLL = LoadLibraryExW(pszPath, 0, DONT_RESOLVE_DLL_REFERENCES|
LOAD_LIBRARY_AS_DATAFILE|LOAD_WITH_ALTERED_SEARCH_PATH);
if (hinstDLL)
{
More information about the wine-cvs
mailing list