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.

103 lines
3.9 KiB

  1. #include "drmkPCH.h"
  2. #include <winerror.h>
  3. #include "VRoot.h"
  4. //------------------------------------------------------------------------------
  5. VRoot::VRoot(){
  6. outPinType=IsUndefined;
  7. outPinUnk=NULL;
  8. outPinFileObject=NULL;
  9. outPinDeviceObject=NULL;
  10. };
  11. //------------------------------------------------------------------------------
  12. DRM_STATUS VRoot::initiateValidation(PFILE_OBJECT OutPinFileObject, PDEVICE_OBJECT OutPinDeviceObject, DWORD StreamId){
  13. // validate myself - kick off by forwarding to myself
  14. outPinFileObject=OutPinFileObject;
  15. outPinDeviceObject = OutPinDeviceObject;
  16. outPinType=IsFileObject;
  17. myStreamId=StreamId;
  18. IUnknown* myUnk=static_cast<IUnknown*>(this);
  19. // numMethods is 3 (IUnknown) + 1 (IDrmAudioStream)
  20. ULONG numComMethods=3 + 1;
  21. NTSTATUS stat = DrmForwardContentToInterface(StreamId, myUnk, numComMethods);
  22. if(!NT_SUCCESS(stat)){
  23. _DbgPrintF(DEBUGLVL_VERBOSE,("DrmForwardContentToInterface(FILE_OBJECT) error on stream %d (Status=%d, %x)", StreamId, stat, stat));
  24. return stat;
  25. };
  26. // In the process of the above ForwardContent call weexpect some callbacks into
  27. // StreamMgr telling us about DispatchTable and COM fucntions that will touch premium content
  28. return DRM_OK;
  29. };
  30. //------------------------------------------------------------------------------
  31. DRM_STATUS VRoot::initiateValidation(IUnknown* OutPin, DWORD StreamId){
  32. myStreamId=StreamId;
  33. outPinUnk=OutPin;
  34. outPinType=IsCOM;
  35. IUnknown* myUnk=static_cast<IUnknown*>(this);
  36. NTSTATUS stat = DrmForwardContentToInterface(StreamId, myUnk, 4);
  37. if(!NT_SUCCESS(stat)){
  38. _DbgPrintF(DEBUGLVL_VERBOSE,("DrmForwardContentToInterface(INTERFACE) error on stream %d (Status=%d, %x)", StreamId, stat, stat));
  39. return stat;
  40. };
  41. // In the process of the above ForwardContent call weexpect some callbacks into
  42. // StreamMgr telling us about DispatchTable and COM fucntions that will touch premium content
  43. return DRM_OK;
  44. };
  45. //------------------------------------------------------------------------------
  46. STDMETHODIMP VRoot::QueryInterface(REFIID iid, void ** ppInt){
  47. if(iid==IID_IUnknown){
  48. *ppInt=static_cast<void*> (this);
  49. AddRef();
  50. return S_OK;
  51. };
  52. if(iid==IID_IDrmAudioStream){
  53. *ppInt = static_cast<void*> (this);
  54. AddRef();
  55. return S_OK;
  56. };
  57. *ppInt=NULL;
  58. return E_NOINTERFACE;
  59. };
  60. //------------------------------------------------------------------------------
  61. STDMETHODIMP_(ULONG) VRoot::AddRef(void){
  62. return 0;
  63. };
  64. //------------------------------------------------------------------------------
  65. STDMETHODIMP_(ULONG) VRoot::Release(void){
  66. return 0;
  67. };
  68. //------------------------------------------------------------------------------
  69. NTSTATUS __stdcall VRoot::SetContentId(IN ULONG ContentId, IN PCDRMRIGHTS DrmRights){
  70. DWORD theStreamId= ContentId;
  71. _DbgPrintF(DEBUGLVL_VERBOSE,("VRoot for %d on behest of %d", myStreamId, theStreamId));
  72. if(outPinType==IsCOM){
  73. if(outPinUnk==NULL){
  74. _DbgPrintF(DEBUGLVL_VERBOSE,("VRoot:: OutInterface not set for for stream %x", ContentId));
  75. return STATUS_INVALID_PARAMETER;
  76. }
  77. NTSTATUS stat = DrmForwardContentToInterface(theStreamId, outPinUnk, 4);
  78. return stat;
  79. };
  80. if(outPinType==IsFileObject){
  81. if(outPinFileObject==NULL){
  82. _DbgPrintF(DEBUGLVL_VERBOSE,("VRoot:: out FILE_OBJECT not set for for stream %x", ContentId));
  83. return STATUS_INVALID_PARAMETER;
  84. }
  85. DRMFORWARD DrmForward;
  86. RtlZeroMemory(&DrmForward, sizeof(DrmForward));
  87. DrmForward.Flags = 0;
  88. DrmForward.DeviceObject = outPinDeviceObject;
  89. DrmForward.FileObject = outPinFileObject;
  90. DrmForward.Context = outPinFileObject;
  91. DRM_STATUS stat=DrmForwardContentToDeviceObject(theStreamId, NULL, &DrmForward);
  92. return stat;
  93. };
  94. // should not get here
  95. _DbgPrintF(DEBUGLVL_ERROR,("DRMK: No output pin set"));
  96. return STATUS_INVALID_PARAMETER;
  97. };
  98. //------------------------------------------------------------------------------