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.

365 lines
9.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1992 **/
  4. /**********************************************************************/
  5. /*
  6. MPRProp.cxx
  7. This file contains the implementation for the
  8. WNetGetPropertyTextW
  9. WNetPropertyDialogW
  10. FILE HISTORY:
  11. 05-May-1999 jschwart
  12. Make provider addition/removal dynamic
  13. 27-May-1994 danl
  14. WNetGetPropertyTextW & WNetPropertyDialogW: If no provider
  15. claims the connection in question, then we try all providers.
  16. The actual rule is that we need to pass it to the lanman
  17. provider anyway (so it can check for a share). But to play
  18. completely fair, we'll pass it to everyone.
  19. Johnl 07-Jan-1991 Boilerplated from Danl's code
  20. */
  21. #include "precomp.hxx"
  22. DWORD
  23. WNetGetPropertyTextW (
  24. DWORD iButton,
  25. DWORD nPropSel,
  26. LPTSTR lpszName,
  27. LPTSTR lpszButtonName,
  28. DWORD nButtonNameLength,
  29. DWORD nType
  30. )
  31. /*++
  32. Routine Description:
  33. Arguments:
  34. Return Value:
  35. Note:
  36. --*/
  37. {
  38. DWORD status=WN_SUCCESS;
  39. LPPROVIDER provider;
  40. BOOL fcnSupported = FALSE; // Is fcn supported by a provider?
  41. DWORD providerIndex;
  42. LPDWORD index;
  43. DWORD indexArray[DEFAULT_MAX_PROVIDERS];
  44. DWORD numProviders;
  45. DWORD statusFlag = 0; // used to indicate major error types
  46. DWORD i;
  47. MprCheckProviders();
  48. CProviderSharedLock PLock;
  49. INIT_IF_NECESSARY(NETWORK_LEVEL,status);
  50. index = indexArray;
  51. //
  52. // Find the Provider Index associated with the drive letter in
  53. // the pathname (lpszName).
  54. // NOTE: This function handles exceptions.
  55. //
  56. status = MprFindProviderForPath(lpszName, &providerIndex);
  57. if (status != WN_SUCCESS) {
  58. MPR_LOG1(ERROR,"WNetGetPropertyText: Couldn't find provider for this "
  59. "path. Error = %d\n",status);
  60. //
  61. // Find the list of providers to call for this request.
  62. // Since no provider claimed this path, then
  63. // we need to at least try the lanman provider.
  64. // Actually we'll give them all a chance.
  65. //
  66. status = MprFindCallOrder(
  67. NULL,
  68. &index,
  69. &numProviders,
  70. NETWORK_TYPE);
  71. if (status != WN_SUCCESS) {
  72. return(status);
  73. }
  74. }
  75. else {
  76. numProviders = 1;
  77. index[0] = providerIndex;
  78. }
  79. //
  80. // Loop through the list of providers until one answers the request,
  81. // or the list is exhausted.
  82. //
  83. for (i=0; i<numProviders; i++) {
  84. //
  85. // Call the appropriate provider's API entry point
  86. //
  87. provider = GlobalProviderInfo + index[i];
  88. if (provider->GetPropertyText != NULL) {
  89. fcnSupported = TRUE;
  90. __try {
  91. status = provider->GetPropertyText(
  92. iButton,
  93. nPropSel,
  94. lpszName,
  95. lpszButtonName,
  96. nButtonNameLength,
  97. nType
  98. );
  99. }
  100. __except(MPR_EXCEPTION_FILTER) {
  101. status = GetExceptionCode();
  102. if (status != EXCEPTION_ACCESS_VIOLATION) {
  103. MPR_LOG(ERROR,"WNetGetPropertyText:Unexpected Exception "
  104. "0x%lx\n",status);
  105. }
  106. status = WN_BAD_POINTER;
  107. }
  108. if (status == WN_NO_NETWORK) {
  109. statusFlag |= NO_NET;
  110. }
  111. else if ((status == WN_NOT_CONNECTED) ||
  112. (status == WN_BAD_LOCALNAME)){
  113. statusFlag |= BAD_NAME;
  114. }
  115. else {
  116. //
  117. // If it wasn't one of those errors, then the provider
  118. // must have accepted responsiblity for the request.
  119. // so we exit and process the results. Note that the
  120. // statusFlag is cleared because we want to ignore other
  121. // error information that we gathered up until now.
  122. //
  123. statusFlag = 0;
  124. break;
  125. }
  126. } // End if this provider supports GetPropertyText.
  127. }
  128. if (fcnSupported == FALSE) {
  129. //
  130. // No providers in the list support the API function. Therefore,
  131. // we assume that no networks are installed.
  132. //
  133. status = WN_NOT_SUPPORTED;
  134. }
  135. //
  136. // If memory was allocated by MprFindCallOrder, free it.
  137. //
  138. if (index != indexArray) {
  139. LocalFree(index);
  140. }
  141. //
  142. // Handle special errors.
  143. //
  144. if (statusFlag == (NO_NET | BAD_NAME)) {
  145. //
  146. // Check to see if there was a mix of special errors that occured.
  147. // If so, pass back the combined error message. Otherwise, let the
  148. // last error returned get passed back.
  149. //
  150. status = WN_NO_NET_OR_BAD_PATH;
  151. }
  152. if (status != WN_SUCCESS){
  153. SetLastError(status);
  154. }
  155. //
  156. // Handle normal errors passed back from the provider
  157. //
  158. return(status);
  159. }
  160. DWORD
  161. WNetPropertyDialogW (
  162. HWND hwndParent,
  163. DWORD iButton,
  164. DWORD nPropSel,
  165. LPTSTR lpszName,
  166. DWORD nType
  167. )
  168. /*++
  169. Routine Description:
  170. Arguments:
  171. Return Value:
  172. Note:
  173. --*/
  174. {
  175. DWORD status=WN_SUCCESS;
  176. LPPROVIDER provider;
  177. BOOL fcnSupported = FALSE; // Is fcn supported by a provider?
  178. DWORD providerIndex;
  179. LPDWORD index;
  180. DWORD indexArray[DEFAULT_MAX_PROVIDERS];
  181. DWORD numProviders;
  182. DWORD statusFlag = 0; // used to indicate major error types
  183. DWORD i;
  184. MprCheckProviders();
  185. CProviderSharedLock PLock;
  186. INIT_IF_NECESSARY(NETWORK_LEVEL,status);
  187. index = indexArray;
  188. //
  189. // Find the Provider Index associated with the drive letter in
  190. // the pathname (lpszName).
  191. // NOTE: This function handles exceptions.
  192. //
  193. status = MprFindProviderForPath(lpszName, &providerIndex);
  194. if (status != WN_SUCCESS) {
  195. MPR_LOG1(ERROR,"WNetPropertyDialog: Couldn't find provider for this "
  196. "path. Error = %d\n",status);
  197. //
  198. // Find the list of providers to call for this request.
  199. // Since no provider claimed this path, then
  200. // we need to at least try the lanman provider.
  201. // Actually we'll give them all a chance.
  202. //
  203. status = MprFindCallOrder(
  204. NULL,
  205. &index,
  206. &numProviders,
  207. NETWORK_TYPE);
  208. if (status != WN_SUCCESS) {
  209. return(status);
  210. }
  211. }
  212. else {
  213. numProviders = 1;
  214. index[0] = providerIndex;
  215. }
  216. //
  217. // Loop through the list of providers until one answers the request,
  218. // or the list is exhausted.
  219. //
  220. for (i=0; i<numProviders; i++) {
  221. //
  222. // Call the appropriate provider's API entry point
  223. //
  224. provider = GlobalProviderInfo + index[i];
  225. if (provider->PropertyDialog != NULL) {
  226. fcnSupported = TRUE;
  227. __try {
  228. status = provider->PropertyDialog(
  229. hwndParent,
  230. iButton,
  231. nPropSel,
  232. lpszName,
  233. nType
  234. );
  235. }
  236. __except(MPR_EXCEPTION_FILTER) {
  237. status = GetExceptionCode();
  238. if (status != EXCEPTION_ACCESS_VIOLATION) {
  239. MPR_LOG(ERROR,"WNetPropertyDialog:Unexpected Exception "
  240. "0x%lx\n",status);
  241. }
  242. status = WN_BAD_POINTER;
  243. }
  244. if (status == WN_NO_NETWORK) {
  245. statusFlag |= NO_NET;
  246. }
  247. else if ((status == WN_NOT_CONNECTED) ||
  248. (status == WN_BAD_LOCALNAME)){
  249. statusFlag |= BAD_NAME;
  250. }
  251. else {
  252. //
  253. // If it wasn't one of those errors, then the provider
  254. // must have accepted responsiblity for the request.
  255. // so we exit and process the results. Note that the
  256. // statusFlag is cleared because we want to ignore other
  257. // error information that we gathered up until now.
  258. //
  259. statusFlag = 0;
  260. break;
  261. }
  262. } // End if this provider supports PropertyDialog
  263. }
  264. if (fcnSupported == FALSE) {
  265. //
  266. // No providers in the list support the API function. Therefore,
  267. // we assume that no networks are installed.
  268. //
  269. status = WN_NOT_SUPPORTED;
  270. }
  271. //
  272. // If memory was allocated by MprFindCallOrder, free it.
  273. //
  274. if (index != indexArray) {
  275. LocalFree(index);
  276. }
  277. //
  278. // Handle special errors.
  279. //
  280. if (statusFlag == (NO_NET | BAD_NAME)) {
  281. //
  282. // Check to see if there was a mix of special errors that occured.
  283. // If so, pass back the combined error message. Otherwise, let the
  284. // last error returned get passed back.
  285. //
  286. status = WN_NO_NET_OR_BAD_PATH;
  287. }
  288. //
  289. // Handle normal errors passed back from the provider
  290. //
  291. if (status != WN_SUCCESS){
  292. SetLastError(status);
  293. }
  294. return(status);
  295. }