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.

153 lines
3.1 KiB

  1. /****************************************************************************
  2. *
  3. * UNMARSH.CPP
  4. *
  5. * unmarshalling stub
  6. *
  7. * Copyright (c) 1992 - 1995 Microsoft Corporation. All Rights Reserved.
  8. *
  9. * You have a royalty-free right to use, modify, reproduce and
  10. * distribute the Sample Files (and/or any modified version) in
  11. * any way you find useful, provided that you agree that
  12. * Microsoft has no warranty obligations or liability for any
  13. * Sample Application Files which are modified.
  14. *
  15. ***************************************************************************/
  16. #include <win32.h>
  17. #include <vfw.h>
  18. #include "avifilei.h"
  19. #include <storage.h>
  20. #include "unmarsh.h"
  21. #include "debug.h"
  22. HRESULT CUnMarshal::Create(
  23. IUnknown FAR* pUnknownOuter,
  24. const IID FAR& riid,
  25. void FAR* FAR* ppv)
  26. {
  27. IUnknown FAR* pUnknown;
  28. CUnMarshal FAR* pUnMarshal;
  29. HRESULT hresult;
  30. DPF("Creating Simple UnMarshal Instance....\n");
  31. pUnMarshal = new FAR CUnMarshal(pUnknownOuter, &pUnknown);
  32. if (!pUnMarshal)
  33. return ResultFromScode(E_OUTOFMEMORY);
  34. hresult = pUnknown->QueryInterface(riid, ppv);
  35. if (FAILED(GetScode(hresult)))
  36. delete pUnMarshal;
  37. return hresult;
  38. }
  39. CUnMarshal::CUnMarshal(
  40. IUnknown FAR* pUnknownOuter,
  41. IUnknown FAR* FAR* ppUnknown)
  42. {
  43. if (pUnknownOuter)
  44. m_pUnknownOuter = pUnknownOuter;
  45. else
  46. m_pUnknownOuter = this;
  47. *ppUnknown = this;
  48. }
  49. STDMETHODIMP CUnMarshal::QueryInterface(
  50. const IID FAR& iid,
  51. void FAR* FAR* ppv)
  52. {
  53. if (iid == IID_IUnknown)
  54. *ppv = this;
  55. else if (iid == IID_IMarshal) {
  56. *ppv = this;
  57. } else {
  58. *ppv = NULL;
  59. return ResultFromScode(E_NOINTERFACE);
  60. }
  61. AddRef();
  62. return NULL;
  63. }
  64. /* - - - - - - - - */
  65. STDMETHODIMP_(ULONG) CUnMarshal::AddRef()
  66. {
  67. uUseCount++;
  68. return ++m_refs;
  69. }
  70. STDMETHODIMP_(ULONG) CUnMarshal::Release()
  71. {
  72. uUseCount--;
  73. if (!--m_refs) {
  74. delete this;
  75. return 0;
  76. }
  77. return m_refs;
  78. }
  79. // *** IMarshal methods ***
  80. STDMETHODIMP CUnMarshal::GetUnmarshalClass (THIS_ REFIID riid, LPVOID pv,
  81. DWORD dwDestContext, LPVOID pvDestContext,
  82. DWORD mshlflags, LPCLSID pCid)
  83. {
  84. HRESULT hr = NOERROR;
  85. return hr;
  86. }
  87. STDMETHODIMP CUnMarshal::GetMarshalSizeMax (THIS_ REFIID riid, LPVOID pv,
  88. DWORD dwDestContext, LPVOID pvDestContext,
  89. DWORD mshlflags, LPDWORD pSize)
  90. {
  91. HRESULT hr = NOERROR;
  92. return hr;
  93. }
  94. STDMETHODIMP CUnMarshal::MarshalInterface (THIS_ LPSTREAM pStm, REFIID riid,
  95. LPVOID pv, DWORD dwDestContext, LPVOID pvDestContext,
  96. DWORD mshlflags)
  97. {
  98. HRESULT hr = NOERROR;
  99. return hr;
  100. }
  101. STDMETHODIMP CUnMarshal::UnmarshalInterface (THIS_ LPSTREAM pStm, REFIID riid,
  102. LPVOID FAR* ppv)
  103. {
  104. HRESULT hr;
  105. IUnknown FAR * punk;
  106. hr = pStm->Read(&punk,sizeof(punk),NULL);
  107. DPF("Unmarshalling %08lx\n", (DWORD) (LPVOID) punk);
  108. if (hr == NOERROR) {
  109. hr = punk->QueryInterface(riid, ppv);
  110. if (hr == NOERROR)
  111. punk->Release();
  112. }
  113. return hr;
  114. }
  115. STDMETHODIMP CUnMarshal::ReleaseMarshalData (THIS_ LPSTREAM pStm)
  116. {
  117. HRESULT hr = NOERROR;
  118. return hr;
  119. }
  120. STDMETHODIMP CUnMarshal::DisconnectObject (THIS_ DWORD dwReserved)
  121. {
  122. HRESULT hr = NOERROR;
  123. return hr;
  124. }