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.

325 lines
6.5 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: dfsprocs.h
  4. //
  5. // Contents:
  6. //
  7. // This module defines all of the globally used procedures in the Dfs server
  8. // driver
  9. //
  10. // Functions:
  11. //
  12. //-----------------------------------------------------------------------------
  13. #ifndef _DFSPROCS_
  14. #define _DFSPROCS_
  15. #include <ntos.h>
  16. #include <string.h>
  17. #include <fsrtl.h>
  18. #include <zwapi.h>
  19. #include <tdi.h>
  20. #include <ntddnfs.h> // For communicating with
  21. // the SMB Rdr
  22. #include <ntddmup.h> // For UNC registration
  23. #include <winnetwk.h> // For NETRESOURCE def'n
  24. #include <dfsfsctl.h> // Dfs FsControl Codes.
  25. #include "dfserr.h"
  26. #include "dfsstr.h"
  27. #include "nodetype.h"
  28. #include "dfsmrshl.h"
  29. #include "dfsrtl.h"
  30. #include "pkt.h"
  31. #include "dfslpc.h"
  32. #include "dfsstruc.h"
  33. #include "dfsdata.h"
  34. #include "localvol.h"
  35. #include "log.h"
  36. #include "lvolinfo.h"
  37. #include "fcbsup.h"
  38. #include "reset.h"
  39. #ifndef i386
  40. #define DFS_UNALIGNED UNALIGNED
  41. #else
  42. #define DFS_UNALIGNED
  43. #endif // i386
  44. //
  45. // The FSD Level dispatch routines. These routines are called by the
  46. // I/O system via the dispatch table in the Driver Object.
  47. //
  48. NTSTATUS
  49. DfsFsdCleanup ( // implemented in Close.c
  50. IN PDEVICE_OBJECT DeviceObject,
  51. IN PIRP Irp
  52. );
  53. NTSTATUS
  54. DfsFsdClose ( // implemented in Close.c
  55. IN PDEVICE_OBJECT DeviceObject,
  56. IN PIRP Irp
  57. );
  58. NTSTATUS
  59. DfsFsdCreate ( // implemented in Create.c
  60. IN PDEVICE_OBJECT DeviceObject,
  61. IN PIRP Irp
  62. );
  63. NTSTATUS
  64. DfsFsdFileSystemControl ( // implemented in Fsctrl.c
  65. IN PDEVICE_OBJECT DeviceObject,
  66. IN PIRP Irp
  67. );
  68. NTSTATUS
  69. DfsFsdSetInformation ( // implemented in Fileinfo.c
  70. IN PDEVICE_OBJECT DeviceObject,
  71. IN PIRP Irp
  72. );
  73. //
  74. // Miscellaneous support routines
  75. //
  76. NTSTATUS
  77. DfspInitSecDesc(
  78. PDFS_PKT pkt);
  79. NTSTATUS
  80. DfsInitializeLogicalRoot (
  81. IN LPCWSTR Name,
  82. IN PUNICODE_STRING Prefix OPTIONAL,
  83. IN USHORT VcbFlags OPTIONAL
  84. );
  85. NTSTATUS
  86. DfsInsertProvider(
  87. IN PUNICODE_STRING pustrProviderName,
  88. IN ULONG fProvCapability,
  89. IN ULONG eProviderId);
  90. NTSTATUS
  91. DfsDeleteLogicalRoot (
  92. IN PWSTR Name,
  93. IN BOOLEAN fForce
  94. );
  95. NTSTATUS
  96. DfspLogRootNameToPath(
  97. LPCWSTR Name,
  98. PUNICODE_STRING RootName
  99. );
  100. BOOLEAN
  101. DfsLogicalRootExists(
  102. PWSTR pwszName
  103. );
  104. PDFS_LOCAL_VOLUME_CONFIG
  105. DfsNetInfoToConfigInfo(
  106. ULONG EntryType,
  107. ULONG ServiceType,
  108. LPWSTR pwszStgId,
  109. LPWSTR pwszShareName,
  110. GUID *pUid,
  111. LPWSTR pwszEntryPrefix,
  112. LPWSTR pwszShortPrefix,
  113. LPNET_DFS_ENTRY_ID_CONTAINER NetInfo);
  114. NTSTATUS
  115. DfsCreateConnection(
  116. IN PDFS_SERVICE pService,
  117. IN PPROVIDER_DEF pProvider,
  118. OUT PHANDLE handle
  119. );
  120. NTSTATUS
  121. DfsCloseConnection(
  122. IN PDFS_SERVICE pService
  123. );
  124. BOOLEAN
  125. DfsConcatenateFilePath (
  126. IN PUNICODE_STRING Dest,
  127. IN PWSTR RemainingPath,
  128. IN USHORT Length
  129. );
  130. VOID
  131. DfspGetMaxReferrals (
  132. VOID
  133. );
  134. //
  135. // This macro returns TRUE if a flag in a set of flags is on and FALSE
  136. // otherwise
  137. //
  138. #ifdef FlagOn
  139. #undef FlagOn
  140. #endif
  141. #define FlagOn(Flags,SingleFlag) ( \
  142. (BOOLEAN)(((Flags) & (SingleFlag)) != 0 ? TRUE : FALSE) \
  143. )
  144. #define SetFlag(Flags,SingleFlag) { \
  145. (Flags) |= (SingleFlag); \
  146. }
  147. #define ClearFlag(Flags,SingleFlag) { \
  148. (Flags) &= ~(SingleFlag); \
  149. }
  150. VOID GuidToString(
  151. IN GUID *pGuid,
  152. OUT PWSTR pwszGuid);
  153. VOID StringToGuid(
  154. IN PWSTR pwszGuid,
  155. OUT GUID *pGuid);
  156. //
  157. // The following macro is used to determine if an FSD thread can block
  158. // for I/O or wait for a resource. It returns TRUE if the thread can
  159. // block and FALSE otherwise. This attribute can then be used to call
  160. // the FSD & FSP common work routine with the proper wait value.
  161. //
  162. #define CanFsdWait(IRP) ((BOOLEAN)( \
  163. IoIsOperationSynchronous(IRP) || \
  164. DfsData.OurProcess == PsGetCurrentProcess()) \
  165. )
  166. //
  167. // The following macro is used by the FSP and FSD routines to complete
  168. // an IRP.
  169. //
  170. VOID
  171. DfsCompleteRequest_Real (
  172. IN PIRP Irp,
  173. IN NTSTATUS Status
  174. );
  175. #define DfsCompleteRequest(IRP,STATUS) { \
  176. DfsCompleteRequest_Real(IRP,STATUS); \
  177. }
  178. //
  179. // The following two macros are used by the Fsd/Fsp exception handlers to
  180. // process an exception. The first macro is the exception filter used in
  181. // the Fsd/Fsp to decide if an exception should be handled at this level.
  182. // The second macro decides if the exception is to be finished off by
  183. // completing the IRP, and cleaning up the Irp Context, or if we should
  184. // bugcheck. Exception values such as STATUS_FILE_INVALID (raised by
  185. // VerfySup.c) cause us to complete the Irp and cleanup, while exceptions
  186. // such as accvio cause us to bugcheck.
  187. //
  188. // The basic structure for fsd/fsp exception handling is as follows:
  189. //
  190. // DfsFsdXxx(...)
  191. // {
  192. // try {
  193. //
  194. // ...
  195. //
  196. // } except(DfsExceptionFilter("Xxx\n")) {
  197. //
  198. // DfsProcessException( Irp, &Status );
  199. // }
  200. //
  201. // Return Status;
  202. // }
  203. //
  204. // LONG
  205. // DfsExceptionFilter (
  206. // IN PSZ String
  207. // );
  208. //
  209. // VOID
  210. // DfsProcessException (
  211. // IN PIRP Irp,
  212. // IN PNTSTATUS ExceptionCode
  213. // );
  214. //
  215. LONG
  216. DfsExceptionFilter (
  217. IN NTSTATUS ExceptionCode,
  218. IN PEXCEPTION_POINTERS ExceptionPointer
  219. );
  220. NTSTATUS
  221. DfsProcessException (
  222. IN PIRP Irp,
  223. IN NTSTATUS ExceptionCode
  224. );
  225. //
  226. // VOID
  227. // DfsRaiseStatus (
  228. // IN NT_STATUS Status
  229. // );
  230. //
  231. //
  232. #define DfsRaiseStatus(STATUS) { \
  233. ExRaiseStatus( (STATUS) ); \
  234. BugCheck( "DfsRaiseStatus " #STATUS ); \
  235. }
  236. //
  237. // The following macros are used to establish the semantics needed
  238. // to do a return from within a try-finally clause. As a rule every
  239. // try clause must end with a label call try_exit. For example,
  240. //
  241. // try {
  242. // :
  243. // :
  244. //
  245. // try_exit: NOTHING;
  246. // } finally {
  247. //
  248. // :
  249. // :
  250. // }
  251. //
  252. // Every return statement executed inside of a try clause should use the
  253. // try_return macro. If the compiler fully supports the try-finally construct
  254. // then the macro should be
  255. //
  256. // #define try_return(S) { return(S); }
  257. //
  258. // If the compiler does not support the try-finally construct then the macro
  259. // should be
  260. //
  261. // #define try_return(S) { S; goto try_exit; }
  262. //
  263. #define try_return(S) { S; goto try_exit; }
  264. #endif // _DFSPROCS_