Handles can represent files, ports, mutexes and other objects. By using the undocumented Native API function NTQuerySystemInformation() you can list all open handles from all processes. Here’s a small program that does that.
This is basically a ported version of “HandleList” application by someone known as Napalm on sysinternals.com forums. I added and removed some bits, and translated it to Delphi.
The handle values returned by NTQuerySystemInformation are only meaningful to the processes that opened those handles, so we need to call DuplicateHandle to get our own copy of any given handle. Some handles can’t be duplicated, so this application won’t be able to retrieve their type/name. However, you could inject a DLL in those applications to analyze a handle in its owners’ context.
There’s a lot of possible improvements I can’t be bothered to make now 😛
Source code (7 KB, Delphi)