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.

294 lines
8.3 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ntumrefl.h
  5. Abstract:
  6. This module defines the types and functions which make up the reflector
  7. library. These functions are used by the miniredirs to reflect calls upto
  8. the user mode.
  9. Author:
  10. Andy Herron (andyhe)
  11. --*/
  12. #ifndef _NTUMREFL_H
  13. #define _NTUMREFL_H
  14. //
  15. // These two structures are opaque to callers of the reflector library but
  16. // we'll define them here to make the compiler validate the types sent in.
  17. //
  18. typedef struct _UMRX_USERMODE_REFLECT_BLOCK *PUMRX_USERMODE_REFLECT_BLOCK;
  19. typedef struct _UMRX_USERMODE_WORKER_INSTANCE *PUMRX_USERMODE_WORKER_INSTANCE;
  20. //
  21. // These structures and function prototypes are for the user mode reflector.
  22. //
  23. #define UMREFLECTOR_CURRENT_VERSION 1
  24. //
  25. // This structure will be exposed to both user and kernel mode components.
  26. //
  27. #define UMRX_WORKITEM_IMPERSONATING 0X00000001
  28. typedef struct _UMRX_USERMODE_WORKITEM_HEADER {
  29. //
  30. // The kernel mode component stores the context in here.
  31. //
  32. PVOID Context;
  33. //
  34. // The kernel mode context uses the serial number to keep track of the
  35. // number of requests.
  36. //
  37. ULONG SerialNumber;
  38. //
  39. // This allows the kernel mode component of the reflector library to track
  40. // request to response. If this is zero, then no response is present in the
  41. // workitem.
  42. //
  43. USHORT WorkItemMID;
  44. //
  45. // Length of the workitem.
  46. //
  47. ULONG WorkItemLength;
  48. //
  49. // Flags describing the state of the request.
  50. //
  51. ULONG Flags;
  52. BOOL callWorkItemCleanup;
  53. union {
  54. IO_STATUS_BLOCK IoStatus;
  55. IO_STATUS_BLOCK;
  56. };
  57. } UMRX_USERMODE_WORKITEM_HEADER, *PUMRX_USERMODE_WORKITEM_HEADER;
  58. //
  59. // The structure that is sent down to the usermode when starting the
  60. // DAV MiniRedir.
  61. //
  62. typedef struct _DAV_USERMODE_DATA {
  63. //
  64. // The ProcessId of the svchost.exe process that is loading the webclnt.dll
  65. //
  66. ULONG ProcessId;
  67. //
  68. // The WinInet's Cache Path.
  69. //
  70. WCHAR WinInetCachePath[MAX_PATH];
  71. } DAV_USERMODE_DATA, *PDAV_USERMODE_DATA;
  72. //
  73. // This routine registers the user mode process with the kernel mode component.
  74. // The DriverDeviceName must be a valid name of the form L"\\Device\\foobar"
  75. // where foobar is the device name registered with RxRegisterMinirdr. The
  76. // Reflector is returned by the call and points to an opaque structure that
  77. // should be passed to subsequent calls. This structure gets initialized during
  78. // this call. The return value is a Win32 error code. STATUS_SUCCESS is
  79. // returned on success.
  80. //
  81. ULONG
  82. UMReflectorRegister (
  83. PWCHAR DriverDeviceName,
  84. ULONG ReflectorVersion,
  85. PUMRX_USERMODE_REFLECT_BLOCK *Reflector
  86. );
  87. //
  88. // This will close down the associated user mode reflector instance. If any user
  89. // mode threads are waiting for requests, they'll return immediately. This call
  90. // will not return until all threads are closed down and all associated
  91. // structures are freed. A user application should not use the Reflector after
  92. // this call has been started except to complete work on a request that is
  93. // pending.
  94. //
  95. ULONG
  96. UMReflectorUnregister(
  97. PUMRX_USERMODE_REFLECT_BLOCK Reflector
  98. );
  99. //
  100. // We have instance handles for those apps with multiple threads pending in
  101. // the library at once. You should open an instance thread for each worker
  102. // thread you'll have sending down an IOCTL waiting for work.
  103. //
  104. ULONG
  105. UMReflectorOpenWorker(
  106. PUMRX_USERMODE_REFLECT_BLOCK ReflectorHandle,
  107. PUMRX_USERMODE_WORKER_INSTANCE *WorkerHandle
  108. );
  109. //
  110. // Even after calling UMReflectorUnregister, you should still call
  111. // UMReflectorCloseWorker on each worker handle instance you have open.
  112. //
  113. VOID
  114. UMReflectorCloseWorker(
  115. PUMRX_USERMODE_WORKER_INSTANCE WorkerHandle
  116. );
  117. //
  118. // This starts the Mini-Redir.
  119. //
  120. ULONG
  121. UMReflectorStart(
  122. ULONG ReflectorVersion,
  123. PUMRX_USERMODE_REFLECT_BLOCK ReflectorHandle
  124. );
  125. //
  126. // This stops the Mini-Redir.
  127. //
  128. ULONG
  129. UMReflectorStop(
  130. PUMRX_USERMODE_REFLECT_BLOCK ReflectorHandle
  131. );
  132. //
  133. // If any user mode threads are waiting for requests, they'll return
  134. // immediately.
  135. //
  136. ULONG
  137. UMReflectorReleaseThreads(
  138. PUMRX_USERMODE_REFLECT_BLOCK ReflectorHandle
  139. );
  140. //
  141. // This allocates a work item that may have additional space below it for
  142. // Mini-Redir specific information. It should be freed using
  143. // ReflectorCompleteWorkItem below.
  144. //
  145. PUMRX_USERMODE_WORKITEM_HEADER
  146. UMReflectorAllocateWorkItem(
  147. PUMRX_USERMODE_WORKER_INSTANCE WorkerHandle,
  148. ULONG AdditionalBytes
  149. );
  150. //
  151. // This may free the work item. It may unmap and possibly free both the user
  152. // and kernel mode associated buffers. If a kernel mode associated buffer is
  153. // stored in this WorkItem, the WorkItem will be posted back to the kernel mode
  154. // process for freeing. Once the call to ReflectorCompleteWorkItem is called,
  155. // the WorkItem should not be touched by the calling application.
  156. //
  157. ULONG
  158. UMReflectorCompleteWorkItem(
  159. PUMRX_USERMODE_WORKER_INSTANCE WorkerHandle,
  160. PUMRX_USERMODE_WORKITEM_HEADER WorkItem
  161. );
  162. //
  163. // This user mode thread is requesting a client request to work on. It will not
  164. // return until the kernel portion of the library has a request to send up to
  165. // user mode. If the PreviousWorkItem is not NULL, then this work item contains
  166. // a response that will be sent down to the kernel. This eliminates a transition
  167. // for the typical case of a worker thread returning a result and then asking
  168. // for another work item.
  169. //
  170. ULONG
  171. UMReflectorGetRequest (
  172. PUMRX_USERMODE_WORKER_INSTANCE WorkerHandle,
  173. PUMRX_USERMODE_WORKITEM_HEADER ResponseWorkItem OPTIONAL,
  174. PUMRX_USERMODE_WORKITEM_HEADER ReceiveWorkItem,
  175. BOOL revertAlreadyDone
  176. );
  177. //
  178. // A response is sent down to kernel mode due to an action in user mode being
  179. // completed. The kernel mode library does not get another request for this
  180. // thread. Both the request and response buffers associated with the WorkItem
  181. // will be unmapped/unlocked/freed (when the library has done the
  182. // allocating/locking/mapping).
  183. //
  184. ULONG
  185. UMReflectorSendResponse(
  186. PUMRX_USERMODE_WORKER_INSTANCE WorkerHandle,
  187. PUMRX_USERMODE_WORKITEM_HEADER WorkItem
  188. );
  189. ULONG
  190. UMReflectorImpersonate(
  191. PUMRX_USERMODE_WORKITEM_HEADER IncomingWorkItem,
  192. HANDLE ImpersonationToken
  193. );
  194. ULONG
  195. UMReflectorRevert (
  196. PUMRX_USERMODE_WORKITEM_HEADER IncomingWorkItem
  197. );
  198. //
  199. // If the user mode side needs to allocate memory in the shared memory
  200. // area, it can do so using these calls. Note that if the memory isn't
  201. // freed up by the caller, it will be freed when the kernel mode async work
  202. // context is freed.
  203. //
  204. ULONG
  205. UMReflectorAllocateSharedMemory(
  206. PUMRX_USERMODE_WORKER_INSTANCE WorkerHandle,
  207. PUMRX_USERMODE_WORKITEM_HEADER WorkItem,
  208. SIZE_T SizeRequired,
  209. PVOID *SharedBuffer
  210. );
  211. ULONG
  212. UMReflectorFreeSharedMemory(
  213. PUMRX_USERMODE_WORKER_INSTANCE WorkerHandle,
  214. PUMRX_USERMODE_WORKITEM_HEADER WorkItem,
  215. PVOID SharedBuffer
  216. );
  217. VOID
  218. UMReflectorCompleteRequest(
  219. PUMRX_USERMODE_REFLECT_BLOCK ReflectorHandle,
  220. PUMRX_USERMODE_WORKITEM_HEADER WorkItemHeader
  221. );
  222. VOID
  223. DavCleanupWorkItem(
  224. PUMRX_USERMODE_WORKITEM_HEADER UserWorkItem
  225. );
  226. //
  227. // The control codes specific to the reflector library.
  228. //
  229. #define IOCTL_UMRX_RELEASE_THREADS \
  230. _RDR_CONTROL_CODE(222, METHOD_BUFFERED, FILE_ANY_ACCESS)
  231. #define IOCTL_UMRX_GET_REQUEST \
  232. _RDR_CONTROL_CODE(223, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
  233. #define IOCTL_UMRX_RESPONSE_AND_REQUEST \
  234. _RDR_CONTROL_CODE(224, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
  235. #define IOCTL_UMRX_RESPONSE \
  236. _RDR_CONTROL_CODE(225, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
  237. #define IOCTL_UMRX_GET_LOCK_OWNER \
  238. _RDR_CONTROL_CODE(226, METHOD_BUFFERED, FILE_ANY_ACCESS)
  239. #define FSCTL_UMRX_START \
  240. _RDR_CONTROL_CODE(227, METHOD_BUFFERED, FILE_ANY_ACCESS)
  241. #define FSCTL_UMRX_STOP \
  242. _RDR_CONTROL_CODE(228, METHOD_BUFFERED, FILE_ANY_ACCESS)
  243. #endif // _NTUMREFL_H