fix: make HookManager.TrackedHooks thread-safe, might fix invalid CLR state

This commit is contained in:
goaaats 2022-01-12 18:33:40 +01:00
parent af4a25c74b
commit 0e95424704
No known key found for this signature in database
GPG key ID: F18F057873895461
4 changed files with 16 additions and 6 deletions

View file

@ -49,7 +49,7 @@ namespace Dalamud.Hooking
this.statsMethod.GetILGenerator().Emit(OpCodes.Ret);
var dele = this.statsMethod.CreateDelegate(typeof(Action));
HookManager.TrackedHooks.Add(new HookInfo(this, dele, Assembly.GetCallingAssembly()));
HookManager.TrackedHooks.TryAdd(Guid.NewGuid(), new HookInfo(this, dele, Assembly.GetCallingAssembly()));
}
/// <summary>
@ -79,7 +79,7 @@ namespace Dalamud.Hooking
this.statsMethod.GetILGenerator().Emit(OpCodes.Ret);
var dele = this.statsMethod.CreateDelegate(typeof(Action));
HookManager.TrackedHooks.Add(new HookInfo(this, dele, Assembly.GetCallingAssembly()));
HookManager.TrackedHooks.TryAdd(Guid.NewGuid(), new HookInfo(this, dele, Assembly.GetCallingAssembly()));
}
/// <summary>