Commit 251bab8a authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ole32: Implement TYMED_FILE for STGMEDIUM marshaling and unmarshaling.

parent 05e99099
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include "ole2.h" #include "ole2.h"
#include "oleauto.h" #include "oleauto.h"
#include "rpcproxy.h" #include "rpcproxy.h"
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole); WINE_DEFAULT_DEBUG_CHANNEL(ole);
...@@ -1471,7 +1473,13 @@ ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM ...@@ -1471,7 +1473,13 @@ ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM
size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal); size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
break; break;
case TYMED_FILE: case TYMED_FILE:
FIXME("TYMED_FILE\n"); TRACE("TYMED_FILE\n");
if (pStgMedium->u.lpszFileName)
{
TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
size += 3 * sizeof(DWORD) +
(strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
}
break; break;
case TYMED_ISTREAM: case TYMED_ISTREAM:
FIXME("TYMED_ISTREAM\n"); FIXME("TYMED_ISTREAM\n");
...@@ -1545,7 +1553,24 @@ unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *p ...@@ -1545,7 +1553,24 @@ unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *p
pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal); pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
break; break;
case TYMED_FILE: case TYMED_FILE:
FIXME("TYMED_FILE\n"); TRACE("TYMED_FILE\n");
if (pStgMedium->u.lpszFileName)
{
DWORD len;
len = strlenW(pStgMedium->u.lpszFileName);
/* conformance */
*(DWORD *)pBuffer = len + 1;
pBuffer += sizeof(DWORD);
/* offset */
*(DWORD *)pBuffer = 0;
pBuffer += sizeof(DWORD);
/* variance */
*(DWORD *)pBuffer = len + 1;
pBuffer += sizeof(DWORD);
TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
}
break; break;
case TYMED_ISTREAM: case TYMED_ISTREAM:
FIXME("TYMED_ISTREAM\n"); FIXME("TYMED_ISTREAM\n");
...@@ -1595,7 +1620,7 @@ unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *p ...@@ -1595,7 +1620,7 @@ unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *p
*/ */
unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium) unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
{ {
DWORD content; DWORD content = 0;
DWORD releaseunk; DWORD releaseunk;
ALIGN_POINTER(pBuffer, 3); ALIGN_POINTER(pBuffer, 3);
...@@ -1622,7 +1647,43 @@ unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char ...@@ -1622,7 +1647,43 @@ unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char
pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal); pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
break; break;
case TYMED_FILE: case TYMED_FILE:
FIXME("TYMED_FILE\n"); TRACE("TYMED_FILE\n");
if (content)
{
DWORD conformance;
DWORD variance;
conformance = *(DWORD *)pBuffer;
pBuffer += sizeof(DWORD);
if (*(DWORD *)pBuffer != 0)
{
ERR("invalid offset %d\n", *(DWORD *)pBuffer);
RpcRaiseException(RPC_S_INVALID_BOUND);
return NULL;
}
pBuffer += sizeof(DWORD);
variance = *(DWORD *)pBuffer;
pBuffer += sizeof(DWORD);
if (conformance != variance)
{
ERR("conformance (%d) and variance (%d) should be equal\n",
conformance, variance);
RpcRaiseException(RPC_S_INVALID_BOUND);
return NULL;
}
if (conformance > 0x7fffffff)
{
ERR("conformance 0x%x too large\n", conformance);
RpcRaiseException(RPC_S_INVALID_BOUND);
return NULL;
}
pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
pBuffer += variance * sizeof(WCHAR);
}
else
pStgMedium->u.lpszFileName = NULL;
break; break;
case TYMED_ISTREAM: case TYMED_ISTREAM:
FIXME("TYMED_ISTREAM\n"); FIXME("TYMED_ISTREAM\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment