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.

306 lines
11 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. wsuse.h
  5. Abstract:
  6. Private header file to be included by Workstation service modules that
  7. implement the NetUse APIs.
  8. Author:
  9. Rita Wong (ritaw) 05-Mar-1991
  10. Revision History:
  11. --*/
  12. #ifndef _WSUSE_INCLUDED_
  13. #define _WSUSE_INCLUDED_
  14. #include <lmuse.h> // LAN Man Use API definitions
  15. #include <dns.h> // DNS_MAX_NAME_LENGTH definition
  16. //
  17. // Length of fixed size portion of a use info structure
  18. //
  19. #define USE_FIXED_LENGTH(Level) \
  20. (DWORD) \
  21. ((Level == 0) ? sizeof(USE_INFO_0) : \
  22. ((Level == 1) ? sizeof(USE_INFO_1) : \
  23. ((Level == 2) ? sizeof(USE_INFO_2) : \
  24. sizeof(USE_INFO_3))))
  25. //
  26. // Total length of a use info structure (fixed and variable length portions)
  27. //
  28. #define USE_TOTAL_LENGTH(Level, LocalandUncNameLength, UserNameLength) \
  29. (DWORD) \
  30. ((Level >= 2) ? (LocalandUncNameLength) + (UserNameLength) + \
  31. ((Level == 3) ? sizeof(USE_INFO_3) : sizeof(USE_INFO_2)) : \
  32. (LocalandUncNameLength) + ((Level == 1) ? \
  33. sizeof(USE_INFO_1) : \
  34. sizeof(USE_INFO_0)))
  35. //
  36. // Hint size of an entry of use information from redirector
  37. //
  38. #define HINT_REDIR_INFO(Level) \
  39. (DWORD) \
  40. ((Level == 1) ? sizeof(LMR_CONNECTION_INFO_1) + \
  41. MAX_PATH * sizeof(WCHAR) : \
  42. sizeof(LMR_CONNECTION_INFO_2) + \
  43. (MAX_PATH + MAX_PATH) * sizeof(WCHAR))
  44. //
  45. // Length of fixed size portion of a redirector enumerate info structure
  46. //
  47. #define REDIR_ENUM_INFO_FIXED_LENGTH(Level) \
  48. (DWORD) \
  49. ((Level == 0) ? sizeof(LMR_CONNECTION_INFO_0) : \
  50. ((Level == 1) ? sizeof(LMR_CONNECTION_INFO_1) : \
  51. sizeof(LMR_CONNECTION_INFO_2)))
  52. #define REDIR_LIST 0x80000000
  53. //-----------------------------------------------------------------------//
  54. // //
  55. // Use Table //
  56. // //
  57. // +-----------------+ +-----------------+ //
  58. // |TotalUseCount = 6| |TotalUseCount = 1| //
  59. // +-----------------+ +-----------------+ //
  60. // | RedirUseInfo | | RedirUseInfo | //
  61. // +-----------------+ +-----------------+ //
  62. // | UncNameLength | | UncNameLength | //
  63. // +-----------------+ +-----------------+ //
  64. // |\\POPCORN\RAZZLE | |\\FUZZY\PRINTER | //
  65. // +-----------------+ +-----------------+ //
  66. // ^ ^ ^ //
  67. // | | | //
  68. // +---+ +---+ | //
  69. // | | | //
  70. // +------------+ +--|--+------+ +--|--+------+ +--|--+------+ //
  71. // | | | * | *---->| * | *---->| * | *---->... //
  72. // | *-------->+-----+------+ +-----+------+ +-----+------+ //
  73. // | | | P: |Local | |NULL |Local | |LPT1 |Local | //
  74. // +------------+ | |Length| | |Length| | |Length| //
  75. // | | +-----+------+ +-----+------+ +-----+------+ //
  76. // | | |UseCount = 1| |UseCount = 5| |UseCount = 1| //
  77. // 0 | LogonId | +------------+ +------------+ +------------+ //
  78. // | | |Tree | |Tree | |Tree | //
  79. // | | |Connection | |Connection | |Connection | //
  80. // | | +------------+ +------------+ +------------+ //
  81. // | | |ResumeKey | |ResumeKey | |ResumeKey | //
  82. // | | +------------+ +------------+ +------------+ //
  83. // | | |TreeConnStr | | NULL | |TreeConnStr | //
  84. // | | +------------+ +------------+ +------------+ //
  85. // | | //
  86. // +============+ //
  87. // | | //
  88. // | *--------> ... //
  89. // | | //
  90. // +------------+ //
  91. // | | //
  92. // | LogonId | //
  93. // 1 | | //
  94. // | | //
  95. // | | //
  96. // | | //
  97. // | | //
  98. // | | //
  99. // | | //
  100. // | | //
  101. // +============+ //
  102. // | . | //
  103. // | . | //
  104. // | . | //
  105. // //
  106. // //
  107. // The Use Table maintained by the Workstation service keeps a list of //
  108. // explicit connections established by each user. A use entry is always //
  109. // inserted into the end of the list. //
  110. // //
  111. // Implicit connections are not maintained in the Use Table. The //
  112. // Workstation service has to ask the redirector to list all established //
  113. // implicit connections when enumerating all active connections for a //
  114. // user. //
  115. // //
  116. //-----------------------------------------------------------------------//
  117. //
  118. // The structure definition for the per user entry, which consists of a
  119. // Logon Id and a pointer to a list, is defined in wsutil.h
  120. //
  121. //
  122. // A remote entry for every unique shared resource name (\\server\share)
  123. // of explicit connections.
  124. //
  125. typedef struct _UNC_NAME {
  126. DWORD TotalUseCount;
  127. DWORD UncNameLength;
  128. LPTSTR UncName[1];
  129. } UNC_NAME, *PUNC_NAME;
  130. //
  131. // A use entry in the linked list of connections.
  132. //
  133. typedef struct _USE_ENTRY {
  134. struct _USE_ENTRY *Next;
  135. PUNC_NAME Remote;
  136. LPTSTR Local;
  137. DWORD LocalLength;
  138. DWORD UseCount;
  139. HANDLE TreeConnection;
  140. DWORD ResumeKey;
  141. LPTSTR TreeConnectStr;
  142. DWORD Flags;
  143. } USE_ENTRY, *PUSE_ENTRY;
  144. //
  145. // Values for flags field
  146. //
  147. // USE_DEFAULT_CREDENTIALS 0x4 (defined in lmuse.h)
  148. //
  149. // Enumerated data type to say whether to pause or continue the redirection
  150. //
  151. typedef enum _REDIR_OPERATION {
  152. PauseRedirection,
  153. ContinueRedirection
  154. } REDIR_OPERATION;
  155. //-------------------------------------------------------------------//
  156. // //
  157. // Utility functions from useutil.c //
  158. // //
  159. //-------------------------------------------------------------------//
  160. NET_API_STATUS
  161. WsInitUseStructures(
  162. VOID
  163. );
  164. VOID
  165. WsDestroyUseStructures(
  166. VOID
  167. );
  168. VOID
  169. WsFindInsertLocation(
  170. IN PUSE_ENTRY UseList,
  171. IN LPTSTR UncName,
  172. OUT PUSE_ENTRY *MatchedPointer,
  173. OUT PUSE_ENTRY *InsertPointer
  174. );
  175. NET_API_STATUS
  176. WsFindUse(
  177. IN PLUID LogonId,
  178. IN PUSE_ENTRY UseList,
  179. IN LPTSTR UseName,
  180. OUT PHANDLE TreeConnection,
  181. OUT PUSE_ENTRY *MatchedPointer,
  182. OUT PUSE_ENTRY *BackPointer OPTIONAL
  183. );
  184. VOID
  185. WsFindUncName(
  186. IN PUSE_ENTRY UseList,
  187. IN LPTSTR UncName,
  188. OUT PUSE_ENTRY *MatchedPointer,
  189. OUT PUSE_ENTRY *BackPointer
  190. );
  191. NET_API_STATUS
  192. WsCreateTreeConnectName(
  193. IN LPTSTR UncName,
  194. IN DWORD UncNameLength,
  195. IN LPTSTR LocalName,
  196. IN DWORD SessionId,
  197. OUT PUNICODE_STRING TreeConnectStr
  198. );
  199. NET_API_STATUS
  200. WsOpenCreateConnection(
  201. IN PUNICODE_STRING TreeConnectionName,
  202. IN LPTSTR UserName OPTIONAL,
  203. IN LPTSTR DomainName OPTIONAL,
  204. IN LPTSTR Password OPTIONAL,
  205. IN ULONG CreateFlags,
  206. IN ULONG CreateDisposition,
  207. IN ULONG ConnectionType,
  208. OUT PHANDLE TreeConnectionHandle,
  209. OUT PULONG_PTR Information OPTIONAL
  210. );
  211. NET_API_STATUS
  212. WsDeleteConnection(
  213. IN PLUID LogonId,
  214. IN HANDLE TreeConnection,
  215. IN DWORD ForceLevel
  216. );
  217. BOOL
  218. WsRedirectionPaused(
  219. IN LPTSTR LocalDeviceName
  220. );
  221. VOID
  222. WsPauseOrContinueRedirection(
  223. IN REDIR_OPERATION OperationType
  224. );
  225. NET_API_STATUS
  226. WsCreateSymbolicLink(
  227. IN LPWSTR Local,
  228. IN DWORD DeviceType,
  229. IN LPWSTR TreeConnectStr,
  230. IN PUSE_ENTRY UseList,
  231. IN OUT LPWSTR *Session,
  232. IN OUT HANDLE *lphToken
  233. );
  234. VOID
  235. WsDeleteSymbolicLink(
  236. IN LPWSTR LocalDeviceName,
  237. IN LPWSTR TreeConnectStr,
  238. IN LPWSTR SessionDeviceName,
  239. IN HANDLE hToken
  240. );
  241. NET_API_STATUS
  242. WsUseCheckRemote(
  243. IN LPTSTR RemoteResource,
  244. OUT LPTSTR UncName,
  245. OUT LPDWORD UncNameLength
  246. );
  247. NET_API_STATUS
  248. WsUseCheckLocal(
  249. IN LPTSTR LocalDevice,
  250. OUT LPTSTR Local,
  251. OUT LPDWORD LocalLength
  252. );
  253. //-------------------------------------------------------------------//
  254. // //
  255. // External global variables //
  256. // //
  257. //-------------------------------------------------------------------//
  258. //
  259. // Use Table
  260. //
  261. extern USERS_OBJECT Use;
  262. #endif // ifndef _WSUSE_INCLUDED_
  263.