- Document CoSetState & CoGetState.
- Rewrite them to only retrieve TLS info once. - Remove trailing whitespace in COM_CurrentInfo.
This commit is contained in:
parent
2891bc53ba
commit
452491bd03
|
@ -2034,40 +2034,69 @@ HRESULT WINAPI CoInitializeWOW(DWORD x,DWORD y) {
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* CoGetState [OLE32.@]
|
* CoGetState [OLE32.@]
|
||||||
*
|
*
|
||||||
* NOTES: might be incomplete
|
* Retrieves the thread state object previously stored by CoSetState().
|
||||||
|
*
|
||||||
|
* PARAMS
|
||||||
|
* ppv [I] Address where pointer to object will be stored.
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
* Success: S_OK.
|
||||||
|
* Failure: E_OUTOFMEMORY.
|
||||||
|
*
|
||||||
|
* NOTES
|
||||||
|
* Crashes on all invalid ppv addresses, including NULL.
|
||||||
|
* If the function returns a non-NULL object then the caller must release its
|
||||||
|
* reference on the object when the object is no longer required.
|
||||||
|
*
|
||||||
|
* SEE ALSO
|
||||||
|
* CoSetState().
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI CoGetState(IUnknown ** ppv)
|
HRESULT WINAPI CoGetState(IUnknown ** ppv)
|
||||||
{
|
{
|
||||||
HRESULT hr = E_FAIL;
|
struct oletls *info = COM_CurrentInfo();
|
||||||
|
if (!info) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
*ppv = NULL;
|
*ppv = NULL;
|
||||||
|
|
||||||
if (COM_CurrentInfo()->state)
|
if (info->state)
|
||||||
{
|
{
|
||||||
IUnknown_AddRef(COM_CurrentInfo()->state);
|
IUnknown_AddRef(info->state);
|
||||||
*ppv = COM_CurrentInfo()->state;
|
*ppv = info->state;
|
||||||
TRACE("apt->state=%p\n", COM_CurrentInfo()->state);
|
TRACE("apt->state=%p\n", info->state);
|
||||||
hr = S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* CoSetState [OLE32.@]
|
* CoSetState [OLE32.@]
|
||||||
*
|
*
|
||||||
|
* Sets the thread state object.
|
||||||
|
*
|
||||||
|
* PARAMS
|
||||||
|
* pv [I] Pointer to state object to be stored.
|
||||||
|
*
|
||||||
|
* NOTES
|
||||||
|
* The system keeps a reference on the object while the object stored.
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
* Success: S_OK.
|
||||||
|
* Failure: E_OUTOFMEMORY.
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI CoSetState(IUnknown * pv)
|
HRESULT WINAPI CoSetState(IUnknown * pv)
|
||||||
{
|
{
|
||||||
|
struct oletls *info = COM_CurrentInfo();
|
||||||
|
if (!info) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
if (pv) IUnknown_AddRef(pv);
|
if (pv) IUnknown_AddRef(pv);
|
||||||
|
|
||||||
if (COM_CurrentInfo()->state)
|
if (info->state)
|
||||||
{
|
{
|
||||||
TRACE("-- release %p now\n", COM_CurrentInfo()->state);
|
TRACE("-- release %p now\n", info->state);
|
||||||
IUnknown_Release(COM_CurrentInfo()->state);
|
IUnknown_Release(info->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
COM_CurrentInfo()->state = pv;
|
info->state = pv;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,9 +227,9 @@ struct oletls
|
||||||
/* will create if necessary */
|
/* will create if necessary */
|
||||||
static inline struct oletls *COM_CurrentInfo(void)
|
static inline struct oletls *COM_CurrentInfo(void)
|
||||||
{
|
{
|
||||||
if (!NtCurrentTeb()->ReservedForOle)
|
if (!NtCurrentTeb()->ReservedForOle)
|
||||||
NtCurrentTeb()->ReservedForOle = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct oletls));
|
NtCurrentTeb()->ReservedForOle = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct oletls));
|
||||||
|
|
||||||
return NtCurrentTeb()->ReservedForOle;
|
return NtCurrentTeb()->ReservedForOle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue