OleConvertOLESTREAMToIStorage fails (returns REGDB_E_CLASSNOTREG) when

the CLSID of the OLE object is not found in the registry. Fixed.
This commit is contained in:
Noomen Hamza 2000-06-20 20:49:53 +00:00 committed by Alexandre Julliard
parent d88fbb7a78
commit 3b3779b260
3 changed files with 90 additions and 38 deletions

View File

@ -457,6 +457,24 @@ HRESULT WINAPI CLSIDFromString16(
if (!s)
s = "{00000000-0000-0000-0000-000000000000}";
else { /* validate the CLSID string */
if (strlen(s) != 38)
return CO_E_CLASSSTRING;
if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
return CO_E_CLASSSTRING;
for (i=1; i<37; i++)
{
if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
if (!(((s[i] >= '0') && (s[i] <= '9')) ||
((s[i] >= 'a') && (s[i] <= 'f')) ||
((s[i] >= 'A') && (s[i] <= 'F')))
)
return CO_E_CLASSSTRING;
}
}
TRACE("%s -> %p\n", s, id);
@ -473,9 +491,6 @@ HRESULT WINAPI CLSIDFromString16(
/* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
if (strlen(s) != 38)
return OLE_ERROR_OBJECT;
p = (BYTE *) id;
s++; /* skip leading brace */
@ -933,13 +948,13 @@ HRESULT WINAPI CLSIDFromProgID16(
sprintf(buf,"%s\\CLSID",progid);
if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {
HeapFree(GetProcessHeap(),0,buf);
return OLE_ERROR_GENERIC;
return CO_E_CLASSSTRING;
}
HeapFree(GetProcessHeap(),0,buf);
buf2len = sizeof(buf2);
if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {
RegCloseKey(xhkey);
return OLE_ERROR_GENERIC;
return CO_E_CLASSSTRING;
}
RegCloseKey(xhkey);
return CLSIDFromString16(buf2,riid);

View File

@ -6401,11 +6401,7 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName
/* Get the CLSID */
hRes = CLSIDFromProgID16(IStorageCompObj.strProgIDName, &(IStorageCompObj.clsid));
if(hRes != S_OK)
{
hRes = REGDB_E_CLASSNOTREG;
}
else
if(hRes == S_OK)
{
HKEY hKey;
LONG hErr;
@ -6422,34 +6418,29 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName
}
RegCloseKey(hKey);
}
if(hErr != ERROR_SUCCESS)
{
hRes = REGDB_E_CLASSNOTREG;
}
}
if(hRes == S_OK )
/* Write CompObj Structure to stream */
hRes = IStream_Write(pStream, IStorageCompObj.byUnknown1, sizeof(IStorageCompObj.byUnknown1), NULL);
WriteClassStm(pStream,&(IStorageCompObj.clsid));
hRes = IStream_Write(pStream, &(IStorageCompObj.dwCLSIDNameLength), sizeof(IStorageCompObj.dwCLSIDNameLength), NULL);
if(IStorageCompObj.dwCLSIDNameLength > 0)
{
/* Write CompObj Structure to stream */
hRes = IStream_Write(pStream, IStorageCompObj.byUnknown1, sizeof(IStorageCompObj.byUnknown1), NULL);
hRes = IStream_Write(pStream, &(IStorageCompObj.clsid) , sizeof(IStorageCompObj.clsid ), NULL);
hRes = IStream_Write(pStream, &(IStorageCompObj.dwCLSIDNameLength), sizeof(IStorageCompObj.dwCLSIDNameLength), NULL);
if(IStorageCompObj.dwCLSIDNameLength > 0)
{
hRes = IStream_Write(pStream, IStorageCompObj.strCLSIDName, IStorageCompObj.dwCLSIDNameLength, NULL);
}
hRes = IStream_Write(pStream, &(IStorageCompObj.dwOleTypeNameLength) , sizeof(IStorageCompObj.dwOleTypeNameLength), NULL);
if(IStorageCompObj.dwOleTypeNameLength > 0)
{
hRes = IStream_Write(pStream, IStorageCompObj.strOleTypeName , IStorageCompObj.dwOleTypeNameLength, NULL);
}
hRes = IStream_Write(pStream, &(IStorageCompObj.dwProgIDNameLength) , sizeof(IStorageCompObj.dwProgIDNameLength), NULL);
if(IStorageCompObj.dwProgIDNameLength > 0)
{
hRes = IStream_Write(pStream, IStorageCompObj.strProgIDName , IStorageCompObj.dwProgIDNameLength, NULL);
}
hRes = IStream_Write(pStream, IStorageCompObj.byUnknown2 , sizeof(IStorageCompObj.byUnknown2), NULL);
hRes = IStream_Write(pStream, IStorageCompObj.strCLSIDName, IStorageCompObj.dwCLSIDNameLength, NULL);
}
hRes = IStream_Write(pStream, &(IStorageCompObj.dwOleTypeNameLength) , sizeof(IStorageCompObj.dwOleTypeNameLength), NULL);
if(IStorageCompObj.dwOleTypeNameLength > 0)
{
hRes = IStream_Write(pStream, IStorageCompObj.strOleTypeName , IStorageCompObj.dwOleTypeNameLength, NULL);
}
hRes = IStream_Write(pStream, &(IStorageCompObj.dwProgIDNameLength) , sizeof(IStorageCompObj.dwProgIDNameLength), NULL);
if(IStorageCompObj.dwProgIDNameLength > 0)
{
hRes = IStream_Write(pStream, IStorageCompObj.strProgIDName , IStorageCompObj.dwProgIDNameLength, NULL);
}
hRes = IStream_Write(pStream, IStorageCompObj.byUnknown2 , sizeof(IStorageCompObj.byUnknown2), NULL);
IStream_Release(pStream);
}
return hRes;

