Skip to content

Commit b6c91b9

Browse files
committed
Windows 7 Temp-Fix
Temp Fix when using Win 7 (not exactly, but a check if it's a different than Win 10 or Windows Server)
1 parent 856f47b commit b6c91b9

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

WaGis IP-Blacklister/Form1.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Threading;
1515
using System.Threading.Tasks;
1616
using System.Windows.Forms;
17+
using Microsoft.Win32;
1718
using NetFwTypeLib;
1819
using Newtonsoft.Json.Linq;
1920

@@ -28,6 +29,8 @@ public partial class MainForm : Form
2829
int listindex = 0;
2930
string newV;
3031

32+
int BlockSize = 1000;
33+
3134
int protocolNumber = Properties.Settings.Default.Protocol_Number;
3235
string protDesc = Properties.Settings.Default.Protocol;
3336

@@ -39,7 +42,16 @@ public partial class MainForm : Form
3942
public MainForm()
4043
{
4144
InitializeComponent();
42-
lblInfo.Text = string.Empty;
45+
lblInfo.Text = string.Empty;
46+
}
47+
48+
static bool Win10orWinServer()
49+
{
50+
var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
51+
52+
string productName = (string)reg.GetValue("ProductName");
53+
54+
return (productName.Contains("Windows 10") || productName.Contains("Windows Server"));
4355
}
4456

4557
protected String WaGiRequest(string url)
@@ -79,6 +91,17 @@ private void MainForm_Load(object sender, EventArgs e)
7991
btnLoadSettings.PerformClick();
8092
///////////////////
8193

94+
///////////////////// WORKAROUND FOR DIFFERENT WINDOWS VERSIONS
95+
if (Win10orWinServer()) // [DIRTY FIX] If we use Windows 10 or Server, you can add 10k Rules instead of 1k like in Windows 7. I am not sure about versions between so i leave them at 1000 which is quite low. I need to find a better method to detect the BlockSize-Limit (Maximum IP's allowed per FireWall-Rule on different Windows Versions)
96+
{
97+
BlockSize = 10000;
98+
}
99+
else
100+
{
101+
BlockSize = 1000;
102+
MessageBox.Show("Seems you're not using Windows 10 or Windows Server.\nMaximum IP's per Rule will be reduced from 10k to 1k.\nNo worries, you can still use this Tool.");
103+
}
104+
82105
// Maybe Check for Updates - NOT DONE
83106
try
84107
{
@@ -201,13 +224,13 @@ private void btnADD_Click(object sender, EventArgs e)
201224
while (allips.Count >= 1)
202225
{
203226
List<string> list5k = new List<string>();
204-
list5k.AddRange(allips.Take(5000));
227+
list5k.AddRange(allips.Take(BlockSize));
205228
fiveklists.Add(list5k);
206-
if (allips.Count >= 5000)
229+
if (allips.Count >= BlockSize)
207230
{
208-
allips.RemoveRange(0, 5000);
231+
allips.RemoveRange(0, BlockSize);
209232
}
210-
else if (allips.Count > 0 && allips.Count < 5000)
233+
else if (allips.Count > 0 && allips.Count < BlockSize)
211234
{
212235
allips.RemoveRange(0, allips.Count);
213236
}
@@ -344,8 +367,7 @@ private void MakeRule(string str, int protNumber, NET_FW_RULE_DIRECTION_ ruleDir
344367
firewallPolicy.Rules.Add(Rule);
345368
}
346369
catch (Exception ex)
347-
{
348-
MessageBox.Show(ex.ToString());
370+
{
349371
throw;
350372
}
351373

WaGis IP-Blacklister/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
// You can specify all the values or you can default the Build and Revision Numbers
2121
// by using the '*' as shown below:
2222
// [assembly: AssemblyVersion("1.0.*")]
23-
[assembly: AssemblyVersion("1.3.1")]
24-
[assembly: AssemblyFileVersion("1.3.1")]
23+
[assembly: AssemblyVersion("1.3.2")]
24+
[assembly: AssemblyFileVersion("1.3.2")]

0 commit comments

Comments
 (0)