09.02.2014 Views

Windows sysinternals

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

256 Part II Usage Guide<br />

Handle<br />

Handle is a console utility that displays information about object handles held by processes<br />

on the system. Handles represent open instances of basic operating system objects that<br />

applications interact with, such as files, registry keys, synchronization primitives, and shared<br />

memory. You can use the Handle utility to search for programs that have a file or folder<br />

open, preventing its access or deletion from another program. You can also use Handle to list<br />

the object types and names held by a particular program. For more information about object<br />

handles, see “Handles” in Chapter 2.<br />

Because the primary purpose for Handle is to identify in-use files and folders, running<br />

Handle without any command-line parameters lists all the File and named Section handles<br />

owned by those processes. Handle’s command-line parameters in various combinations<br />

allow you to list all object types, search for objects by name, limit which process or processes<br />

to include, display handle counts by object type, show details about pagefile-backed<br />

Section objects, display the user name with the handle information, or (although generally<br />

ill- advised) close open handles.<br />

Note that loading a DLL or mapping another file type into a process’ address space via<br />

the LoadLibrary API does not also add a handle to the process’ handle table. Such files can<br />

therefore be in use and not be able to be deleted, even though a handle search might come<br />

up empty. ListDLLs, described earlier in this chapter, can identify DLLs loaded as executable<br />

images. More powerfully, Process Explorer’s Find feature searches for both DLL and<br />

handle names in a single operation, and it includes DLLs mapped as data. Process Explorer is<br />

described in Chapter 3.<br />

Handle List and Search<br />

The command-line syntax to list object handles is<br />

handle [-a [-l]] [-p process|PID] [[-u] objname]<br />

If you specify no command-line parameters, Handle lists all processes and all the File and<br />

named Section handles owned by those processes, with dashed-line separators between the<br />

information for each process. For each process, Handle displays the process name, PID, and<br />

account name that the process is running under, followed by the handles belonging to that<br />

process. The handle value is displayed in hexadecimal, along with the object type and the<br />

object name (if it has one).<br />

“File” handles can include folders, device drivers, and communication endpoints, in addition<br />

to normal files. File handle information also includes the sharing mode that was set when<br />

the handle was opened. The parenthesized sharing flags can include R, W, or D, indicating<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!