8

How to get PIDs of processes that are using a given file name and mutex name? (Not by custom kernel driver, but in C# in user mode.)

UPDATE: Thanks to Daniel Renshaw I found a script that lists all handles with PIDs. (Using a not undocumented and unfrozen functions.)

Community
  • 1
  • 1
TN.
  • 18,874
  • 30
  • 99
  • 157

1 Answers1

1

The following two SO questions may be of use:

How do I find out which process is locking a file using .NET?

Summary: use handle.exe and parse the output (i.e. not a great solution)

Win32: How to get the process/thread that owns a mutex?

Summary: may not be possible in user mode without using deprecated or undocumented functions (but some smaple code is provided in this question).

Community
  • 1
  • 1
Daniel Renshaw
  • 33,729
  • 8
  • 75
  • 94
  • Maybe I am wrong, but `handle.exe` does not seem to work well. I was trying running from a cmd `handle C:\Windows\System32\cmd.exe`. It says: `No matching handles found.` (I am using latest version.) And also does not seem to work for mutexes. How to make the script in the second post to print the handle names? – TN. Jun 10 '10 at 09:52