Source code of Windows XP (NT5)
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.

134 lines
3.0 KiB

  1. /*===================================================================
  2. Microsoft ASP
  3. Microsoft Confidential.
  4. Copyright 1996, 1997, 1998 Microsoft Corporation. All Rights Reserved.
  5. Component: Free Threaded Marshaller Base Class
  6. File: ftm.cpp
  7. Owner: Lei Jin
  8. This is the free threaded marshaller base class implementation.
  9. ===================================================================*/
  10. #include "denpre.h"
  11. #pragma hdrstop
  12. #include "ftm.h"
  13. #include "memchk.h"
  14. IMarshal* CFTMImplementation::m_pUnkFTM = NULL;
  15. STDMETHODIMP
  16. CFTMImplementation::GetUnmarshalClass
  17. (
  18. /* [in] */ REFIID riid,
  19. /* [unique][in] */ void __RPC_FAR *pv,
  20. /* [in] */ DWORD dwDestContext,
  21. /* [unique][in] */ void __RPC_FAR *pvDestContext,
  22. /* [in] */ DWORD mshlflags,
  23. /* [out] */ CLSID __RPC_FAR *pCid
  24. )
  25. {
  26. DBG_ASSERT(m_pUnkFTM != NULL);
  27. return m_pUnkFTM->GetUnmarshalClass(riid, pv, dwDestContext, pvDestContext, mshlflags, pCid);
  28. }
  29. STDMETHODIMP
  30. CFTMImplementation::GetMarshalSizeMax(
  31. /* [in] */ REFIID riid,
  32. /* [unique][in] */ void __RPC_FAR *pv,
  33. /* [in] */ DWORD dwDestContext,
  34. /* [unique][in] */ void __RPC_FAR *pvDestContext,
  35. /* [in] */ DWORD mshlflags,
  36. /* [out] */ DWORD __RPC_FAR *pSize)
  37. {
  38. DBG_ASSERT(m_pUnkFTM != NULL);
  39. return m_pUnkFTM->GetMarshalSizeMax(riid, pv, dwDestContext, pvDestContext, mshlflags, pSize);
  40. }
  41. STDMETHODIMP
  42. CFTMImplementation::MarshalInterface(
  43. /* [unique][in] */ IStream __RPC_FAR *pStm,
  44. /* [in] */ REFIID riid,
  45. /* [unique][in] */ void __RPC_FAR *pv,
  46. /* [in] */ DWORD dwDestContext,
  47. /* [unique][in] */ void __RPC_FAR *pvDestContext,
  48. /* [in] */ DWORD mshlflags)
  49. {
  50. DBG_ASSERT(m_pUnkFTM != NULL);
  51. return m_pUnkFTM->MarshalInterface(pStm, riid, pv, dwDestContext, pvDestContext, mshlflags);
  52. }
  53. STDMETHODIMP
  54. CFTMImplementation::UnmarshalInterface
  55. (
  56. /* [unique][in] */ IStream __RPC_FAR *pStm,
  57. /* [in] */ REFIID riid,
  58. /* [out] */ void __RPC_FAR *__RPC_FAR *ppv
  59. )
  60. {
  61. DBG_ASSERT(m_pUnkFTM != NULL);
  62. return m_pUnkFTM->UnmarshalInterface(pStm, riid, ppv);
  63. }
  64. STDMETHODIMP
  65. CFTMImplementation::ReleaseMarshalData
  66. (
  67. /* [unique][in] */ IStream __RPC_FAR *pStm
  68. )
  69. {
  70. DBG_ASSERT(m_pUnkFTM != NULL);
  71. return m_pUnkFTM->ReleaseMarshalData(pStm);
  72. }
  73. STDMETHODIMP
  74. CFTMImplementation::DisconnectObject
  75. (
  76. /* [in] */ DWORD dwReserved
  77. )
  78. {
  79. DBG_ASSERT(m_pUnkFTM != NULL);
  80. return m_pUnkFTM->DisconnectObject(dwReserved);
  81. }
  82. HRESULT
  83. CFTMImplementation::Init
  84. (
  85. void
  86. )
  87. {
  88. IUnknown *pUnkFTMTemp = NULL;
  89. HRESULT hr;
  90. hr = CoCreateFreeThreadedMarshaler(NULL, (IUnknown**)&pUnkFTMTemp);
  91. DBG_ASSERT(SUCCEEDED(hr));
  92. if (SUCCEEDED(hr))
  93. {
  94. hr = pUnkFTMTemp->QueryInterface(IID_IMarshal, reinterpret_cast<void **>(&m_pUnkFTM));
  95. DBG_ASSERT(SUCCEEDED(hr) && m_pUnkFTM != NULL);
  96. pUnkFTMTemp->Release();
  97. }
  98. return hr;
  99. }
  100. HRESULT
  101. CFTMImplementation::UnInit
  102. (
  103. void
  104. )
  105. {
  106. DBG_ASSERT(m_pUnkFTM != NULL);
  107. m_pUnkFTM->Release();
  108. m_pUnkFTM = NULL;
  109. return S_OK;
  110. }