ReactOS 0.4.16-dev-329-g9223134
errorinfo.c File Reference
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "oleauto.h"
#include "winerror.h"
#include "compobj_private.h"
#include "wine/debug.h"
Include dependency graph for errorinfo.c:

Go to the source code of this file.

Classes

struct  ErrorInfoImpl
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct ErrorInfoImpl ErrorInfoImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static WCHARheap_strdupW (const WCHAR *str)
 
static ErrorInfoImplimpl_from_IErrorInfo (IErrorInfo *iface)
 
static ErrorInfoImplimpl_from_ICreateErrorInfo (ICreateErrorInfo *iface)
 
static ErrorInfoImplimpl_from_ISupportErrorInfo (ISupportErrorInfo *iface)
 
static HRESULT WINAPI IErrorInfoImpl_QueryInterface (IErrorInfo *iface, REFIID riid, void **ppvoid)
 
static ULONG WINAPI IErrorInfoImpl_AddRef (IErrorInfo *iface)
 
static ULONG WINAPI IErrorInfoImpl_Release (IErrorInfo *iface)
 
static HRESULT WINAPI IErrorInfoImpl_GetGUID (IErrorInfo *iface, GUID *pGUID)
 
static HRESULT WINAPI IErrorInfoImpl_GetSource (IErrorInfo *iface, BSTR *pBstrSource)
 
static HRESULT WINAPI IErrorInfoImpl_GetDescription (IErrorInfo *iface, BSTR *pBstrDescription)
 
static HRESULT WINAPI IErrorInfoImpl_GetHelpFile (IErrorInfo *iface, BSTR *pBstrHelpFile)
 
static HRESULT WINAPI IErrorInfoImpl_GetHelpContext (IErrorInfo *iface, DWORD *pdwHelpContext)
 
static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface (ICreateErrorInfo *iface, REFIID riid, VOID **ppvoid)
 
static ULONG WINAPI ICreateErrorInfoImpl_AddRef (ICreateErrorInfo *iface)
 
static ULONG WINAPI ICreateErrorInfoImpl_Release (ICreateErrorInfo *iface)
 
static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID (ICreateErrorInfo *iface, REFGUID rguid)
 
static HRESULT WINAPI ICreateErrorInfoImpl_SetSource (ICreateErrorInfo *iface, LPOLESTR szSource)
 
static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription (ICreateErrorInfo *iface, LPOLESTR szDescription)
 
static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile (ICreateErrorInfo *iface, LPOLESTR szHelpFile)
 
static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext (ICreateErrorInfo *iface, DWORD dwHelpContext)
 
static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface (ISupportErrorInfo *iface, REFIID riid, VOID **ppvoid)
 
static ULONG WINAPI ISupportErrorInfoImpl_AddRef (ISupportErrorInfo *iface)
 
static ULONG WINAPI ISupportErrorInfoImpl_Release (ISupportErrorInfo *iface)
 
static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo (ISupportErrorInfo *iface, REFIID riid)
 
static IErrorInfoIErrorInfoImpl_Constructor (void)
 
HRESULT WINAPI CreateErrorInfo (ICreateErrorInfo **pperrinfo)
 
HRESULT WINAPI GetErrorInfo (ULONG dwReserved, IErrorInfo **pperrinfo)
 
HRESULT WINAPI SetErrorInfo (ULONG dwReserved, IErrorInfo *perrinfo)
 

Variables

static const IErrorInfoVtbl ErrorInfoVtbl
 
static const ICreateErrorInfoVtbl CreateErrorInfoVtbl
 
static const ISupportErrorInfoVtbl SupportErrorInfoVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 29 of file errorinfo.c.

Typedef Documentation

◆ ErrorInfoImpl

Function Documentation

◆ CreateErrorInfo()

HRESULT WINAPI CreateErrorInfo ( ICreateErrorInfo **  pperrinfo)

Definition at line 386 of file errorinfo.c.

387{
388 IErrorInfo * pei;
389 HRESULT res;
390 TRACE("(%p)\n", pperrinfo);
391 if(! pperrinfo ) return E_INVALIDARG;
392 if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY;
393
394 res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo);
395 IErrorInfo_Release(pei);
396 return res;
397}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
static IErrorInfo * IErrorInfoImpl_Constructor(void)
Definition: errorinfo.c:356
GLuint res
Definition: glext.h:9613
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by test_error_info().

