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