From 472a5e52eb8fb1cf2b279a1a7920edc5a32a2705 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Fri, 16 Aug 2002 01:39:12 +0000 Subject: [PATCH] Fixed GetClassFile implementation. --- dlls/ole32/compobj.c | 31 +++++++++++++++++-------------- dlls/ole32/filemoniker.c | 2 ++ dlls/ole32/ole32.spec | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index dc4927f3951..166af1aaf27 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -1211,12 +1211,14 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid) { IStorage *pstg=0; HRESULT res; - int nbElm=0,length=0,i=0; - LONG sizeProgId=20; + int nbElm, length, i; + LONG sizeProgId; LPOLESTR *pathDec=0,absFile=0,progId=0; - WCHAR extention[100]={0}; + LPWSTR extension; + static const WCHAR bkslashW[] = {'\\',0}; + static const WCHAR dotW[] = {'.',0}; - TRACE("()\n"); + TRACE("%s, %p\n", debugstr_w(filePathName), pclsid); /* if the file contain a storage object the return the CLSID writen by IStorage_SetClass method*/ if((StgIsStorageFile(filePathName))==S_OK){ @@ -1260,23 +1262,24 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid) absFile=pathDec[nbElm-1]; /* failed if the path represente a directory and not an absolute file name*/ - if (lstrcmpW(absFile,(LPOLESTR)"\\")) + if (!lstrcmpW(absFile, bkslashW)) return MK_E_INVALIDEXTENSION; /* get the extension of the file */ + extension = NULL; length=lstrlenW(absFile); - for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--); + for(i = length-1; (i >= 0) && *(extension = &absFile[i]) != '.'; i--) + /* nothing */; + + if (!extension || !lstrcmpW(extension, dotW)) + return MK_E_INVALIDEXTENSION; + + res=RegQueryValueW(HKEY_CLASSES_ROOT, extension, NULL, &sizeProgId); /* get the progId associated to the extension */ - progId=CoTaskMemAlloc(sizeProgId); + progId = CoTaskMemAlloc(sizeProgId); + res = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId); - res=RegQueryValueW(HKEY_CLASSES_ROOT,extention,progId,&sizeProgId); - - if (res==ERROR_MORE_DATA){ - - progId = CoTaskMemRealloc(progId,sizeProgId); - res=RegQueryValueW(HKEY_CLASSES_ROOT,extention,progId,&sizeProgId); - } if (res==ERROR_SUCCESS) /* return the clsid associated to the progId */ res= CLSIDFromProgID(progId,pclsid); diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c index e8e03796159..bf70e784b68 100644 --- a/dlls/ole32/filemoniker.c +++ b/dlls/ole32/filemoniker.c @@ -1096,6 +1096,8 @@ int WINAPI FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable) int len=lstrlenW(str); + TRACE("%s, %p\n", debugstr_w(str), *stringTable); + strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR)); if (strgtable==NULL) diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index 8b83bcd87ad..c0a9425829c 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -66,7 +66,7 @@ init OLE32_DllEntryPoint 64 stub DllGetClassObjectWOW 65 stdcall DoDragDrop(ptr ptr long ptr) DoDragDrop 66 stub EnableHookObject - 67 stdcall GetClassFile(ptr ptr) GetClassFile + 67 stdcall GetClassFile(wstr ptr) GetClassFile 68 stdcall GetConvertStg(ptr) GetConvertStg 69 stub GetDocumentBitStg 70 stdcall GetHGlobalFromILockBytes(ptr ptr) GetHGlobalFromILockBytes