fix: crash on windows

develop
paring 2022-11-10 18:10:35 +09:00
parent 5caebf2b34
commit 9fa6841266
Signed by: pikokr
GPG Key ID: 2C097B03E9D823C4
2 changed files with 14 additions and 3 deletions

View File

@ -40,6 +40,8 @@ namespace SkyHook
// ReSharper disable once MemberCanBePrivate.Global
public static readonly UnityEvent<SkyHookEvent> KeyUpdated = new();
private SkyHookNative.Callback _callback;
/// <summary>
/// The instance of <see cref="SkyHookManager"/>.
/// A new instance will be created if it does not exist.
@ -85,24 +87,32 @@ namespace SkyHook
{
try
{
var result = SkyHookNative.StartHook(HookCallback);
_callback = HookCallback;
var result = SkyHookNative.StartHook(_callback);
if (result != null)
{
exception = new SkyHookException(result);
}
isHookActive = true;
started = true;
_mre.WaitOne();
Debug.Log("Thread ended");
}
catch (Exception e)
{
exception = e;
Debug.LogError(e);
throw;
}
}).Start();
isHookActive = true;
started = true;
while (!started && exception == null)
{

View File

@ -10,6 +10,7 @@ namespace SkyHook
/// <summary>
/// The native callback handled by <see cref="SkyHookManager"/>.
/// </summary>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void Callback(SkyHookEvent ev);
private const string Lib = "skyhook";