Browse Source

Misc

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
tags/3.3.3
Syrone Wong 8 years ago
parent
commit
10702a029c
3 changed files with 46 additions and 9 deletions
  1. +19
    -1
      shadowsocks-csharp/Util/SystemProxy/INTERNET_PER_CONN_OPTION.cs
  2. +27
    -2
      shadowsocks-csharp/Util/SystemProxy/INTERNET_PER_CONN_OPTION_LIST.cs
  3. +0
    -6
      shadowsocks-csharp/Util/SystemProxy/WinINet.cs

+ 19
- 1
shadowsocks-csharp/Util/SystemProxy/INTERNET_PER_CONN_OPTION.cs View File

@@ -76,7 +76,7 @@ namespace Shadowsocks.Util.SystemProxy
/// The StructLayout and FieldOffset attributes could help to decrease the struct size.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
public struct INTERNET_PER_CONN_OPTION_OptionUnion
public struct INTERNET_PER_CONN_OPTION_OptionUnion : IDisposable
{
// A value in INTERNET_OPTION_PER_CONN_FLAGS.
[FieldOffset(0)]
@@ -85,6 +85,24 @@ namespace Shadowsocks.Util.SystemProxy
public System.IntPtr pszValue;
[FieldOffset(0)]
public System.Runtime.InteropServices.ComTypes.FILETIME ftValue;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (disposing)
{
if (pszValue != IntPtr.Zero)
{
Marshal.FreeHGlobal(pszValue);
pszValue = IntPtr.Zero;
}
}
}
}
[StructLayout(LayoutKind.Sequential)]


+ 27
- 2
shadowsocks-csharp/Util/SystemProxy/INTERNET_PER_CONN_OPTION_LIST.cs View File

@@ -17,22 +17,47 @@
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Shadowsocks.Util.SystemProxy
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct INTERNET_PER_CONN_OPTION_LIST
public struct INTERNET_PER_CONN_OPTION_LIST : IDisposable
{
public int Size;
// The connection to be set. NULL means LAN.
public System.IntPtr Connection;
public int OptionCount;
public int OptionError;
// List of INTERNET_PER_CONN_OPTIONs.
public System.IntPtr pOptions;
public void Dispose()
{
Dispose( true );
GC.SuppressFinalize( this );
}
private void Dispose( bool disposing )
{
if ( disposing )
{
if ( Connection != IntPtr.Zero )
{
Marshal.FreeHGlobal( Connection );
Connection = IntPtr.Zero;
}
if ( pOptions != IntPtr.Zero )
{
Marshal.FreeHGlobal( pOptions );
pOptions = IntPtr.Zero;
}
}
}
}
}

+ 0
- 6
shadowsocks-csharp/Util/SystemProxy/WinINet.cs View File

@@ -121,12 +121,6 @@ namespace Shadowsocks.Util.SystemProxy
intptrStruct, optionListSize);
// Free the allocated memory.
foreach (var v in _optionlist)
{
// free strings
if (v.Value.pszValue != IntPtr.Zero)
Marshal.FreeHGlobal(v.Value.pszValue);
}
Marshal.FreeCoTaskMem(buffer);
Marshal.FreeCoTaskMem(intptrStruct);


Loading…
Cancel
Save