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.

730 lines
18 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. mprui.cxx
  5. Abstract:
  6. Contains the entry points for the UI pieces that live in a
  7. separate DLL. The entry points are made available here, but
  8. will not load the MPRUI.DLL until it is needed.
  9. Contains:
  10. Author:
  11. Chuck Y Chan (chuckc) 20-Jul-1992
  12. Environment:
  13. User Mode -Win32
  14. Notes:
  15. Revision History:
  16. 20-Jul-1992 chuckc created
  17. 25-Oct-1992 CongpaY added ShowReconnectDialog
  18. 30-Nov-1992 Yi-HsinS added WNetSupportGlobalEnum
  19. 12-May-1993 Danl
  20. WNetClearConnections: Added code to free MPRUI.DLL after calling
  21. the MPRUI function to clear connections. REASON:
  22. This code path is called by winlogon. It causes mprui.dll
  23. to get loaded. Mprui references MPR.DLL. Because MPRUI.DLL was never
  24. getting freed, winlogon could never free MPR.DLL.
  25. 05-May-1999 jschwart
  26. Make provider addition/removal dynamic
  27. --*/
  28. #include "precomp.hxx"
  29. /*
  30. * global functions
  31. */
  32. BOOL MprGetProviderIndexFromDriveName(LPWSTR lpDriveName, LPDWORD lpnIndex );
  33. /*******************************************************************
  34. NAME: WNetConnectionDialog1A
  35. SYNOPSIS: calls thru to the superset function
  36. HISTORY:
  37. chuckc 29-Jul-1992 Created
  38. brucefo 18-May-1995 Created
  39. ********************************************************************/
  40. DWORD
  41. WNetConnectionDialog1A(
  42. LPCONNECTDLGSTRUCTA lpConnDlgStruct
  43. )
  44. {
  45. return MPRUI_WNetConnectionDialog1A(lpConnDlgStruct);
  46. }
  47. /*******************************************************************
  48. NAME: WNetConnectionDialog1W
  49. SYNOPSIS: calls thru to the superset function
  50. HISTORY:
  51. chuckc 29-Jul-1992 Created
  52. brucefo 18-May-1995 Created
  53. ********************************************************************/
  54. DWORD
  55. WNetConnectionDialog1W(
  56. LPCONNECTDLGSTRUCTW lpConnDlgStruct
  57. )
  58. {
  59. return MPRUI_WNetConnectionDialog1W(lpConnDlgStruct);
  60. }
  61. /*******************************************************************
  62. NAME: WNetDisconnectDialog1A
  63. SYNOPSIS: calls thru to the superset function
  64. HISTORY:
  65. chuckc 29-Jul-1992 Created
  66. brucefo 18-May-1995 Created
  67. ********************************************************************/
  68. DWORD
  69. WNetDisconnectDialog1A(
  70. LPDISCDLGSTRUCTA lpDiscDlgStruct
  71. )
  72. {
  73. return MPRUI_WNetDisconnectDialog1A(lpDiscDlgStruct);
  74. }
  75. /*******************************************************************
  76. NAME: WNetDisconnectDialog1W
  77. SYNOPSIS: calls thru to the superset function
  78. HISTORY:
  79. chuckc 29-Jul-1992 Created
  80. brucefo 18-May-1995 Created
  81. ********************************************************************/
  82. DWORD
  83. WNetDisconnectDialog1W(
  84. LPDISCDLGSTRUCTW lpDiscDlgStruct
  85. )
  86. {
  87. return MPRUI_WNetDisconnectDialog1W(lpDiscDlgStruct);
  88. }
  89. /*******************************************************************
  90. NAME: WNetConnectionDialog
  91. SYNOPSIS: calls thru to the actual implementation in MPRUI.DLL
  92. HISTORY:
  93. chuckc 29-Jul-1992 Created
  94. ********************************************************************/
  95. DWORD
  96. WNetConnectionDialog(
  97. HWND hwnd,
  98. DWORD dwType
  99. )
  100. {
  101. return MPRUI_WNetConnectionDialog(hwnd, dwType);
  102. }
  103. /*******************************************************************
  104. NAME: WNetConnectionDialog2
  105. SYNOPSIS: calls thru to the actual implementation in MPRUI.DLL
  106. HISTORY:
  107. chuckc 29-Jul-1992 Created
  108. JSchwart 11-Mar-2001 Readded for winfile.exe support
  109. ********************************************************************/
  110. DWORD
  111. WNetConnectionDialog2(
  112. HWND hwnd,
  113. DWORD dwType,
  114. LPWSTR lpHelpFile,
  115. DWORD nHelpContext
  116. )
  117. {
  118. return WNetConnectionDialog(hwnd, dwType);
  119. }
  120. /*******************************************************************
  121. NAME: WNetDisconnectDialog
  122. SYNOPSIS: calls thru to the actual implementation in MPRUI.DLL
  123. HISTORY:
  124. chuckc 29-Jul-1992 Created
  125. ********************************************************************/
  126. DWORD
  127. WNetDisconnectDialog(
  128. HWND hwnd,
  129. DWORD dwType
  130. )
  131. {
  132. return MPRUI_WNetDisconnectDialog(hwnd, dwType);
  133. }
  134. /*******************************************************************
  135. NAME: WNetConnectionDialog2
  136. SYNOPSIS: calls thru to the actual implementation in MPRUI.DLL
  137. HISTORY:
  138. chuckc 29-Jul-1992 Created
  139. JSchwart 11-Mar-2001 Readded for winfile.exe support
  140. ********************************************************************/
  141. DWORD
  142. WNetDisconnectDialog2(
  143. HWND hwnd,
  144. DWORD dwType,
  145. LPWSTR lpHelpFile,
  146. DWORD nHelpContext
  147. )
  148. {
  149. return WNetDisconnectDialog(hwnd, dwType);
  150. }
  151. /*******************************************************************
  152. NAME: WNetClearConnections
  153. SYNOPSIS: calls thru to the actual implementation in MPRUI.DLL
  154. HISTORY:
  155. chuckc 29-Jul-1992 Created
  156. ********************************************************************/
  157. DWORD
  158. WNetClearConnections(
  159. HWND hWndParent
  160. )
  161. {
  162. return MPRUI_WNetClearConnections(hWndParent);
  163. }
  164. /*******************************************************************
  165. NAME: DoPasswordDialog
  166. SYNOPSIS: calls thru to the actual implementation in MPRUI.DLL
  167. HISTORY:
  168. chuckc 29-Jul-1992 Created
  169. ********************************************************************/
  170. DWORD
  171. DoPasswordDialog(
  172. HWND hwndOwner,
  173. LPWSTR pchResource,
  174. LPWSTR pchUserName,
  175. LPWSTR pchPasswordReturnBuffer,
  176. ULONG cbPasswordReturnBuffer, // bytes!
  177. BOOL * pfDidCancel,
  178. DWORD dwError
  179. )
  180. {
  181. return MPRUI_DoPasswordDialog(hwndOwner,
  182. pchResource,
  183. pchUserName,
  184. pchPasswordReturnBuffer,
  185. cbPasswordReturnBuffer,
  186. pfDidCancel,
  187. dwError);
  188. }
  189. /*******************************************************************
  190. NAME: DoProfileErrorDialog
  191. SYNOPSIS: calls thru to the actual implementation in MPRUI.DLL
  192. HISTORY:
  193. chuckc 29-Jul-1992 Created
  194. ********************************************************************/
  195. DWORD
  196. DoProfileErrorDialog(
  197. HWND hwndOwner,
  198. const TCHAR * pchDevice,
  199. const TCHAR * pchResource,
  200. const TCHAR * pchProvider,
  201. DWORD dwError,
  202. BOOL fAllowCancel,
  203. BOOL * pfDidCancel,
  204. BOOL * pfDisconnect,
  205. BOOL * pfHideErrors
  206. )
  207. {
  208. return MPRUI_DoProfileErrorDialog(hwndOwner,
  209. pchDevice,
  210. pchResource,
  211. pchProvider,
  212. dwError,
  213. fAllowCancel,
  214. pfDidCancel,
  215. pfDisconnect,
  216. pfHideErrors);
  217. }
  218. /*******************************************************************
  219. NAME: ShowReconnectDialog
  220. SYNOPSIS: calls thru to the actual implementation in MPRUI.DLL
  221. HISTORY:
  222. congpay 25-Oct-1992 Created
  223. ********************************************************************/
  224. DWORD
  225. ShowReconnectDialog(
  226. HWND hwndParent,
  227. PARAMETERS *Params
  228. )
  229. {
  230. return MPRUI_ShowReconnectDialog(hwndParent, Params);
  231. }
  232. /*******************************************************************
  233. NAME: WNetGetSearchDialog
  234. SYNOPSIS: gets the pointer to NPSearchDialog() from named provider
  235. ENTRY: Assumes the provider table in router has been setup,
  236. which is always the case after DLL init.
  237. lpProvider - name of provider to query
  238. EXIT:
  239. NOTES:
  240. HISTORY:
  241. chuckc 19-Mar-1992 Created
  242. ********************************************************************/
  243. FARPROC WNetGetSearchDialog(LPWSTR lpProvider)
  244. {
  245. ULONG index ;
  246. BOOL fOK ;
  247. DWORD status;
  248. MprCheckProviders();
  249. CProviderSharedLock PLock;
  250. //
  251. // INIT_IF_NECESSARY
  252. //
  253. if (!(GlobalInitLevel & NETWORK_LEVEL)) {
  254. status = MprLevel2Init(NETWORK_LEVEL);
  255. if (status != WN_SUCCESS) {
  256. return(NULL);
  257. }
  258. }
  259. if (lpProvider == NULL)
  260. return NULL ;
  261. fOK = MprGetProviderIndex(lpProvider, &index) ;
  262. if (!fOK)
  263. return(NULL) ;
  264. return((FARPROC)GlobalProviderInfo[index].SearchDialog) ;
  265. }
  266. /*******************************************************************
  267. NAME: WNetSupportGlobalEnum
  268. SYNOPSIS: Check if the provider supports global enumeration
  269. ENTRY: Assumes the provider table in router has been setup,
  270. which is always the case after DLL init.
  271. lpProvider - name of provider to query
  272. EXIT:
  273. NOTES:
  274. HISTORY:
  275. Yi-HsinS 30-Nov-1992 Created
  276. ********************************************************************/
  277. BOOL WNetSupportGlobalEnum( LPWSTR lpProvider )
  278. {
  279. MprCheckProviders();
  280. CProviderSharedLock PLock;
  281. //
  282. // INIT_IF_NECESSARY
  283. //
  284. DWORD status;
  285. if (!(GlobalInitLevel & NETWORK_LEVEL)) {
  286. status = MprLevel2Init(NETWORK_LEVEL);
  287. if (status != WN_SUCCESS) {
  288. return(FALSE);
  289. }
  290. }
  291. if ( lpProvider != NULL )
  292. {
  293. ULONG index;
  294. if ( MprGetProviderIndex( lpProvider, &index )
  295. && ( GlobalProviderInfo[index].GetCaps(WNNC_ENUMERATION)
  296. & WNNC_ENUM_GLOBAL )
  297. )
  298. {
  299. return TRUE;
  300. }
  301. }
  302. return FALSE;
  303. }
  304. /*******************************************************************
  305. NAME: WNetFMXGetPermCaps
  306. SYNOPSIS: Gets the permission capabilites from the provider
  307. supporting the given drive.
  308. ENTRY: Assumes the provider table in router has been setup,
  309. which is always the case after DLL init.
  310. lpDriveName - Name of drive
  311. EXIT:
  312. Returns a bitmask representing the permission capabilities
  313. of the provider.
  314. NOTES:
  315. HISTORY:
  316. YiHsinS 11-Apr-1994 Created
  317. ********************************************************************/
  318. DWORD WNetFMXGetPermCaps( LPWSTR lpDriveName )
  319. {
  320. ULONG index ;
  321. BOOL fOK ;
  322. DWORD status;
  323. MprCheckProviders();
  324. CProviderSharedLock PLock;
  325. //
  326. // INIT_IF_NECESSARY
  327. //
  328. if (!(GlobalInitLevel & NETWORK_LEVEL))
  329. {
  330. status = MprLevel2Init(NETWORK_LEVEL);
  331. if (status != WN_SUCCESS)
  332. return 0;
  333. }
  334. if ( lpDriveName != NULL)
  335. {
  336. fOK = MprGetProviderIndexFromDriveName( lpDriveName, &index);
  337. if ( fOK
  338. && ( GlobalProviderInfo[index].FMXGetPermCaps != NULL )
  339. )
  340. {
  341. return( GlobalProviderInfo[index].FMXGetPermCaps( lpDriveName));
  342. }
  343. }
  344. return 0;
  345. }
  346. /*******************************************************************
  347. NAME: WNetFMXEditPerm
  348. SYNOPSIS: Asks the provider supporting the given drive to pop up
  349. its own permission editor.
  350. ENTRY: Assumes the provider table in router has been setup,
  351. which is always the case after DLL init.
  352. lpDriveName - Name of drive
  353. hwndFMX - Handle of the FMX window in File Manager
  354. nDialogType - Specify the type of permission dialog to bring up.
  355. It can be one of the following values:
  356. WNPERM_DLG_PERM
  357. WNPERM_DLG_AUDIT
  358. WNPERM_DLG_OWNER
  359. EXIT:
  360. Returns WN_SUCCESS or any error that occurred
  361. NOTES:
  362. HISTORY:
  363. YiHsinS 11-Apr-1994 Created
  364. ********************************************************************/
  365. DWORD WNetFMXEditPerm( LPWSTR lpDriveName, HWND hwndFMX, DWORD nDialogType )
  366. {
  367. ULONG index ;
  368. BOOL fOK ;
  369. DWORD status = WN_SUCCESS;
  370. MprCheckProviders();
  371. CProviderSharedLock PLock;
  372. //
  373. // INIT_IF_NECESSARY
  374. //
  375. if (!(GlobalInitLevel & NETWORK_LEVEL))
  376. {
  377. status = MprLevel2Init(NETWORK_LEVEL);
  378. if (status != WN_SUCCESS)
  379. return status;
  380. }
  381. //
  382. // Check input parameters
  383. //
  384. if ( ( lpDriveName == NULL)
  385. || ( hwndFMX == NULL )
  386. || ( nDialogType != WNPERM_DLG_PERM
  387. && nDialogType != WNPERM_DLG_AUDIT
  388. && nDialogType != WNPERM_DLG_OWNER )
  389. )
  390. {
  391. status = WN_BAD_VALUE;
  392. }
  393. else
  394. {
  395. fOK = MprGetProviderIndexFromDriveName( lpDriveName, &index) ;
  396. if ( !fOK )
  397. {
  398. status = WN_NO_NET_OR_BAD_PATH;
  399. }
  400. else
  401. {
  402. if ( GlobalProviderInfo[index].FMXEditPerm == NULL )
  403. status = WN_NOT_SUPPORTED;
  404. else
  405. status = GlobalProviderInfo[index].FMXEditPerm( lpDriveName,
  406. hwndFMX,
  407. nDialogType );
  408. }
  409. }
  410. if ( status != WN_SUCCESS )
  411. SetLastError( status );
  412. return status;
  413. }
  414. /*******************************************************************
  415. NAME: WNetFMXGetPermHelp
  416. SYNOPSIS: Requests the provider supporting the given drive for
  417. the help file name and help context for the menu item
  418. with the given type of permission dialog.
  419. i.e. the help when F1 is pressed when a menu item is
  420. selected.
  421. ENTRY: Assumes the provider table in router has been setup,
  422. which is always the case after DLL init.
  423. lpDriveName - Name of drive
  424. nDialogType - Specify the type of help requested.
  425. It can be one of the following values:
  426. WNPERM_DLG_PERM
  427. WNPERM_DLG_AUDIT
  428. WNPERM_DLG_OWNER
  429. fDirectory - TRUE if the selected item is a directory, FALSE otherwise
  430. lpFileNameBuffer - Pointer to buffer that will receive the
  431. help file name
  432. lpBufferSize - Specify the size of lpBuffer
  433. lpnHelpContext - Points to a DWORD that will receive the help context
  434. EXIT:
  435. Returns WN_SUCCESS or any error that occurred
  436. NOTES:
  437. HISTORY:
  438. YiHsinS 11-Apr-1994 Created
  439. ********************************************************************/
  440. DWORD WNetFMXGetPermHelp( LPWSTR lpDriveName,
  441. DWORD nDialogType,
  442. BOOL fDirectory,
  443. LPVOID lpFileNameBuffer,
  444. LPDWORD lpBufferSize,
  445. LPDWORD lpnHelpContext )
  446. {
  447. ULONG index ;
  448. BOOL fOK ;
  449. DWORD status = WN_SUCCESS;
  450. MprCheckProviders();
  451. CProviderSharedLock PLock;
  452. //
  453. // INIT_IF_NECESSARY
  454. //
  455. if (!(GlobalInitLevel & NETWORK_LEVEL))
  456. {
  457. status = MprLevel2Init(NETWORK_LEVEL);
  458. if (status != WN_SUCCESS)
  459. return status;
  460. }
  461. //
  462. // Check input parameters
  463. //
  464. if ( ( lpDriveName == NULL)
  465. || ( nDialogType != WNPERM_DLG_PERM
  466. && nDialogType != WNPERM_DLG_AUDIT
  467. && nDialogType != WNPERM_DLG_OWNER )
  468. )
  469. {
  470. status = WN_BAD_VALUE;
  471. }
  472. else
  473. {
  474. fOK = MprGetProviderIndexFromDriveName( lpDriveName, &index) ;
  475. if ( !fOK )
  476. {
  477. status = WN_NO_NET_OR_BAD_PATH;
  478. }
  479. else
  480. {
  481. if ( GlobalProviderInfo[index].FMXGetPermHelp == NULL )
  482. status = WN_NOT_SUPPORTED;
  483. else
  484. status = GlobalProviderInfo[index].FMXGetPermHelp(
  485. lpDriveName,
  486. nDialogType,
  487. fDirectory,
  488. lpFileNameBuffer,
  489. lpBufferSize,
  490. lpnHelpContext );
  491. }
  492. }
  493. if ( status != WN_SUCCESS )
  494. SetLastError( status );
  495. return status;
  496. }
  497. /*******************************************************************
  498. NAME: MprGetProviderIndexFromDriveName
  499. SYNOPSIS: Gets the index of the provider in the provider array
  500. supporting the drive name connection.
  501. ENTRY:
  502. lpDriveName - Name of the drive
  503. lpnIndex - Points to a DWORD that will receive the index
  504. EXIT:
  505. TRUE if we successfully retrieved the index, FALSE otherwise.
  506. NOTES:
  507. HISTORY:
  508. YiHsinS 11-Apr-1994 Created
  509. ********************************************************************/
  510. BOOL MprGetProviderIndexFromDriveName(LPWSTR lpDriveName, LPDWORD lpnIndex )
  511. {
  512. DWORD status;
  513. WCHAR szRemoteName[MAX_PATH];
  514. DWORD nBufferSize = sizeof(szRemoteName);
  515. status = MprGetConnection( lpDriveName,
  516. szRemoteName,
  517. &nBufferSize,
  518. lpnIndex );
  519. //
  520. // *lpnIndex will be correct if status is WN_SUCCESS or WN_MORE_DATA
  521. // and we don't really need the remote name. Hence, we don't need to
  522. // call MprGetConnection again with a bigger buffer if WN_MORE_DATA
  523. // is returned.
  524. //
  525. return ( status == WN_SUCCESS || status == WN_MORE_DATA );
  526. }