Murali Pattathe

This is the patch for the OleConvertOLESTREAMToIStorage wine API.
This API calls another function called OLECONVERT_LoadOLE10 which
basically read the OLE stream from the file through the callback
function (this is passed by the application).

The reading format was wrong. Still I am not very sure this is 100 %
correct format. I did some reverse engineering and found the format. I
have tried with different OLE object and its worked in paradox. I
haven't tested with any other apps.
This commit is contained in:
Alexandre Julliard 2000-02-29 22:03:14 +00:00
parent 194bd05260
commit 8eba5c2a21
1 changed files with 61 additions and 9 deletions

View File

@ -44,8 +44,11 @@ typedef struct
DWORD dwTypeID; DWORD dwTypeID;
DWORD dwOleTypeNameLength; DWORD dwOleTypeNameLength;
CHAR strOleTypeName[OLESTREAM_MAX_STR_LEN]; CHAR strOleTypeName[OLESTREAM_MAX_STR_LEN];
CHAR *pstrOleObjFileName;
DWORD dwOleObjFileNameLength;
DWORD dwMetaFileWidth; DWORD dwMetaFileWidth;
DWORD dwMetaFileHeight; DWORD dwMetaFileHeight;
CHAR strUnknown[8]; //don't know what is this 8 byts information in OLE stream.
DWORD dwDataLength; DWORD dwDataLength;
BYTE *pData; BYTE *pData;
}OLECONVERT_OLESTREAM_DATA; }OLECONVERT_OLESTREAM_DATA;
@ -5929,12 +5932,18 @@ static DWORD GetCreationModeFromSTGM(DWORD stgm)
* *
* Memory allocated for pData must be freed by the caller * Memory allocated for pData must be freed by the caller
*/ */
HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData) HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData, BOOL bStrem1)
{ {
DWORD dwSize; DWORD dwSize;
HRESULT hRes = S_OK; HRESULT hRes = S_OK;
pData->pData = NULL; int nTryCnt=0;
int max_try = 6;
pData->pData = NULL;
pData->pstrOleObjFileName = (CHAR *) NULL;
for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
{
/* Get the OleID */ /* Get the OleID */
dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID)); dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
if(dwSize != sizeof(pData->dwOleID)) if(dwSize != sizeof(pData->dwOleID))
@ -5945,6 +5954,12 @@ HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *
{ {
hRes = CONVERT10_E_OLESTREAM_FMT; hRes = CONVERT10_E_OLESTREAM_FMT;
} }
else
{
hRes = S_OK;
break;
}
}
if(hRes == S_OK) if(hRes == S_OK)
{ {
@ -5955,7 +5970,6 @@ HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *
hRes = CONVERT10_E_OLESTREAM_GET; hRes = CONVERT10_E_OLESTREAM_GET;
} }
} }
if(hRes == S_OK) if(hRes == S_OK)
{ {
if(pData->dwTypeID != 0) if(pData->dwTypeID != 0)
@ -5979,8 +5993,31 @@ HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *
} }
} }
} }
if(bStrem1)
{
dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
if(dwSize != sizeof(pData->dwOleObjFileNameLength))
{
hRes = CONVERT10_E_OLESTREAM_GET;
}
if(hRes == S_OK) if(hRes == S_OK)
{
if(pData->dwOleObjFileNameLength < 1) //there is no file name exist
pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength);
if(pData->pstrOleObjFileName)
{
dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength);
if(dwSize != pData->dwOleObjFileNameLength)
{
hRes = CONVERT10_E_OLESTREAM_GET;
}
}
else
hRes = CONVERT10_E_OLESTREAM_GET;
}
}
else
{ {
/* Get the Width of the Metafile */ /* Get the Width of the Metafile */
dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth)); dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
@ -5988,8 +6025,6 @@ HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *
{ {
hRes = CONVERT10_E_OLESTREAM_GET; hRes = CONVERT10_E_OLESTREAM_GET;
} }
}
if(hRes == S_OK) if(hRes == S_OK)
{ {
/* Get the Height of the Metafile */ /* Get the Height of the Metafile */
@ -5999,7 +6034,7 @@ HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *
hRes = CONVERT10_E_OLESTREAM_GET; hRes = CONVERT10_E_OLESTREAM_GET;
} }
} }
}
if(hRes == S_OK) if(hRes == S_OK)
{ {
/* Get the Lenght of the Data */ /* Get the Lenght of the Data */
@ -6010,6 +6045,18 @@ HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *
} }
} }
if(hRes == S_OK) // I don't know what is this 8 byts information is we have to figure out
{
if(!bStrem1) //if it is a second OLE stream data
{
pData->dwDataLength -= 8;
dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown));
if(dwSize != sizeof(pData->strUnknown))
{
hRes = CONVERT10_E_OLESTREAM_GET;
}
}
}
if(hRes == S_OK) if(hRes == S_OK)
{ {
if(pData->dwDataLength > 0) if(pData->dwDataLength > 0)
@ -6779,13 +6826,13 @@ HRESULT WINAPI OleConvertOLESTREAMToIStorage (
if(hRes == S_OK) if(hRes == S_OK)
{ {
/* Load the OLESTREAM to Memory */ /* Load the OLESTREAM to Memory */
hRes = OLECONVERT_LoadOLE10(pOleStream, &pOleStreamData[0]); hRes = OLECONVERT_LoadOLE10(pOleStream, &pOleStreamData[0], TRUE);
} }
if(hRes == S_OK) if(hRes == S_OK)
{ {
/* Load the OLESTREAM to Memory (part 2)*/ /* Load the OLESTREAM to Memory (part 2)*/
hRes = OLECONVERT_LoadOLE10(pOleStream, &pOleStreamData[1]); hRes = OLECONVERT_LoadOLE10(pOleStream, &pOleStreamData[1], FALSE);
} }
if(hRes == S_OK) if(hRes == S_OK)
@ -6828,6 +6875,11 @@ HRESULT WINAPI OleConvertOLESTREAMToIStorage (
{ {
HeapFree(GetProcessHeap(),0,pOleStreamData[i].pData); HeapFree(GetProcessHeap(),0,pOleStreamData[i].pData);
} }
if(pOleStreamData[i].pstrOleObjFileName != NULL)
{
HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);
pOleStreamData[i].pstrOleObjFileName = NULL;
}
} }
return hRes; return hRes;
} }