Skip to content

Commit

Permalink
Fix startup crash on systems with no accessible network interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Klocman committed Mar 4, 2023
1 parent 4d348c7 commit 9c7b8a5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions source/BulkCrapUninstaller/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,20 @@ private static ulong GetUniqueUserId()
{
// Get an ID that is unlikely to be duplicate but that should always return the same on current pc
var windowsIdentity = WindowsIdentity.GetCurrent();
var networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
var idStr = windowsIdentity.User?.Value + string.Join("", windowsIdentity.Claims.Select(x => x.Value).Concat(networkInterfaces.Select(x => x.GetPhysicalAddress().ToString())));

string networkIdentity;
try
{
var networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
networkIdentity = string.Join("", networkInterfaces.Select(x => x.GetPhysicalAddress().ToString()));
}
catch (Exception e)
{
Console.WriteLine(e);
networkIdentity = e.ToString();
}

var idStr = windowsIdentity.User?.Value + string.Join("", windowsIdentity.Claims.Select(x => x.Value)) + networkIdentity;
return UninstallerRatingManager.Utils.StableHash(idStr);
}

Expand Down

0 comments on commit 9c7b8a5

Please sign in to comment.