Windows NT 4.0 source code leak
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.

313 lines
5.5 KiB

4 years ago
  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. PIRP
  45. MupBuildIoControlRequest (
  46. IN OUT PIRP Irp OPTIONAL,
  47. IN PFILE_OBJECT FileObject OPTIONAL,
  48. IN PVOID Context,
  49. IN UCHAR MajorFunction,
  50. IN ULONG IoControlCode,
  51. IN PVOID MainBuffer,
  52. IN ULONG InputBufferLength,
  53. IN PVOID AuxiliaryBuffer OPTIONAL,
  54. IN ULONG OutputBufferLength,
  55. IN PIO_COMPLETION_ROUTINE CompletionRoutine
  56. );
  57. NTSTATUS
  58. MupRerouteOpen (
  59. IN PFILE_OBJECT FileObject,
  60. IN PUNC_PROVIDER UncProvider
  61. );
  62. VOID
  63. MupCalculateTimeout(
  64. PLARGE_INTEGER Time
  65. );
  66. //
  67. // Block Management functions.
  68. //
  69. VOID
  70. MupInitializeVcb(
  71. IN PVCB Vcb
  72. );
  73. VOID
  74. MupDereferenceVcb(
  75. PVCB Vcb
  76. );
  77. PFCB
  78. MupCreateFcb(
  79. VOID
  80. );
  81. VOID
  82. MupDereferenceFcb(
  83. PFCB Fcb
  84. );
  85. VOID
  86. MupFreeFcb(
  87. PFCB Fcb
  88. );
  89. PCCB
  90. MupCreateCcb(
  91. VOID
  92. );
  93. VOID
  94. MupDereferenceCcb(
  95. PCCB Ccb
  96. );
  97. VOID
  98. MupFreeCcb(
  99. PCCB Ccb
  100. );
  101. PUNC_PROVIDER
  102. MupAllocateUncProvider(
  103. ULONG DataLength
  104. );
  105. VOID
  106. MupDereferenceUncProvider(
  107. PUNC_PROVIDER UncProvider
  108. );
  109. VOID
  110. MupCloseUncProvider(
  111. PUNC_PROVIDER UncProvider
  112. );
  113. PKNOWN_PREFIX
  114. MupAllocatePrefixEntry(
  115. ULONG DataLength
  116. );
  117. VOID
  118. MupDereferenceKnownPrefix(
  119. PKNOWN_PREFIX KnownPrefix
  120. );
  121. VOID
  122. MupFreeKnownPrefix(
  123. PKNOWN_PREFIX KnownPrefix
  124. );
  125. PMASTER_FORWARDED_IO_CONTEXT
  126. MupAllocateMasterIoContext(
  127. VOID
  128. );
  129. NTSTATUS
  130. MupDereferenceMasterIoContext(
  131. PMASTER_FORWARDED_IO_CONTEXT MasterContext,
  132. PNTSTATUS Status
  133. );
  134. VOID
  135. MupFreeMasterIoContext(
  136. PMASTER_FORWARDED_IO_CONTEXT MasterContext
  137. );
  138. PMASTER_QUERY_PATH_CONTEXT
  139. MupAllocateMasterQueryContext(
  140. VOID
  141. );
  142. NTSTATUS
  143. MupDereferenceMasterQueryContext(
  144. PMASTER_QUERY_PATH_CONTEXT MasterContext
  145. );
  146. VOID
  147. MupFreeMasterQueryContext(
  148. PMASTER_QUERY_PATH_CONTEXT MasterContext
  149. );
  150. //
  151. // File object support functions.
  152. //
  153. VOID
  154. MupSetFileObject (
  155. IN PFILE_OBJECT FileObject OPTIONAL,
  156. IN PVOID FsContext,
  157. IN PVOID FsContext2
  158. );
  159. BLOCK_TYPE
  160. MupDecodeFileObject (
  161. IN PFILE_OBJECT FileObject,
  162. OUT PVOID *FsContext,
  163. OUT PVOID *FsContext2
  164. );
  165. //
  166. // Registry Functions
  167. //
  168. VOID
  169. MupGetProviderInformation (
  170. VOID
  171. );
  172. PUNC_PROVIDER
  173. MupCheckForUnregisteredProvider(
  174. PUNICODE_STRING DeviceName
  175. );
  176. //
  177. // Acquiring and releasing MUP locks.
  178. //
  179. #define MupAcquireGlobalLock() ACQUIRE_LOCK( &MupGlobalLock )
  180. #define MupReleaseGlobalLock() RELEASE_LOCK( &MupGlobalLock )
  181. #define BlockType( Block ) ((PBLOCK_HEADER)(Block))->BlockType
  182. #define MupCompleteRequest( Irp, Status ) FsRtlCompleteRequest( Irp, Status )
  183. #define MupReferenceBlock( Block ) ++((PBLOCK_HEADER)(Block))->ReferenceCount
  184. #define MupVerifyBlock( Block, Type) \
  185. \
  186. if ( ((PBLOCK_HEADER)(Block))->BlockState != BlockStateActive \
  187. || \
  188. ((PBLOCK_HEADER)(Block))->BlockType != Type) { \
  189. \
  190. ExRaiseStatus( STATUS_INVALID_HANDLE ); \
  191. \
  192. }
  193. //
  194. // Memory allocation and free
  195. //
  196. #if !MUPDBG
  197. #define ALLOCATE_PAGED_POOL( size, type ) FsRtlAllocatePool( PagedPool, (size) )
  198. #define ALLOCATE_NONPAGED_POOL( size, type ) FsRtlAllocatePool( NonPagedPool, (size) )
  199. #define FREE_POOL( buffer ) ExFreePool( buffer )
  200. #else
  201. PVOID
  202. MupAllocatePoolDebug (
  203. IN POOL_TYPE PoolType,
  204. IN CLONG BlockSize,
  205. IN BLOCK_TYPE BlockType
  206. );
  207. VOID
  208. MupFreePoolDebug (
  209. IN PVOID P
  210. );
  211. #define ALLOCATE_PAGED_POOL( size, type ) MupAllocatePoolDebug( PagedPool, (size), (type) )
  212. #define ALLOCATE_NONPAGED_POOL( size, type ) MupAllocatePoolDebug( NonPagedPool, (size), (type) )
  213. #define FREE_POOL( buffer ) MupFreePoolDebug( buffer )
  214. #endif
  215. //
  216. // The following macros are used to establish the semantics needed
  217. // to do a return from within a try-finally clause. As a rule every
  218. // try clause must end with a label call try_exit. For example,
  219. //
  220. // try {
  221. // :
  222. // :
  223. //
  224. // try_exit: NOTHING;
  225. // } finally {
  226. //
  227. // :
  228. // :
  229. // }
  230. //
  231. // Every return statement executed inside of a try clause should use the
  232. // try_return macro. If the compiler fully supports the try-finally construct
  233. // then the macro should be
  234. //
  235. // #define try_return(S) { return(S); }
  236. //
  237. // If the compiler does not support the try-finally construct then the macro
  238. // should be
  239. //
  240. // #define try_return(S) { S; goto try_exit; }
  241. //
  242. #define try_return(S) { S; goto try_exit; }
  243. //
  244. // General purpose
  245. //
  246. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  247. #endif // _MUPFUNC_