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.

180 lines
4.7 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1997 Microsoft Corporation. All Rights Reserved.
  5. Component: Global Interface Pointer API support
  6. File: Gip.h
  7. Owner: DmitryR
  8. This is the GIP header file.
  9. ===================================================================*/
  10. #ifndef _ASP_GIP_H
  11. #define _ASP_GIP_H
  12. /*===================================================================
  13. Includes
  14. ===================================================================*/
  15. #include "debug.h"
  16. /*===================================================================
  17. Defines
  18. ===================================================================*/
  19. #define NULL_GIP_COOKIE 0xFFFFFFFF
  20. /*===================================================================
  21. C G l o b a l I n t e r f a c e A P I
  22. ===================================================================*/
  23. class CGlobalInterfaceAPI
  24. {
  25. private:
  26. // Is inited?
  27. DWORD m_fInited : 1;
  28. // Pointer to the COM object
  29. IGlobalInterfaceTable *m_pGIT;
  30. public:
  31. CGlobalInterfaceAPI();
  32. ~CGlobalInterfaceAPI();
  33. HRESULT Init();
  34. HRESULT UnInit();
  35. // inlines for the real API calls:
  36. HRESULT Register(IUnknown *pUnk, REFIID riid, DWORD *pdwCookie);
  37. HRESULT Get(DWORD dwCookie, REFIID riid, void **ppv);
  38. HRESULT Revoke(DWORD dwCookie);
  39. public:
  40. #ifdef DBG
  41. inline void AssertValid() const
  42. {
  43. Assert(m_fInited);
  44. Assert(m_pGIT);
  45. }
  46. #else
  47. inline void AssertValid() const {}
  48. #endif
  49. };
  50. /*===================================================================
  51. CGlobalInterfaceAPI inlines
  52. ===================================================================*/
  53. inline HRESULT CGlobalInterfaceAPI::Register
  54. (
  55. IUnknown *pUnk,
  56. REFIID riid,
  57. DWORD *pdwCookie
  58. )
  59. {
  60. HRESULT hr = S_OK;
  61. IUnknown *pUnkTemp = NULL;
  62. IClientSecurity * pICS = NULL;
  63. DWORD dwAuthnSvc = RPC_C_AUTHN_DEFAULT;
  64. DWORD dwAuthzSvc = RPC_C_AUTHZ_DEFAULT;
  65. OLECHAR *pwszServerPrincName = NULL;
  66. DWORD dwAuthnLevel = RPC_C_AUTHN_LEVEL_DEFAULT;
  67. DWORD dwImpLevel = RPC_C_IMP_LEVEL_DEFAULT;
  68. RPC_AUTH_IDENTITY_HANDLE AuthInfo = NULL;
  69. DWORD dwCapabilities = EOAC_DEFAULT;
  70. Assert(m_fInited);
  71. Assert(m_pGIT);
  72. hr = pUnk->QueryInterface(IID_IUnknown, (VOID**)&pUnkTemp);
  73. if (SUCCEEDED(hr))
  74. {
  75. hr = pUnkTemp->QueryInterface( IID_IClientSecurity, (VOID**) &pICS );
  76. if (SUCCEEDED(hr))
  77. {
  78. hr = pICS->QueryBlanket( pUnkTemp,
  79. &dwAuthnSvc,
  80. &dwAuthzSvc,
  81. &pwszServerPrincName,
  82. &dwAuthnLevel,
  83. &dwImpLevel,
  84. &AuthInfo,
  85. &dwCapabilities );
  86. if (SUCCEEDED(hr))
  87. {
  88. dwCapabilities &= ~EOAC_DYNAMIC_CLOAKING;
  89. dwCapabilities |= EOAC_STATIC_CLOAKING;
  90. hr = pICS->SetBlanket( pUnkTemp,
  91. dwAuthnSvc,
  92. dwAuthzSvc,
  93. pwszServerPrincName,
  94. dwAuthnLevel,
  95. dwImpLevel,
  96. AuthInfo,
  97. dwCapabilities );
  98. }
  99. }
  100. else
  101. {
  102. hr = S_OK;
  103. }
  104. }
  105. if (SUCCEEDED(hr))
  106. {
  107. hr = m_pGIT->RegisterInterfaceInGlobal(pUnk, riid, pdwCookie);
  108. }
  109. if (pwszServerPrincName)
  110. {
  111. CoTaskMemFree( pwszServerPrincName );
  112. }
  113. if (pICS)
  114. {
  115. pICS->Release();
  116. pICS = NULL;
  117. }
  118. if (pUnkTemp)
  119. {
  120. pUnkTemp->Release();
  121. pUnkTemp = NULL;
  122. }
  123. return hr;
  124. }
  125. inline HRESULT CGlobalInterfaceAPI::Get
  126. (
  127. DWORD dwCookie,
  128. REFIID riid,
  129. void **ppv
  130. )
  131. {
  132. Assert(m_fInited);
  133. Assert(m_pGIT);
  134. return m_pGIT->GetInterfaceFromGlobal(dwCookie, riid, ppv);
  135. }
  136. inline HRESULT CGlobalInterfaceAPI::Revoke
  137. (
  138. DWORD dwCookie
  139. )
  140. {
  141. Assert(m_fInited);
  142. Assert(m_pGIT);
  143. return m_pGIT->RevokeInterfaceFromGlobal(dwCookie);
  144. }
  145. /*===================================================================
  146. Globals
  147. ===================================================================*/
  148. extern CGlobalInterfaceAPI g_GIPAPI;
  149. #endif