Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small program fixes #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PrivateWin10/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ public static void Main(string[] args)
else if (conRes == -1)
{
MessageBox.Show(Translate.fmt("msg_dupliate_session", Title), Title);
client.Close();
return; // no point in cintinuing without admin rights or an already running engine
}
}
Expand Down
4 changes: 2 additions & 2 deletions PrivateWin10/Core/WindowsFirewall/FirewallRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public static bool MatchPort(UInt16 numPort, string strPorts)
{
UInt16 beginPort = 0;
UInt16 endPort = 0;
if (UInt16.TryParse(strTemp[0], out beginPort) && UInt16.TryParse(strTemp[0], out endPort))
if (UInt16.TryParse(strTemp[0], out beginPort) && UInt16.TryParse(strTemp[1], out endPort))
{
if (beginPort <= numPort && numPort <= endPort)
return true;
Expand Down Expand Up @@ -605,4 +605,4 @@ public static string GetSpecialNet(string SubNet, NetworkMonitor.AdapterInfo Nic
return string.Join(",", IpRanges.ToArray());
}
}
}
}
14 changes: 7 additions & 7 deletions PrivateWin10/Core/WindowsFirewall/WinNetFwAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public RuleCompat(ushort fwApiVersion)

case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_WIN8:
case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_WIN10: Size = (int)Marshal.OffsetOf(typeof(FW_RULE), "OnNetworkNames"); break;

case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_THRESHOLD: Size = (int)Marshal.OffsetOf(typeof(FW_RULE), "wFlags2"); break;
case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_THRESHOLD2: Size = (int)Marshal.OffsetOf(typeof(FW_RULE), "RemoteOutServerNames"); break;
case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_REDSTONE1: Size = (int)Marshal.OffsetOf(typeof(FW_RULE), "wszFqbn"); break;

case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_THRESHOLD: Size = (int)Marshal.OffsetOf(typeof(FW_RULE), "wFlags2"); break;
case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_THRESHOLD2: Size = (int)Marshal.OffsetOf(typeof(FW_RULE), "RemoteOutServerNames"); break;
case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_REDSTONE1: Size = (int)Marshal.OffsetOf(typeof(FW_RULE), "wszFqbn"); break;
//case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_170x:
//case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_180x:
//case (ushort)FW_BINARY_VERSION.FW_BINARY_VERSION_19Hx:
Expand Down Expand Up @@ -806,7 +806,7 @@ private static FW_PORTS MakePortsArray(string portsStr, ref List<GCHandle> handl
{
ushort begin;
ushort end;
if (ushort.TryParse(portStr, out begin) && ushort.TryParse(portStr, out end))
if (ushort.TryParse(portRange[0], out begin) && ushort.TryParse(portRange[1], out end))
{
portRanges.Add(new PortRange()
{
Expand Down Expand Up @@ -838,7 +838,7 @@ private static FW_PORTS MakePortsArray(string portsStr, ref List<GCHandle> handl
portRangeArray[i].uEnd = portRanges[i].End;
}

ports.Ports.dwNumEntries = (ushort)portList.Count;
ports.Ports.dwNumEntries = (ushort)portRanges.Count;
handles.Add(GCHandle.Alloc(portRangeArray, GCHandleType.Pinned));
ports.Ports.pPorts = Marshal.UnsafeAddrOfPinnedArrayElement(portRangeArray, 0);
}
Expand Down