文件修改或文件打开时的断点
我想在特定文件的文件修改或打开特定文件时设置断点。这是我们的软件在部分遗留代码期间打开和修改的文件。我不太确定如何解决这个问题。我考虑过的一种方法是找到我们打开文件的所有位置,对所有位置进行中断,然后检查文件路径以确定它是否是我们关心的路径。我想到的另一种方法是,当路径与我关心的路径匹配时,尝试在文件系统打开代码中设置断点(可能更困难,因为我目前在 Windows 下运行。这可能是 Linux 下的一个选项,但是Visual Studio 2005 解决方案是理想的解决方案,Linux 解决方案可能有用)。
目前,我正在使用 Visual Studio 2005 来完成我的 C++ 软件项目。我在网上找不到任何有关此选项或人们愿意采取的方法的信息。
通常,我会说我应该只了解该文件在哪里打开。不幸的是,这部分代码非常难以理解,并且将被重构,但在不久的将来,此功能将对我有所帮助。
非常感谢您阅读我的问题,
-Brian J. Stinar-
I would like to set a break point on file modification for a particular file, or on opening a particular file. This is a file which our software opens and modifies during portions of legacy code. I'm not exactly sure how to approach this problem. One approach I have thought about was to find all of the places where we are opening files, break on all of them, and inspect the file path to determine if it is the path we are concerned with. The other approach I was thinking was to attempt to set a break point in the file system opening code when the path matches what I am concerned with (possibly more difficult, as I am presently running under Windows. This might be an option under Linux but a Visual Studio 2005 solution would be ideal and a Linux solution potentially useful).
Presently, I am using Visual Studio 2005 for my software project in C++. I was not able to find anything online about this as an option or an approach people would like to take.
Normally, I would say that I should just understand where this file is being opened. Unfortunately this section of code is quite difficult to understand and will be re-factored, but for the immediate future this functionality would help me.
Thank you very much for reading my question,
-Brian J. Stinar-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在kernel32.CreateFileW处设置条件断点并检查文件名。
然后你将获得文件句柄,因此你可以在 kernel32.CreateFileW 处放置条件断点并检查文件句柄。
您还可以挂钩 CreateFileW 并在其中调用 __debugbreak() 。
Put conditional breakpoint to kernel32.CreateFileW and check file name.
Then you will get file handle, so you can put conditional breakpoint to kernel32.CreateFileW and check file handle.
Also you can hook CreateFileW and call __debugbreak() in it.