Author: pschweitzer
Date: Mon Feb 15 20:32:25 2016
New Revision: 70755
URL:
http://svn.reactos.org/svn/reactos?rev=70755&view=rev
Log:
[MPR]
Import Wine commit:
- d070c263adf840cc14dde84eb8e73b04490d1900, Partially implement WNetUseConnectionW().
This reduces diff to Wine, by providing a cleaner implementation of WNetUseConnectionW().
CORE-10032
Modified:
trunk/reactos/dll/win32/mpr/mpr_ros.diff
trunk/reactos/dll/win32/mpr/wnet.c
Modified: trunk/reactos/dll/win32/mpr/mpr_ros.diff
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mpr/mpr_ros.diff…
==============================================================================
--- trunk/reactos/dll/win32/mpr/mpr_ros.diff [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/mpr/mpr_ros.diff [iso-8859-1] Mon Feb 15 20:32:25 2016
@@ -156,84 +156,3 @@
}
/*****************************************************************
-@@ -1577,12 +1659,75 @@
- LPWSTR lpAccessName, LPDWORD lpBufferSize,
- LPDWORD lpResult )
- {
-- FIXME( "(%p, %p, %p, %s, 0x%08X, %s, %p, %p), stub\n",
-- hwndOwner, lpNetResource, lpPassword, debugstr_w(lpUserID), dwFlags,
-- debugstr_w(lpAccessName), lpBufferSize, lpResult );
-+ DWORD provider;
-+ DWORD cap;
-+ char id;
-+ DWORD drives;
-+ DWORD ret;
-+ PF_NPAddConnection3 addConn3;
-+ PF_NPAddConnection addConn;
-
-- SetLastError(WN_NO_NETWORK);
-- return WN_NO_NETWORK;
-+ if (!providerTable || providerTable->numProviders == 0) {
-+ SetLastError(WN_NO_NETWORK);
-+ return WN_NO_NETWORK;
-+ }
-+
-+ if (!lpNetResource) {
-+ SetLastError(ERROR_INVALID_PARAMETER);
-+ return ERROR_INVALID_PARAMETER;
-+ }
-+
-+ if (!lpNetResource->lpProvider || !*lpNetResource->lpProvider) {
-+ SetLastError(ERROR_BAD_PROVIDER);
-+ return ERROR_BAD_PROVIDER;
-+ }
-+
-+ if (!lpNetResource->lpLocalName || !*lpNetResource->lpLocalName) {
-+ SetLastError(ERROR_BAD_DEVICE);
-+ return ERROR_BAD_DEVICE;
-+ }
-+
-+ if ((!(lpNetResource->lpLocalName[0] >= 'a' &&
lpNetResource->lpLocalName[0] <= 'z') &&
-+ !(lpNetResource->lpLocalName[0] >= 'A' &&
lpNetResource->lpLocalName[0] <= 'Z')) ||
-+ lpNetResource->lpLocalName[1] != ':' ||
lpNetResource->lpLocalName[2]) {
-+ SetLastError(ERROR_BAD_DEVICE);
-+ return ERROR_BAD_DEVICE;
-+ }
-+
-+ id = (lpNetResource->lpLocalName[0] >= 'a') ?
lpNetResource->lpLocalName[0] - 'a' : lpNetResource->lpLocalName[0] -
'A';
-+ drives = GetLogicalDrives();
-+ if (drives & (1 << id)) {
-+ SetLastError(ERROR_ALREADY_ASSIGNED);
-+ return ERROR_ALREADY_ASSIGNED;
-+ }
-+
-+ provider = _findProviderIndexW(lpNetResource->lpProvider);
-+ if (provider == BAD_PROVIDER_INDEX) {
-+ SetLastError(ERROR_BAD_PROVIDER);
-+ return ERROR_BAD_PROVIDER;
-+ }
-+
-+ cap = providerTable->table[provider].getCaps(WNNC_CONNECTION);
-+ if (!(cap & WNNC_CON_ADDCONNECTION) && !(cap &
WNNC_CON_ADDCONNECTION3)) {
-+ SetLastError(ERROR_BAD_PROVIDER);
-+ return ERROR_BAD_PROVIDER;
-+ }
-+
-+ ret = WN_ACCESS_DENIED;
-+ if (cap & WNNC_CON_ADDCONNECTION3) {
-+ addConn3 =
(PF_NPAddConnection3)GetProcAddress(providerTable->table[provider].hLib,
"NPAddConnection3");
-+ if (addConn3) {
-+ ret = addConn3(hwndOwner, lpNetResource, (LPWSTR)lpPassword,
(LPWSTR)lpUserID, dwFlags);
-+ }
-+ }
-+ else if (cap & WNNC_CON_ADDCONNECTION) {
-+ addConn =
(PF_NPAddConnection)GetProcAddress(providerTable->table[provider].hLib,
"NPAddConnection");
-+ if (addConn) {
-+ ret = addConn(lpNetResource, (LPWSTR)lpPassword, (LPWSTR)lpUserID);
-+ }
-+ }
-+
-+ return ret;
- }
-
- /*********************************************************************
Modified: trunk/reactos/dll/win32/mpr/wnet.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mpr/wnet.c?rev=7…
==============================================================================
--- trunk/reactos/dll/win32/mpr/wnet.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/mpr/wnet.c [iso-8859-1] Mon Feb 15 20:32:25 2016
@@ -1654,77 +1654,76 @@
/*****************************************************************
* WNetUseConnectionW [MPR.@]
*/
-DWORD WINAPI WNetUseConnectionW( HWND hwndOwner, LPNETRESOURCEW lpNetResource,
- LPCWSTR lpPassword, LPCWSTR lpUserID, DWORD dwFlags,
- LPWSTR lpAccessName, LPDWORD lpBufferSize,
- LPDWORD lpResult )
-{
- DWORD provider;
- DWORD cap;
- char id;
- DWORD drives;
- DWORD ret;
- PF_NPAddConnection3 addConn3;
- PF_NPAddConnection addConn;
-
- if (!providerTable || providerTable->numProviders == 0) {
- SetLastError(WN_NO_NETWORK);
+DWORD WINAPI WNetUseConnectionW( HWND hwndOwner, NETRESOURCEW *resource, LPCWSTR
password,
+ LPCWSTR userid, DWORD flags, LPWSTR accessname, DWORD *buffer_size, DWORD *result )
+{
+ WNetProvider *provider;
+ DWORD index, ret, caps;
+
+ TRACE( "(%p, %p, %p, %s, 0x%08X, %p, %p, %p)\n",
+ hwndOwner, resource, password, debugstr_w(userid), flags,
+ accessname, buffer_size, result );
+
+ if (!providerTable || providerTable->numProviders == 0)
return WN_NO_NETWORK;
- }
-
- if (!lpNetResource) {
- SetLastError(ERROR_INVALID_PARAMETER);
+
+ if (!resource)
return ERROR_INVALID_PARAMETER;
- }
-
- if (!lpNetResource->lpProvider || !*lpNetResource->lpProvider) {
- SetLastError(ERROR_BAD_PROVIDER);
+
+ if (!resource->lpProvider)
+ {
+ FIXME("Networking provider selection is not implemented.\n");
+ return WN_NO_NETWORK;
+ }
+
+ if (!resource->lpLocalName && (flags & CONNECT_REDIRECT))
+ {
+ FIXME("Locale device selection is not implemented.\n");
+ return WN_NO_NETWORK;
+ }
+
+ if (flags & CONNECT_INTERACTIVE)
+ return ERROR_BAD_NET_NAME;
+
+ index = _findProviderIndexW(resource->lpProvider);
+ if (index == BAD_PROVIDER_INDEX)
return ERROR_BAD_PROVIDER;
- }
-
- if (!lpNetResource->lpLocalName || !*lpNetResource->lpLocalName) {
- SetLastError(ERROR_BAD_DEVICE);
- return ERROR_BAD_DEVICE;
- }
-
- if ((!(lpNetResource->lpLocalName[0] >= 'a' &&
lpNetResource->lpLocalName[0] <= 'z') &&
- !(lpNetResource->lpLocalName[0] >= 'A' &&
lpNetResource->lpLocalName[0] <= 'Z')) ||
- lpNetResource->lpLocalName[1] != ':' ||
lpNetResource->lpLocalName[2]) {
- SetLastError(ERROR_BAD_DEVICE);
- return ERROR_BAD_DEVICE;
- }
-
- id = (lpNetResource->lpLocalName[0] >= 'a') ?
lpNetResource->lpLocalName[0] - 'a' : lpNetResource->lpLocalName[0] -
'A';
- drives = GetLogicalDrives();
- if (drives & (1 << id)) {
- SetLastError(ERROR_ALREADY_ASSIGNED);
- return ERROR_ALREADY_ASSIGNED;
- }
-
- provider = _findProviderIndexW(lpNetResource->lpProvider);
- if (provider == BAD_PROVIDER_INDEX) {
- SetLastError(ERROR_BAD_PROVIDER);
+
+ provider = &providerTable->table[index];
+ caps = provider->getCaps(WNNC_CONNECTION);
+ if (!(caps & (WNNC_CON_ADDCONNECTION | WNNC_CON_ADDCONNECTION3)))
return ERROR_BAD_PROVIDER;
- }
-
- cap = providerTable->table[provider].getCaps(WNNC_CONNECTION);
- if (!(cap & WNNC_CON_ADDCONNECTION) && !(cap &
WNNC_CON_ADDCONNECTION3)) {
- SetLastError(ERROR_BAD_PROVIDER);
- return ERROR_BAD_PROVIDER;
- }
+
+ if (accessname && buffer_size && *buffer_size)
+ {
+ DWORD len;
+
+ if (resource->lpLocalName)
+ len = strlenW(resource->lpLocalName);
+ else
+ len = strlenW(resource->lpRemoteName);
+
+ if (++len > *buffer_size)
+ {
+ *buffer_size = len;
+ return ERROR_MORE_DATA;
+ }
+ }
+ else
+ accessname = NULL;
ret = WN_ACCESS_DENIED;
- if (cap & WNNC_CON_ADDCONNECTION3) {
- addConn3 =
(PF_NPAddConnection3)GetProcAddress(providerTable->table[provider].hLib,
"NPAddConnection3");
- if (addConn3) {
- ret = addConn3(hwndOwner, lpNetResource, (LPWSTR)lpPassword,
(LPWSTR)lpUserID, dwFlags);
- }
- }
- else if (cap & WNNC_CON_ADDCONNECTION) {
- addConn =
(PF_NPAddConnection)GetProcAddress(providerTable->table[provider].hLib,
"NPAddConnection");
- if (addConn) {
- ret = addConn(lpNetResource, (LPWSTR)lpPassword, (LPWSTR)lpUserID);
- }
+ if ((caps & WNNC_CON_ADDCONNECTION3) && provider->addConnection3)
+ ret = provider->addConnection3(hwndOwner, resource, (LPWSTR)password,
(LPWSTR)userid, flags);
+ else if ((caps & WNNC_CON_ADDCONNECTION) && provider->addConnection)
+ ret = provider->addConnection(resource, (LPWSTR)password, (LPWSTR)userid);
+
+ if (ret == WN_SUCCESS && accessname)
+ {
+ if (resource->lpLocalName)
+ strcpyW(accessname, resource->lpLocalName);
+ else
+ strcpyW(accessname, resource->lpRemoteName);
}
return ret;