Browse Source

Cleanup

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
tags/3.3.5
Syrone Wong 8 years ago
parent
commit
217e818339
3 changed files with 19 additions and 35 deletions
  1. +14
    -13
      shadowsocks-csharp/Util/SystemProxy/RAS.cs
  2. +1
    -10
      shadowsocks-csharp/Util/SystemProxy/WinINet.cs
  3. +4
    -12
      shadowsocks-csharp/Util/Util.cs

+ 14
- 13
shadowsocks-csharp/Util/SystemProxy/RAS.cs View File

@@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace Shadowsocks.Util.SystemProxy
{
public static class RAS
internal static class RemoteAccessService
{
private enum RasFieldSizeConstants
{
@@ -69,22 +64,28 @@ namespace Shadowsocks.Util.SystemProxy
#endregion
public int dwSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=(int)RasFieldSizeConstants.RAS_MaxEntryName + 1)]
public string szEntryName;
public int dwFlags;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=(int)RasFieldSizeConstants.RAS_MaxPath + 1)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=(int)RasFieldSizeConstants.RAS_MaxPath + 1)]
public string szPhonebookPath;
}
[DllImport("rasapi32.dll", CharSet = CharSet.Auto)]
private static extern uint RasEnumEntries(
string reserved, // reserved, must be NULL
string lpszPhonebook, // pointer to full path and file name of phone-book file
[In, Out] RasEntryName[] lprasentryname, // buffer to receive phone-book entries
ref int lpcb, // size in bytes of buffer
out int lpcEntries // number of entries written to buffer
// reserved, must be NULL
string reserved,
// pointer to full path and file name of phone-book file
string lpszPhonebook,
// buffer to receive phone-book entries
[In, Out] RasEntryName[] lprasentryname,
// size in bytes of buffer
ref int lpcb,
// number of entries written to buffer
out int lpcEntries
);
/// <summary>


+ 1
- 10
shadowsocks-csharp/Util/SystemProxy/WinINet.cs View File

@@ -136,15 +136,6 @@ namespace Shadowsocks.Util.SystemProxy
// Notify the system that the registry settings have been changed and cause
// the proxy data to be reread from the registry for a handle.
// bReturn = NativeMethods.InternetSetOption(
// IntPtr.Zero,
// INTERNET_OPTION.INTERNET_OPTION_SETTINGS_CHANGED,
// IntPtr.Zero, 0);
// if ( ! bReturn )
// {
// Logging.Error("InternetSetOption:INTERNET_OPTION_SETTINGS_CHANGED");
// }
bReturn = NativeMethods.InternetSetOption(
IntPtr.Zero,
INTERNET_OPTION.INTERNET_OPTION_PROXY_SETTINGS_CHANGED,
@@ -167,7 +158,7 @@ namespace Shadowsocks.Util.SystemProxy
public static void SetIEProxy(bool enable, bool global, string proxyServer, string pacURL)
{
string[] allConnections = null;
var ret = RAS.GetAllConns(ref allConnections);
var ret = RemoteAccessService.GetAllConns(ref allConnections);
if (ret == 2)
throw new Exception("Cannot get all connections");


+ 4
- 12
shadowsocks-csharp/Util/Util.cs View File

@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Windows.Forms;
using Microsoft.Win32;
using Shadowsocks.Controller;
@@ -224,19 +221,14 @@ namespace Shadowsocks.Util
.OpenSubKey(name, writable);
return userKey;
}
catch (UnauthorizedAccessException uae)
{
Logging.LogUsefulException(uae);
return null;
}
catch (SecurityException se)
catch (ArgumentException ae)
{
Logging.LogUsefulException(se);
MessageBox.Show("OpenRegKey: " + ae.ToString());
return null;
}
catch (ArgumentException ae)
catch (Exception e)
{
MessageBox.Show("OpenRegKey: " + ae.ToString());
Logging.LogUsefulException(e);
return null;
}
}


Loading…
Cancel
Save