mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-19 15:51:45 +00:00
BepInEx.IL2CPP: Fix mutex checks
This commit is contained in:
1 parent
8dc326c652
commit
b80f29784c
2 files changed
+22
-3
No files matched your search
@@ -320,6 +320,23 @@ public static class Utility
|
||||
return ByteArrayToString(md5.Hash);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash a list of strings using MD5
|
||||
/// </summary>
|
||||
/// <param name="strings">Strings to hash</param>
|
||||
/// <returns>MD5 of the strings</returns>
|
||||
public static string HashStrings(params string[] strings)
|
||||
{
|
||||
using var md5 = MD5.Create();
|
||||
|
||||
foreach (var str in strings)
|
||||
md5.TransformBlock(Encoding.UTF8.GetBytes(str), 0, str.Length, null, 0);
|
||||
|
||||
md5.TransformFinalBlock(new byte[0], 0, 0);
|
||||
|
||||
return ByteArrayToString(md5.Hash);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the given array to a hex string.
|
||||
/// </summary>
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using BepInEx;
|
||||
using BepInEx.IL2CPP;
|
||||
using BepInEx.Preloader.Core;
|
||||
|
||||
@@ -25,9 +26,10 @@ internal static class Entrypoint
|
||||
silentExceptionLog =
|
||||
Path.Combine(Path.GetDirectoryName(EnvVars.DOORSTOP_PROCESS_PATH), silentExceptionLog);
|
||||
|
||||
mutex = new Mutex(false,
|
||||
Process.GetCurrentProcess().ProcessName + EnvVars.DOORSTOP_PROCESS_PATH +
|
||||
typeof(Doorstop.Entrypoint).FullName);
|
||||
var mutexId = Utility.HashStrings(Process.GetCurrentProcess().ProcessName, EnvVars.DOORSTOP_PROCESS_PATH,
|
||||
typeof(Entrypoint).FullName);
|
||||
|
||||
mutex = new Mutex(false, $"Global\\{mutexId}");
|
||||
mutex.WaitOne();
|
||||
|
||||
UnityPreloaderRunner.PreloaderMain();
|
||||
|
||||
Reference in new issue
Block a user