diff --git a/ArchiSteamFarm/Plugins/PluginsCore.cs b/ArchiSteamFarm/Plugins/PluginsCore.cs index 477aae406..56737bee4 100644 --- a/ArchiSteamFarm/Plugins/PluginsCore.cs +++ b/ArchiSteamFarm/Plugins/PluginsCore.cs @@ -64,18 +64,18 @@ internal static class PluginsCore { throw new InvalidOperationException(nameof(ASF.GlobalConfig)); } - string resourceName = OS.GetOsResourceName(objectName); - // The only purpose of using hashing here is to cut on a potential size of the resource name - paths can be really long, and we almost certainly have some upper limit on the resource name we can allocate // At the same time it'd be the best if we avoided all special characters, such as '/' found e.g. in base64, as we can't be sure that it's not a prohibited character in regards to native OS implementation // Because of that, SHA256 is sufficient for our case, as it generates alphanumeric characters only, and is barely 256-bit long. We don't need any kind of complex cryptography or collision detection here, any hashing will do, and the shorter the better if (!string.IsNullOrEmpty(Program.NetworkGroup)) { // ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework - resourceName += $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(Program.NetworkGroup!)))}"; + objectName += $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(Program.NetworkGroup!)))}"; } else if (!string.IsNullOrEmpty(ASF.GlobalConfig.WebProxyText)) { - resourceName += $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(ASF.GlobalConfig.WebProxyText!)))}"; + objectName += $"-{Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(ASF.GlobalConfig.WebProxyText!)))}"; } + string resourceName = OS.GetOsResourceName(objectName); + if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { return new CrossProcessFileBasedSemaphore(resourceName); }