diff options
Diffstat (limited to 'ARMeilleure/Signal/WindowsSignalHandlerRegistration.cs')
-rw-r--r-- | ARMeilleure/Signal/WindowsSignalHandlerRegistration.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ARMeilleure/Signal/WindowsSignalHandlerRegistration.cs b/ARMeilleure/Signal/WindowsSignalHandlerRegistration.cs new file mode 100644 index 00000000..959d1c47 --- /dev/null +++ b/ARMeilleure/Signal/WindowsSignalHandlerRegistration.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace ARMeilleure.Signal +{ + class WindowsSignalHandlerRegistration + { + [DllImport("kernel32.dll")] + private static extern IntPtr AddVectoredExceptionHandler(uint first, IntPtr handler); + + [DllImport("kernel32.dll")] + private static extern ulong RemoveVectoredExceptionHandler(IntPtr handle); + + public static IntPtr RegisterExceptionHandler(IntPtr action) + { + return AddVectoredExceptionHandler(1, action); + } + + public static bool RemoveExceptionHandler(IntPtr handle) + { + return RemoveVectoredExceptionHandler(handle) != 0; + } + } +} |