Question

I need to list all open handles in current process. Since i could not find any function like "EnumHandles", I was thinking of making a loop from 0 to 1000. The question is how i can retrieve the name of each handle? I am using c++ and the OS is Win7 32-bit EDIT: The handle I need name of is a Mutex. By comparing the name of the mutex, i want to get the handle id I seem to have found solution using OpenMutex, but i don't know what to pass on 3rd parameter,

Was it helpful?

Solution

I believe you have to use the NTDLL.DLL. To my knowledge this is what all tools monitoring processes, handles and other system information, have to use in the end, under Windows. I used it in a small Win32 tool, however never had to list handles.

Check here for a good intro of that library and related to your question. http://forum.sysinternals.com/howto-enumerate-handles_topic18892.html

Also the GetObjectName function in the first post of http://forum.sysinternals.com/enumerate-opened-files_topic3577.html

Accessing this kind of information in Windows may seem to be a lot of work and looks frightening because Microsoft does not want to support it, but you will see that when the 'easy' API is not giving you what you need, you have to dig to NTDLL. This is what tools like ProcessExplorer use in the end. It is not so hard to use: load the DLL, get the right function pointers to fill the structs that you declare yourself with what you will find on the net.

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