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