简体   繁体   English

在Visual Studio中的DLL中的函数处设置断点?

[英]Set breakpoint at function inside dll in Visual Studio?

I want to set a breakpoint at a specific function that's located in a dll. 我想在dll中的特定功能处设置断点。 The pdb's are public so I know the function name (say namespace1::namespace2::className::functionName ), but no sources. pdb是公共的,因此我知道函数名称(例如namespace1::namespace2::className::functionName ),但是没有源。

Is there a way to do this in Visual Studio? 在Visual Studio中有没有办法做到这一点?

I've tried "Breakpoints -> New -> Break at function". 我已经尝试过“断点->新建->功能中断”。 I wouldn't be asking had that worked. 我不会问这是否有效。 :) :)

void wrapper_func(parameters...){
    // call the real function
    std::cout<<"before call dll func"<<std::endl;
    namespace1::namespace2::className::functionName(parameters...);
    std::cout<<"after call dll func"<<std::endl;
}

then set breakpoint on wrapper_func.but you need to do some work to call the wrapper func instead of the dll func. 然后在wrapper_func上设置断点。但是您需要做一些工作来调用包装函数,而不是dll函数。

another way is set breakpoint on function address 另一种方法是在函数地址上设置断点

If you don't like to load the NT symbols, there is another method Get the relative address of the function in which you want to set breakpoint with some PE tools. 如果您不希望加载NT符号,则可以使用另一种方法来获取要使用某些PE工具设置断点的函数的相对地址。 For example, just type “dumpbin /exports C:\\Windows\\System32\\user32.dll” in the Visual Studio command line, you can get “RVA” of each exported symbol in “user32.dll”. 例如,只需在Visual Studio命令行中键入“ dumpbin / exports C:\\ Windows \\ System32 \\ user32.dll”,即可在“ user32.dll”中获取每个导出符号的“ RVA”。 For instance, “RVA” of “GetMessageW” is “000091C6”. 例如,“ GetMessageW”的“ RVA”是“ 000091C6”。

Now check the image base of “user32.dll” in the VS debugger's “Modules” windows, the values is “7E410000” on my laptop (Generally, the system dlls would not be relocated, so the image base value here is equal to the value written in PE file). 现在,在VS调试器的“模块”窗口中检查“ user32.dll”的映像库,在我的笔记本电脑上,该值为“ 7E410000”(通常不会重定位系统dll,因此此处的映像库值等于值写入PE文件)。 Then the starting address of “GetMessageW” is “7E410000+000091C6= 7E4191C6”. 然后,“ GetMessageW”的起始地址为“ 7E410000 + 000091C6 = 7E4191C6”。 Just set a function breakpoint at this address. 只需在此地址设置一个函数断点即可。 Then the debugger will stop when calling into “GetMessageW” 然后当调用“ GetMessageW”时调试器将停止

see this bolg 看到这个突击

You will need the Source Code Files which contains the function which you want to debug. 您将需要包含要调试功能的源代码文件。 pdb files has information/directions to get you to function. pdb files具有使您正常运行的信息/方向。 https://en.wikipedia.org/wiki/Program_database https://en.wikipedia.org/wiki/Program_database

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio中的DLL上设置断点? - How to set a breakpoint on a DLL in Visual Studio? 如何在Visual Studio中的匿名命名空间内按函数名设置断点? - How to set breakpoint by function name inside anonymous namespace in Visual Studio? Visual Studio 无法在断点中设置条件表达式 - Visual Studio unable to set conditional expression in breakpoint 在Visual Studio中有一种方法可以在通过GetModuleHandle + GetProcAddress调用的某个函数中设置断点吗? - In Visual Studio is there a way to set a breakpoint in some function called via GetModuleHandle + GetProcAddress? 是否可以在Visual Studio 2013中设置多个条件断点? - Is it possible to set a multiple conditions Breakpoint in Visual Studio 2013? 在局部变量值上设置Visual Studio(条件)断点 - Set Visual Studio (conditional) breakpoint on local variable value 如何在 Visual Studio 中设置依赖 DLL 路径? - How to set dependency DLL paths in Visual Studio? Visual Studio C++ 在主 function 末尾触发断点 - Visual Studio C++ trigger a breakpoint at the end of main function Visual Studio:断点不包括来自特定函数的调用 - Visual Studio: breakpoint excluding calls from a specific function 页面分配时的Visual Studio断点 - Visual Studio Breakpoint at page allocation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM