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.

227 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. global.h
  5. Abstract:
  6. This module contains data declarations necessary for the user mode
  7. reflector user mode library.
  8. Author:
  9. Andy Herron (andyhe) 19-Apr-1999
  10. Revision History:
  11. --*/
  12. //
  13. // This structure is maintained one per reflector instance. We pass it back to
  14. // the calling app and he always passes it in to us. If we loose it, we're lost.
  15. //
  16. typedef struct _UMRX_USERMODE_REFLECT_BLOCK {
  17. //
  18. // Reference count of this reflector block.
  19. //
  20. ULONG ReferenceCount;
  21. //
  22. // Handle to the Mini-Redirs device object.
  23. //
  24. HANDLE DeviceHandle;
  25. //
  26. // Lock used to synchronize access to the fields of this reflect block.
  27. //
  28. CRITICAL_SECTION Lock;
  29. //
  30. // Name of the Device object.
  31. //
  32. PWCHAR DriverDeviceName;
  33. //
  34. // Is this reflector block active ? Closing = FALSE : Closing = TRUE;
  35. //
  36. BOOL Closing;
  37. //
  38. // List of user mode worker thread(s) instance blocks.
  39. //
  40. LIST_ENTRY WorkerList;
  41. //
  42. // List of work items currently in use to satisfy requests getting
  43. // reflected from the kernel.
  44. //
  45. LIST_ENTRY WorkItemList;
  46. //
  47. // For efficiency, we hold a few workitems around in a small cache. Note
  48. // that if the entry size changes, the cache will not be as effective.
  49. //
  50. //
  51. // List of work items which are available for use. After a workitem gets
  52. // finalized, it moves from the WorkItemList (see above) to the
  53. // AvailableList.
  54. //
  55. LIST_ENTRY AvailableList;
  56. //
  57. // Number of work items present on the AvailableList.
  58. //
  59. ULONG NumberAvailable;
  60. //
  61. // The maximum number of workitems that can be cached on the AvailableList.
  62. // When NumberAvailable exceeds the CacheLimit, one of the work items on the
  63. // list (specifically the last entry) is freed up.
  64. //
  65. ULONG CacheLimit;
  66. //
  67. // Must be last element.
  68. //
  69. WCHAR DeviceNameBuffers[1];
  70. } UMRX_USERMODE_REFLECT_BLOCK, *PUMRX_USERMODE_REFLECT_BLOCK;
  71. //
  72. // This structure is maintained one per worker thread. It holds the handle
  73. // on which we do our IOCTLs down to kernel.
  74. //
  75. typedef struct _UMRX_USERMODE_WORKER_INSTANCE {
  76. //
  77. // Used to add it to the reflect block list of worker instances.
  78. //
  79. LIST_ENTRY WorkerListEntry;
  80. //
  81. // The instance (user mode process) being served.
  82. //
  83. PUMRX_USERMODE_REFLECT_BLOCK ReflectorInstance;
  84. //
  85. // Is this thread impersonating a client ?
  86. //
  87. BOOL IsImpersonating;
  88. //
  89. // Handle of kernel device for this registered instance.
  90. //
  91. HANDLE ReflectorHandle;
  92. } UMRX_USERMODE_WORKER_INSTANCE, *PUMRX_USERMODE_WORKER_INSTANCE;
  93. //
  94. // User mode Work Item States : Mostly for debugging/support purposes.
  95. //
  96. typedef enum _USERMODE_WORKITEM_STATE {
  97. //
  98. // It's about to be freed back to the heap.
  99. //
  100. WorkItemStateFree = 0,
  101. //
  102. // It's on the list of freed and available for reallocation.
  103. //
  104. WorkItemStateAvailable,
  105. //
  106. // Has been sent to kernel to get a request.
  107. //
  108. WorkItemStateInKernel,
  109. //
  110. // Allocated by UMReflectorAllocateWorkItem but UMReflectorGetRequest
  111. // has not yet been called.
  112. //
  113. WorkItemStateNotYetSentToKernel,
  114. //
  115. // UMReflectorGetRequest is back from kernel but a response has not yet
  116. // been sent for this work item.
  117. //
  118. WorkItemStateReceivedFromKernel,
  119. //
  120. // During UMReflectorGetRequest, responses that are in flight to the kernel
  121. // are set with this state.
  122. //
  123. WorkItemStateResponseNotYetToKernel,
  124. //
  125. // After UMReflectorGetRequest, response workitem is set to this state on
  126. // the way to free or available.
  127. //
  128. WorkItemStateResponseFromKernel
  129. } USERMODE_WORKITEM_STATE;
  130. //
  131. // This structure is maintained one per reflection down to kernel mode. We give
  132. // it to the calling app, he fills it in and gives it back to us to give to
  133. // kernel and then we return it when kernel has a request. This structure is
  134. // just for housekeeping and is not passed between user and kernel mode. It sits
  135. // directly in front of the UMRX_USERMODE_WORKITEM_HEADER structure.
  136. //
  137. typedef struct _UMRX_USERMODE_WORKITEM_ADDON {
  138. //
  139. // Size of this entry.
  140. //
  141. ULONG EntrySize;
  142. //
  143. // The user mode instance with which this work item is associated.
  144. //
  145. PUMRX_USERMODE_REFLECT_BLOCK ReflectorInstance;
  146. //
  147. // Used in adding it to the reflect blocks list.
  148. //
  149. LIST_ENTRY ListEntry;
  150. //
  151. // The state of the work item.
  152. //
  153. USERMODE_WORKITEM_STATE WorkItemState;
  154. //
  155. // The work item header which the user mode instance gets back to use.
  156. //
  157. union {
  158. UMRX_USERMODE_WORKITEM_HEADER Header;
  159. UMRX_USERMODE_WORKITEM_HEADER;
  160. };
  161. } UMRX_USERMODE_WORKITEM_ADDON, *PUMRX_USERMODE_WORKITEM_ADDON;
  162. #if DBG
  163. #define RlDavDbgPrint(_x_) DbgPrint _x_
  164. #else
  165. #define RlDavDbgPrint(_x_)
  166. #endif
  167. VOID
  168. DereferenceReflectorBlock (
  169. PUMRX_USERMODE_REFLECT_BLOCK reflectorInstance
  170. );
  171. ULONG
  172. ReflectorSendSimpleFsControl(
  173. PUMRX_USERMODE_REFLECT_BLOCK ReflectorHandle,
  174. ULONG IoctlCode
  175. );
  176. // global.h eof.