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.

65 lines
1.5 KiB

  1. #include "stdafx.h"
  2. #include "mswmdm.h"
  3. #include "spinfo.h"
  4. #include "loghelp.h"
  5. // We don't want to dll's using our lib to link to drmutil2.lib.
  6. // So disable DRM logging.
  7. #define DISABLE_DRM_LOG
  8. #include "drmerr.h"
  9. #include "key.h"
  10. #include "wmsstd.h"
  11. CSPInfo::CSPInfo() : m_pSP(NULL), m_pSCClient(NULL)
  12. {
  13. m_pSCClient = new CSecureChannelClient();
  14. }
  15. CSPInfo::~CSPInfo()
  16. {
  17. SAFE_DELETE(m_pSCClient);
  18. SAFE_RELEASE(m_pSP);
  19. }
  20. HRESULT CSPInfo::hrInitialize(LPWSTR pwszProgID)
  21. {
  22. HRESULT hr;
  23. CLSID clsid;
  24. IComponentAuthenticate *pAuth = NULL;
  25. if (!m_pSCClient)
  26. {
  27. hr = E_FAIL;
  28. goto exit;
  29. }
  30. CORg( m_pSCClient->SetCertificate(SAC_CERT_V1, (BYTE*)g_abAppCert, sizeof(g_abAppCert), (BYTE*)g_abPriv, sizeof(g_abPriv)) );
  31. CORg( CLSIDFromProgID(pwszProgID, &clsid) );
  32. CORg( CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IComponentAuthenticate, (void**)&pAuth) );
  33. m_pSCClient->SetInterface(pAuth);
  34. CORg( m_pSCClient->Authenticate(SAC_PROTOCOL_V1) );
  35. CORg( pAuth->QueryInterface(IID_IMDServiceProvider, (void**)&m_pSP) );
  36. exit:
  37. Error:
  38. SAFE_RELEASE(pAuth);
  39. hrLogDWORD("CSPInfo::hrInitialize returned 0x%08lx", hr, hr);
  40. return hr;
  41. }
  42. HRESULT CSPInfo::hrGetInterface(IMDServiceProvider **ppProvider)
  43. {
  44. m_pSP->AddRef();
  45. *ppProvider = m_pSP;
  46. return S_OK;
  47. }
  48. void CSPInfo::GetSCClient(CSecureChannelClient **ppSCClient)
  49. {
  50. *ppSCClient = m_pSCClient;
  51. }