请问如何在Ubuntu 上使用 libdbgshim.so

在Ubuntu 上,.NetCore 的可执行程序中,访问 libdbgshim.so 中的 GetStartupNotificationEvent,得到的返回结果不正确

代码为:

    static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");

        try
        {
            var startupEvent = IntPtr.Zero;
            var hr = dbgShimState.GetStartupNotificationEvent((uint)Process.GetCurrentProcess().Id, out startupEvent);

            Console.WriteLine($"hr is {hr}, startupEvent is {startupEvent}");
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }

public static class dbgShimState
{
    //[global::System.Runtime.InteropServices.DllImport("dbgshim.dll", EntryPoint = "GetStartupNotificationEvent")] ===> Windows 上用这个
    [global::System.Runtime.InteropServices.DllImport("libdbgshim.so", EntryPoint = "GetStartupNotificationEvent")]
    public static extern int GetStartupNotificationEvent(uint debuggeePID, out IntPtr phStartupEvent);
}

运行结果是:
hr is -2147467263, startupEvent is 0。

但是在Windows 上运行,结果是OK 的,
结果是 hr is 0, startupEvent is 1220。

请问这个差异是什么原因造成的,要如何解决?

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。