From: Pierre Schweitzer Date: Mon, 31 Oct 2016 21:20:32 +0000 (+0000) Subject: [MPR] X-Git-Tag: ReactOS-0.4.4-FOSDEM2017~437 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=fdc18e536d37c9a6a7be04baa797d858e8f5086f [MPR] Delete saved connection on disconnection if asked (even though the resource wasn't connected). This allows net use to properly remove connections it may have created. CORE-11757 svn path=/trunk/; revision=73092 --- diff --git a/reactos/dll/win32/mpr/mpr_ros.diff b/reactos/dll/win32/mpr/mpr_ros.diff index 230e5edaca5..f7cdf9d1f5a 100644 --- a/reactos/dll/win32/mpr/mpr_ros.diff +++ b/reactos/dll/win32/mpr/mpr_ros.diff @@ -113,7 +113,45 @@ Index: wnet.c return ret; } -@@ -2188,6 +2221,7 @@ +@@ -2061,6 +2094,37 @@ + } + } + } ++#ifdef __REACTOS__ ++ ++ if (dwFlags & CONNECT_UPDATE_PROFILE) ++ { ++ HKEY user_profile; ++ WCHAR *coma = strchrW(lpName, ':'); ++ ++ if (coma && RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS) ++ { ++ WCHAR *subkey; ++ DWORD len; ++ ++ len = (ULONG_PTR)coma - (ULONG_PTR)lpName + sizeof(L"Network\\"); ++ subkey = HeapAlloc(GetProcessHeap(), 0, len); ++ if (subkey) ++ { ++ strcpyW(subkey, L"Network\\"); ++ memcpy(subkey + (sizeof(L"Network\\") / sizeof(WCHAR)) - 1, lpName, (ULONG_PTR)coma - (ULONG_PTR)lpName); ++ subkey[len / sizeof(WCHAR) - 1] = 0; ++ ++ TRACE("Removing: %S\n", subkey); ++ ++ RegDeleteKeyW(user_profile, subkey); ++ HeapFree(GetProcessHeap(), 0, subkey); ++ } ++ ++ RegCloseKey(user_profile); ++ } ++ } ++ ++#endif + return ret; + } + +@@ -2188,6 +2252,7 @@ /* find the network connection for a given drive; helper for WNetGetConnection */ static DWORD get_drive_connection( WCHAR letter, LPWSTR remote, LPDWORD size ) { @@ -121,7 +159,7 @@ Index: wnet.c char buffer[1024]; struct mountmgr_unix_drive *data = (struct mountmgr_unix_drive *)buffer; HANDLE mgr; -@@ -2230,6 +2264,32 @@ +@@ -2230,6 +2295,32 @@ } CloseHandle( mgr ); return ret; diff --git a/reactos/dll/win32/mpr/wnet.c b/reactos/dll/win32/mpr/wnet.c index ae281e3a8da..07c0844886f 100644 --- a/reactos/dll/win32/mpr/wnet.c +++ b/reactos/dll/win32/mpr/wnet.c @@ -2094,6 +2094,37 @@ DWORD WINAPI WNetCancelConnection2W( LPCWSTR lpName, DWORD dwFlags, BOOL fForce } } } +#ifdef __REACTOS__ + + if (dwFlags & CONNECT_UPDATE_PROFILE) + { + HKEY user_profile; + WCHAR *coma = strchrW(lpName, ':'); + + if (coma && RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS) + { + WCHAR *subkey; + DWORD len; + + len = (ULONG_PTR)coma - (ULONG_PTR)lpName + sizeof(L"Network\\"); + subkey = HeapAlloc(GetProcessHeap(), 0, len); + if (subkey) + { + strcpyW(subkey, L"Network\\"); + memcpy(subkey + (sizeof(L"Network\\") / sizeof(WCHAR)) - 1, lpName, (ULONG_PTR)coma - (ULONG_PTR)lpName); + subkey[len / sizeof(WCHAR) - 1] = 0; + + TRACE("Removing: %S\n", subkey); + + RegDeleteKeyW(user_profile, subkey); + HeapFree(GetProcessHeap(), 0, subkey); + } + + RegCloseKey(user_profile); + } + } + +#endif return ret; }