◆ GetErrorInfo()

HRESULT WINAPI GetErrorInfo ( ULONG  dwReserved,
IErrorInfo **  pperrinfo 
)

Definition at line 417 of file errorinfo.c.

418{
419 TRACE("(%d, %p, %p)\n", dwReserved, pperrinfo, COM_CurrentInfo()->errorinfo);
420
421 if (dwReserved)
422 {
423 ERR("dwReserved (0x%x) != 0\n", dwReserved);
424 return E_INVALIDARG;
425 }
426
427 if(!pperrinfo) return E_INVALIDARG;
428
429 if (!COM_CurrentInfo()->errorinfo)
430 {
431 *pperrinfo = NULL;
432 return S_FALSE;
433 }
434
435 *pperrinfo = COM_CurrentInfo()->errorinfo;
436
437 /* clear thread error state */
438 COM_CurrentInfo()->errorinfo = NULL;
439 return S_OK;
440}
#define ERR(fmt,...)
Definition: precomp.h:57
static struct oletls * COM_CurrentInfo(void)
#define NULL
Definition: types.h:112
#define S_OK
Definition: intsafe.h:52
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
#define S_FALSE
Definition: winerror.h:2357

Referenced by _com_issue_errorex(), ITypeInfo_fnInvoke(), and test_error_info().

◆ heap_strdupW()

static WCHAR * heap_strdupW ( const WCHAR str)
inlinestatic

Definition at line 43 of file errorinfo.c.

44{
45 WCHAR *ret = NULL;
46
47 if(str) {
48 size_t size;
49
50 size = (lstrlenW(str)+1)*sizeof(WCHAR);
52 if(ret)
53 memcpy(ret, str, size);
54 }
55
56 return ret;
57}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
#define lstrlenW
Definition: compat.h:750
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const WCHAR * str
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ICreateErrorInfoImpl_SetDescription(), ICreateErrorInfoImpl_SetHelpFile(), and ICreateErrorInfoImpl_SetSource().

◆ ICreateErrorInfoImpl_AddRef()

static ULONG WINAPI ICreateErrorInfoImpl_AddRef ( ICreateErrorInfo iface)
static

Definition at line 235 of file errorinfo.c.

237{
239 return IErrorInfo_AddRef(&This->IErrorInfo_iface);
240}
static ErrorInfoImpl * impl_from_ICreateErrorInfo(ICreateErrorInfo *iface)
Definition: errorinfo.c:78

◆ ICreateErrorInfoImpl_QueryInterface()

static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface ( ICreateErrorInfo iface,
REFIID  riid,
VOID **  ppvoid 
)
static

Definition at line 226 of file errorinfo.c.

230{
232 return IErrorInfo_QueryInterface(&This->IErrorInfo_iface, riid, ppvoid);
233}
REFIID riid
Definition: atlbase.h:39

◆ ICreateErrorInfoImpl_Release()

static ULONG WINAPI ICreateErrorInfoImpl_Release ( ICreateErrorInfo iface)
static

Definition at line 242 of file errorinfo.c.

244{
246 return IErrorInfo_Release(&This->IErrorInfo_iface);
247}

◆ ICreateErrorInfoImpl_SetDescription()

static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription ( ICreateErrorInfo iface,
LPOLESTR  szDescription 
)
static

Definition at line 273 of file errorinfo.c.

276{
278 TRACE("(%p): %s\n",This, debugstr_w(szDescription));
279
280 heap_free(This->description);
281 This->description = heap_strdupW(szDescription);
282 return S_OK;
283}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static const WCHAR szDescription[]
Definition: provider.c:55
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: errorinfo.c:43
#define debugstr_w
Definition: kernel32.h:32

◆ ICreateErrorInfoImpl_SetGUID()

static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID ( ICreateErrorInfo iface,
REFGUID  rguid 
)
static

Definition at line 250 of file errorinfo.c.

253{
255 TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid));
256 This->m_Guid = *rguid;
257 return S_OK;
258}
#define debugstr_guid
Definition: kernel32.h:35

◆ ICreateErrorInfoImpl_SetHelpContext()

static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext ( ICreateErrorInfo iface,
DWORD  dwHelpContext 
)
static

Definition at line 296 of file errorinfo.c.

299{
301 TRACE("(%p,%d)\n",This,dwHelpContext);
302 This->m_dwHelpContext = dwHelpContext;
303 return S_OK;
304}

◆ ICreateErrorInfoImpl_SetHelpFile()

static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile ( ICreateErrorInfo iface,
LPOLESTR  szHelpFile 
)
static

Definition at line 285 of file errorinfo.c.

288{
290 TRACE("(%p,%s)\n",This,debugstr_w(szHelpFile));
291 heap_free(This->help_file);
292 This->help_file = heap_strdupW(szHelpFile);
293 return S_OK;
294}
TCHAR szHelpFile[]
Definition: scrnsave.c:31

◆ ICreateErrorInfoImpl_SetSource()

static HRESULT WINAPI ICreateErrorInfoImpl_SetSource ( ICreateErrorInfo iface,
LPOLESTR  szSource 
)
static

Definition at line 260 of file errorinfo.c.

263{
265 TRACE("(%p): %s\n",This, debugstr_w(szSource));
266
267 heap_free(This->source);
268 This->source = heap_strdupW(szSource);
269
270 return S_OK;
271}

◆ IErrorInfoImpl_AddRef()

static ULONG WINAPI IErrorInfoImpl_AddRef ( IErrorInfo iface)
static

Definition at line 121 of file errorinfo.c.

123{
125 TRACE("(%p)->(count=%u)\n",This,This->ref);
126 return InterlockedIncrement(&This->ref);
127}
#define InterlockedIncrement
Definition: armddk.h:53
static ErrorInfoImpl * impl_from_IErrorInfo(IErrorInfo *iface)
Definition: errorinfo.c:73

◆ IErrorInfoImpl_Constructor()

static IErrorInfo * IErrorInfoImpl_Constructor ( void  )
static

Definition at line 356 of file errorinfo.c.

357{
359
360 if (!This) return NULL;
361
362 This->IErrorInfo_iface.lpVtbl = &ErrorInfoVtbl;
363 This->ICreateErrorInfo_iface.lpVtbl = &CreateErrorInfoVtbl;
364 This->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
365 This->ref = 1;
366 This->source = NULL;
367 This->description = NULL;
368 This->help_file = NULL;
369 This->m_dwHelpContext = 0;
370
371 return &This->IErrorInfo_iface;
372}
static const IErrorInfoVtbl ErrorInfoVtbl
Definition: errorinfo.c:213
static const ICreateErrorInfoVtbl CreateErrorInfoVtbl
Definition: errorinfo.c:306
static const ISupportErrorInfoVtbl SupportErrorInfoVtbl
Definition: errorinfo.c:348

Referenced by CreateErrorInfo().

◆ IErrorInfoImpl_GetDescription()

static HRESULT WINAPI IErrorInfoImpl_GetDescription ( IErrorInfo iface,
BSTR pBstrDescription 
)
static

Definition at line 172 of file errorinfo.c.

175{
177
178 TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
179 if (pBstrDescription == NULL)
180 return E_INVALIDARG;
181 *pBstrDescription = SysAllocString(This->description);
182
183 return S_OK;
184}
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238

◆ IErrorInfoImpl_GetGUID()

static HRESULT WINAPI IErrorInfoImpl_GetGUID ( IErrorInfo iface,
GUID pGUID 
)
static

Definition at line 149 of file errorinfo.c.

152{
154 TRACE("(%p)->(count=%u)\n",This,This->ref);
155 if(!pGUID )return E_INVALIDARG;
156 *pGUID = This->m_Guid;
157 return S_OK;
158}

◆ IErrorInfoImpl_GetHelpContext()

static HRESULT WINAPI IErrorInfoImpl_GetHelpContext ( IErrorInfo iface,
DWORD pdwHelpContext 
)
static

Definition at line 200 of file errorinfo.c.

203{
205 TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
206 if (pdwHelpContext == NULL)
207 return E_INVALIDARG;
208 *pdwHelpContext = This->m_dwHelpContext;
209
210 return S_OK;
211}

