- Add error messages on failure in file moniker load function.

- Fix incorrect pointer check in both monikers.
- Fix max size calculation of item moniker to match native.
This commit is contained in:
Robert Shearman 2005-05-23 10:27:42 +00:00 committed by Alexandre Julliard
parent 27d73d6115
commit 8d6a673cf7
2 changed files with 20 additions and 6 deletions

View File

@ -198,31 +198,46 @@ FileMonikerImpl_Load(IMoniker* iface,IStream* pStm)
/* first WORD is non significative */
res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
if (bread!=sizeof(WORD) || wbuffer!=0)
{
ERR("Couldn't read 0 word\n");
return E_FAIL;
}
/* read filePath string length (plus one) */
res=IStream_Read(pStm,&length,sizeof(DWORD),&bread);
if (bread != sizeof(DWORD))
{
ERR("Couldn't read file string length\n");
return E_FAIL;
}
/* read filePath string */
filePathA=HeapAlloc(GetProcessHeap(),0,length);
res=IStream_Read(pStm,filePathA,length,&bread);
HeapFree(GetProcessHeap(),0,filePathA);
if (bread != length)
{
ERR("Couldn't read file path string\n");
return E_FAIL;
}
/* read the first constant */
IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF)
{
ERR("Couldn't read 0xDEADFFFF constant\n");
return E_FAIL;
}
length--;
for(i=0;i<10;i++){
res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
if (bread!=sizeof(WORD) || wbuffer!=0)
{
ERR("Couldn't read 0 padding\n");
return E_FAIL;
}
}
if (length>8)
@ -364,7 +379,7 @@ FileMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
TRACE("(%p,%p)\n",iface,pcbSize);
if (pcbSize!=NULL)
if (!pcbSize)
return E_POINTER;
/* for more details see FileMonikerImpl_Save coments */

View File

@ -369,17 +369,16 @@ HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface,
TRACE("(%p,%p)\n",iface,pcbSize);
if (pcbSize!=NULL)
if (!pcbSize)
return E_POINTER;
/* for more details see ItemMonikerImpl_Save coments */
pcbSize->u.LowPart = sizeof(DWORD) + /* DWORD which contains delimiter length */
delimiterLength + /* item delimiter string */
delimiterLength*4 + /* item delimiter string */
sizeof(DWORD) + /* DWORD which contains item name length */
nameLength + /* item name string */
34; /* this constant was added ! because when I tested this function it usually */
/* returns 34 bytes more than the number of bytes used by IMoniker::Save function */
nameLength*4 + /* item name string */
18; /* strange, but true */
pcbSize->u.HighPart=0;
return S_OK;