将功能断点分配给Windows DLL/API函数调用



我试图为每当调用kernel32.dll函数时设置一个断点。与此相似,当kernel32.dll函数称为

时获取callstack(s)

我分配了一个函数断点,但是在分配它后,它的符号说它们将永远不会被击中,而不会被击中。我需要在X86中进行操作,但甚至无法获得这个简单的64位工作。

我确实在工具 ->选项/调试/符号中检查了" Microsoft符号服务器",但缓存目录仍然为空。我认为这是问题,但不确定。如何确保正确加载DLL调试符号?

示例代码。

using System;
using System.Runtime.InteropServices;
namespace DebugAPI
{
  class Program
  {
    [DllImport("kernel32.dll")]
    public static extern System.UInt32 GetCurrentProcessorNumber();
    static void Main(string[] args)
    {
      var num = GetCurrentProcessorNumber();
      Console.WriteLine("Proc# " + num.ToString());
    }
  }  
}

我尝试了两种用于64位的功能断点的方法。kernel32!getCurrentProcessOrnumber{,, kernel32.dll} getCurrentProcessornumber

x86我尝试了以下内容{,, kernel32.dll} _getCurrentProcessornumber @4//不确定 @4是否正确

对于记录,这是以getCorrent processOrnumber为例设置断点的完整步骤。注意VS2017似乎具有X64平台目标的错误。必须是x86或anycpu。

  1. 在解决方案中,右键单击" yourproject" -> properties-> debug->"启用本机代码调试" =检查
  2. 在主菜单中,调试 ->选项 -> debugging->符号 ->" Microsoft符号服务器" =已检查。&分配缓存路径
  3. 添加功能断点debug->新断点 ->功能断点。

[名称选项]

[x86&x64] - 函数名称= kernel32!getCurrentProcessornumber语言= all

[x86]函数名称= {,, kernel32.dll)getCurrentProcessOrnumber语言= all

[x86]函数名称= _ntgetCurrentProcessornumber @ 0语言= alling(#after @ https://stackoverflow.com/a/a/40031574/1132334 Credit -dlatikay -dlatikay)

注意:第一次调试要下载符号需要一段时间。

最新更新