views:

125

answers:

2

Hi,

We are using a third part library to render 3d. In this library there is a "memory tracker" functionality that keeps track of all memory the library has allocated and freed during execution. This is a nice feature, since it helps by determining e.g. memory leaks.

By calling a certain function in this library a log file is generated in the current working directory of the process. Lately I've noticed that this file shows up in several different places, so my first thought was of course to always set the current working directory to the folder I want the log to show up in, and this works fine.

However, it turns out that this file is still created in various places without above mentioned function ever being called by the program. Hence, the file must somehow be created by the library without my consent. The creator of this library says that the engine never calls this method internally.

So, in order to prove him wrong (alternatively proving myself to be stupid (won't be the first time though)), I need a way to catch exactly when this file is created. FindFirstChangeNotification() will not do, since this will only provide me with information that something happened in some folder. Ideally I'd like to (either in process or out of process) intercept when this happens and somehow inject a process exception (e.g. make WinDbg catch this), so I through the callstack get the information I want.

Any suggestions are welcome.

Cheers!

+3  A: 

You could try:

  1. Use a tool like FileMon or Process Explorer, they might be enough to track it down.
  2. Use a hooking a library and replace CreateFile (or more functions if you need to) with your own function. I've had good experience with Detours, it has some really nice examples that you could use straight out of the box.
Idan K
+2  A: 
nhaa123
+1 for code sample. But daniel was first, sorry :)
Magnus Skog