Click here to Skip to main content
Licence 
First Posted 20 Sep 2005
Views 51,426
Bookmarked 19 times

Hex Editor in c#

By | 20 Sep 2005 | Article
This is a hex editor in c#

Introduction

The project I am submitting is a Hex Editor, and an accompanying ASCII linked window.

The Editor is derived from a RichTextBox, as is the Linked window. You set up each of them as you would a RichTextBox, and add the following code in the Forms Constructor (as you can see). The Hex Editor is independent of the Linked window, and does not require it to operate.

public Form1()
{
   <FONT color=#339933> //
    // Required for Windows Form Designer support
    //</FONT>
    InitializeComponent();

  <FONT color=#339933>  //
    // TODO: Add any constructor code after ..
    //</FONT>
    m_edtHex.InitializeComponent();
    m_edtASCII.InitializeComponent();
    m_edtHex.LinkDisplay(m_edtASCII);
    m_edtHex.LoadData(m_abyData);
}

The Hex Editor is comprised of a base class, HexEditBase. This is the class that is derived from the rich text box. All of the common operations are preformed here. HexEditBox and LinkedBox are derived from HexEditBase.

As you can see from the above sample the Hex Editor requires a buffer to operate on

<FONT color=#339933>/*
** Use this function if you already have the data you wish to edit
*/</FONT>
public void LoadData(byte[] abyData);

<FONT color=#339933>/*
** Use this function if just need to edit hex of some size
*/</FONT>
public void NewData(int iSize);

You can get the modified buffer using the function ArrayData which will return the buffer that the editor is working with.

public byte[] ArrayData

This is an example of the hex editor and associated Linked window. There are several context sensitive menus available when you right click on each of the windows;

 

Good luck and I hope that this code helps you – enjoy

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Glenn Inman

Web Developer

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 2 Pinmembermikkojay16:57 12 Sep '10  
GeneralNeeds a screen shot PinmemberAndrew Phillips18:51 7 Apr '08  
QuestionIs this Glenn Inman from FL? Pinmemberdvann8:09 27 Sep '05  
GeneralCode comments and missing article's image PinmemberNinjaCross4:48 21 Sep '05  

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.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 20 Sep 2005
Article Copyright 2005 by Glenn Inman
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid