ole32: Add support for non-default counter for anti moniker.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
57a34227c2
commit
b9ce037abb
|
@ -40,6 +40,7 @@ typedef struct AntiMonikerImpl{
|
||||||
IROTData IROTData_iface;
|
IROTData IROTData_iface;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
IUnknown *pMarshal; /* custom marshaler */
|
IUnknown *pMarshal; /* custom marshaler */
|
||||||
|
DWORD count;
|
||||||
} AntiMonikerImpl;
|
} AntiMonikerImpl;
|
||||||
|
|
||||||
static inline AntiMonikerImpl *impl_from_IMoniker(IMoniker *iface)
|
static inline AntiMonikerImpl *impl_from_IMoniker(IMoniker *iface)
|
||||||
|
@ -168,30 +169,35 @@ AntiMonikerImpl_IsDirty(IMoniker* iface)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* AntiMoniker_Load
|
* AntiMoniker_Load
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static HRESULT WINAPI
|
static HRESULT WINAPI AntiMonikerImpl_Load(IMoniker *iface, IStream *stream)
|
||||||
AntiMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
|
||||||
{
|
{
|
||||||
DWORD constant=1,dwbuffer;
|
AntiMonikerImpl *moniker = impl_from_IMoniker(iface);
|
||||||
HRESULT res;
|
DWORD count = 0;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
/* data read by this function is only a DWORD constant (must be 1) ! */
|
TRACE("%p, %p.\n", iface, stream);
|
||||||
res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),NULL);
|
|
||||||
|
|
||||||
if (SUCCEEDED(res)&& dwbuffer!=constant)
|
if (FAILED(hr = IStream_Read(stream, &count, sizeof(count), NULL)))
|
||||||
return E_FAIL;
|
return hr;
|
||||||
|
|
||||||
return res;
|
if (count > 0xfffff)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
moniker->count = count;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* AntiMoniker_Save
|
* AntiMoniker_Save
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static HRESULT WINAPI
|
static HRESULT WINAPI AntiMonikerImpl_Save(IMoniker *iface, IStream *stream, BOOL clear_dirty)
|
||||||
AntiMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty)
|
|
||||||
{
|
{
|
||||||
static const DWORD constant = 1;
|
AntiMonikerImpl *moniker = impl_from_IMoniker(iface);
|
||||||
/* data written by this function is only a DWORD constant set to 1 ! */
|
|
||||||
return IStream_Write(pStm,&constant,sizeof(constant),NULL);
|
TRACE("%p, %p, %d.\n", iface, stream, clear_dirty);
|
||||||
|
|
||||||
|
return IStream_Write(stream, &moniker->count, sizeof(moniker->count), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -323,12 +329,16 @@ AntiMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* AntiMoniker_Hash
|
* AntiMoniker_Hash
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static HRESULT WINAPI AntiMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
|
static HRESULT WINAPI AntiMonikerImpl_Hash(IMoniker *iface, DWORD *hash)
|
||||||
{
|
{
|
||||||
if (pdwHash==NULL)
|
AntiMonikerImpl *moniker = impl_from_IMoniker(iface);
|
||||||
|
|
||||||
|
TRACE("%p, %p.\n", iface, hash);
|
||||||
|
|
||||||
|
if (!hash)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
||||||
*pdwHash = 0x80000001;
|
*hash = 0x80000000 | moniker->count;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -434,14 +444,16 @@ AntiMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
|
||||||
* AntiMoniker_GetDisplayName
|
* AntiMoniker_GetDisplayName
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static HRESULT WINAPI
|
static HRESULT WINAPI
|
||||||
AntiMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc,
|
AntiMonikerImpl_GetDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR *displayname)
|
||||||
IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
|
|
||||||
{
|
{
|
||||||
static const WCHAR back[]={'\\','.','.',0};
|
AntiMonikerImpl *moniker = impl_from_IMoniker(iface);
|
||||||
|
static const WCHAR nameW[] = {'\\','.','.'};
|
||||||
|
WCHAR *ptrW;
|
||||||
|
int i;
|
||||||
|
|
||||||
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
|
TRACE("%p, %p, %p, %p.\n", iface, pbc, pmkToLeft, displayname);
|
||||||
|
|
||||||
if (ppszDisplayName==NULL)
|
if (!displayname)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
||||||
if (pmkToLeft!=NULL){
|
if (pmkToLeft!=NULL){
|
||||||
|
@ -449,12 +461,13 @@ AntiMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc,
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppszDisplayName=CoTaskMemAlloc(sizeof(back));
|
*displayname = ptrW = CoTaskMemAlloc((moniker->count * ARRAY_SIZE(nameW) + 1) * sizeof(WCHAR));
|
||||||
|
if (!*displayname)
|
||||||
if (*ppszDisplayName==NULL)
|
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
lstrcpyW(*ppszDisplayName,back);
|
for (i = 0; i < moniker->count; ++i)
|
||||||
|
memcpy(ptrW + i * ARRAY_SIZE(nameW), nameW, sizeof(nameW));
|
||||||
|
ptrW[moniker->count * ARRAY_SIZE(nameW)] = 0;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -598,6 +611,7 @@ static HRESULT AntiMonikerImpl_Construct(AntiMonikerImpl* This)
|
||||||
This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
|
This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
|
||||||
This->ref = 0;
|
This->ref = 0;
|
||||||
This->pMarshal = NULL;
|
This->pMarshal = NULL;
|
||||||
|
This->count = 1;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2328,7 +2328,6 @@ todo_wine
|
||||||
stream_write_dword(stream, 2);
|
stream_write_dword(stream, 2);
|
||||||
|
|
||||||
hr = IMoniker_Load(moniker, stream);
|
hr = IMoniker_Load(moniker, stream);
|
||||||
todo_wine
|
|
||||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IMoniker_IsEqual(moniker, moniker2);
|
hr = IMoniker_IsEqual(moniker, moniker2);
|
||||||
|
@ -2341,13 +2340,11 @@ todo_wine
|
||||||
|
|
||||||
hr = IMoniker_Hash(moniker, &hash);
|
hr = IMoniker_Hash(moniker, &hash);
|
||||||
ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr);
|
||||||
todo_wine
|
|
||||||
ok(hash == 0x80000002, "Unexpected hash value %#x.\n", hash);
|
ok(hash == 0x80000002, "Unexpected hash value %#x.\n", hash);
|
||||||
|
|
||||||
/* Display name reflects anti combination. */
|
/* Display name reflects anti combination. */
|
||||||
hr = IMoniker_GetDisplayName(moniker, bindctx, NULL, &name);
|
hr = IMoniker_GetDisplayName(moniker, bindctx, NULL, &name);
|
||||||
ok(hr == S_OK, "Failed to get display name, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to get display name, hr %#x.\n", hr);
|
||||||
todo_wine
|
|
||||||
ok(!lstrcmpW(name, L"\\..\\.."), "Unexpected display name %s.\n", wine_dbgstr_w(name));
|
ok(!lstrcmpW(name, L"\\..\\.."), "Unexpected display name %s.\n", wine_dbgstr_w(name));
|
||||||
CoTaskMemFree(name);
|
CoTaskMemFree(name);
|
||||||
|
|
||||||
|
@ -2355,30 +2352,25 @@ todo_wine
|
||||||
stream_write_dword(stream, 0xfffff);
|
stream_write_dword(stream, 0xfffff);
|
||||||
|
|
||||||
hr = IMoniker_Load(moniker, stream);
|
hr = IMoniker_Load(moniker, stream);
|
||||||
todo_wine
|
|
||||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IMoniker_Hash(moniker, &hash);
|
hr = IMoniker_Hash(moniker, &hash);
|
||||||
ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr);
|
||||||
todo_wine
|
|
||||||
ok(hash == 0x800fffff, "Unexpected hash value %#x.\n", hash);
|
ok(hash == 0x800fffff, "Unexpected hash value %#x.\n", hash);
|
||||||
|
|
||||||
stream_write_dword(stream, 0xfffff + 1);
|
stream_write_dword(stream, 0xfffff + 1);
|
||||||
|
|
||||||
hr = IMoniker_Load(moniker, stream);
|
hr = IMoniker_Load(moniker, stream);
|
||||||
todo_wine
|
|
||||||
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IMoniker_Hash(moniker, &hash);
|
hr = IMoniker_Hash(moniker, &hash);
|
||||||
ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr);
|
||||||
todo_wine
|
|
||||||
ok(hash == 0x800fffff, "Unexpected hash value %#x.\n", hash);
|
ok(hash == 0x800fffff, "Unexpected hash value %#x.\n", hash);
|
||||||
|
|
||||||
/* Zero combining counter is also valid. */
|
/* Zero combining counter is also valid. */
|
||||||
stream_write_dword(stream, 0);
|
stream_write_dword(stream, 0);
|
||||||
|
|
||||||
hr = IMoniker_Load(moniker, stream);
|
hr = IMoniker_Load(moniker, stream);
|
||||||
todo_wine
|
|
||||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IMoniker_IsEqual(moniker, moniker2);
|
hr = IMoniker_IsEqual(moniker, moniker2);
|
||||||
|
@ -2391,12 +2383,10 @@ todo_wine
|
||||||
|
|
||||||
hr = IMoniker_Hash(moniker, &hash);
|
hr = IMoniker_Hash(moniker, &hash);
|
||||||
ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr);
|
||||||
todo_wine
|
|
||||||
ok(hash == 0x80000000, "Unexpected hash value %#x.\n", hash);
|
ok(hash == 0x80000000, "Unexpected hash value %#x.\n", hash);
|
||||||
|
|
||||||
hr = IMoniker_GetDisplayName(moniker, bindctx, NULL, &name);
|
hr = IMoniker_GetDisplayName(moniker, bindctx, NULL, &name);
|
||||||
ok(hr == S_OK, "Failed to get display name, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to get display name, hr %#x.\n", hr);
|
||||||
todo_wine
|
|
||||||
ok(!lstrcmpW(name, L""), "Unexpected display name %s.\n", wine_dbgstr_w(name));
|
ok(!lstrcmpW(name, L""), "Unexpected display name %s.\n", wine_dbgstr_w(name));
|
||||||
CoTaskMemFree(name);
|
CoTaskMemFree(name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue