[英]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函数。
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”时调试器将停止
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.