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.

297 lines
8.3 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. nt5csc.h
  5. Abstract:
  6. The global include file for nt5csc within the nt5csc library
  7. Author:
  8. Joe Linn (Joelinn) - Created 5-may-97
  9. Revision History:
  10. --*/
  11. #ifndef _NT5CSC_H_
  12. #define _NT5CSC_H_
  13. //this include finds ntcsc.h from rdr2\inc
  14. #include "..\csc\record.mgr\ntcsc.h"
  15. #define CSC_AGENT_NOTIFIED (0x11111111)
  16. #define CSC_AGENT_NOT_NOTIFIED (0x22222222)
  17. extern LONG CscNetPresent;
  18. extern LONG CscAgentNotifiedOfNetStatusChange;
  19. extern LONG CscAgentNotifiedOfFullCache;
  20. extern VOID
  21. CscNotifyAgentOfNetStatusChangeIfRequired(BOOLEAN fInvokeAutodial);
  22. // this event and mutex is used for synchronizing the transitioning of a
  23. // server entry from connected to disconnected mode
  24. extern KEVENT CscServerEntryTransitioningEvent;
  25. extern FAST_MUTEX CscServerEntryTransitioningMutex;
  26. extern FAST_MUTEX MRxSmbCscShadowReadWriteMutex;
  27. //shared routines
  28. INLINE
  29. BOOLEAN
  30. CscIsDfsOpen(
  31. PRX_CONTEXT RxContext)
  32. {
  33. ASSERT(RxContext->MajorFunction == IRP_MJ_CREATE);
  34. return (RxContext->Create.NtCreateParameters.DfsContext != NULL);
  35. }
  36. PDFS_NAME_CONTEXT
  37. CscIsValidDfsNameContext(
  38. PVOID pFsContext);
  39. NTSTATUS
  40. CscDfsParseDfsPath(
  41. PUNICODE_STRING pDfsPath,
  42. PUNICODE_STRING pServerName,
  43. PUNICODE_STRING pSharePath,
  44. PUNICODE_STRING pFilePathRelativeToShare);
  45. NTSTATUS
  46. CscGrabPathFromDfs(
  47. PFILE_OBJECT pFileObject,
  48. PDFS_NAME_CONTEXT pDfsNameContext);
  49. NTSTATUS
  50. MRxSmbCscObtainShareHandles (
  51. IN PUNICODE_STRING ShareName,
  52. IN BOOLEAN DisconnectedMode,
  53. IN BOOLEAN CopyChunkOpen,
  54. IN OUT PSMBCEDB_NET_ROOT_ENTRY pNetRootEntry
  55. );
  56. //acquire/release stuff
  57. // Another view of the minirdr context in the RxContext is as
  58. // links for Csc Synchronization. This is used both for read/write
  59. // synchronization and open synchornization when surrogate opens are
  60. // involved
  61. typedef struct _MRXSMBCSC_SYNC_RX_CONTEXT {
  62. ULONG Dummy; //this is the cancel routine....it must not be filled in
  63. USHORT TypeOfAcquire;
  64. UCHAR FcbLockWasDropped;
  65. LIST_ENTRY CscSyncLinks;
  66. } MRXSMBCSC_SYNC_RX_CONTEXT, *PMRXSMBCSC_SYNC_RX_CONTEXT;
  67. #define MRxSmbGetMinirdrContextForCscSync(pRxContext) \
  68. ((PMRXSMBCSC_SYNC_RX_CONTEXT)(&(pRxContext)->MRxContext[0]))
  69. #define Shared_SmbFcbAcquire SmbFcb_HeldShared
  70. #define Exclusive_SmbFcbAcquire SmbFcb_HeldExclusive
  71. #define DroppingFcbLock_SmbFcbAcquire 0x80000000
  72. #define FailImmediately_SmbFcbAcquire 0x40000000
  73. typedef struct _SID_CONTEXT_ {
  74. PSID pSid;
  75. PVOID Context;
  76. } SID_CONTEXT, *PSID_CONTEXT;
  77. NTSTATUS
  78. MRxSmbCscAcquireSmbFcb (
  79. IN OUT PRX_CONTEXT RxContext,
  80. IN ULONG TypeOfAcquirePlusFlags,
  81. OUT SMBFCB_HOLDING_STATE *SmbFcbHoldingState
  82. );
  83. VOID
  84. MRxSmbCscReleaseSmbFcb (
  85. IN OUT PRX_CONTEXT RxContext,
  86. IN SMBFCB_HOLDING_STATE *SmbFcbHoldingState
  87. );
  88. VOID
  89. MRxSmbCSCResumeAllOutstandingOperations(
  90. PSMBCEDB_SERVER_ENTRY pServerEntry
  91. );
  92. // Control flag definitions for creating shadow handles
  93. #define CREATESHADOW_NO_SPECIAL_CONTROLS 0x0000
  94. #define CREATESHADOW_CONTROL_NOCREATE 0x0001
  95. #define CREATESHADOW_CONTROL_NOREVERSELOOKUP 0x0002
  96. #define CREATESHADOW_CONTROL_NOCREATELEAF 0x0004
  97. #define CREATESHADOW_CONTROL_NOCREATENONLEAF 0x0008
  98. #define CREATESHADOW_CONTROL_SPARSECREATE 0x0010
  99. #define CREATESHADOW_CONTROL_FILE_WITH_HEURISTIC 0x0020 //.exe or .dll
  100. #define CREATESHADOW_CONTROL_FAIL_IF_MARKED_FOR_DELETION 0x0040
  101. #define CREATESHADOW_CONTROL_DO_SHARE_ACCESS_CHECK 0x0080
  102. #define CREATESHADOW_CONTROL_STRIP_SHARE_NAME 0x0100
  103. #ifdef DEBUG
  104. //Hook dbgprint interface
  105. #define HookKdPrint(__bit,__x) {\
  106. if (((HOOK_KDP_##__bit)==0) || FlagOn(HookKdPrintVector,(HOOK_KDP_##__bit))) {\
  107. KdPrint (__x);\
  108. }\
  109. }
  110. #define HOOK_KDP_ALWAYS 0x00000000
  111. #define HOOK_KDP_BADERRORS 0x00000001
  112. #define HOOK_KDP_NAME 0x00000002
  113. #define HOOK_KDP_NET 0x00000004
  114. #define HOOK_KDP_RW 0x00000008
  115. #define HOOK_KDP_TRANSITION 0x00000010
  116. #define HOOK_KDP_AGENT 0x00000020
  117. #define HOOK_KDP_IOCTL 0x00000040
  118. #define HOOK_KDP_BITCOPY 0x00000080
  119. #define HOOK_KDP_GOOD_DEFAULT (HOOK_KDP_BADERRORS \
  120. | 0)
  121. extern ULONG HookKdPrintVector;
  122. extern ULONG HookKdPrintVectorDef;
  123. #else
  124. #define HookKdPrint(__bit,__x) {NOTHING;}
  125. #endif
  126. extern NTSTATUS
  127. MRxSmbCscCreateShadowFromPath (
  128. IN PUNICODE_STRING AlreadyPrefixedName,
  129. IN PCSC_ROOT_INFO pCscRootInfo,
  130. OUT _WIN32_FIND_DATA *Find32,
  131. OUT PBOOLEAN Created OPTIONAL,
  132. IN ULONG Controls,
  133. IN OUT PMINIMAL_CSC_SMBFCB MinimalCscSmbFcb,
  134. IN OUT PRX_CONTEXT RxContext,
  135. IN BOOLEAN fDisconnected,
  136. OUT ULONG *pulInheritedHintFlags
  137. );
  138. #ifndef MRXSMB_BUILD_FOR_CSC_DCON
  139. #define MRxSmbCscWriteDisconnected(__RXCONTEXT) (STATUS_SUCCESS)
  140. #else
  141. NTSTATUS
  142. MRxSmbCscWriteDisconnected (
  143. IN OUT PRX_CONTEXT RxContext
  144. );
  145. #endif
  146. //NTSTATUS
  147. //MRxSmbCscSpecialShadowWriteForPagingIo (
  148. // IN OUT PRX_CONTEXT RxContext,
  149. // IN ULONG ShadowFileLength,
  150. // OUT PULONG LengthActuallyWritten
  151. // );
  152. #define CSC_REPORT_CHANGE(pNetRootEntry, pFcb, pSmbFcb, Filter, Action) \
  153. (pNetRootEntry)->NetRoot.pNotifySync, \
  154. &((pNetRootEntry)->NetRoot.DirNotifyList) \
  155. (pFcb)->pPrivateAlreaydPrefixedName.Buffer, \
  156. (USHORT)(GET_ALREADY_PREFIXED_NAME(pFcb)->PrivateAlreaydPrefixedName.Length - \
  157. (pSmbFcb)->MinimalCscSmbFcb.LastComponentLength), \
  158. NULL, \
  159. NULL, \
  160. (ULONG)Filter, \
  161. (ULONG)Action, \
  162. NULL)
  163. #ifdef RX_PRIVATE_BUILD
  164. #if 1
  165. #ifdef RDBSSTRACE
  166. extern ULONG MRxSmbCscDbgPrintF;
  167. #undef RxDbgTrace
  168. #define RxDbgTrace(a,b,__d__) { if(MRxSmbCscDbgPrintF){DbgPrint __d__;}}
  169. #undef RxDbgTraceUnIndent
  170. #define RxDbgTraceUnIndent(a,b) {NOTHING;}
  171. #endif //#ifdef RDBSSTRACE
  172. #endif //if 1
  173. #endif //ifdef RX_PRIVATE_BUILD
  174. //CODE.IMPROVEMENT if we added another field to the large_integer union then we'd
  175. // eliminate these 2 macros
  176. #define COPY_LARGEINTEGER_TO_STRUCTFILETIME(dest,src) {\
  177. (dest).dwLowDateTime = (src).LowPart; \
  178. (dest).dwHighDateTime = (src).HighPart; \
  179. }
  180. #define COPY_STRUCTFILETIME_TO_LARGEINTEGER(dest,src) {\
  181. (dest).LowPart = (src).dwLowDateTime; \
  182. (dest).HighPart = (src).dwHighDateTime; \
  183. }
  184. NTSTATUS
  185. CscDfsDoDfsNameMapping(
  186. PUNICODE_STRING pDfsPrefix,
  187. PUNICODE_STRING pActualPrefix,
  188. PUNICODE_STRING pNameToReverseMap,
  189. BOOL fResolvedNameToDFSName,
  190. PUNICODE_STRING pResult);
  191. NTSTATUS
  192. CscDfsObtainReverseMapping(
  193. PUNICODE_STRING pDfsPath,
  194. PUNICODE_STRING pResolvedPath,
  195. PUNICODE_STRING pReversemappingFrom,
  196. PUNICODE_STRING pReverseMappingTo);
  197. NTSTATUS
  198. CscDfsStripLeadingServerShare(
  199. IN PUNICODE_STRING pDfsRootPath
  200. );
  201. BOOLEAN
  202. MRxSmbCSCIsDisconnectedOpen(
  203. PMRX_FCB pFcb,
  204. PMRX_SMB_SRV_OPEN smbSrvOpen
  205. );
  206. BOOL
  207. CloseOpenFiles(
  208. HSHARE hShare,
  209. PUNICODE_STRING pServerName,
  210. int lenSkip
  211. );
  212. VOID
  213. MRxSmbCSCObtainRightsForUserOnFile(
  214. IN PRX_CONTEXT pRxContext,
  215. HSHADOW hDir,
  216. HSHADOW hShadow,
  217. OUT ACCESS_MASK *pMaximalAccessRights,
  218. OUT ACCESS_MASK *pGuestMaximalAccessRights
  219. );
  220. NTSTATUS
  221. CscRetrieveSid(
  222. PRX_CONTEXT pRxContext,
  223. PSID_CONTEXT pSidContext
  224. );
  225. VOID
  226. CscDiscardSid(
  227. PSID_CONTEXT pSidContext
  228. );
  229. #endif // _NT5CSC_H_