Click here to Skip to main content
Click here to Skip to main content

JumpTo RegEdit

, 30 Aug 2007
Rate this:
Please Sign up or sign in to vote.
A Sysinternals JumpTo clone
Screenshot - RegEdit_JumpTo_Dlg.png

Introduction

Did you ever wonder how RegJump from Sysinternals works? I was quite amazed when I first saw that functionality and was wondering how this could be done in C#.

The library presented here uses Windows messages to automate Regedit. The content of the tree is read by TVM_GETITEM messages and the tree is navigated by issuing WM_Keyxx messages appropriately. The only tricky part is handling memory allocation for TVM_GETITEM. Because the message is sent to another process, the memory used by the message has to be allocated in the target process. Fortunately, this can be done by using VirtualAllocEx and providing a handle to the remote process.

Jeffrey Richter has an article on MSJ that describes in detail how it's done, Cory Nelson wrote an excellent article which is using the same technique and Chris Taylor had some interop code on his blog that I could use.

Using the Code

The following code fragment shows how the code from the sample project is used:

RegEditLocator.Locate(@"HKCU\SOFTWARE\Microsoft\.NETFramework");

Points of Interest

According to MSDN, the function OpenProcess requires SeDebugPrivilege to work. I tried to verify this by running the sample program on a normal user account in XP and was quite surprised that it worked. Repeating the same test in Vista gave me the expected result: the program will not work with a limited account.

Another issue I don't feel quite comfortable with is that the implementation is basically a hack that relies on internals of Regedit.exe. This means that any hotfix or security update from Microsoft can potentially break the code.

The code is meant to be more of a guide/example on how to automate an application using messages in C# than a library ready to be used in production code.

History

  • 30th August, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Reto Ravasio

Switzerland Switzerland
No Biography provided

Comments and Discussions

 
GeneralSweet - nicely done PinmemberMichael B. Hansen30-Aug-07 22:59 
GeneralRe: Sweet - nicely done PinmemberReto Ravasio31-Aug-07 12:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 30 Aug 2007
Article Copyright 2007 by Reto Ravasio
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid