| 1 | /* $Id: errorinfo.c,v 1.3 2001-09-05 13:17:09 bird Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * ErrorInfo API
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 2000 Patrik Stridvall, Juergen Schmied
|
|---|
| 6 | *
|
|---|
| 7 | *
|
|---|
| 8 | * The errorinfo is a per-thread object. The reference is stored in the
|
|---|
| 9 | * TEB at offset 0xf80
|
|---|
| 10 | */
|
|---|
| 11 |
|
|---|
| 12 | #include <string.h>
|
|---|
| 13 | #include "debugtools.h"
|
|---|
| 14 | #include "windef.h"
|
|---|
| 15 | #include "heap.h"
|
|---|
| 16 | #include "winerror.h"
|
|---|
| 17 | #include "thread.h"
|
|---|
| 18 | #include "debugtools.h"
|
|---|
| 19 | #include "wine/obj_base.h"
|
|---|
| 20 | #include "wine/obj_oleaut.h"
|
|---|
| 21 | #include "wine/obj_errorinfo.h"
|
|---|
| 22 | #include "wine/unicode.h"
|
|---|
| 23 |
|
|---|
| 24 | DEFAULT_DEBUG_CHANNEL(ole);
|
|---|
| 25 |
|
|---|
| 26 | /* this code is from SysAllocStringLen (ole2disp.c in oleaut32) */
|
|---|
| 27 | static BSTR WINAPI ERRORINFO_SysAllocString(const OLECHAR* in)
|
|---|
| 28 | {
|
|---|
| 29 | DWORD bufferSize;
|
|---|
| 30 | DWORD* newBuffer;
|
|---|
| 31 | WCHAR* stringBuffer;
|
|---|
| 32 | DWORD len;
|
|---|
| 33 |
|
|---|
| 34 | if (in == NULL)
|
|---|
| 35 | return NULL;
|
|---|
| 36 | /*
|
|---|
| 37 | * Find the lenth of the buffer passed-in in bytes.
|
|---|
| 38 | */
|
|---|
| 39 | len = strlenW(in);
|
|---|
| 40 | bufferSize = len * sizeof (WCHAR);
|
|---|
| 41 |
|
|---|
| 42 | /*
|
|---|
| 43 | * Allocate a new buffer to hold the string.
|
|---|
| 44 | * dont't forget to keep an empty spot at the begining of the
|
|---|
| 45 | * buffer for the character count and an extra character at the
|
|---|
| 46 | * end for the NULL.
|
|---|
| 47 | */
|
|---|
| 48 | newBuffer = (DWORD*)HeapAlloc(GetProcessHeap(),
|
|---|
| 49 | 0,
|
|---|
| 50 | bufferSize + sizeof(WCHAR) + sizeof(DWORD));
|
|---|
| 51 |
|
|---|
| 52 | /*
|
|---|
| 53 | * If the memory allocation failed, return a null pointer.
|
|---|
| 54 | */
|
|---|
| 55 | if (newBuffer==0)
|
|---|
| 56 | return 0;
|
|---|
| 57 |
|
|---|
| 58 | /*
|
|---|
| 59 | * Copy the length of the string in the placeholder.
|
|---|
| 60 | */
|
|---|
| 61 | *newBuffer = bufferSize;
|
|---|
| 62 |
|
|---|
| 63 | /*
|
|---|
| 64 | * Skip the byte count.
|
|---|
| 65 | */
|
|---|
| 66 | newBuffer++;
|
|---|
| 67 |
|
|---|
| 68 | /*
|
|---|
| 69 | * Copy the information in the buffer.
|
|---|
| 70 | * Since it is valid to pass a NULL pointer here, we'll initialize the
|
|---|
| 71 | * buffer to nul if it is the case.
|
|---|
| 72 | */
|
|---|
| 73 | if (in != 0)
|
|---|
| 74 | memcpy(newBuffer, in, bufferSize);
|
|---|
| 75 | else
|
|---|
| 76 | memset(newBuffer, 0, bufferSize);
|
|---|
| 77 |
|
|---|
| 78 | /*
|
|---|
| 79 | * Make sure that there is a nul character at the end of the
|
|---|
| 80 | * string.
|
|---|
| 81 | */
|
|---|
| 82 | stringBuffer = (WCHAR*)newBuffer;
|
|---|
| 83 | stringBuffer[len] = 0;
|
|---|
| 84 |
|
|---|
| 85 | return (LPWSTR)stringBuffer;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | /* this code is from SysFreeString (ole2disp.c in oleaut32)*/
|
|---|
| 89 | static VOID WINAPI ERRORINFO_SysFreeString(BSTR in)
|
|---|
| 90 | {
|
|---|
| 91 | DWORD* bufferPointer;
|
|---|
| 92 |
|
|---|
| 93 | /* NULL is a valid parameter */
|
|---|
| 94 | if(!in) return;
|
|---|
| 95 |
|
|---|
| 96 | /*
|
|---|
| 97 | * We have to be careful when we free a BSTR pointer, it points to
|
|---|
| 98 | * the beginning of the string but it skips the byte count contained
|
|---|
| 99 | * before the string.
|
|---|
| 100 | */
|
|---|
| 101 | bufferPointer = (DWORD*)in;
|
|---|
| 102 |
|
|---|
| 103 | bufferPointer--;
|
|---|
| 104 |
|
|---|
| 105 | /*
|
|---|
| 106 | * Free the memory from it's "real" origin.
|
|---|
| 107 | */
|
|---|
| 108 | HeapFree(GetProcessHeap(), 0, bufferPointer);
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | typedef struct ErrorInfoImpl
|
|---|
| 113 | {
|
|---|
| 114 | ICOM_VTABLE(IErrorInfo) *lpvtei;
|
|---|
| 115 | ICOM_VTABLE(ICreateErrorInfo) *lpvtcei;
|
|---|
| 116 | ICOM_VTABLE(ISupportErrorInfo) *lpvtsei;
|
|---|
| 117 | DWORD ref;
|
|---|
| 118 |
|
|---|
| 119 | GUID m_Guid;
|
|---|
| 120 | BSTR bstrSource;
|
|---|
| 121 | BSTR bstrDescription;
|
|---|
| 122 | BSTR bstrHelpFile;
|
|---|
| 123 | DWORD m_dwHelpContext;
|
|---|
| 124 | } ErrorInfoImpl;
|
|---|
| 125 |
|
|---|
| 126 | static ICOM_VTABLE(IErrorInfo) IErrorInfoImpl_VTable;
|
|---|
| 127 | static ICOM_VTABLE(ICreateErrorInfo) ICreateErrorInfoImpl_VTable;
|
|---|
| 128 | static ICOM_VTABLE(ISupportErrorInfo) ISupportErrorInfoImpl_VTable;
|
|---|
| 129 |
|
|---|
| 130 | /*
|
|---|
| 131 | converts a objectpointer to This
|
|---|
| 132 | */
|
|---|
| 133 | #define _IErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtei)))
|
|---|
| 134 | #define _ICOM_THIS_From_IErrorInfo(class, name) class* This = (class*)(((char*)name)-_IErrorInfo_Offset);
|
|---|
| 135 |
|
|---|
| 136 | #define _ICreateErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtcei)))
|
|---|
| 137 | #define _ICOM_THIS_From_ICreateErrorInfo(class, name) class* This = (class*)(((char*)name)-_ICreateErrorInfo_Offset);
|
|---|
| 138 |
|
|---|
| 139 | #define _ISupportErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtsei)))
|
|---|
| 140 | #define _ICOM_THIS_From_ISupportErrorInfo(class, name) class* This = (class*)(((char*)name)-_ISupportErrorInfo_Offset);
|
|---|
| 141 |
|
|---|
| 142 | /*
|
|---|
| 143 | converts This to a objectpointer
|
|---|
| 144 | */
|
|---|
| 145 | #define _IErrorInfo_(This) (IErrorInfo*)&(This->lpvtei)
|
|---|
| 146 | #define _ICreateErrorInfo_(This) (ICreateErrorInfo*)&(This->lpvtcei)
|
|---|
| 147 | #define _ISupportErrorInfo_(This) (ISupportErrorInfo*)&(This->lpvtsei)
|
|---|
| 148 |
|
|---|
| 149 | IErrorInfo * IErrorInfoImpl_Constructor()
|
|---|
| 150 | {
|
|---|
| 151 | ErrorInfoImpl * ei = HeapAlloc(GetProcessHeap(), 0, sizeof(ErrorInfoImpl));
|
|---|
| 152 | if (ei)
|
|---|
| 153 | {
|
|---|
| 154 | ei->lpvtei = &IErrorInfoImpl_VTable;
|
|---|
| 155 | ei->lpvtcei = &ICreateErrorInfoImpl_VTable;
|
|---|
| 156 | ei->lpvtsei = &ISupportErrorInfoImpl_VTable;
|
|---|
| 157 | ei->ref = 1;
|
|---|
| 158 | ei->bstrSource = NULL;
|
|---|
| 159 | ei->bstrDescription = NULL;
|
|---|
| 160 | ei->bstrHelpFile = NULL;
|
|---|
| 161 | ei->m_dwHelpContext = 0;
|
|---|
| 162 | }
|
|---|
| 163 | return (IErrorInfo *)ei;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 | static HRESULT WINAPI IErrorInfoImpl_QueryInterface(
|
|---|
| 168 | IErrorInfo* iface,
|
|---|
| 169 | REFIID riid,
|
|---|
| 170 | VOID** ppvoid)
|
|---|
| 171 | {
|
|---|
| 172 | _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 173 | TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvoid);
|
|---|
| 174 |
|
|---|
| 175 | *ppvoid = NULL;
|
|---|
| 176 |
|
|---|
| 177 | if(IsEqualIID(riid, &IID_IErrorInfo))
|
|---|
| 178 | {
|
|---|
| 179 | *ppvoid = _IErrorInfo_(This);
|
|---|
| 180 | }
|
|---|
| 181 | else if(IsEqualIID(riid, &IID_ICreateErrorInfo))
|
|---|
| 182 | {
|
|---|
| 183 | *ppvoid = _ICreateErrorInfo_(This);
|
|---|
| 184 | }
|
|---|
| 185 | else if(IsEqualIID(riid, &IID_ISupportErrorInfo))
|
|---|
| 186 | {
|
|---|
| 187 | *ppvoid = _ISupportErrorInfo_(This);
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | if(*ppvoid)
|
|---|
| 191 | {
|
|---|
| 192 | IUnknown_AddRef( (IUnknown*)*ppvoid );
|
|---|
| 193 | TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid);
|
|---|
| 194 | return S_OK;
|
|---|
| 195 | }
|
|---|
| 196 | TRACE("-- Interface: E_NOINTERFACE\n");
|
|---|
| 197 | return E_NOINTERFACE;
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | static ULONG WINAPI IErrorInfoImpl_AddRef(
|
|---|
| 201 | IErrorInfo* iface)
|
|---|
| 202 | {
|
|---|
| 203 | _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 204 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
|---|
| 205 | return InterlockedIncrement(&This->ref);
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | static ULONG WINAPI IErrorInfoImpl_Release(
|
|---|
| 209 | IErrorInfo* iface)
|
|---|
| 210 | {
|
|---|
| 211 | _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 212 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
|---|
| 213 |
|
|---|
| 214 | if (!InterlockedDecrement(&This->ref))
|
|---|
| 215 | {
|
|---|
| 216 | TRACE("-- destroying IErrorInfo(%p)\n",This);
|
|---|
| 217 | HeapFree(GetProcessHeap(),0,This);
|
|---|
| 218 | return 0;
|
|---|
| 219 | }
|
|---|
| 220 | return This->ref;
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | static HRESULT WINAPI IErrorInfoImpl_GetGUID(
|
|---|
| 224 | IErrorInfo* iface,
|
|---|
| 225 | GUID * pGUID)
|
|---|
| 226 | {
|
|---|
| 227 | _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 228 | TRACE("(%p)->(count=%lu)\n",This,This->ref);
|
|---|
| 229 | if(!pGUID )return E_INVALIDARG;
|
|---|
| 230 | memcpy(pGUID, &This->m_Guid, sizeof(GUID));
|
|---|
| 231 | return S_OK;
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | static HRESULT WINAPI IErrorInfoImpl_GetSource(
|
|---|
| 235 | IErrorInfo* iface,
|
|---|
| 236 | BSTR *pBstrSource)
|
|---|
| 237 | {
|
|---|
| 238 | _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 239 | TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
|
|---|
| 240 | if (pBstrSource == NULL)
|
|---|
| 241 | return E_INVALIDARG;
|
|---|
| 242 | *pBstrSource = ERRORINFO_SysAllocString(This->bstrSource);
|
|---|
| 243 | return S_OK;
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | static HRESULT WINAPI IErrorInfoImpl_GetDescription(
|
|---|
| 247 | IErrorInfo* iface,
|
|---|
| 248 | BSTR *pBstrDescription)
|
|---|
| 249 | {
|
|---|
| 250 | _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 251 |
|
|---|
| 252 | TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
|
|---|
| 253 | if (pBstrDescription == NULL)
|
|---|
| 254 | return E_INVALIDARG;
|
|---|
| 255 | *pBstrDescription = ERRORINFO_SysAllocString(This->bstrDescription);
|
|---|
| 256 |
|
|---|
| 257 | return S_OK;
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | static HRESULT WINAPI IErrorInfoImpl_GetHelpFile(
|
|---|
| 261 | IErrorInfo* iface,
|
|---|
| 262 | BSTR *pBstrHelpFile)
|
|---|
| 263 | {
|
|---|
| 264 | _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 265 |
|
|---|
| 266 | TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
|
|---|
| 267 | if (pBstrHelpFile == NULL)
|
|---|
| 268 | return E_INVALIDARG;
|
|---|
| 269 | *pBstrHelpFile = ERRORINFO_SysAllocString(This->bstrHelpFile);
|
|---|
| 270 |
|
|---|
| 271 | return S_OK;
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | static HRESULT WINAPI IErrorInfoImpl_GetHelpContext(
|
|---|
| 275 | IErrorInfo* iface,
|
|---|
| 276 | DWORD *pdwHelpContext)
|
|---|
| 277 | {
|
|---|
| 278 | _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 279 | TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
|
|---|
| 280 | if (pdwHelpContext == NULL)
|
|---|
| 281 | return E_INVALIDARG;
|
|---|
| 282 | *pdwHelpContext = This->m_dwHelpContext;
|
|---|
| 283 |
|
|---|
| 284 | return S_OK;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | static ICOM_VTABLE(IErrorInfo) IErrorInfoImpl_VTable =
|
|---|
| 288 | {
|
|---|
| 289 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|---|
| 290 | IErrorInfoImpl_QueryInterface,
|
|---|
| 291 | IErrorInfoImpl_AddRef,
|
|---|
| 292 | IErrorInfoImpl_Release,
|
|---|
| 293 |
|
|---|
| 294 | IErrorInfoImpl_GetGUID,
|
|---|
| 295 | IErrorInfoImpl_GetSource,
|
|---|
| 296 | IErrorInfoImpl_GetDescription,
|
|---|
| 297 | IErrorInfoImpl_GetHelpFile,
|
|---|
| 298 | IErrorInfoImpl_GetHelpContext
|
|---|
| 299 | };
|
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 | static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface(
|
|---|
| 303 | ICreateErrorInfo* iface,
|
|---|
| 304 | REFIID riid,
|
|---|
| 305 | VOID** ppvoid)
|
|---|
| 306 | {
|
|---|
| 307 | _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 308 | TRACE("(%p)\n", This);
|
|---|
| 309 | return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | static ULONG WINAPI ICreateErrorInfoImpl_AddRef(
|
|---|
| 313 | ICreateErrorInfo* iface)
|
|---|
| 314 | {
|
|---|
| 315 | _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 316 | TRACE("(%p)\n", This);
|
|---|
| 317 | return IErrorInfo_AddRef(_IErrorInfo_(This));
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 | static ULONG WINAPI ICreateErrorInfoImpl_Release(
|
|---|
| 321 | ICreateErrorInfo* iface)
|
|---|
| 322 | {
|
|---|
| 323 | _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 324 | TRACE("(%p)\n", This);
|
|---|
| 325 | return IErrorInfo_Release(_IErrorInfo_(This));
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 | static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID(
|
|---|
| 330 | ICreateErrorInfo* iface,
|
|---|
| 331 | REFGUID rguid)
|
|---|
| 332 | {
|
|---|
| 333 | _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 334 | TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid));
|
|---|
| 335 | memcpy(&This->m_Guid, rguid, sizeof(GUID));
|
|---|
| 336 | return S_OK;
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 | static HRESULT WINAPI ICreateErrorInfoImpl_SetSource(
|
|---|
| 340 | ICreateErrorInfo* iface,
|
|---|
| 341 | LPOLESTR szSource)
|
|---|
| 342 | {
|
|---|
| 343 | _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 344 | TRACE("(%p)\n",This);
|
|---|
| 345 | if (This->bstrSource != NULL)
|
|---|
| 346 | ERRORINFO_SysFreeString(This->bstrSource);
|
|---|
| 347 | This->bstrSource = ERRORINFO_SysAllocString(szSource);
|
|---|
| 348 |
|
|---|
| 349 | return S_OK;
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription(
|
|---|
| 353 | ICreateErrorInfo* iface,
|
|---|
| 354 | LPOLESTR szDescription)
|
|---|
| 355 | {
|
|---|
| 356 | _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 357 | TRACE("(%p)\n",This);
|
|---|
| 358 | if (This->bstrDescription != NULL)
|
|---|
| 359 | ERRORINFO_SysFreeString(This->bstrDescription);
|
|---|
| 360 | This->bstrDescription = ERRORINFO_SysAllocString(szDescription);
|
|---|
| 361 |
|
|---|
| 362 | return S_OK;
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile(
|
|---|
| 366 | ICreateErrorInfo* iface,
|
|---|
| 367 | LPOLESTR szHelpFile)
|
|---|
| 368 | {
|
|---|
| 369 | _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 370 | TRACE("(%p)\n",This);
|
|---|
| 371 | if (This->bstrHelpFile != NULL)
|
|---|
| 372 | ERRORINFO_SysFreeString(This->bstrHelpFile);
|
|---|
| 373 | This->bstrHelpFile = ERRORINFO_SysAllocString(szHelpFile);
|
|---|
| 374 |
|
|---|
| 375 | return S_OK;
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext(
|
|---|
| 379 | ICreateErrorInfo* iface,
|
|---|
| 380 | DWORD dwHelpContext)
|
|---|
| 381 | {
|
|---|
| 382 | _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 383 | TRACE("(%p)\n",This);
|
|---|
| 384 | This->m_dwHelpContext = dwHelpContext;
|
|---|
| 385 |
|
|---|
| 386 | return S_OK;
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | static ICOM_VTABLE(ICreateErrorInfo) ICreateErrorInfoImpl_VTable =
|
|---|
| 390 | {
|
|---|
| 391 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|---|
| 392 | ICreateErrorInfoImpl_QueryInterface,
|
|---|
| 393 | ICreateErrorInfoImpl_AddRef,
|
|---|
| 394 | ICreateErrorInfoImpl_Release,
|
|---|
| 395 |
|
|---|
| 396 | ICreateErrorInfoImpl_SetGUID,
|
|---|
| 397 | ICreateErrorInfoImpl_SetSource,
|
|---|
| 398 | ICreateErrorInfoImpl_SetDescription,
|
|---|
| 399 | ICreateErrorInfoImpl_SetHelpFile,
|
|---|
| 400 | ICreateErrorInfoImpl_SetHelpContext
|
|---|
| 401 | };
|
|---|
| 402 |
|
|---|
| 403 | static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface(
|
|---|
| 404 | ISupportErrorInfo* iface,
|
|---|
| 405 | REFIID riid,
|
|---|
| 406 | VOID** ppvoid)
|
|---|
| 407 | {
|
|---|
| 408 | _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 409 | TRACE("(%p)\n", This);
|
|---|
| 410 |
|
|---|
| 411 | return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | static ULONG WINAPI ISupportErrorInfoImpl_AddRef(
|
|---|
| 415 | ISupportErrorInfo* iface)
|
|---|
| 416 | {
|
|---|
| 417 | _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 418 | TRACE("(%p)\n", This);
|
|---|
| 419 | return IErrorInfo_AddRef(_IErrorInfo_(This));
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | static ULONG WINAPI ISupportErrorInfoImpl_Release(
|
|---|
| 423 | ISupportErrorInfo* iface)
|
|---|
| 424 | {
|
|---|
| 425 | _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 426 | TRACE("(%p)\n", This);
|
|---|
| 427 | return IErrorInfo_Release(_IErrorInfo_(This));
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 | static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo(
|
|---|
| 432 | ISupportErrorInfo* iface,
|
|---|
| 433 | REFIID riid)
|
|---|
| 434 | {
|
|---|
| 435 | _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
|
|---|
| 436 | TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
|
|---|
| 437 | return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
|
|---|
| 438 | }
|
|---|
| 439 |
|
|---|
| 440 | static ICOM_VTABLE(ISupportErrorInfo) ISupportErrorInfoImpl_VTable =
|
|---|
| 441 | {
|
|---|
| 442 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|---|
| 443 | ISupportErrorInfoImpl_QueryInterface,
|
|---|
| 444 | ISupportErrorInfoImpl_AddRef,
|
|---|
| 445 | ISupportErrorInfoImpl_Release,
|
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 | ISupportErrorInfoImpl_InterfaceSupportsErrorInfo
|
|---|
| 449 | };
|
|---|
| 450 | /***********************************************************************
|
|---|
| 451 | * CreateErrorInfo
|
|---|
| 452 | */
|
|---|
| 453 | HRESULT WINAPI CreateErrorInfo(ICreateErrorInfo **pperrinfo)
|
|---|
| 454 | {
|
|---|
| 455 | IErrorInfo * pei;
|
|---|
| 456 | HRESULT res;
|
|---|
| 457 | TRACE("(%p): stub:\n", pperrinfo);
|
|---|
| 458 | if(! pperrinfo ) return E_INVALIDARG;
|
|---|
| 459 | if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY;
|
|---|
| 460 |
|
|---|
| 461 | res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo);
|
|---|
| 462 | IErrorInfo_Release(pei);
|
|---|
| 463 | return res;
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 | /***********************************************************************
|
|---|
| 467 | * GetErrorInfo
|
|---|
| 468 | */
|
|---|
| 469 | HRESULT WINAPI GetErrorInfo(ULONG dwReserved, IErrorInfo **pperrinfo)
|
|---|
| 470 | {
|
|---|
| 471 | TRACE("(%ld, %p, %p): stub:\n", dwReserved, pperrinfo, NtCurrentTeb()->ErrorInfo);
|
|---|
| 472 |
|
|---|
| 473 | if(! pperrinfo ) return E_INVALIDARG;
|
|---|
| 474 | if(!(*pperrinfo = (IErrorInfo*)(NtCurrentTeb()->ErrorInfo))) return S_FALSE;
|
|---|
| 475 |
|
|---|
| 476 | /* clear thread error state */
|
|---|
| 477 | NtCurrentTeb()->ErrorInfo = NULL;
|
|---|
| 478 | return S_OK;
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| 481 | /***********************************************************************
|
|---|
| 482 | * SetErrorInfo
|
|---|
| 483 | */
|
|---|
| 484 | HRESULT WINAPI SetErrorInfo(ULONG dwReserved, IErrorInfo *perrinfo)
|
|---|
| 485 | {
|
|---|
| 486 | IErrorInfo * pei;
|
|---|
| 487 | TRACE("(%ld, %p): stub:\n", dwReserved, perrinfo);
|
|---|
| 488 |
|
|---|
| 489 | /* release old errorinfo */
|
|---|
| 490 | pei = (IErrorInfo*)NtCurrentTeb()->ErrorInfo;
|
|---|
| 491 | if(pei) IErrorInfo_Release(pei);
|
|---|
| 492 |
|
|---|
| 493 | /* set to new value */
|
|---|
| 494 | NtCurrentTeb()->ErrorInfo = perrinfo;
|
|---|
| 495 | if(perrinfo) IErrorInfo_AddRef(perrinfo);
|
|---|
| 496 | return S_OK;
|
|---|
| 497 | }
|
|---|