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.

329 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. mupfunc.h
  5. Abstract:
  6. This module defines all the function prototypes and macros for the MUP.
  7. Author:
  8. Manny Weiser (mannyw) 17-Dec-1991
  9. Revision History:
  10. --*/
  11. #ifndef _MUPFUNC_
  12. #define _MUPFUNC_
  13. NTSTATUS
  14. MupCreate (
  15. IN PMUP_DEVICE_OBJECT MupDeviceObject,
  16. IN PIRP Irp
  17. );
  18. NTSTATUS
  19. MupFsControl (
  20. IN PMUP_DEVICE_OBJECT MupDeviceObject,
  21. IN PIRP Irp
  22. );
  23. NTSTATUS
  24. MupCleanup (
  25. IN PMUP_DEVICE_OBJECT MupDeviceObject,
  26. IN PIRP Irp
  27. );
  28. NTSTATUS
  29. MupClose (
  30. IN PMUP_DEVICE_OBJECT MupDeviceObject,
  31. IN PIRP Irp
  32. );
  33. NTSTATUS
  34. MupForwardIoRequest (
  35. IN PMUP_DEVICE_OBJECT MupDeviceObject,
  36. IN PIRP Irp
  37. );
  38. //
  39. // Internal support functions
  40. //
  41. NTSTATUS
  42. MupInitializeData(
  43. );
  44. VOID
  45. MupUninitializeData(
  46. VOID
  47. );
  48. PIRP
  49. MupBuildIoControlRequest (
  50. IN OUT PIRP Irp OPTIONAL,
  51. IN PFILE_OBJECT FileObject OPTIONAL,
  52. IN PVOID Context,
  53. IN UCHAR MajorFunction,
  54. IN ULONG IoControlCode,
  55. IN PVOID MainBuffer,
  56. IN ULONG InputBufferLength,
  57. IN PVOID AuxiliaryBuffer OPTIONAL,
  58. IN ULONG OutputBufferLength,
  59. IN PIO_COMPLETION_ROUTINE CompletionRoutine
  60. );
  61. NTSTATUS
  62. MupRerouteOpen (
  63. IN PFILE_OBJECT FileObject,
  64. IN PUNC_PROVIDER UncProvider
  65. );
  66. VOID
  67. MupCalculateTimeout(
  68. PLARGE_INTEGER Time
  69. );
  70. //
  71. // Block Management functions.
  72. //
  73. VOID
  74. MupInitializeVcb(
  75. IN PVCB Vcb
  76. );
  77. VOID
  78. MupDereferenceVcb(
  79. PVCB Vcb
  80. );
  81. PFCB
  82. MupCreateFcb(
  83. VOID
  84. );
  85. VOID
  86. MupDereferenceFcb(
  87. PFCB Fcb
  88. );
  89. VOID
  90. MupFreeFcb(
  91. PFCB Fcb
  92. );
  93. PCCB
  94. MupCreateCcb(
  95. VOID
  96. );
  97. VOID
  98. MupDereferenceCcb(
  99. PCCB Ccb
  100. );
  101. VOID
  102. MupFreeCcb(
  103. PCCB Ccb
  104. );
  105. PUNC_PROVIDER
  106. MupAllocateUncProvider(
  107. ULONG DataLength
  108. );
  109. VOID
  110. MupDereferenceUncProvider(
  111. PUNC_PROVIDER UncProvider
  112. );
  113. VOID
  114. MupCloseUncProvider(
  115. PUNC_PROVIDER UncProvider
  116. );
  117. PKNOWN_PREFIX
  118. MupAllocatePrefixEntry(
  119. ULONG DataLength
  120. );
  121. VOID
  122. MupDereferenceKnownPrefix(
  123. PKNOWN_PREFIX KnownPrefix
  124. );
  125. VOID
  126. MupFreeKnownPrefix(
  127. PKNOWN_PREFIX KnownPrefix
  128. );
  129. PMASTER_FORWARDED_IO_CONTEXT
  130. MupAllocateMasterIoContext(
  131. VOID
  132. );
  133. NTSTATUS
  134. MupDereferenceMasterIoContext(
  135. PMASTER_FORWARDED_IO_CONTEXT MasterContext,
  136. PNTSTATUS Status
  137. );
  138. VOID
  139. MupFreeMasterIoContext(
  140. PMASTER_FORWARDED_IO_CONTEXT MasterContext
  141. );
  142. PMASTER_QUERY_PATH_CONTEXT
  143. MupAllocateMasterQueryContext(
  144. VOID
  145. );
  146. NTSTATUS
  147. MupDereferenceMasterQueryContext(
  148. PMASTER_QUERY_PATH_CONTEXT MasterContext
  149. );
  150. VOID
  151. MupFreeMasterQueryContext(
  152. PMASTER_QUERY_PATH_CONTEXT MasterContext
  153. );
  154. //
  155. // File object support functions.
  156. //
  157. VOID
  158. MupSetFileObject (
  159. IN PFILE_OBJECT FileObject OPTIONAL,
  160. IN PVOID FsContext,
  161. IN PVOID FsContext2
  162. );
  163. BLOCK_TYPE
  164. MupDecodeFileObject (
  165. IN PFILE_OBJECT FileObject,
  166. OUT PVOID *FsContext,
  167. OUT PVOID *FsContext2
  168. );
  169. //
  170. // Registry Functions
  171. //
  172. VOID
  173. MupGetProviderInformation (
  174. VOID
  175. );
  176. PUNC_PROVIDER
  177. MupCheckForUnregisteredProvider(
  178. PUNICODE_STRING DeviceName
  179. );
  180. VOID
  181. MupRemoveKnownPrefixEntry(
  182. PKNOWN_PREFIX KnownPrefix
  183. );
  184. //
  185. // Acquiring and releasing MUP locks.
  186. //
  187. #define MupAcquireGlobalLock() ACQUIRE_LOCK( &MupGlobalLock )
  188. #define MupReleaseGlobalLock() RELEASE_LOCK( &MupGlobalLock )
  189. #define BlockType( Block ) ((PBLOCK_HEADER)(Block))->BlockType
  190. #define MupCompleteRequest( Irp, Status ) FsRtlCompleteRequest( Irp, Status )
  191. #define MupReferenceBlock( Block ) ++((PBLOCK_HEADER)(Block))->ReferenceCount
  192. #define MupVerifyBlock( Block, Type) \
  193. \
  194. if ( ((PBLOCK_HEADER)(Block))->BlockState != BlockStateActive \
  195. || \
  196. ((PBLOCK_HEADER)(Block))->BlockType != Type) { \
  197. \
  198. ExRaiseStatus( STATUS_INVALID_HANDLE ); \
  199. \
  200. }
  201. //
  202. // Memory allocation and free
  203. //
  204. #if !MUPDBG
  205. #define ALLOCATE_PAGED_POOL( size, type ) FsRtlAllocatePoolWithTag( PagedPool, (size), ' puM' )
  206. #define ALLOCATE_NONPAGED_POOL( size, type ) FsRtlAllocatePoolWithTag( NonPagedPool, (size), ' puM' )
  207. #define FREE_POOL( buffer ) ExFreePool( buffer )
  208. #else
  209. PVOID
  210. MupAllocatePoolDebug (
  211. IN POOL_TYPE PoolType,
  212. IN CLONG BlockSize,
  213. IN BLOCK_TYPE BlockType
  214. );
  215. VOID
  216. MupFreePoolDebug (
  217. IN PVOID P
  218. );
  219. #define ALLOCATE_PAGED_POOL( size, type ) MupAllocatePoolDebug( PagedPool, (size), (type) )
  220. #define ALLOCATE_NONPAGED_POOL( size, type ) MupAllocatePoolDebug( NonPagedPool, (size), (type) )
  221. #define FREE_POOL( buffer ) MupFreePoolDebug( buffer )
  222. #endif
  223. //
  224. // The following macros are used to establish the semantics needed
  225. // to do a return from within a try-finally clause. As a rule every
  226. // try clause must end with a label call try_exit. For example,
  227. //
  228. // try {
  229. // :
  230. // :
  231. //
  232. // try_exit: NOTHING;
  233. // } finally {
  234. //
  235. // :
  236. // :
  237. // }
  238. //
  239. // Every return statement executed inside of a try clause should use the
  240. // try_return macro. If the compiler fully supports the try-finally construct
  241. // then the macro should be
  242. //
  243. // #define try_return(S) { return(S); }
  244. //
  245. // If the compiler does not support the try-finally construct then the macro
  246. // should be
  247. //
  248. // #define try_return(S) { S; goto try_exit; }
  249. //
  250. #define try_return(S) { S; goto try_exit; }
  251. //
  252. // General purpose
  253. //
  254. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  255. //
  256. // Terminal Server Macro.
  257. //
  258. #define IsTerminalServer() (BOOLEAN)(SharedUserData->SuiteMask & (1 << TerminalServer))
  259. #endif // _MUPFUNC_