Question

I am iterating over all the handles opened by my process after making sure that I have opened up a volume handle. During iteration, I use GetFinalPathNameByHandle() to receive information about object associated with the certain handle but as I see it this function only works with files and returns ERROR_INVALID_HANDLE (0x06) error in case of handles other than files. Am I right on this? If yes, then how can I check whether the handle in question is associated with volume so that I can close it?

Any help woudl be appreciated.

Was it helpful?

Solution

You are doing this all wrong. When you create a handle, remember it. When you are done with it, close it.

You cannot hope to be able to enumerate all open handles in your process and close a bunch of them that meet some criteria. You have no way of knowing whether or not the handle is in use. There will be handles open in your process that were not opened by your code. Closing such handles will lead to all sorts of pain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top