feat: integrate hook_is_running

main
paring 2023-05-28 17:33:49 +09:00
parent 8f96fc8bf0
commit c44be95ca0
Signed by: pikokr
GPG Key ID: 8C7ABCEF704FD728
3 changed files with 10 additions and 5 deletions

View File

@ -31,7 +31,7 @@ namespace SkyHook
/// <summary>
/// Whether the hook is active now.
/// </summary>
public bool isHookActive;
public bool isHookActive => SkyHookNative.HookIsRunning();
/// <summary>
/// Your callback for each key updated events.
@ -90,13 +90,12 @@ namespace SkyHook
_callback = HookCallback;
var result = SkyHookNative.StartHook(_callback);
if (result != null)
{
exception = new SkyHookException(result);
}
isHookActive = true;
started = true;
_mre.WaitOne();
@ -113,6 +112,7 @@ namespace SkyHook
while (!started && exception == null)
{
Thread.Yield();
}
if (exception != null)
@ -134,8 +134,6 @@ namespace SkyHook
{
_mre.Set();
}
isHookActive = false;
}
/// <summary>

View File

@ -29,5 +29,12 @@ namespace SkyHook
/// <returns><c>null</c> if no error, or an error message.</returns>
[DllImport(Lib, EntryPoint = "stop_hook", CallingConvention = CallingConvention.Cdecl)]
public static extern string StopHook();
/// <summary>
/// The native version of <see cref="SkyHookManager.StopHook"/> method handled by <see cref="SkyHookManager"/>.
/// </summary>
/// <returns><c>null</c> if no error, or an error message.</returns>
[DllImport(Lib, EntryPoint = "hook_is_running", CallingConvention = CallingConvention.Cdecl)]
public static extern bool HookIsRunning();
}
}

Binary file not shown.