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.

138 lines
2.8 KiB

  1. /*===================================================================
  2. Microsoft IIS
  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 <w3p.hxx>
  11. #pragma hdrstop
  12. #include "ftm.h"
  13. IMarshal* CFTMImplementation::m_pFTM = NULL;
  14. STDMETHODIMP
  15. CFTMImplementation::GetUnmarshalClass
  16. (
  17. /* [in] */ REFIID riid,
  18. /* [unique][in] */ void __RPC_FAR *pv,
  19. /* [in] */ DWORD dwDestContext,
  20. /* [unique][in] */ void __RPC_FAR *pvDestContext,
  21. /* [in] */ DWORD mshlflags,
  22. /* [out] */ CLSID __RPC_FAR *pCid
  23. )
  24. {
  25. DBG_ASSERT(m_pFTM != NULL);
  26. return m_pFTM->GetUnmarshalClass(riid, pv, dwDestContext, pvDestContext, mshlflags, pCid);
  27. }
  28. STDMETHODIMP
  29. CFTMImplementation::GetMarshalSizeMax(
  30. /* [in] */ REFIID riid,
  31. /* [unique][in] */ void __RPC_FAR *pv,
  32. /* [in] */ DWORD dwDestContext,
  33. /* [unique][in] */ void __RPC_FAR *pvDestContext,
  34. /* [in] */ DWORD mshlflags,
  35. /* [out] */ DWORD __RPC_FAR *pSize)
  36. {
  37. DBG_ASSERT(m_pFTM != NULL);
  38. return m_pFTM->GetMarshalSizeMax(riid, pv, dwDestContext, pvDestContext, mshlflags, pSize);
  39. }
  40. STDMETHODIMP
  41. CFTMImplementation::MarshalInterface(
  42. /* [unique][in] */ IStream __RPC_FAR *pStm,
  43. /* [in] */ REFIID riid,
  44. /* [unique][in] */ void __RPC_FAR *pv,
  45. /* [in] */ DWORD dwDestContext,
  46. /* [unique][in] */ void __RPC_FAR *pvDestContext,
  47. /* [in] */ DWORD mshlflags)
  48. {
  49. DBG_ASSERT(m_pFTM != NULL);
  50. return m_pFTM->MarshalInterface(pStm, riid, pv, dwDestContext, pvDestContext, mshlflags);
  51. }
  52. STDMETHODIMP
  53. CFTMImplementation::UnmarshalInterface
  54. (
  55. /* [unique][in] */ IStream __RPC_FAR *pStm,
  56. /* [in] */ REFIID riid,
  57. /* [out] */ void __RPC_FAR *__RPC_FAR *ppv
  58. )
  59. {
  60. DBG_ASSERT(m_pFTM != NULL);
  61. return m_pFTM->UnmarshalInterface(pStm, riid, ppv);
  62. }
  63. STDMETHODIMP
  64. CFTMImplementation::ReleaseMarshalData
  65. (
  66. /* [unique][in] */ IStream __RPC_FAR *pStm
  67. )
  68. {
  69. DBG_ASSERT(m_pFTM != NULL);
  70. return m_pFTM->ReleaseMarshalData(pStm);
  71. }
  72. STDMETHODIMP
  73. CFTMImplementation::DisconnectObject
  74. (
  75. /* [in] */ DWORD dwReserved
  76. )
  77. {
  78. DBG_ASSERT(m_pFTM != NULL);
  79. return m_pFTM->DisconnectObject(dwReserved);
  80. }
  81. HRESULT
  82. CFTMImplementation::Init
  83. (
  84. void
  85. )
  86. {
  87. HRESULT hr;
  88. IUnknown *pUnk;
  89. hr = CoCreateFreeThreadedMarshaler(NULL, (IUnknown**)&pUnk);
  90. if(SUCCEEDED(hr)) {
  91. hr = pUnk->QueryInterface(IID_IMarshal, (void **) &m_pFTM);
  92. pUnk->Release();
  93. } else {
  94. DBG_ASSERT(SUCCEEDED(hr));
  95. }
  96. return hr;
  97. }
  98. HRESULT
  99. CFTMImplementation::UnInit
  100. (
  101. void
  102. )
  103. {
  104. DBG_ASSERT(m_pFTM != NULL);
  105. m_pFTM->Release();
  106. m_pFTM = NULL;
  107. return NOERROR;
  108. }