◆ IErrorInfoImpl_GetHelpFile()

static HRESULT WINAPI IErrorInfoImpl_GetHelpFile ( IErrorInfo iface,
BSTR pBstrHelpFile 
)
static

Definition at line 186 of file errorinfo.c.

189{
191
192 TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
193 if (pBstrHelpFile == NULL)
194 return E_INVALIDARG;
195 *pBstrHelpFile = SysAllocString(This->help_file);
196
197 return S_OK;
198}

◆ IErrorInfoImpl_GetSource()

static HRESULT WINAPI IErrorInfoImpl_GetSource ( IErrorInfo iface,
BSTR pBstrSource 
)
static

Definition at line 160 of file errorinfo.c.

163{
165 TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
166 if (pBstrSource == NULL)
167 return E_INVALIDARG;
168 *pBstrSource = SysAllocString(This->source);
169 return S_OK;
170}

◆ IErrorInfoImpl_QueryInterface()

static HRESULT WINAPI IErrorInfoImpl_QueryInterface ( IErrorInfo iface,
REFIID  riid,
void **  ppvoid 
)
static

Definition at line 88 of file errorinfo.c.

92{
94 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid),ppvoid);
95
96 *ppvoid = NULL;
97
98 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IErrorInfo))
99 {
100 *ppvoid = &This->IErrorInfo_iface;
101 }
102 else if(IsEqualIID(riid, &IID_ICreateErrorInfo))
103 {
104 *ppvoid = &This->ICreateErrorInfo_iface;
105 }
106 else if(IsEqualIID(riid, &IID_ISupportErrorInfo))
107 {
108 *ppvoid = &This->ISupportErrorInfo_iface;
109 }
110
111 if(*ppvoid)
112 {
113 IUnknown_AddRef( (IUnknown*)*ppvoid );
114 TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid);
115 return S_OK;
116 }
117 TRACE("-- Interface: E_NOINTERFACE\n");
118 return E_NOINTERFACE;
119}
const GUID IID_IUnknown
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ IErrorInfoImpl_Release()

static ULONG WINAPI IErrorInfoImpl_Release ( IErrorInfo iface)
static

Definition at line 129 of file errorinfo.c.

131{
134
135 TRACE("(%p)->(count=%u)\n",This,ref+1);
136
137 if (!ref)
138 {
139 TRACE("-- destroying IErrorInfo(%p)\n",This);
140
141 heap_free(This->source);
142 heap_free(This->description);
143 heap_free(This->help_file);
145 }
146 return ref;
147}
#define InterlockedDecrement
Definition: armddk.h:52
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ impl_from_ICreateErrorInfo()

◆ impl_from_IErrorInfo()

◆ impl_from_ISupportErrorInfo()

static ErrorInfoImpl * impl_from_ISupportErrorInfo ( ISupportErrorInfo iface)
inlinestatic

◆ ISupportErrorInfoImpl_AddRef()

static ULONG WINAPI ISupportErrorInfoImpl_AddRef ( ISupportErrorInfo iface)
static

Definition at line 327 of file errorinfo.c.

328{
330 return IErrorInfo_AddRef(&This->IErrorInfo_iface);
331}
static ErrorInfoImpl * impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
Definition: errorinfo.c:83

◆ ISupportErrorInfoImpl_InterfaceSupportsErrorInfo()

static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo ( ISupportErrorInfo iface,
REFIID  riid 
)
static

Definition at line 339 of file errorinfo.c.

342{
344 TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
345 return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
346}

◆ ISupportErrorInfoImpl_QueryInterface()

static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface ( ISupportErrorInfo iface,
REFIID  riid,
VOID **  ppvoid 
)
static

Definition at line 318 of file errorinfo.c.

322{
324 return IErrorInfo_QueryInterface(&This->IErrorInfo_iface, riid, ppvoid);
325}

◆ ISupportErrorInfoImpl_Release()

static ULONG WINAPI ISupportErrorInfoImpl_Release ( ISupportErrorInfo iface)
static

Definition at line 333 of file errorinfo.c.

334{
336 return IErrorInfo_Release(&This->IErrorInfo_iface);
337}

◆ SetErrorInfo()

