Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
53X Again 32!
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor authored and Taiizor committed Mar 5, 2021
1 parent 9c0e1ef commit 03103fe
Show file tree
Hide file tree
Showing 112 changed files with 2,914 additions and 422 deletions.
62 changes: 29 additions & 33 deletions MAChanger/Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private Adapter(string AName)
{
AdapterName = AName;

ManagementObjectSearcher Searcher = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter WHERE Name='" + AdapterName + "'");
ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_NetworkAdapter WHERE Name='" + AdapterName + "'");
ManagementObjectCollection Found = Searcher.Get();
VAdapter = Found.Cast<ManagementObject>().FirstOrDefault();

Expand Down Expand Up @@ -71,10 +71,8 @@ public string RegistryMAC
{
try
{
using (RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(RegistryKey, false))
{
return RegKey.GetValue("NetworkAddress").ToString();
}
using RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(RegistryKey, false);
return RegKey.GetValue("NetworkAddress").ToString();
}
catch
{
Expand All @@ -94,46 +92,44 @@ public bool SetRegistryMAC(string Value, string Title)
}
else
{
using (RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(RegistryKey, true))
using RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(RegistryKey, true);
if (RegKey == null)
{
if (RegKey == null)
{
throw new Exception("Registry Key Could Not Be Opened!");
}
else if (RegKey.GetValue("AdapterModel") as string != AdapterName && RegKey.GetValue("DriverDesc") as string != AdapterName)
throw new Exception("Registry Key Could Not Be Opened!");
}
else if (RegKey.GetValue("AdapterModel") as string != AdapterName && RegKey.GetValue("DriverDesc") as string != AdapterName)
{
throw new Exception("Adapter Not Found in Registry!");
}
else
{
string Question = Value.Length > 0 ? "MAC Address of Adapter {0}: {1}\nChange New MAC Address To {2}?" : "Retract MAC Address Settings of Adapter {0}?";
DialogResult Proceed = MessageBox.Show(string.Format(Question, ToString(), GMAC, Value), Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (Proceed != DialogResult.Yes)
{
throw new Exception("Adapter Not Found in Registry!");
return false;
}
else
{
string Question = Value.Length > 0 ? "MAC Address of Adapter {0}: {1}\nChange New MAC Address To {2}?" : "Retract MAC Address Settings of Adapter {0}?";
DialogResult Proceed = MessageBox.Show(string.Format(Question, ToString(), GMAC, Value), Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (Proceed != DialogResult.Yes)
uint Result = (uint)VAdapter.InvokeMethod("Disable", null);
if (Result != 0)
{
return false;
throw new Exception("Adapter Could Not Be Disabled!");
}
else
{
uint Result = (uint)VAdapter.InvokeMethod("Disable", null);
if (Result != 0)
ShouldReenable = true;

if (Value.Length > 0)
{
throw new Exception("Adapter Could Not Be Disabled!");
RegKey.SetValue("NetworkAddress", Value, RegistryValueKind.String);
}
else
else if (!string.IsNullOrEmpty(RegKey.GetValue("NetworkAddress") as string))
{
ShouldReenable = true;

if (Value.Length > 0)
{
RegKey.SetValue("NetworkAddress", Value, RegistryValueKind.String);
}
else if (!string.IsNullOrEmpty(RegKey.GetValue("NetworkAddress") as string))
{
RegKey.DeleteValue("NetworkAddress");
}

return true;
RegKey.DeleteValue("NetworkAddress");
}

return true;
}
}
}
Expand Down Expand Up @@ -164,7 +160,7 @@ public override string ToString()

public static string CreateMAC()
{
Random RM = new Random();
Random RM = new();

byte[] Bytes = new byte[6];
RM.NextBytes(Bytes);
Expand Down
210 changes: 105 additions & 105 deletions MAChanger/LAST.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions MAChanger/LAST.resx
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,8 @@
<metadata name="BACK.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAQEAAAAEAIAAoQgAAFgAAACgAAABAAAAAgAAAAAEAIAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Expand Down
3 changes: 3 additions & 0 deletions MAChanger/MAChanger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
#if NET5_0 || NET6_0
Application.SetHighDpiMode(HighDpiMode.SystemAware);
#endif
Application.Run(new MAIN());
}
}
Expand Down
Loading

0 comments on commit 03103fe

Please sign in to comment.