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.

147 lines
3.7 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1992 - 1996
  6. //
  7. // File: ctxtmgr.h
  8. //
  9. // Contents: Structures and prototyps for Kerberos context list
  10. //
  11. //
  12. // History: 17-April-1996 Created MikeSw
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef __CTXTMGR_H__
  16. #define __CTXTMGR_H__
  17. //
  18. // All global variables declared as EXTERN will be allocated in the file
  19. // that defines CTXTMGR_ALLOCATE
  20. //
  21. #ifdef EXTERN
  22. #undef EXTERN
  23. #endif
  24. #ifdef CTXTMGR_ALLOCATE
  25. #define EXTERN
  26. #else
  27. #define EXTERN extern
  28. #endif
  29. EXTERN ERESOURCE KerbContextResource;
  30. EXTERN KERBEROS_LIST KerbContextList;
  31. EXTERN BOOLEAN KerberosContextsInitialized;
  32. #define KerbGetContextHandle(_Context_) ((ULONG_PTR)(_Context_))
  33. //
  34. // Context flags - these are attributes of a context and are stored in
  35. // the ContextAttributes field of a KERB_KERNEL_CONTEXT.
  36. //
  37. #define KERB_CONTEXT_MAPPED 0x1
  38. #define KERB_CONTEXT_OUTBOUND 0x2
  39. #define KERB_CONTEXT_INBOUND 0x4
  40. #define KERB_CONTEXT_USER_TO_USER 0x10
  41. #define KERB_CONTEXT_IMPORTED 0x80
  42. #define KERB_CONTEXT_EXPORTED 0x100
  43. //
  44. // NOTICE: The logon session resource, credential resource, and context
  45. // resource must all be acquired carefully to prevent deadlock. They
  46. // can only be acquired in this order:
  47. //
  48. // 1. Logon Sessions
  49. // 2. Credentials
  50. // 3. Contexts
  51. //
  52. #define KerbWriteLockContexts() \
  53. { \
  54. if ( KerbPoolType == PagedPool ) \
  55. { \
  56. DebugLog((DEB_TRACE_LOCKS,"Write locking Contexts\n")); \
  57. KeEnterCriticalRegion(); \
  58. ExAcquireResourceExclusiveLite(&KerbContextResource,TRUE); \
  59. } \
  60. }
  61. #define KerbReadLockContexts() \
  62. { \
  63. if ( KerbPoolType == PagedPool ) \
  64. { \
  65. DebugLog((DEB_TRACE_LOCKS,"Read locking Contexts\n")); \
  66. KeEnterCriticalRegion(); \
  67. ExAcquireSharedWaitForExclusive(&KerbContextResource, TRUE); \
  68. } \
  69. }
  70. #define KerbUnlockContexts() \
  71. { \
  72. if ( KerbPoolType == PagedPool ) \
  73. { \
  74. DebugLog((DEB_TRACE_LOCKS,"Unlocking Contexts\n")); \
  75. ExReleaseResourceLite(&KerbContextResource); \
  76. KeLeaveCriticalRegion(); \
  77. } \
  78. }
  79. NTSTATUS
  80. KerbInitContextList(
  81. VOID
  82. );
  83. VOID
  84. KerbFreeContextList(
  85. VOID
  86. );
  87. NTSTATUS
  88. KerbAllocateContext(
  89. PKERB_KERNEL_CONTEXT * NewContext
  90. );
  91. NTSTATUS
  92. KerbInsertContext(
  93. IN PKERB_KERNEL_CONTEXT Context
  94. );
  95. PKERB_KERNEL_CONTEXT
  96. KerbReferenceContext(
  97. IN LSA_SEC_HANDLE ContextHandle,
  98. IN BOOLEAN RemoveFromList
  99. );
  100. VOID
  101. KerbDereferenceContext(
  102. IN PKERB_KERNEL_CONTEXT Context
  103. );
  104. VOID
  105. KerbReferenceContextByPointer(
  106. IN PKERB_KERNEL_CONTEXT Context,
  107. IN BOOLEAN RemoveFromList
  108. );
  109. PKERB_KERNEL_CONTEXT
  110. KerbReferenceContextByLsaHandle(
  111. IN LSA_SEC_HANDLE ContextHandle,
  112. IN BOOLEAN RemoveFromList
  113. );
  114. NTSTATUS
  115. KerbCreateKernelModeContext(
  116. IN LSA_SEC_HANDLE ContextHandle,
  117. IN PSecBuffer MarshalledContext,
  118. OUT PKERB_KERNEL_CONTEXT * NewContext
  119. );
  120. #endif // __CTXTMGR_H__