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.

766 lines
18 KiB

  1. // MDSPDevice.cpp : Implementation of CMDSPDevice
  2. #include "stdafx.h"
  3. #include "MsPMSP.h"
  4. #include "MDSPDevice.h"
  5. #include "MDSPEnumStorage.h"
  6. #include "MDSPStorage.h"
  7. #include "MdspDefs.h"
  8. #include "SerialNumber.h"
  9. #include "loghelp.h"
  10. #include "wmsstd.h"
  11. #define STRSAFE_NO_DEPRECATE
  12. #include "strsafe.h"
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMDSPDevice
  15. HRESULT CMDSPDevice::InitGlobalDeviceInfo()
  16. {
  17. return SetGlobalDeviceStatus(m_wcsName, 0, FALSE);
  18. }
  19. CMDSPDevice::CMDSPDevice()
  20. {
  21. m_wcsName[0] = 0;
  22. }
  23. CMDSPDevice::~CMDSPDevice()
  24. {
  25. //----------------------------------------------------------
  26. // PnP Notification Code, removed for public beta release
  27. //----------------------------------------------------------
  28. // // Search for existing entries to see if there is a match
  29. // g_CriticalSection.Lock();
  30. // for(int i=0; i<MDSP_MAX_DEVICE_OBJ; i++)
  31. // {
  32. // // Release Notification connectors
  33. // if( g_NotifyInfo[i].bValid &&
  34. // g_NotifyInfo[i].pDeviceObj == this ) // need to release
  35. // {
  36. // if( g_NotifyInfo[i].pIWMDMConnect )
  37. // {
  38. // //((IWMDMConnect *)(g_NotifyInfo[i].pIWMDMConnect))->Release();
  39. // }
  40. // g_NotifyInfo[i].bValid=FALSE;
  41. // }
  42. // }
  43. // g_CriticalSection.Unlock();
  44. }
  45. STDMETHODIMP CMDSPDevice::GetName(LPWSTR pwszName, UINT nMaxChars)
  46. {
  47. USES_CONVERSION;
  48. HRESULT hr=E_FAIL;
  49. CFRg(g_pAppSCServer);
  50. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  51. {
  52. CORg(WMDM_E_NOTCERTIFIED);
  53. }
  54. CARg(pwszName);
  55. if( m_wcsName && m_wcsName[0] )
  56. {
  57. // WinNT
  58. if( IsWinNT() )
  59. {
  60. SHFILEINFOW sfiw = { 0 };
  61. WCHAR pswzRoot[MAX_PATH+1];
  62. DWORD dwLen = wcslen(m_wcsName);
  63. // We reserve one char for the \ that PathAddBackslashW might
  64. // add
  65. if (dwLen >= ARRAYSIZE(pswzRoot)-1)
  66. {
  67. hr = STRSAFE_E_INSUFFICIENT_BUFFER; //defined in strsafe.h
  68. goto Error;
  69. }
  70. wcscpy(pswzRoot, m_wcsName );
  71. PathAddBackslashW(pswzRoot);
  72. // Try to get the shell name for this path
  73. if( SHGetFileInfoW( pswzRoot, FILE_ATTRIBUTE_DIRECTORY, &sfiw, sizeof(sfiw),
  74. SHGFI_USEFILEATTRIBUTES | SHGFI_DISPLAYNAME) )
  75. {
  76. CPRg( nMaxChars> wcslen(sfiw.szDisplayName));
  77. wcscpy(pwszName, sfiw.szDisplayName );
  78. }
  79. else
  80. {
  81. // Use path name on failure
  82. CPRg( nMaxChars > wcslen(m_wcsName));
  83. wcscpy( pwszName, m_wcsName);
  84. }
  85. }
  86. // Win9x
  87. else
  88. {
  89. SHFILEINFO sfi = { 0 };
  90. CHAR pszRoot[MAX_PATH];
  91. strcpy( pszRoot, W2A(m_wcsName) );
  92. PathAddBackslashA(pszRoot);
  93. // Try to get the shell name for this path
  94. if (SHGetFileInfoA( pszRoot, FILE_ATTRIBUTE_DIRECTORY, &sfi, sizeof(sfi),
  95. SHGFI_USEFILEATTRIBUTES | SHGFI_DISPLAYNAME))
  96. {
  97. CPRg( nMaxChars> strlen(sfi.szDisplayName));
  98. wcscpy(pwszName, A2W(sfi.szDisplayName) );
  99. }
  100. else
  101. {
  102. // Use path name on failure
  103. CPRg( nMaxChars > wcslen(m_wcsName));
  104. wcscpy( pwszName, m_wcsName);
  105. }
  106. }
  107. hr = S_OK;
  108. }
  109. else
  110. {
  111. hr = WMDM_E_NOTSUPPORTED;
  112. }
  113. Error:
  114. hrLogDWORD("IMDSPDevice::GetName returned 0x%08lx", hr, hr);
  115. return hr;
  116. }
  117. STDMETHODIMP CMDSPDevice::GetManufacturer(LPWSTR pwszName, UINT nMaxChars)
  118. {
  119. HRESULT hr=S_OK;
  120. CFRg(g_pAppSCServer);
  121. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  122. {
  123. CORg(WMDM_E_NOTCERTIFIED);
  124. }
  125. CARg(pwszName);
  126. if(FAILED(UtilGetManufacturer(m_wcsName, &pwszName, nMaxChars)))
  127. hr=E_NOTIMPL;
  128. Error:
  129. hrLogDWORD("IMDSPDevice::GetManufacturer returned 0x%08lx", hr, hr);
  130. return hr;
  131. }
  132. STDMETHODIMP CMDSPDevice::GetVersion(DWORD * pdwVersion)
  133. {
  134. HRESULT hr;
  135. CFRg(g_pAppSCServer);
  136. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  137. {
  138. CORg(WMDM_E_NOTCERTIFIED);
  139. }
  140. hr = WMDM_E_NOTSUPPORTED;
  141. Error:
  142. hrLogDWORD("IMDSPDevice::GetVersion returned 0x%08lx", hr, hr);
  143. return hr;
  144. }
  145. STDMETHODIMP CMDSPDevice::GetType(DWORD * pdwType)
  146. {
  147. HRESULT hr=S_OK;
  148. WMDMID snTmp;
  149. CFRg(g_pAppSCServer);
  150. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  151. {
  152. CORg(WMDM_E_NOTCERTIFIED);
  153. }
  154. CARg(pdwType);
  155. *pdwType = WMDM_DEVICE_TYPE_STORAGE | WMDM_DEVICE_TYPE_NONSDMI;
  156. snTmp.cbSize = sizeof(WMDMID);
  157. hr = UtilGetSerialNumber(m_wcsName, &snTmp, FALSE);
  158. if( hr == S_OK )
  159. {
  160. *pdwType |= WMDM_DEVICE_TYPE_SDMI;
  161. }
  162. hr=S_OK;
  163. Error:
  164. hrLogDWORD("IMDSPDevice::GetType returned 0x%08lx", hr, hr);
  165. return hr;
  166. }
  167. STDMETHODIMP CMDSPDevice::GetSerialNumber(PWMDMID pSerialNumber,
  168. BYTE abMac[WMDM_MAC_LENGTH])
  169. {
  170. HRESULT hr;
  171. CFRg(g_pAppSCServer);
  172. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  173. {
  174. CORg(WMDM_E_NOTCERTIFIED);
  175. }
  176. CARg(pSerialNumber);
  177. // CARg((pSerialNumber->cbSize)==sizeof(WMDMID));
  178. hr = UtilGetSerialNumber(m_wcsName, pSerialNumber, TRUE);
  179. if( hr == HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) )
  180. {
  181. hr = WMDM_E_NOTSUPPORTED;
  182. }
  183. if( hr == S_OK )
  184. {
  185. // MAC the parameters
  186. HMAC hMAC;
  187. CORg(g_pAppSCServer->MACInit(&hMAC));
  188. CORg(g_pAppSCServer->MACUpdate(hMAC, (BYTE*)(pSerialNumber), sizeof(WMDMID)));
  189. CORg(g_pAppSCServer->MACFinal(hMAC, abMac));
  190. }
  191. Error:
  192. hrLogDWORD("IMDSPDevice::GetSerialNumber returned 0x%08lx", hr, hr);
  193. return hr;
  194. }
  195. STDMETHODIMP CMDSPDevice::GetPowerSource(DWORD * pdwPowerSource, DWORD * pdwPercentRemaining)
  196. {
  197. HRESULT hr=S_OK;
  198. CFRg(g_pAppSCServer);
  199. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  200. {
  201. CORg(WMDM_E_NOTCERTIFIED);
  202. }
  203. CARg(pdwPowerSource);
  204. CARg(pdwPercentRemaining);
  205. *pdwPowerSource = WMDM_POWER_CAP_EXTERNAL |
  206. WMDM_POWER_IS_EXTERNAL | WMDM_POWER_PERCENT_AVAILABLE;
  207. *pdwPercentRemaining = 100;
  208. Error:
  209. hrLogDWORD("IMDSPDevice::GetPowerSource returned 0x%08lx", hr, hr);
  210. return hr;
  211. }
  212. BOOL IsDriveReady(int nDriveNum)
  213. {
  214. DWORD dwRet=ERROR_SUCCESS;
  215. // Disable drive error popup
  216. UINT uPrevErrMode=SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
  217. char szDL[32]="A:\\D569CFEE41e6A522E8F5.jnk";
  218. szDL[0] += (char)nDriveNum;
  219. HANDLE hFile=CreateFile(
  220. szDL, // file name
  221. 0, // access mode
  222. 0, // share mode
  223. NULL, // SD
  224. OPEN_EXISTING, // how to create
  225. 0, // file attributes
  226. NULL // handle to template file
  227. );
  228. if( hFile == INVALID_HANDLE_VALUE )
  229. {
  230. dwRet=GetLastError();
  231. }
  232. else
  233. {
  234. CloseHandle(hFile); // rare situation when such a file exists.
  235. }
  236. // Restore default system error handling
  237. SetErrorMode(uPrevErrMode);
  238. return (ERROR_FILE_NOT_FOUND==dwRet || ERROR_SUCCESS==dwRet);
  239. }
  240. STDMETHODIMP CMDSPDevice::GetStatus(DWORD * pdwStatus)
  241. {
  242. HRESULT hr=S_OK;
  243. CFRg(g_pAppSCServer);
  244. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  245. {
  246. CORg(WMDM_E_NOTCERTIFIED);
  247. }
  248. CARg(pdwStatus);
  249. CHRg(GetGlobalDeviceStatus(m_wcsName, pdwStatus));
  250. if( !( *pdwStatus & WMDM_STATUS_BUSY) )
  251. {
  252. if( IsDriveReady((m_wcsName[0]>96)?(m_wcsName[0]-L'a'):(m_wcsName[0]-L'A')))
  253. {
  254. *pdwStatus = WMDM_STATUS_READY;
  255. }
  256. else
  257. {
  258. *pdwStatus = WMDM_STATUS_STORAGE_NOTPRESENT;
  259. }
  260. }
  261. hr=S_OK;
  262. Error:
  263. hrLogDWORD("IMDSPDevice::GetStatus returned 0x%08lx", hr, hr);
  264. return hr;
  265. }
  266. STDMETHODIMP CMDSPDevice::GetDeviceIcon(ULONG *hIcon)
  267. {
  268. USES_CONVERSION;
  269. HRESULT hr=S_OK;
  270. SHFILEINFO sfi = { 0 };
  271. TCHAR szRoot[MAX_PATH+1];
  272. CFRg(g_pAppSCServer);
  273. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  274. {
  275. CORg(WMDM_E_NOTCERTIFIED);
  276. }
  277. CARg(hIcon);
  278. if (!m_wcsName || !(m_wcsName[0]))
  279. {
  280. CORg(WMDM_E_NOTSUPPORTED);
  281. }
  282. DWORD dwLen = wcslen(m_wcsName);
  283. // We reserve one char for the \ that PathAddBackslash might add
  284. if (dwLen >= ARRAYSIZE(szRoot)-1)
  285. {
  286. hr = STRSAFE_E_INSUFFICIENT_BUFFER; //defined in strsafe.h
  287. goto Error;
  288. }
  289. _tcscpy(szRoot, W2T(m_wcsName));
  290. PathAddBackslash(szRoot);
  291. if (SHGetFileInfo( szRoot, FILE_ATTRIBUTE_DIRECTORY, &sfi, sizeof(sfi),
  292. SHGFI_USEFILEATTRIBUTES | SHGFI_ICONLOCATION ))
  293. {
  294. TCHAR pszFilePath[MAX_PATH];
  295. // Got the path of the file containing the HICON.
  296. // Load the icon as a shared resource so that the user can get to all different
  297. // sizes of the icon.
  298. ExpandEnvironmentStrings( sfi.szDisplayName, pszFilePath, MAX_PATH );
  299. if( sfi.iIcon > 0 )
  300. {
  301. *hIcon = HandleToULong(ExtractIcon( g_hinstance, pszFilePath, sfi.iIcon ));
  302. }
  303. else
  304. {
  305. HMODULE hmod = LoadLibrary(pszFilePath);
  306. if (hmod)
  307. {
  308. *hIcon = HandleToULong(LoadImage( hmod, MAKEINTRESOURCE(-sfi.iIcon),
  309. IMAGE_ICON, 0, 0,
  310. LR_SHARED|LR_DEFAULTSIZE ));
  311. FreeLibrary(hmod);
  312. }
  313. }
  314. CWRg( *hIcon ); // now has an HICON
  315. }
  316. else
  317. {
  318. CFRg(g_hinstance);
  319. *hIcon = HandleToULong(LoadImage( g_hinstance, MAKEINTRESOURCEA(IDI_ICON_PM),IMAGE_ICON, 0, 0,LR_SHARED ));
  320. CWRg( *hIcon );
  321. }
  322. Error:
  323. hrLogDWORD("IMDSPDevice::GetDeviceIcon returned 0x%08lx", hr, hr);
  324. return hr;
  325. }
  326. STDMETHODIMP CMDSPDevice::SendOpaqueCommand(OPAQUECOMMAND *pCommand)
  327. {
  328. HRESULT hr;
  329. CFRg(g_pAppSCServer);
  330. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  331. {
  332. CORg(WMDM_E_NOTCERTIFIED);
  333. }
  334. hr = WMDM_E_NOTSUPPORTED;
  335. Error:
  336. hrLogDWORD("IMDSPDevice::SendOpaqueCommand returned 0x%08lx", hr, hr);
  337. return hr;
  338. }
  339. // IMDSPDevice2
  340. STDMETHODIMP CMDSPDevice::GetStorage( LPCWSTR pszStorageName, IMDSPStorage** ppStorage )
  341. {
  342. HRESULT hr = S_OK;
  343. HRESULT hrTemp;
  344. WCHAR pwszFileName[MAX_PATH+1];
  345. CComObject<CMDSPStorage> *pStg = NULL;
  346. DWORD dwAttrib;
  347. // Get name of file asked for
  348. DWORD dwLen = wcslen(m_wcsName);
  349. // We reserve one char for the \ that might be added below
  350. if (dwLen >= ARRAYSIZE(pwszFileName)-1)
  351. {
  352. hr = STRSAFE_E_INSUFFICIENT_BUFFER; //defined in strsafe.h
  353. goto Error;
  354. }
  355. wcscpy( pwszFileName, m_wcsName );
  356. if( pwszFileName[dwLen-1] != '\\' )
  357. wcscat( pwszFileName, L"\\" );
  358. hrTemp = StringCchCatW( pwszFileName,
  359. ARRAYSIZE(pwszFileName) - 1,
  360. // - 1 ensures the result fits into a MAX_PATH buffer.
  361. // This makes the wcscpy into pStg->m_wcsName (below) safe.
  362. pszStorageName );
  363. if (FAILED(hrTemp))
  364. {
  365. // The file does not exist
  366. hr = E_FAIL; // @@@@ Something else? S_FALSE?
  367. goto Error;
  368. }
  369. // Check if the file exists (NT)
  370. if( g_bIsWinNT )
  371. {
  372. dwAttrib = GetFileAttributesW( pwszFileName );
  373. if( dwAttrib == -1 )
  374. {
  375. // The file does not exist
  376. hr = S_FALSE;
  377. goto Error;
  378. }
  379. }
  380. // For Win9x use A-version of Win32 APIs
  381. else if( !g_bIsWinNT )
  382. {
  383. char pszTemp[MAX_PATH];
  384. WideCharToMultiByte(CP_ACP, NULL, pwszFileName, -1, pszTemp, MAX_PATH, NULL, NULL);
  385. dwAttrib = GetFileAttributesA( pszTemp );
  386. if( dwAttrib == -1 )
  387. {
  388. // The file does not exist
  389. hr = S_FALSE;
  390. goto Error;
  391. }
  392. }
  393. // Create new storage object
  394. CORg( CComObject<CMDSPStorage>::CreateInstance(&pStg) );
  395. CORg( pStg->QueryInterface( IID_IMDSPStorage, reinterpret_cast<void**>(ppStorage)) );
  396. wcscpy(pStg->m_wcsName, pwszFileName);
  397. pStg->m_bIsDirectory = ((dwAttrib & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
  398. Error:
  399. if( hr != S_OK )
  400. {
  401. if( pStg ) delete pStg;
  402. *ppStorage = NULL;
  403. }
  404. return hr;
  405. }
  406. STDMETHODIMP CMDSPDevice::GetFormatSupport2(
  407. DWORD dwFlags,
  408. _WAVEFORMATEX** ppAudioFormatEx,
  409. UINT* pnAudioFormatCount,
  410. _VIDEOINFOHEADER** ppVideoFormatEx,
  411. UINT* pnVideoFormatCount,
  412. WMFILECAPABILITIES** ppFileType,
  413. UINT* pnFileTypeCount )
  414. {
  415. return E_NOTIMPL;
  416. }
  417. STDMETHODIMP CMDSPDevice::GetSpecifyPropertyPages(
  418. ISpecifyPropertyPages** ppSpecifyPropPages,
  419. IUnknown*** pppUnknowns,
  420. ULONG* pcUnks )
  421. {
  422. return E_NOTIMPL;
  423. }
  424. STDMETHODIMP CMDSPDevice::GetPnPName( LPWSTR pwszPnPName, UINT nMaxChars )
  425. {
  426. return E_NOTIMPL;
  427. }
  428. // IMDSPDeviceControl
  429. STDMETHODIMP CMDSPDevice::GetDCStatus(/*[out]*/ DWORD *pdwStatus)
  430. {
  431. HRESULT hr=E_FAIL;
  432. CFRg(g_pAppSCServer);
  433. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  434. {
  435. CORg(WMDM_E_NOTCERTIFIED);
  436. }
  437. hr = GetStatus(pdwStatus);
  438. Error:
  439. hrLogDWORD("IMDSPDeviceControl::GetDCStatus returned 0x%08lx", hr, hr);
  440. return hr;
  441. }
  442. STDMETHODIMP CMDSPDevice::GetCapabilities(/*[out]*/ DWORD *pdwCapabilitiesMask)
  443. {
  444. HRESULT hr;
  445. CFRg(g_pAppSCServer);
  446. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  447. {
  448. CORg(WMDM_E_NOTCERTIFIED);
  449. }
  450. if( !pdwCapabilitiesMask ) return E_INVALIDARG;
  451. *pdwCapabilitiesMask = WMDM_DEVICECAP_CANSTREAMPLAY;
  452. hr = S_OK;
  453. Error:
  454. hrLogDWORD("IMDSPDeviceControl::GetCapabilities returned 0x%08lx", hr, hr);
  455. return S_OK;
  456. }
  457. STDMETHODIMP CMDSPDevice::Play()
  458. {
  459. HRESULT hr;
  460. CFRg(g_pAppSCServer);
  461. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  462. {
  463. CORg(WMDM_E_NOTCERTIFIED);
  464. }
  465. hr = WMDM_E_NOTSUPPORTED;
  466. Error:
  467. hrLogDWORD("IMDSPDeviceControl::Play returned 0x%08lx", hr, hr);
  468. return hr;
  469. }
  470. STDMETHODIMP CMDSPDevice::Record(/*[in]*/ _WAVEFORMATEX *pFormat)
  471. {
  472. HRESULT hr;
  473. CFRg(g_pAppSCServer);
  474. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  475. {
  476. CORg(WMDM_E_NOTCERTIFIED);
  477. }
  478. hr = WMDM_E_NOTSUPPORTED;
  479. Error:
  480. hrLogDWORD("IMDSPDeviceControl::Record returned 0x%08lx", hr, hr);
  481. return hr;
  482. }
  483. STDMETHODIMP CMDSPDevice::Pause()
  484. {
  485. HRESULT hr;
  486. CFRg(g_pAppSCServer);
  487. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  488. {
  489. CORg(WMDM_E_NOTCERTIFIED);
  490. }
  491. hr = WMDM_E_NOTSUPPORTED;
  492. Error:
  493. hrLogDWORD("IMDSPDeviceControl::Pause returned 0x%08lx", hr, hr);
  494. return hr;
  495. }
  496. STDMETHODIMP CMDSPDevice::Resume()
  497. {
  498. HRESULT hr;
  499. CFRg(g_pAppSCServer);
  500. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  501. {
  502. CORg(WMDM_E_NOTCERTIFIED);
  503. }
  504. hr = WMDM_E_NOTSUPPORTED;
  505. Error:
  506. hrLogDWORD("IMDSPDeviceControl::Resume returned 0x%08lx", hr, hr);
  507. return hr;
  508. }
  509. STDMETHODIMP CMDSPDevice::Stop()
  510. {
  511. HRESULT hr;
  512. CFRg(g_pAppSCServer);
  513. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  514. {
  515. CORg(WMDM_E_NOTCERTIFIED);
  516. }
  517. hr = WMDM_E_NOTSUPPORTED;
  518. Error:
  519. hrLogDWORD("IMDSPDeviceControl::Stop returned 0x%08lx", hr, hr);
  520. return hr;
  521. }
  522. STDMETHODIMP CMDSPDevice::Seek(/*[in]*/ UINT fuMode, /*[in]*/ int nOffset)
  523. {
  524. HRESULT hr;
  525. CFRg(g_pAppSCServer);
  526. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  527. {
  528. CORg(WMDM_E_NOTCERTIFIED);
  529. }
  530. hr = WMDM_E_NOTSUPPORTED;
  531. Error:
  532. hrLogDWORD("IMDSPDeviceControl::Seek returned 0x%08lx", hr, hr);
  533. return hr;
  534. }
  535. STDMETHODIMP CMDSPDevice::GetFormatSupport( _WAVEFORMATEX **pFormatEx,
  536. UINT *pnFormatCount,
  537. LPWSTR **pppwszMimeType,
  538. UINT *pnMimeTypeCount)
  539. {
  540. HRESULT hr=S_OK;
  541. CFRg(g_pAppSCServer);
  542. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  543. {
  544. CORg(WMDM_E_NOTCERTIFIED);
  545. }
  546. CARg(pFormatEx);
  547. CARg(pppwszMimeType);
  548. CARg(pnFormatCount);
  549. CARg(pnMimeTypeCount);
  550. *pnFormatCount = 1;
  551. *pFormatEx = (_WAVEFORMATEX *)CoTaskMemAlloc(sizeof(_WAVEFORMATEX));
  552. CPRg( *pFormatEx);
  553. (*pFormatEx)->wFormatTag = WMDM_WAVE_FORMAT_ALL;
  554. (*pFormatEx)->nChannels = 2;
  555. (*pFormatEx)->cbSize = 0;
  556. (*pFormatEx)->nSamplesPerSec=0;
  557. (*pFormatEx)->nAvgBytesPerSec=0;
  558. (*pFormatEx)->nBlockAlign=0;
  559. (*pFormatEx)->wBitsPerSample=0;
  560. *pnMimeTypeCount= 1;
  561. *pppwszMimeType = (LPWSTR *)CoTaskMemAlloc(sizeof(LPWSTR)*1);
  562. CPRg(*pppwszMimeType);
  563. **pppwszMimeType = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR)*(wcslen(WCS_MIME_TYPE_ALL)+1));
  564. CPRg(**pppwszMimeType);
  565. wcscpy(**pppwszMimeType, WCS_MIME_TYPE_ALL);
  566. Error:
  567. hrLogDWORD("IMDSPDevice::GetFormatSupport returned 0x%08lx", hr, hr);
  568. return hr;
  569. }
  570. STDMETHODIMP CMDSPDevice::EnumStorage(IMDSPEnumStorage * * ppEnumStorage)
  571. {
  572. HRESULT hr;
  573. CFRg(g_pAppSCServer);
  574. if ( !(g_pAppSCServer->fIsAuthenticated()) )
  575. {
  576. CORg(WMDM_E_NOTCERTIFIED);
  577. }
  578. CARg(ppEnumStorage);
  579. CComObject<CMDSPEnumStorage> *pEnumObj;
  580. CORg(CComObject<CMDSPEnumStorage>::CreateInstance(&pEnumObj));
  581. hr=pEnumObj->QueryInterface(IID_IMDSPEnumStorage, reinterpret_cast<void**>(ppEnumStorage));
  582. if( FAILED(hr) )
  583. delete pEnumObj;
  584. else
  585. {
  586. hr = StringCbCopyW(pEnumObj->m_wcsPath,
  587. ARRAYSIZE(pEnumObj->m_wcsPath),
  588. m_wcsName);
  589. if (FAILED(hr))
  590. {
  591. (*ppEnumStorage)->Release();
  592. *ppEnumStorage = NULL;
  593. goto Error;
  594. }
  595. }
  596. Error:
  597. hrLogDWORD("IMDSPDevice::EnumStorage returned 0x%08lx", hr, hr);
  598. return hr;
  599. }