Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the file handles of given process [duplicate]

Tags:

c#

winapi

I need a way for getting all of the file handles of a given process.

for example, given a the winword.exe process handle, i would like to get the list of the file handles of that process (doc files etc).

i'm using the Win32 api via C#/pInvoke.

Thanks!

like image 576
Rubinsh Avatar asked Nov 21 '09 10:11

Rubinsh


1 Answers

An easy solution would be to use handle.exe and read its output. Another solution is to use P/Invoke with NtQuerySystemInformation function. This and this forum post on SysInternals has more details as well as this article on CodeProject. Doing it in managed code could be very difficult as you will need to write a driver to read the kernel address space.

I would suggest you to expose the needed functionality in a Win32 function that you could call from managed code.

like image 157
Darin Dimitrov Avatar answered Oct 13 '22 20:10

Darin Dimitrov