using System;
using System.Runtime.InteropServices;

namespace MoonlitAttach {
    // Detection only. Does not map/read the handler address or change the process.
    public static class NativeCapability {
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        static extern IntPtr OpenFileMapping(uint access, bool inherit, string name);
        [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
        public static bool HasDebugHandler(int processId) {
            var handle = OpenFileMapping(4, false, "node-debug-handler-" + processId);
            if (handle == IntPtr.Zero) return false;
            CloseHandle(handle);
            return true;
        }
    }
}
