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.

146 lines
3.8 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. #define KerbGetContextHandle(_Context_) ((ULONG_PTR)(_Context_))
  32. //
  33. // Context flags - these are attributes of a context and are stored in
  34. // the ContextAttributes field of a KERB_KERNEL_CONTEXT.
  35. //
  36. #define KERB_CONTEXT_MAPPED 0x1
  37. #define KERB_CONTEXT_OUTBOUND 0x2
  38. #define KERB_CONTEXT_INBOUND 0x4
  39. #define KERB_CONTEXT_USER_TO_USER 0x10
  40. #define KERB_CONTEXT_IMPORTED 0x80
  41. #define KERB_CONTEXT_EXPORTED 0x100
  42. //
  43. // NOTICE: The logon session resource, credential resource, and context
  44. // resource must all be acquired carefully to prevent deadlock. They
  45. // can only be acquired in this order:
  46. //
  47. // 1. Logon Sessions
  48. // 2. Credentials
  49. // 3. Contexts
  50. //
  51. #define KerbWriteLockContexts() \
  52. { \
  53. if ( KerbPoolType == PagedPool ) \
  54. { \
  55. DebugLog((DEB_TRACE_LOCKS,"Write locking Contexts\n")); \
  56. KeEnterCriticalRegion(); \
  57. ExAcquireResourceExclusiveLite(&KerbContextResource,TRUE); \
  58. } \
  59. }
  60. #define KerbReadLockContexts() \
  61. { \
  62. if ( KerbPoolType == PagedPool ) \
  63. { \
  64. DebugLog((DEB_TRACE_LOCKS,"Read locking Contexts\n")); \
  65. KeEnterCriticalRegion(); \
  66. ExAcquireSharedWaitForExclusive(&KerbContextResource, TRUE); \
  67. } \
  68. }
  69. #define KerbUnlockContexts() \
  70. { \
  71. if ( KerbPoolType == PagedPool ) \
  72. { \
  73. DebugLog((DEB_TRACE_LOCKS,"Unlocking Contexts\n")); \
  74. ExReleaseResourceLite(&KerbContextResource); \
  75. KeLeaveCriticalRegion(); \
  76. } \
  77. }
  78. NTSTATUS
  79. KerbInitContextList(
  80. VOID
  81. );
  82. VOID
  83. KerbFreeContextList(
  84. VOID
  85. );
  86. NTSTATUS
  87. KerbAllocateContext(
  88. PKERB_KERNEL_CONTEXT * NewContext
  89. );
  90. NTSTATUS
  91. KerbInsertContext(
  92. IN PKERB_KERNEL_CONTEXT Context
  93. );
  94. PKERB_KERNEL_CONTEXT
  95. KerbReferenceContext(
  96. IN LSA_SEC_HANDLE ContextHandle,
  97. IN BOOLEAN RemoveFromList
  98. );
  99. VOID
  100. KerbDereferenceContext(
  101. IN PKERB_KERNEL_CONTEXT Context
  102. );
  103. VOID
  104. KerbReferenceContextByPointer(
  105. IN PKERB_KERNEL_CONTEXT Context,
  106. IN BOOLEAN RemoveFromList
  107. );
  108. PKERB_KERNEL_CONTEXT
  109. KerbReferenceContextByLsaHandle(
  110. IN LSA_SEC_HANDLE ContextHandle,
  111. IN BOOLEAN RemoveFromList
  112. );
  113. NTSTATUS
  114. KerbCreateKernelModeContext(
  115. IN LSA_SEC_HANDLE ContextHandle,
  116. IN PSecBuffer MarshalledContext,
  117. OUT PKERB_KERNEL_CONTEXT * NewContext
  118. );
  119. #endif // __CTXTMGR_H__