9.10 Spying on the Registry with RegMonAsk a private investigator what the best way to gather evidence is, and you're likely to get a simple answer: watch and wait. Unfortunately, trying to use RegEdt32 or RegEdit to watch the Registry as it changes is a difficult and unrewarding way to work. Unless you know ahead of time exactly which keys or values you want to watch, it's difficult to monitor individual changes, and there's no easy way to tell which application, process, or driver changed the setting you're trying to watch. Mark Russinovich and Bryce Cogswell have solved this problem, to the delight of administrators and programmers everywhere. They wrote a utility called RegMon (available with source code from http://www.sysinternals.com) that lets you spy on every Registry access made anywhere in the system. It can monitor reads, writes, and queries and record them in a log that you can peruse at will; it can also limit the Registry accesses it records based on filtering criteria you supply. RegMon makes short work of figuring out who modified a particular key or value, and it's a great resource for watching what the system's doing with Registry data. Figure 9.9. The RegMon main interfaceRegMon works by installing a small device driver when you run the application; this driver installs hooks to all the Registry API routines, so it can see what parameters callers pass in and what results the system returns. The RegMon application itself just opens the device driver and waits for it to send along the data it's captured. 9.10.1 Learning the RegMon InterfaceRegMon has an extremely simple interface. As you can see in Figure 9.9, it uses a single document window to display the Registry data it captures. The toolbar offers access to all six menu commands; the bulk of the window is devoted to the list of captured data. Each column of the list has its own header at the top of the list window; you can resize each column in the list by dragging the small vertical lines next to each header. Each entry in the list displays seven fields' worth of data:
9.10.1.1 Controlling what you seeBesides dragging the column headers to resize each individual column, RegMon doesn't offer much in the way of user interface. The EditClear Display command erases the current list of logged Registry accesses, and the OptionsAuto Scroll command toggles whether RegMon attempts to automatically scroll the displayed list to always show the most recently added item. 9.10.1.2 Some other useful Edit menu commandsThere are several other useful commands in the Edit menu, too:
9.10.2 Capturing and FilteringUsing RegMon to figure out what's going on in the Registry is a two-step process. The first step is optional: you may choose which events you want to see (and which you don't) by building a capture filter. RegMon applies this filter during the second step--the actual capture of events. 9.10.2.1 Turning capture on and offWhen you first start RegMon, it's in capture mode. If you just sit there for a minute and let it run, you see an occasional Registry access recorded in its window; you can see many more if you switch to Explorer and open a file, or even click on an icon in your My Computer window. If you leave RegMon in capture mode, it's likely to capture an overwhelming amount of data, much of which won't bear any relation to the data you're actually looking for. The best way to reduce this information overload is simple: turn off capture mode when you don't need it. The OptionsCapture Events command (Ctrl+E is its accelerator) toggles capture mode off and on (as does the toolbar button). 9.10.2.2 Using capture filtersThe EditFilter/Highlight... command is arguably the most useful command in the whole program. The Regmon Filter dialog (see Figure 9.10) lets you specify in detail which events you want to see in the capture list and which you don't. Figure 9.10. RegMon's filter dialogHere are the filter criteria you may specify:
9.10.2.3 Saving your captured dataRegMon can save its logged data as a tab-delimited text file. There's no provision for saving part of a log; you can either save every logged event, or none. This is easy to work around, though; all you need to do is define an appropriate capture filter before you capture data, then there won't be any extraneous stuff in your capture log. The FileSave... and FileSave As... commands let you save logged data to a file you specify. Unlike the Performance Monitor, there's no way to load a file of saved data for further review; you have to use a spreadsheet or text editor to view the saved data if you need it later. 9.10.2.4 Logging boot-to-boot activityIf you've ever wondered what happens behind Windows 2000's chunky-pixeled boot screens, RegMon gives you an easy way to find out. If you choose the EditLog Boot command, RegMon logs pretty much every Registry access from the beginning of the boot cycle. This generates a lot of data (25+ MB on a Windows 2000 Professional machine), but there's a lot of interesting stuff in there. |