Search code examples
windowsdebuggingwinapisysinternals

How to get file handle by path?


Sometimes during debugging I need to get handle value for known object (file or dll) opened by debugee. It can help to find who holds this handle.

How can I achieve that?


Solution

  • There is Sysinternals's utilities named Handle and Process Explorer.

    Handle has command line interface and should be used like this:

    handle [-p <pid>] <file path>
    

    To get handle value in Process Explorer:

    1. Go to main menu View -> Select Columns...
    2. Switch to Handle tab
    3. Check Handle Value
    4. Open Handle pane for desired process