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.

142 lines
4.4 KiB

  1. //
  2. // Microsoft Windows Media Technologies
  3. // Copyright (C) Microsoft Corporation, 1999 - 2001. All rights reserved.
  4. //
  5. // MSHDSP.DLL is a sample WMDM Service Provider(SP) that enumerates fixed drives.
  6. // This sample shows you how to implement an SP according to the WMDM documentation.
  7. // This sample uses fixed drives on your PC to emulate portable media, and
  8. // shows the relationship between different interfaces and objects. Each hard disk
  9. // volume is enumerated as a device and directories and files are enumerated as
  10. // Storage objects under respective devices. You can copy non-SDMI compliant content
  11. // to any device that this SP enumerates. To copy an SDMI compliant content to a
  12. // device, the device must be able to report a hardware embedded serial number.
  13. // Hard disks do not have such serial numbers.
  14. //
  15. // To build this SP, you are recommended to use the MSHDSP.DSP file under Microsoft
  16. // Visual C++ 6.0 and run REGSVR32.EXE to register the resulting MSHDSP.DLL. You can
  17. // then build the sample application from the WMDMAPP directory to see how it gets
  18. // loaded by the application. However, you need to obtain a certificate from
  19. // Microsoft to actually run this SP. This certificate would be in the KEY.C file
  20. // under the INCLUDE directory for one level up.
  21. #ifndef __MDSPDEFS_H__
  22. #define __MDSPDEFS_H__
  23. #if _MSC_VER >= 1000
  24. #pragma once
  25. #endif // _MSC_VER >= 1000
  26. #include "scserver.h"
  27. typedef struct {
  28. BOOL bValid;
  29. WCHAR wcsDevName[32];
  30. DWORD dwStatus;
  31. LPVOID pIMDSPStorageGlobals;
  32. } MDSPGLOBALDEVICEINFO;
  33. #define WMDM_WAVE_FORMAT_ALL (WORD)0xFFFF
  34. #define WCS_MIME_TYPE_ALL L"*/*"
  35. #define MDSP_MAX_DRIVE_COUNT 26
  36. #define MDSP_MAX_DEVICE_OBJ 64
  37. #define STR_MDSPREG "Software\\Microsoft\\Windows Media Device Manager\\Plugins\\SP\\MsHDSP"
  38. #define STR_MDSPPROGID "MDServiceProviderHD.MDServiceProviderHD"
  39. extern HRESULT __stdcall UtilGetSerialNumber(WCHAR *wcsDeviceName, PWMDMID pSerialNumber, BOOL fCreate);
  40. extern HRESULT wcsParseDeviceName(WCHAR *wcsIn, WCHAR *wcsOut, DWORD dwNumCharsInOutBuffer);
  41. extern HRESULT GetFileSizeRecursive(char *szPath, DWORD *pdwSizeLow, DWORD *pdwSizeHigh);
  42. extern HRESULT DeleteFileRecursive(char *szPath);
  43. extern HRESULT SetGlobalDeviceStatus(WCHAR *wcsName, DWORD dwStat, BOOL bClear);
  44. extern HRESULT GetGlobalDeviceStatus(WCHAR *wcsNameIn, DWORD *pdwStat);
  45. extern HRESULT __stdcall UtilGetManufacturer(LPWSTR pDeviceName, LPWSTR *ppwszName, UINT nMaxChars);
  46. extern UINT __stdcall UtilGetDriveType(LPSTR szDL);
  47. extern HINSTANCE g_hinstance;
  48. extern MDSPGLOBALDEVICEINFO g_GlobalDeviceInfo[MDSP_MAX_DEVICE_OBJ];
  49. extern WCHAR g_wcsBackslash[2];
  50. #define BACKSLASH_STRING_LENGTH (ARRAYSIZE(g_wcsBackslash)-1)
  51. extern CHAR g_szBackslash[2];
  52. #define BACKSLASH_SZ_STRING_LENGTH (ARRAYSIZE(g_szBackslash)-1)
  53. extern CSecureChannelServer *g_pAppSCServer;
  54. extern CComMultiThreadModel::AutoCriticalSection g_CriticalSection;
  55. #define fFalse 0
  56. #define fTrue 1
  57. #define hrOK HRESULT(S_OK)
  58. #define hrTrue HRESULT(S_OK)
  59. #define hrFalse ResultFromScode(S_FALSE)
  60. #define hrFail ResultFromScode(E_FAIL)
  61. #define hrNotImpl ResultFromScode(E_NOTIMPL)
  62. #define hrNoInterface ResultFromScode(E_NOINTERFACE)
  63. #define hrNoMem WMDM_E_BUFFERTOOSMALL
  64. #define hrAbort ResultFromScode(E_ABORT)
  65. #define hrInvalidArg ResultFromScode(E_INVALIDARG)
  66. /*----------------------------------------------------------------------------
  67. CORg style error handling
  68. (Historicaly stands for Check OLE Result and Goto)
  69. ----------------------------------------------------------------------------*/
  70. #define CPRg(p)\
  71. do\
  72. {\
  73. if (!(p))\
  74. {\
  75. hr = hrNoMem;\
  76. goto Error;\
  77. }\
  78. }\
  79. while (fFalse)
  80. #define CHRg(hResult) CORg(hResult)
  81. #define CORg(hResult)\
  82. do\
  83. {\
  84. hr = (hResult);\
  85. if (FAILED(hr))\
  86. {\
  87. goto Error;\
  88. }\
  89. }\
  90. while (fFalse)
  91. #define CWRg(fResult)\
  92. {\
  93. if (!(fResult))\
  94. {\
  95. hr = GetLastError();\
  96. if (!(hr & 0xFFFF0000)) hr = HRESULT_FROM_WIN32(hr);\
  97. goto Error;\
  98. }\
  99. }
  100. #define CFRg(fResult)\
  101. {\
  102. if (!(fResult))\
  103. {\
  104. hr = hrFail;\
  105. goto Error;\
  106. }\
  107. }
  108. #define CARg(p)\
  109. do\
  110. {\
  111. if (!(p))\
  112. {\
  113. hr = hrInvalidArg;\
  114. goto Error;\
  115. }\
  116. }\
  117. while (fFalse)
  118. #endif // __MDSPDEFS_H__