Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. Connect.cpp
  5. Abstract:
  6. Handles all outgoing interfaces
  7. Author:
  8. mquinton - 5/7/97
  9. Notes:
  10. optional-notes
  11. Revision History:
  12. --*/
  13. #include "stdafx.h"
  14. #include "windows.h"
  15. #include "wownt32.h"
  16. #include "stdarg.h"
  17. #include "stdio.h"
  18. #include "shellapi.h"
  19. STDMETHODIMP
  20. CDispatchMapper::QueryDispatchInterface(
  21. BSTR pIID,
  22. IDispatch * pDispIn,
  23. IDispatch ** ppDispOut
  24. )
  25. {
  26. IID iid;
  27. HRESULT hr;
  28. void * pVoid;
  29. if ( IsBadReadPtr( pDispIn, sizeof( IDispatch ) ) )
  30. {
  31. LOG((TL_ERROR, "QDI bad pDispIn"));
  32. return E_INVALIDARG;
  33. }
  34. if ( TAPIIsBadWritePtr( ppDispOut, sizeof( IDispatch * ) ) )
  35. {
  36. LOG((TL_ERROR, "QDI bad ppDispOut"));
  37. return E_POINTER;
  38. }
  39. *ppDispOut = NULL;
  40. hr = IIDFromString(
  41. pIID,
  42. &iid
  43. );
  44. if ( !SUCCEEDED(hr) )
  45. {
  46. LOG((TL_ERROR, "QDI bad bstr"));
  47. return E_INVALIDARG;
  48. }
  49. hr = pDispIn->QueryInterface(
  50. iid,
  51. &pVoid
  52. );
  53. if ( !SUCCEEDED(hr) )
  54. {
  55. LOG((TL_ERROR, "QDI invalid IID"));
  56. return E_INVALIDARG;
  57. }
  58. //
  59. // see if the object we are going to QI is safe for scripting
  60. //
  61. CComPtr<IObjectSafety> pObjectSafety;
  62. hr = pDispIn->QueryInterface(IID_IObjectSafety, (void**)&pObjectSafety);
  63. //
  64. // the object _must_ support IObjectSafety interface.
  65. //
  66. // Note: if this requirement is too strict and we need to remove it in the future,
  67. // we need to pass in class id for the object, and query ie category manager if
  68. // the object is marked safe for scripting in the registry
  69. //
  70. if ( FAILED(hr) )
  71. {
  72. ((IUnknown*)pVoid)->Release();
  73. return hr;
  74. }
  75. //
  76. // do what ie does -- call setinterfacesafetyoptions with safe for
  77. // scripting options
  78. //
  79. DWORD dwXSetMask = INTERFACESAFE_FOR_UNTRUSTED_CALLER;
  80. DWORD dwXOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER;
  81. hr = pObjectSafety->SetInterfaceSafetyOptions(iid,
  82. dwXSetMask,
  83. dwXOptions);
  84. if (FAILED(hr))
  85. {
  86. ((IUnknown*)pVoid)->Release();
  87. return hr;
  88. }
  89. //
  90. // If we got here, the object is safe for scripting. Proceeed.
  91. //
  92. *ppDispOut = (IDispatch *) pVoid;
  93. return S_OK;
  94. }