tags:

views:

80

answers:

3

I inherited an application using a large number of texts based files for configuration. The file's names are constructed dynamically in the software, so I can't search directly for a file name if the source code.

Is there any way to break into a program running in the debugger when it touches a particular text file ?

+1  A: 

You can set a breakpoint at a specific location (such as calling the function to open the file) if a variable has a specific value.

Roger Pate
A: 

If you know the place where the files are being open or if the dynamically created file names are assigned to some variable, create an conditional breakpoint that breaks the code execution only if the filename is matching the file that you're interested in.

quosoo
can I use matching in a conditional break point?
Eli
String matching you mean? That depends on the tool, but even if not, you can add a line of code that does the matching and sets some integer variable based on that and than you break conditionaly on that integer value.
quosoo
Even simpler: Add `if (filename=="foo.cfg") { DebugBreak(); }`
MSalters
+1  A: 

In your debugger, set a breakpoint at the CreateFile (kernel32.dll) import.

OllyDbg specific:

Press CTRL + G, type in the function name and press F2.

arul