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->addConnection3 = MPR_GETPROC(NPAddConnection3);
64 if (connectCap & WNNC_CON_CANCELCONNECTION)
65 provider->cancelConnection = MPR_GETPROC(NPCancelConnection);
67 + if (connectCap & WNNC_CON_GETCONNECTIONS)
68 + provider->getConnection = MPR_GETPROC(NPGetConnection);
70 TRACE("NPAddConnection %p\n", provider->addConnection);
71 TRACE("NPAddConnection3 %p\n", provider->addConnection3);
72 TRACE("NPCancelConnection %p\n", provider->cancelConnection);
74 debugstr_w(provider));
78 +static void _restoreSavedConnection(HKEY connection, WCHAR * local)
81 + DWORD type, prov, index, size;
83 + net.lpProvider = NULL;
84 + net.lpRemoteName = NULL;
85 + net.lpLocalName = NULL;
87 + TRACE("Restoring: %S\n", local);
89 + size = sizeof(DWORD);
90 + if (RegQueryValueExW(connection, L"ConnectionType", NULL, &type, (BYTE *)&net.dwType, &size) != ERROR_SUCCESS)
93 + if (type != REG_DWORD || size != sizeof(DWORD))
96 + if (RegQueryValueExW(connection, L"ProviderName", NULL, &type, NULL, &size) != ERROR_SUCCESS)
102 + net.lpProvider = HeapAlloc(GetProcessHeap(), 0, size);
103 + if (!net.lpProvider)
106 + if (RegQueryValueExW(connection, L"ProviderName", NULL, NULL, (BYTE *)net.lpProvider, &size) != ERROR_SUCCESS)
109 + size = sizeof(DWORD);
110 + if (RegQueryValueExW(connection, L"ProviderType", NULL, &type, (BYTE *)&prov, &size) != ERROR_SUCCESS)
113 + if (type != REG_DWORD || size != sizeof(DWORD))
116 + index = _findProviderIndexW(net.lpProvider);
117 + if (index == BAD_PROVIDER_INDEX)
120 + if (providerTable->table[index].dwNetType != prov)
123 + if (RegQueryValueExW(connection, L"RemotePath", NULL, &type, NULL, &size) != ERROR_SUCCESS)
126 + if (type != REG_SZ)
129 + net.lpRemoteName = HeapAlloc(GetProcessHeap(), 0, size);
130 + if (!net.lpRemoteName)
133 + if (RegQueryValueExW(connection, L"RemotePath", NULL, NULL, (BYTE *)net.lpRemoteName, &size) != ERROR_SUCCESS)
136 + size = strlenW(local);
137 + net.lpLocalName = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR) + 2 * sizeof(WCHAR));
138 + if (!net.lpLocalName)
141 + strcpyW(net.lpLocalName, local);
142 + net.lpLocalName[size] = ':';
143 + net.lpLocalName[size + 1] = 0;
145 + TRACE("Attempting connection\n");
147 + WNetAddConnection2W(&net, NULL, NULL, 0);
150 + HeapFree(GetProcessHeap(), 0, net.lpProvider);
151 + HeapFree(GetProcessHeap(), 0, net.lpRemoteName);
152 + HeapFree(GetProcessHeap(), 0, net.lpLocalName);
156 void wnetInit(HINSTANCE hInstDll)
158 static const WCHAR providerOrderKey[] = { 'S','y','s','t','e','m','\\',
169 + if (RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
172 + WCHAR subkey[8] = {'N', 'e', 't', 'w', 'o', 'r', 'k', 0};
174 + if (RegOpenKeyExW(user_profile, subkey, 0, KEY_READ, &network) == ERROR_SUCCESS)
178 + TRACE("Enumerating remembered connections\n");
180 + if (RegQueryInfoKey(network, NULL, NULL, NULL, &max, &size, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
184 + TRACE("There are %lu connections\n", max);
186 + local = HeapAlloc(GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR));
191 + for (index = 0; index < max; ++index)
193 + DWORD len = size + 1;
196 + TRACE("Trying connection %lu\n", index);
198 + if (RegEnumKeyExW(network, index, local, &len, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
201 + TRACE("It is %S\n", local);
203 + if (RegOpenKeyExW(network, local, 0, KEY_READ, &connection) != ERROR_SUCCESS)
206 + _restoreSavedConnection(connection, local);
207 + RegCloseKey(connection);
210 + HeapFree(GetProcessHeap(), 0, local);
214 + RegCloseKey(network);
217 + RegCloseKey(user_profile);
224 @@ -1875,6 +2009,43 @@
229 + if (ret == WN_SUCCESS && ctxt->flags & CONNECT_UPDATE_PROFILE)
233 + if (netres.dwType == RESOURCETYPE_PRINT)
235 + FIXME("Persistent connection are not supported for printers\n");
239 + if (RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
242 + WCHAR subkey[10] = {'N', 'e', 't', 'w', 'o', 'r', 'k', '\\', netres.lpLocalName[0], 0};
244 + if (RegCreateKeyExW(user_profile, subkey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &network, NULL) == ERROR_SUCCESS)
246 + DWORD dword_arg = RESOURCETYPE_DISK;
247 + DWORD len = (strlenW(provider->name) + 1) * sizeof(WCHAR);
249 + RegSetValueExW(network, L"ConnectionType", 0, REG_DWORD, (const BYTE *)&dword_arg, sizeof(DWORD));
250 + RegSetValueExW(network, L"ProviderName", 0, REG_SZ, (const BYTE *)provider->name, len);
251 + dword_arg = provider->dwNetType;
252 + RegSetValueExW(network, L"ProviderType", 0, REG_DWORD, (const BYTE *)&dword_arg, sizeof(DWORD));
253 + len = (strlenW(netres.lpRemoteName) + 1) * sizeof(WCHAR);
254 + RegSetValueExW(network, L"RemotePath", 0, REG_SZ, (const BYTE *)netres.lpRemoteName, len);
256 + RegSetValueExW(network, L"UserName", 0, REG_SZ, (const BYTE *)netres.lpRemoteName, len);
257 + RegCloseKey(network);
260 + RegCloseKey(user_profile);
268 @@ -2066,6 +2237,37 @@
274 + if (dwFlags & CONNECT_UPDATE_PROFILE)
277 + WCHAR *coma = strchrW(lpName, ':');
279 + if (coma && RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
284 + len = (ULONG_PTR)coma - (ULONG_PTR)lpName + sizeof(L"Network\\");
285 + subkey = HeapAlloc(GetProcessHeap(), 0, len);
288 + strcpyW(subkey, L"Network\\");
289 + memcpy(subkey + (sizeof(L"Network\\") / sizeof(WCHAR)) - 1, lpName, (ULONG_PTR)coma - (ULONG_PTR)lpName);
290 + subkey[len / sizeof(WCHAR) - 1] = 0;
292 + TRACE("Removing: %S\n", subkey);
294 + RegDeleteKeyW(user_profile, subkey);
295 + HeapFree(GetProcessHeap(), 0, subkey);
298 + RegCloseKey(user_profile);
306 @@ -2193,6 +2395,7 @@
307 /* find the network connection for a given drive; helper for WNetGetConnection */
308 static DWORD get_drive_connection( WCHAR letter, LPWSTR remote, LPDWORD size )
312 struct mountmgr_unix_drive *data = (struct mountmgr_unix_drive *)buffer;
314 @@ -2235,6 +2438,32 @@
319 + DWORD ret = WN_NO_NETWORK;
321 + WCHAR local[3] = {letter, ':', 0};
323 + if (providerTable != NULL)
325 + for (index = 0; index < providerTable->numProviders; index++)
327 + if(providerTable->table[index].getCaps(WNNC_CONNECTION) &
328 + WNNC_CON_GETCONNECTIONS)
330 + if (providerTable->table[index].getConnection)
331 + ret = providerTable->table[index].getConnection(
332 + local, remote, size);
334 + ret = WN_NO_NETWORK;
335 + if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
346 /**************************************************************************