View File

@ -1518,10 +1518,52 @@ extern int WIN32_LastError;
#define CO_E_INIT_SCM_EXEC_FAILURE 0x80004011
#define CO_E_INIT_ONLY_SINGLE_THREADED 0x80004012 */
#define CO_S_NOTALLINTERFACES 0x00080012
#define CO_E_NOTINITIALIZED 0x800401F0
#define CO_E_ERRORINDLL 0x800401F9
#define CO_E_OBJISREG 0x800401FB
#define CO_S_NOTALLINTERFACES 0x00080012
#define CO_E_NOTINITIALIZED 0x800401F0L
#define CO_E_ALREADYINITIALIZED 0x800401F1L
#define CO_E_CANTDETERMINECLASS 0x800401F2L
#define CO_E_CLASSSTRING 0x800401F3L
#define CO_E_IIDSTRING 0x800401F4L
#define CO_E_APPNOTFOUND 0x800401F5L
#define CO_E_APPSINGLEUSE 0x800401F6L
#define CO_E_ERRORINAPP 0x800401F7L
#define CO_E_DLLNOTFOUND 0x800401F8L
#define CO_E_ERRORINDLL 0x800401F9L
#define CO_E_WRONGOSFORAPP 0x800401FAL
#define CO_E_OBJNOTREG 0x800401FBL
#define CO_E_OBJISREG 0x800401FCL
#define CO_E_OBJNOTCONNECTED 0x800401FDL
#define CO_E_APPDIDNTREG 0x800401FEL
#define CO_E_RELEASED 0x800401FFL
#define CO_E_FAILEDTOIMPERSONATE 0x80040200L
#define CO_E_FAILEDTOGETSECCTX 0x80040201L
#define CO_E_FAILEDTOOPENTHREADTOKEN 0x80040202L
#define CO_E_FAILEDTOGETTOKENINFO 0x80040203L
#define CO_E_TRUSTEEDOESNTMATCHCLIENT 0x80040204L
#define CO_E_FAILEDTOQUERYCLIENTBLANKET 0x80040205L
#define CO_E_FAILEDTOSETDACL 0x80040206L
#define CO_E_ACCESSCHECKFAILED 0x80040207L
#define CO_E_NETACCESSAPIFAILED 0x80040208L
#define CO_E_WRONGTRUSTEENAMESYNTAX 0x80040209L
#define CO_E_INVALIDSID 0x8004020AL
#define CO_E_CONVERSIONFAILED 0x8004020BL
#define CO_E_NOMATCHINGSIDFOUND 0x8004020CL
#define CO_E_LOOKUPACCSIDFAILED 0x8004020DL
#define CO_E_NOMATCHINGNAMEFOUND 0x8004020EL
#define CO_E_LOOKUPACCNAMEFAILED 0x8004020FL
#define CO_E_SETSERLHNDLFAILED 0x80040210L
#define CO_E_FAILEDTOGETWINDIR 0x80040211L
#define CO_E_PATHTOOLONG 0x80040212L
#define CO_E_FAILEDTOGENUUID 0x80040213L
#define CO_E_FAILEDTOCREATEFILE 0x80040214L
#define CO_E_FAILEDTOCLOSEHANDLE 0x80040215L
#define CO_E_EXCEEDSYSACLLIMIT 0x80040216L
#define CO_E_ACESINWRONGORDER 0x80040217L
#define CO_E_INCOMPATIBLESTREAMVERSION 0x80040218L
#define CO_E_FAILEDTOOPENPROCESSTOKEN 0x80040219L
#define CO_E_DECODEFAILED 0x8004021AL
#define CO_E_ACNOTINITIALIZED 0x8004021BL
#define OLE_E_FIRST 0x80040000L
#define OLE_E_LAST 0x800400FFL
@ -1640,7 +1682,11 @@ extern int WIN32_LastError;
/* registry errors */
#define REGDB_E_READREGDB 0x80040150
#define REGDB_E_WRITEREGDB 0x80040151
#define REGDB_E_KEYMISSING 0x80040152
#define REGDB_E_INVALIVALUE 0x80040153
#define REGDB_E_CLASSNOTREG 0x80040154
#define REGDB_E_IIDNOTREG 0x80040155
#define INPLACE_E_NOTUNDOABLE 0x800401A0
#define INPLACE_E_NOTOOLSPACE 0x800401A1