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.

154 lines
3.2 KiB

  1. /****************************************************************************
  2. *
  3. * UNMARSH.CPP
  4. *
  5. * unmarshalling stub
  6. *
  7. * Copyright (c) 1992 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 <storage.h>
  18. #include <avifmt.h>
  19. #include "avifile.h"
  20. #include "avifilei.h"
  21. #include "unmarsh.h"
  22. #include "debug.h"
  23. HRESULT CUnMarshal::Create(
  24. IUnknown FAR* pUnknownOuter,
  25. const IID FAR& riid,
  26. void FAR* FAR* ppv)
  27. {
  28. IUnknown FAR* pUnknown;
  29. CUnMarshal FAR* pUnMarshal;
  30. HRESULT hresult;
  31. DPF("Creating Simple UnMarshal Instance....\n");
  32. pUnMarshal = new FAR CUnMarshal(pUnknownOuter, &pUnknown);
  33. if (!pUnMarshal)
  34. return ResultFromScode(E_OUTOFMEMORY);
  35. hresult = pUnknown->QueryInterface(riid, ppv);
  36. if (FAILED(GetScode(hresult)))
  37. delete pUnMarshal;
  38. return hresult;
  39. }
  40. CUnMarshal::CUnMarshal(
  41. IUnknown FAR* pUnknownOuter,
  42. IUnknown FAR* FAR* ppUnknown)
  43. {
  44. if (pUnknownOuter)
  45. m_pUnknownOuter = pUnknownOuter;
  46. else
  47. m_pUnknownOuter = this;
  48. *ppUnknown = this;
  49. }
  50. STDMETHODIMP CUnMarshal::QueryInterface(
  51. const IID FAR& iid,
  52. void FAR* FAR* ppv)
  53. {
  54. if (iid == IID_IUnknown)
  55. *ppv = this;
  56. else if (iid == IID_IMarshal) {
  57. *ppv = this;
  58. } else
  59. return ResultFromScode(E_NOINTERFACE);
  60. AddRef();
  61. return NULL;
  62. }
  63. /* - - - - - - - - */
  64. STDMETHODIMP_(ULONG) CUnMarshal::AddRef()
  65. {
  66. uUseCount++;
  67. return ++m_refs;
  68. }
  69. STDMETHODIMP_(ULONG) CUnMarshal::Release()
  70. {
  71. uUseCount--;
  72. if (!--m_refs) {
  73. delete this;
  74. return 0;
  75. }
  76. return m_refs;
  77. }
  78. // *** IMarshal methods ***
  79. STDMETHODIMP CUnMarshal::GetUnmarshalClass (THIS_ REFIID riid, LPVOID pv,
  80. DWORD dwDestContext, LPVOID pvDestContext,
  81. DWORD mshlflags, LPCLSID pCid)
  82. {
  83. HRESULT hr = NOERROR;
  84. return hr;
  85. }
  86. STDMETHODIMP CUnMarshal::GetMarshalSizeMax (THIS_ REFIID riid, LPVOID pv,
  87. DWORD dwDestContext, LPVOID pvDestContext,
  88. DWORD mshlflags, LPDWORD pSize)
  89. {
  90. HRESULT hr = NOERROR;
  91. return hr;
  92. }
  93. STDMETHODIMP CUnMarshal::MarshalInterface (THIS_ LPSTREAM pStm, REFIID riid,
  94. LPVOID pv, DWORD dwDestContext, LPVOID pvDestContext,
  95. DWORD mshlflags)
  96. {
  97. HRESULT hr = NOERROR;
  98. return hr;
  99. }
  100. STDMETHODIMP CUnMarshal::UnmarshalInterface (THIS_ LPSTREAM pStm, REFIID riid,
  101. LPVOID FAR* ppv)
  102. {
  103. HRESULT hr;
  104. IUnknown FAR * punk;
  105. hr = pStm->Read(&punk,sizeof(punk),NULL);
  106. DPF("Unmarshalling %08lx\n", (DWORD) (LPVOID) punk);
  107. if (hr == NOERROR) {
  108. hr = punk->QueryInterface(riid, ppv);
  109. if (hr == NOERROR)
  110. punk->Release();
  111. }
  112. return hr;
  113. }
  114. STDMETHODIMP CUnMarshal::ReleaseMarshalData (THIS_ LPSTREAM pStm)
  115. {
  116. HRESULT hr = NOERROR;
  117. return hr;
  118. }
  119. STDMETHODIMP CUnMarshal::DisconnectObject (THIS_ DWORD dwReserved)
  120. {
  121. HRESULT hr = NOERROR;
  122. return hr;
  123. }