aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Cpu/Signal/WindowsSignalHandlerRegistration.cs
blob: 1fbce0f72f03c34a779b677e4ddb264e87b971d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Runtime.InteropServices;

namespace Ryujinx.Cpu.Signal
{
    static partial class WindowsSignalHandlerRegistration
    {
        [LibraryImport("kernel32.dll")]
        private static partial IntPtr AddVectoredExceptionHandler(uint first, IntPtr handler);

        [LibraryImport("kernel32.dll")]
        private static partial ulong RemoveVectoredExceptionHandler(IntPtr handle);

        public static IntPtr RegisterExceptionHandler(IntPtr action)
        {
            return AddVectoredExceptionHandler(1, action);
        }

        public static bool RemoveExceptionHandler(IntPtr handle)
        {
            return RemoveVectoredExceptionHandler(handle) != 0;
        }
    }
}