2 ===================================================================
3 --- mpr.spec (revision 49877)
4 +++ mpr.spec (working copy)
45 22 stdcall @(long) MPR_Alloc
46 23 stdcall @(ptr long) MPR_ReAlloc
47 24 stdcall @(ptr) MPR_Free
49 ===================================================================
50 --- wnet.c (revision 71983)
51 +++ wnet.c (working copy)
53 PF_NPAddConnection addConnection;
54 PF_NPAddConnection3 addConnection3;
55 PF_NPCancelConnection cancelConnection;
57 + PF_NPGetConnection getConnection;
59 } WNetProvider, *PWNetProvider;
61 typedef struct _WNetProviderTable
63 provider->addConnection = MPR_GETPROC(NPAddConnection);
64 provider->addConnection3 = MPR_GETPROC(NPAddConnection3);
65 provider->cancelConnection = MPR_GETPROC(NPCancelConnection);
67 + provider->getConnection = MPR_GETPROC(NPGetConnection);
69 TRACE("NPAddConnection %p\n", provider->addConnection);
70 TRACE("NPAddConnection3 %p\n", provider->addConnection3);
71 TRACE("NPCancelConnection %p\n", provider->cancelConnection);
73 debugstr_w(provider));
77 +static void _restoreSavedConnection(HKEY connection, WCHAR * local)
80 + DWORD type, prov, index, size;
82 + net.lpProvider = NULL;
83 + net.lpRemoteName = NULL;
84 + net.lpLocalName = NULL;
86 + TRACE("Restoring: %S\n", local);
88 + size = sizeof(DWORD);
89 + if (RegQueryValueExW(connection, L"ConnectionType", NULL, &type, (BYTE *)&net.dwType, &size) != ERROR_SUCCESS)
92 + if (type != REG_DWORD || size != sizeof(DWORD))
95 + if (RegQueryValueExW(connection, L"ProviderName", NULL, &type, NULL, &size) != ERROR_SUCCESS)
101 + net.lpProvider = HeapAlloc(GetProcessHeap(), 0, size);
102 + if (!net.lpProvider)
105 + if (RegQueryValueExW(connection, L"ProviderName", NULL, NULL, (BYTE *)net.lpProvider, &size) != ERROR_SUCCESS)
108 + size = sizeof(DWORD);
109 + if (RegQueryValueExW(connection, L"ProviderType", NULL, &type, (BYTE *)&prov, &size) != ERROR_SUCCESS)
112 + if (type != REG_DWORD || size != sizeof(DWORD))
115 + index = _findProviderIndexW(net.lpProvider);
116 + if (index == BAD_PROVIDER_INDEX)
119 + if (providerTable->table[index].dwNetType != prov)
122 + if (RegQueryValueExW(connection, L"RemotePath", NULL, &type, NULL, &size) != ERROR_SUCCESS)
125 + if (type != REG_SZ)
128 + net.lpRemoteName = HeapAlloc(GetProcessHeap(), 0, size);
129 + if (!net.lpRemoteName)
132 + if (RegQueryValueExW(connection, L"RemotePath", NULL, NULL, (BYTE *)net.lpRemoteName, &size) != ERROR_SUCCESS)
135 + size = strlenW(local);
136 + net.lpLocalName = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR) + 2 * sizeof(WCHAR));
137 + if (!net.lpLocalName)
140 + strcpyW(net.lpLocalName, local);
141 + net.lpLocalName[size] = ':';
142 + net.lpLocalName[size + 1] = 0;
144 + TRACE("Attempting connection\n");
146 + WNetAddConnection2W(&net, NULL, NULL, 0);
149 + HeapFree(GetProcessHeap(), 0, net.lpProvider);
150 + HeapFree(GetProcessHeap(), 0, net.lpRemoteName);
151 + HeapFree(GetProcessHeap(), 0, net.lpLocalName);
155 void wnetInit(HINSTANCE hInstDll)
157 static const WCHAR providerOrderKey[] = { 'S','y','s','t','e','m','\\',
168 + if (RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
171 + WCHAR subkey[8] = {'N', 'e', 't', 'w', 'o', 'r', 'k', 0};
173 + if (RegOpenKeyExW(user_profile, subkey, 0, KEY_READ, &network) == ERROR_SUCCESS)
177 + TRACE("Enumerating remembered connections\n");
179 + if (RegQueryInfoKey(network, NULL, NULL, NULL, &max, &size, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
183 + TRACE("There are %lu connections\n", max);
185 + local = HeapAlloc(GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR));
190 + for (index = 0; index < max; ++index)
192 + DWORD len = size + 1;
195 + TRACE("Trying connection %lu\n", index);
197 + if (RegEnumKeyExW(network, index, local, &len, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
200 + TRACE("It is %S\n", local);
202 + if (RegOpenKeyExW(network, local, 0, KEY_READ, &connection) != ERROR_SUCCESS)
205 + _restoreSavedConnection(connection, local);
206 + RegCloseKey(connection);
209 + HeapFree(GetProcessHeap(), 0, local);
213 + RegCloseKey(network);
216 + RegCloseKey(user_profile);
223 @@ -1870,6 +2003,43 @@
228 + if (ret == WN_SUCCESS && ctxt->flags & CONNECT_UPDATE_PROFILE)
232 + if (netres.dwType == RESOURCETYPE_PRINT)
234 + FIXME("Persistent connection are not supported for printers\n");
238 + if (RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
241 + WCHAR subkey[10] = {'N', 'e', 't', 'w', 'o', 'r', 'k', '\\', netres.lpLocalName[0], 0};
243 + if (RegCreateKeyExW(user_profile, subkey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &network, NULL) == ERROR_SUCCESS)
245 + DWORD dword_arg = RESOURCETYPE_DISK;
246 + DWORD len = (strlenW(provider->name) + 1) * sizeof(WCHAR);
248 + RegSetValueExW(network, L"ConnectionType", 0, REG_DWORD, (const BYTE *)&dword_arg, sizeof(DWORD));
249 + RegSetValueExW(network, L"ProviderName", 0, REG_SZ, (const BYTE *)provider->name, len);
250 + dword_arg = provider->dwNetType;
251 + RegSetValueExW(network, L"ProviderType", 0, REG_DWORD, (const BYTE *)&dword_arg, sizeof(DWORD));
252 + len = (strlenW(netres.lpRemoteName) + 1) * sizeof(WCHAR);
253 + RegSetValueExW(network, L"RemotePath", 0, REG_SZ, (const BYTE *)netres.lpRemoteName, len);
255 + RegSetValueExW(network, L"UserName", 0, REG_SZ, (const BYTE *)netres.lpRemoteName, len);
256 + RegCloseKey(network);
259 + RegCloseKey(user_profile);
267 @@ -2061,6 +2231,37 @@
273 + if (dwFlags & CONNECT_UPDATE_PROFILE)
276 + WCHAR *coma = strchrW(lpName, ':');
278 + if (coma && RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
283 + len = (ULONG_PTR)coma - (ULONG_PTR)lpName + sizeof(L"Network\\");
284 + subkey = HeapAlloc(GetProcessHeap(), 0, len);
287 + strcpyW(subkey, L"Network\\");
288 + memcpy(subkey + (sizeof(L"Network\\") / sizeof(WCHAR)) - 1, lpName, (ULONG_PTR)coma - (ULONG_PTR)lpName);
289 + subkey[len / sizeof(WCHAR) - 1] = 0;
291 + TRACE("Removing: %S\n", subkey);
293 + RegDeleteKeyW(user_profile, subkey);
294 + HeapFree(GetProcessHeap(), 0, subkey);
297 + RegCloseKey(user_profile);
305 @@ -2188,6 +2389,7 @@
306 /* find the network connection for a given drive; helper for WNetGetConnection */
307 static DWORD get_drive_connection( WCHAR letter, LPWSTR remote, LPDWORD size )
311 struct mountmgr_unix_drive *data = (struct mountmgr_unix_drive *)buffer;
313 @@ -2230,6 +2432,32 @@
318 + DWORD ret = WN_NO_NETWORK;
320 + WCHAR local[3] = {letter, ':', 0};
322 + if (providerTable != NULL)
324 + for (index = 0; index < providerTable->numProviders; index++)
326 + if(providerTable->table[index].getCaps(WNNC_CONNECTION) &
327 + WNNC_CON_GETCONNECTIONS)
329 + if (providerTable->table[index].getConnection)
330 + ret = providerTable->table[index].getConnection(
331 + local, remote, size);
333 + ret = WN_NO_NETWORK;
334 + if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
345 /**************************************************************************