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.

134 lines
3.7 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: ContextActivation.cpp
  3. //
  4. // Copyright (c) 2000, Microsoft Corporation
  5. //
  6. // Class to implement creating, destroy and scoping a fusion activation
  7. // context.
  8. //
  9. // History: 2000-10-09 vtan created
  10. // 2000-11-04 vtan copied from winlogon
  11. // --------------------------------------------------------------------------
  12. #ifdef _X86_
  13. #include "StandardHeader.h"
  14. #include "ContextActivation.h"
  15. // --------------------------------------------------------------------------
  16. // CContextActivation::s_hActCtx
  17. //
  18. // Purpose: The global activation context for this process.
  19. //
  20. // History: 2000-10-09 vtan created
  21. // --------------------------------------------------------------------------
  22. HANDLE CContextActivation::s_hActCtx = INVALID_HANDLE_VALUE;
  23. // --------------------------------------------------------------------------
  24. // CContextActivation::CContextActivation
  25. //
  26. // Arguments: <none>
  27. //
  28. // Returns: <none>
  29. //
  30. // Purpose: Activate the global activation context for this process.
  31. //
  32. // History: 2000-10-09 vtan created
  33. // --------------------------------------------------------------------------
  34. CContextActivation::CContextActivation (void)
  35. {
  36. (BOOL)ActivateActCtx(s_hActCtx, &ulCookie);
  37. }
  38. // --------------------------------------------------------------------------
  39. // CContextActivation::~CContextActivation
  40. //
  41. // Arguments: <none>
  42. //
  43. // Returns: <none>
  44. //
  45. // Purpose: Deactivates the global activation context for this process.
  46. //
  47. // History: 2000-10-09 vtan created
  48. // --------------------------------------------------------------------------
  49. CContextActivation::~CContextActivation (void)
  50. {
  51. (BOOL)DeactivateActCtx(0, ulCookie);
  52. }
  53. // --------------------------------------------------------------------------
  54. // CContextActivation::Create
  55. //
  56. // Arguments: pszPath = Path to the manifest.
  57. //
  58. // Returns: <none>
  59. //
  60. // Purpose: Creates an activation context for this process from a given
  61. // manifest. If the creation fails use NULL.
  62. //
  63. // History: 2000-10-09 vtan created
  64. // --------------------------------------------------------------------------
  65. void CContextActivation::Create (const TCHAR *pszPath)
  66. {
  67. ACTCTX actCtx;
  68. ZeroMemory(&actCtx, sizeof(actCtx));
  69. actCtx.cbSize = sizeof(actCtx);
  70. actCtx.lpSource = pszPath;
  71. s_hActCtx = CreateActCtx(&actCtx);
  72. if (INVALID_HANDLE_VALUE == s_hActCtx)
  73. {
  74. s_hActCtx = NULL;
  75. }
  76. }
  77. // --------------------------------------------------------------------------
  78. // CContextActivation::Destroy
  79. //
  80. // Arguments: <none>
  81. //
  82. // Returns: <none>
  83. //
  84. // Purpose: Destroy an activation context created in
  85. // CContextActivation::Create.
  86. //
  87. // History: 2000-10-09 vtan created
  88. // --------------------------------------------------------------------------
  89. void CContextActivation::Destroy (void)
  90. {
  91. if (s_hActCtx != NULL)
  92. {
  93. ReleaseActCtx(s_hActCtx);
  94. s_hActCtx = INVALID_HANDLE_VALUE;
  95. }
  96. }
  97. // --------------------------------------------------------------------------
  98. // CContextActivation::HasContext
  99. //
  100. // Arguments: <none>
  101. //
  102. // Returns: bool
  103. //
  104. // Purpose: Returns whether a fusion activation context is available.
  105. //
  106. // History: 2000-11-04 vtan created
  107. // --------------------------------------------------------------------------
  108. bool CContextActivation::HasContext (void)
  109. {
  110. return(s_hActCtx != NULL);
  111. }
  112. #endif /* _X86_ */