Source code of Windows XP (NT5)
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.

140 lines
3.6 KiB

  1. // hsmconpt.cpp : Implementation of CHsmConnPoint
  2. #include "stdafx.h"
  3. #include "Hsmservr.h"
  4. #include "hsmconpt.h"
  5. // define for access to global server objects
  6. extern IHsmServer *g_pEngServer;
  7. extern IFsaServer *g_pFsaServer;
  8. extern CRITICAL_SECTION g_FsaCriticalSection;
  9. extern CRITICAL_SECTION g_EngCriticalSection;
  10. extern BOOL g_bEngInitialized;
  11. extern BOOL g_bFsaInitialized;
  12. static USHORT iCount = 0; // Count of existing objects
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CHsmConnPoint
  15. STDMETHODIMP CHsmConnPoint::FinalConstruct(void)
  16. /*++
  17. Implements:
  18. CComObjectRoot::FinalConstruct().
  19. --*/
  20. {
  21. HRESULT hr = S_OK;
  22. WsbTraceIn(OLESTR("CHsmConnPoint::FinalConstruct"), OLESTR(""));
  23. try {
  24. WsbAffirmHr(CComObjectRoot::FinalConstruct());
  25. // currently, no private initialization
  26. // Add class to object table
  27. WSB_OBJECT_ADD(CLSID_CFsaScanItemNTFS, this);
  28. } WsbCatch(hr);
  29. iCount++;
  30. WsbTraceOut(OLESTR("CHsmConnPoint::FinalConstruct"), OLESTR("hr = <%ls>, Count is <%d>"),
  31. WsbHrAsString(hr), iCount);
  32. return(hr);
  33. }
  34. STDMETHODIMP CHsmConnPoint::FinalRelease(void)
  35. /*++
  36. Implements:
  37. CComObjectRoot::FinalRelease().
  38. --*/
  39. {
  40. HRESULT hr = S_OK;
  41. WsbTraceIn(OLESTR("CHsmConnPoint::FinalRelease"), OLESTR(""));
  42. // Subtract class from object table
  43. WSB_OBJECT_SUB(CLSID_CFsaScanItemNTFS, this);
  44. // currently, no private cleanup
  45. // Let the parent class do his thing.
  46. CComObjectRoot::FinalRelease();
  47. iCount--;
  48. WsbTraceOut(OLESTR("CHsmConnPoint::FinalRelease"), OLESTR("hr = <%ls>, Count is <%d>"),
  49. WsbHrAsString(hr), iCount);
  50. return (hr);
  51. }
  52. STDMETHODIMP CHsmConnPoint::GetEngineServer(IHsmServer **ppHsmServer)
  53. {
  54. // If Engine server has been created, return the pointer. Otherwise, fail.
  55. HRESULT hr = S_OK;
  56. WsbTraceIn(OLESTR("CHsmConnPoint::GetEngineServer"), OLESTR(""));
  57. try {
  58. // verify that pointers are valid
  59. WsbAssert (ppHsmServer != 0, E_POINTER);
  60. WsbAffirm (g_pEngServer != 0, HSM_E_NOT_READY);
  61. // assign in a safe manner (only if manager object is already initializaed)
  62. EnterCriticalSection(&g_EngCriticalSection);
  63. if (g_bEngInitialized) {
  64. _ASSERTE(g_pEngServer != 0); // shouldn't happen
  65. *ppHsmServer = g_pEngServer;
  66. g_pEngServer->AddRef();
  67. } else {
  68. hr = HSM_E_NOT_READY;
  69. }
  70. LeaveCriticalSection (&g_EngCriticalSection);
  71. } WsbCatch (hr);
  72. WsbTraceOut(OLESTR("CHsmConnPoint::GetEngineServer"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  73. return (hr);
  74. }
  75. STDMETHODIMP CHsmConnPoint::GetFsaServer(IFsaServer **ppFsaServer)
  76. {
  77. // If Fsa server has been created, return the pointer. Otherwise, fail.
  78. HRESULT hr = S_OK;
  79. WsbTraceIn(OLESTR("CHsmConnPoint::GetFsaServer"), OLESTR(""));
  80. try {
  81. // verify that pointers are valid
  82. WsbAssert (ppFsaServer != 0, E_POINTER);
  83. WsbAffirm (g_pFsaServer != 0, FSA_E_NOT_READY);
  84. // assign in a safe manner (only if manager object is already initializaed)
  85. EnterCriticalSection(&g_FsaCriticalSection);
  86. if (g_bFsaInitialized) {
  87. _ASSERTE(g_pFsaServer != 0); // shouldn't happen
  88. *ppFsaServer = g_pFsaServer;
  89. g_pFsaServer->AddRef();
  90. } else {
  91. hr = FSA_E_NOT_READY;
  92. }
  93. LeaveCriticalSection(&g_FsaCriticalSection);
  94. } WsbCatch (hr);
  95. WsbTraceOut(OLESTR("CHsmConnPoint::GetFsaServer"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  96. return (hr);
  97. }