Source code of Windows XP (NT5)
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
6.4 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. resinfo.cxx
  5. Abstract:
  6. Contains the entry points for the WinNet Resource Info API supported
  7. by the Multi-Provider Router. The following functions are in this file:
  8. WNetGetResourceInformationW
  9. WNetGetResourceParentW
  10. Author:
  11. Anirudh Sahni (anirudhs) 27-Apr-1995
  12. Environment:
  13. User Mode -Win32
  14. Notes:
  15. Revision History:
  16. 27-Apr-1995 anirudhs
  17. Created
  18. 16-Oct-1995 anirudhs
  19. Converted to use MPR base classes
  20. 05-May-1999 jschwart
  21. Make provider addition/removal dynamic
  22. --*/
  23. //
  24. // INCLUDES
  25. //
  26. #include "precomp.hxx"
  27. //===================================================================
  28. // WNetGetResourceInformationW
  29. //===================================================================
  30. class CGetResourceInformation : public CRoutedOperation
  31. {
  32. public:
  33. CGetResourceInformation(
  34. LPNETRESOURCEW lpNetResource,
  35. LPVOID lpBuffer,
  36. LPDWORD lpBufferSize,
  37. LPWSTR *lplpSystem
  38. ) :
  39. CRoutedOperation(DBGPARM("GetResourceInformation")
  40. PROVIDERFUNC(GetResourceInformation)),
  41. _lpNetResource(lpNetResource),
  42. _lpBuffer (lpBuffer),
  43. _lpBufferSize (lpBufferSize),
  44. _lplpSystem (lplpSystem)
  45. { }
  46. private:
  47. LPNETRESOURCEW _lpNetResource;
  48. LPVOID _lpBuffer;
  49. LPDWORD _lpBufferSize;
  50. LPWSTR * _lplpSystem;
  51. DECLARE_CROUTED
  52. };
  53. DWORD
  54. CGetResourceInformation::ValidateRoutedParameters(
  55. LPCWSTR * ppProviderName,
  56. LPCWSTR * ppRemoteName,
  57. LPCWSTR * ppLocalName
  58. )
  59. {
  60. if (!(ARGUMENT_PRESENT(_lpNetResource) &&
  61. ARGUMENT_PRESENT(_lpBufferSize) &&
  62. ARGUMENT_PRESENT(_lplpSystem)))
  63. {
  64. return WN_BAD_POINTER;
  65. }
  66. if (_lpNetResource->lpRemoteName == NULL)
  67. {
  68. return WN_BAD_NETNAME;
  69. }
  70. //
  71. // If there is an output buffer, probe it.
  72. //
  73. if (IS_BAD_BYTE_BUFFER(_lpBuffer, _lpBufferSize))
  74. {
  75. return WN_BAD_POINTER;
  76. }
  77. *_lplpSystem = NULL;
  78. //
  79. // Set parameters used by base class.
  80. //
  81. *ppProviderName = _lpNetResource->lpProvider;
  82. *ppRemoteName = _lpNetResource->lpRemoteName;
  83. *ppLocalName = NULL;
  84. return WN_SUCCESS;
  85. }
  86. DWORD
  87. CGetResourceInformation::TestProvider(
  88. const PROVIDER * pProvider
  89. )
  90. {
  91. ASSERT_INITIALIZED(NETWORK);
  92. return ( pProvider->GetResourceInformation(
  93. _lpNetResource,
  94. _lpBuffer,
  95. _lpBufferSize,
  96. _lplpSystem) );
  97. }
  98. DWORD
  99. WNetGetResourceInformationW(
  100. LPNETRESOURCEW lpNetResource,
  101. LPVOID lpBuffer,
  102. LPDWORD lpBufferSize,
  103. LPWSTR *lplpSystem
  104. )
  105. /*++
  106. Routine Description:
  107. This API is used to find enumeration information for a resource (whose
  108. name is typically typed in by the user).
  109. Arguments:
  110. lpNetResource -
  111. lpBuffer -
  112. lpBufferSize -
  113. lplpSystem -
  114. Return Value:
  115. WN_SUCCESS - Indicates the operation was successful.
  116. Other errors -
  117. --*/
  118. {
  119. CGetResourceInformation GetResInfo(lpNetResource,
  120. lpBuffer,
  121. lpBufferSize,
  122. lplpSystem);
  123. return (GetResInfo.Perform(TRUE));
  124. }
  125. //===================================================================
  126. // WNetGetResourceParentW
  127. //===================================================================
  128. class CGetResourceParent : public CRoutedOperation
  129. {
  130. public:
  131. CGetResourceParent(
  132. LPNETRESOURCEW lpNetResource,
  133. LPVOID lpBuffer,
  134. LPDWORD lpBufferSize
  135. ) :
  136. CRoutedOperation(DBGPARM("GetResourceParent")
  137. PROVIDERFUNC(GetResourceParent)),
  138. _lpNetResource(lpNetResource),
  139. _lpBuffer (lpBuffer),
  140. _lpBufferSize (lpBufferSize)
  141. { }
  142. private:
  143. LPNETRESOURCEW _lpNetResource;
  144. LPVOID _lpBuffer;
  145. LPDWORD _lpBufferSize;
  146. DECLARE_CROUTED
  147. };
  148. DWORD
  149. CGetResourceParent::ValidateRoutedParameters(
  150. LPCWSTR * ppProviderName,
  151. LPCWSTR * ppRemoteName,
  152. LPCWSTR * ppLocalName
  153. )
  154. {
  155. if (!(ARGUMENT_PRESENT(_lpNetResource) &&
  156. ARGUMENT_PRESENT(_lpBufferSize)))
  157. {
  158. return WN_BAD_POINTER;
  159. }
  160. if (_lpNetResource->lpRemoteName == NULL)
  161. {
  162. return WN_BAD_NETNAME;
  163. }
  164. //
  165. // Unlike Win95, we require a provider name. This allows our providers
  166. // to make several simplifying assumptions.
  167. //
  168. if (IS_EMPTY_STRING(_lpNetResource->lpProvider))
  169. {
  170. return WN_BAD_PROVIDER;
  171. }
  172. //
  173. // If there is an output buffer, probe it.
  174. //
  175. if (IS_BAD_BYTE_BUFFER(_lpBuffer, _lpBufferSize))
  176. {
  177. return WN_BAD_POINTER;
  178. }
  179. //
  180. // Set parameters used by base class.
  181. //
  182. *ppProviderName = _lpNetResource->lpProvider;
  183. *ppRemoteName = _lpNetResource->lpRemoteName;
  184. *ppLocalName = NULL;
  185. return WN_SUCCESS;
  186. }
  187. DWORD
  188. CGetResourceParent::TestProvider(
  189. const PROVIDER * pProvider
  190. )
  191. {
  192. ASSERT_INITIALIZED(NETWORK);
  193. return ( pProvider->GetResourceParent(
  194. _lpNetResource,
  195. _lpBuffer,
  196. _lpBufferSize) );
  197. }
  198. DWORD
  199. WNetGetResourceParentW(
  200. LPNETRESOURCEW lpNetResource,
  201. LPVOID lpBuffer,
  202. LPDWORD lpBufferSize
  203. )
  204. /*++
  205. Routine Description:
  206. This API is used to find enumeration information for a resource (whose
  207. name is typically typed in by the user).
  208. Arguments:
  209. lpNetResource -
  210. lpBuffer -
  211. lpBufferSize -
  212. Return Value:
  213. WN_SUCCESS - Indicates the operation was successful.
  214. Other errors -
  215. --*/
  216. {
  217. CGetResourceParent GetResParent(lpNetResource, lpBuffer, lpBufferSize);
  218. return (GetResParent.Perform(TRUE));
  219. }