HRESULT WINAPI SetErrorInfo ( ULONG  dwReserved,
IErrorInfo perrinfo 
)

Definition at line 455 of file errorinfo.c.

456{
457 IErrorInfo * pei;
458
459 TRACE("(%d, %p)\n", dwReserved, perrinfo);
460
461 if (dwReserved)
462 {
463 ERR("dwReserved (0x%x) != 0\n", dwReserved);
464 return E_INVALIDARG;
465 }
466
467 /* release old errorinfo */
468 pei = COM_CurrentInfo()->errorinfo;
469 if (pei) IErrorInfo_Release(pei);
470
471 /* set to new value */
472 COM_CurrentInfo()->errorinfo = perrinfo;
473 if (perrinfo) IErrorInfo_AddRef(perrinfo);
474
475 return S_OK;
476}

Referenced by test_error_info().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ CreateErrorInfoVtbl

const ICreateErrorInfoVtbl CreateErrorInfoVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription(ICreateErrorInfo *iface, LPOLESTR szDescription)
Definition: errorinfo.c:273
static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile(ICreateErrorInfo *iface, LPOLESTR szHelpFile)
Definition: errorinfo.c:285
static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface(ICreateErrorInfo *iface, REFIID riid, VOID **ppvoid)
Definition: errorinfo.c:226
static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID(ICreateErrorInfo *iface, REFGUID rguid)
Definition: errorinfo.c:250
static HRESULT WINAPI ICreateErrorInfoImpl_SetSource(ICreateErrorInfo *iface, LPOLESTR szSource)
Definition: errorinfo.c:260
static ULONG WINAPI ICreateErrorInfoImpl_AddRef(ICreateErrorInfo *iface)
Definition: errorinfo.c:235
static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext(ICreateErrorInfo *iface, DWORD dwHelpContext)
Definition: errorinfo.c:296
static ULONG WINAPI ICreateErrorInfoImpl_Release(ICreateErrorInfo *iface)
Definition: errorinfo.c:242

Definition at line 306 of file errorinfo.c.

Referenced by IErrorInfoImpl_Constructor().

◆ ErrorInfoVtbl

const IErrorInfoVtbl ErrorInfoVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI IErrorInfoImpl_GetGUID(IErrorInfo *iface, GUID *pGUID)
Definition: errorinfo.c:149
static HRESULT WINAPI IErrorInfoImpl_QueryInterface(IErrorInfo *iface, REFIID riid, void **ppvoid)
Definition: errorinfo.c:88
static ULONG WINAPI IErrorInfoImpl_AddRef(IErrorInfo *iface)
Definition: errorinfo.c:121
static ULONG WINAPI IErrorInfoImpl_Release(IErrorInfo *iface)
Definition: errorinfo.c:129
static HRESULT WINAPI IErrorInfoImpl_GetSource(IErrorInfo *iface, BSTR *pBstrSource)
Definition: errorinfo.c:160
static HRESULT WINAPI IErrorInfoImpl_GetDescription(IErrorInfo *iface, BSTR *pBstrDescription)
Definition: errorinfo.c:172
static HRESULT WINAPI IErrorInfoImpl_GetHelpContext(IErrorInfo *iface, DWORD *pdwHelpContext)
Definition: errorinfo.c:200
static HRESULT WINAPI IErrorInfoImpl_GetHelpFile(IErrorInfo *iface, BSTR *pBstrHelpFile)
Definition: errorinfo.c:186

Definition at line 213 of file errorinfo.c.

Referenced by IErrorInfoImpl_Constructor().

◆ SupportErrorInfoVtbl

const ISupportErrorInfoVtbl SupportErrorInfoVtbl
static
Initial value:
=
{
}
static ULONG WINAPI ISupportErrorInfoImpl_AddRef(ISupportErrorInfo *iface)
Definition: errorinfo.c:327
static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface(ISupportErrorInfo *iface, REFIID riid, VOID **ppvoid)
Definition: errorinfo.c:318
static ULONG WINAPI ISupportErrorInfoImpl_Release(ISupportErrorInfo *iface)
Definition: errorinfo.c:333
static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
Definition: errorinfo.c:339

Definition at line 348 of file errorinfo.c.

Referenced by IErrorInfoImpl_Constructor().