CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 5 1234 ... LastLast
Results 1 to 15 of 67
  1. #1
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Hex Viewer / Editor

    After having read the discution with Rich and Wizbang on this thread, i rememberd one of those shelved progects that I have (I'm trying to either complete or trash and delete them all ).

    I've done some work on a Hex Editor, and it's not looking too bad( 1k Viewer block), only prob is screen update times, the update rolls down the screen (even on a P4 2.4Ghz) .

    Any help with this will be greatly apreciated... (Also comments and sugestions on any extra's I should put in, would be nice.. )

    Functions like Search and Replace are definites that will be put in, eventually . I figure getting the core running smoothly first. then add these functions around that...

    Thanks...

    Gremmy..
    Last edited by GremlinSA; January 7th, 2006 at 03:04 PM. Reason: New Version of file on later Post..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Wow...out of memory error...

    I do have a few other things running right now, but I can see why the updates go slowly anyway. All those boxes loading, and changing all of them as you scroll through the file will be slower than one would want.

    When I needed a Hex viewer with a certain function (at the moment I'm not sure of the exact reason), I whipped up a quick one. I never got around to doing the editor part. What I did was to use a single textbox for the entire thing. A fixed-width font makes everything line up perfectly. That saves a lot over all those seporate boxes. There is an even better way though - use a picturebox, and draw the text into it. Then you can even use colors if you want. It helps also with a more convenient way to scroll, as I ended up with two scrollbars. However, editing would be a different matter since you'd have to use a seporate textbox for typing into. If you want it to look as though the textbox is part of the viewer box, you would have to line it up according to where the user clicks to edit. That's not as hard as it might sound, but still would obviously take more work than a textbox for displaying. Someday maybe I'll get around to it...but probably not.

    Anyway, here's a screenshot of how it looks the way I did it:
    Attached Images Attached Images  
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    Wow...out of memory error...

    I do have a few other things running right now, but I can see why the updates go slowly anyway. All those boxes loading, and changing all of them as you scroll through the file will be slower than one would want.

    When I needed a Hex viewer with a certain function (at the moment I'm not sure of the exact reason), I whipped up a quick one. I never got around to doing the editor part. What I did was to use a single textbox for the entire thing. A fixed-width font makes everything line up perfectly. That saves a lot over all those seporate boxes. There is an even better way though - use a picturebox, and draw the text into it. Then you can even use colors if you want.
    Not sure why Out of memory... Runs fine (used it for +- 1 hour yesterday) on my system, but i'll look into that..

    Thanks for the advice.. I may just use a Rich text box or the picture method..

    Gremmy...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Well i've changed the display to two Rich Text Boxes only.. 1 for Hex, 1 for data.. the display load times has been greatly increased.. Now it's just taking time to convert all the hex editing code to work with single text boxes..

    Thanks Wiz.. its looking much better... will repost when finished the hex editor part..

    Grem.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #5
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Lightbulb Re: Hex Viewer / Editor

    Well I think the editing code is complete, 99% debugged..

    Still waiting for sujestions on what should be included as aditional functions...

    Wiz.. Give this a go....

    Gremmy..

    ----- Edit -----
    New file in later post....
    Last edited by GremlinSA; January 15th, 2006 at 04:41 AM. Reason: Newer File in later post
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  6. #6
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Much improved over the last one for sure

    Two issues which I found are that it requires more space than my resolution offers, so I can't see the entire box on the right side. The other thing I noticed is that if you make some changes, then discard them (clear changes), the entire Hex code box has the red characters used to indicate the edited portions. I do like the way navigation works within the "page", though if I was doing this I'd make the thing scroll one line at a time. That would really help keep ones' place while scrolling. In the one I did, I intended to make the ScrollBar do both, such that the buttons scrolled one line at a time, and the LargeChange would be the amount of one page. As stated, I really never finished the program.

    Now, as for suggestions of additional features, I'd add a "Jump To..." thing, so you can skip to any spot in the file. Make it accept Hex or decimal values. Also enable copy/cut/paste/delete, so you can highlight a group of bytes, and do whatever with them. Let's not forget about appending data to the end of the file. Of course, the search stuff you mentioned is a must. It would be interesting to try to make it searchable by bits as well as bytes. How about editing a value with logical operators like And, Or, Xor, Not, etc? The tricky part about that might be when you have a 32 bit value as opposed to an eight bit value, so I guess it could work by the number of bytes selected.

    I guess that's enough to keep you busy for now
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  7. #7
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Thanks for the info Wiz.. With the width problem, Im thinking of changing the view to allow 32 byte wide (1024 bytes total) or 16 byte wide (512 bytes total) to allow for smaller res. I did the 32 byte width mostly for unicode files.. (You get 16 characters rather than 8).

    I still need to workout some code to handel multiple blocks on the editor with out having to reload it with each scroll..

    Single line scroll sounds like a good idea too.. will work that in..

    Looks like i got a bit of work set out for me.....

    Thanks

    Gremmy...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  8. #8
    Join Date
    Oct 2005
    Location
    England
    Posts
    803

    Re: Hex Viewer / Editor

    As an additional function, coverting strings to Hex values and back again would be handy when writing values to the file.

    Why not even make an "open as Hex" object for VB6 with all the string search functions in and file save functions. Just pass the file into the object and magic .


    Rich
    Last edited by Rich2189; January 8th, 2006 at 08:22 AM.

  9. #9
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Quote Originally Posted by Rich2189
    As an additional function, coverting strings to Hex values and back again would be handy when writing values to the file.
    Actually, it does! I hadn't checked until now, but you can type in the ACSII view too (the right side).

    Kudos GremlinSA. I'm looking forward to your next update.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  10. #10
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    Actually, it does! I hadn't checked until now, but you can type in the ACSII view too (the right side).
    Yep.. One of the first things i did.. what use is a hex editor if you can only enter hex data..

    Quote Originally Posted by WizBang
    Kudos GremlinSA. I'm looking forward to your next update.
    Well here it is.. still far from final.. i've included a popup on the Ascii side to Copy, Paste, Fill, Delete and Clear changes..

    I've given the Multiblock reading a hit and a miss... Too much code to debug, and made a mess of things every now and then.. I simply loaded from file with the line scroll's (Goto the last block and press down or right). (When i eventualy do the API file read it should be faster..)

    I debugged most of the nigglies out of the editor.. working 99.99% now.. (Will never say 100 <--- theres almost always something that is not perfect)

    Still lots to go, Find and replace must still be added (After the API read i think) and i'm thinking of adding a image decoder too.. (select a block of data and open as image, only for the bit mapped images, Like font files..)

    ------- WOW 21 Downloads of this Buggy version --- Get the newer file in a later post..
    Last edited by GremlinSA; January 22nd, 2006 at 03:18 PM.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  11. #11
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Quote Originally Posted by GremlinSA
    Still lots to go, Find and replace must still be added (After the API read i think) and i'm thinking of adding a image decoder too.. (select a block of data and open as image, only for the bit mapped images, Like font files..)
    Funny, I was thinking along those lines as well. My thought was to have a search thing that could locate known headers/GUIDs/markers and such. It can work for BMP, JPEG, GIF, WAV, and other things like mp3's too. There could be an INI file to hold the identifiers, so the user can add to the list. That just emphasizes the need for an "Extract Segment..." function, to pull out such data.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  12. #12
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    I'd add a "Jump To..." thing, so you can skip to any spot in the file. Make it accept Hex or decimal values. [ Done ]

    Also enable copy/cut/paste/delete, so you can highlight a group of bytes, and do whatever with them. [ Done ]

    Let's not forget about appending data to the end of the file. Of course, the search stuff you mentioned is a must. It would be interesting to try to make it searchable by bits as well as bytes.

    How about editing a value with logical operators like And, Or, Xor, Not, etc? The tricky part about that might be when you have a 32 bit value as opposed to an eight bit value, so I guess it could work by the number of bytes selected. [ Doing ]

    I guess that's enough to keep you busy for now
    As you can see i've been busy with this.. BUT..

    Cut and Delete ?? Been a hex editor i do not want to alter the file by deleteing characters in the middle, thus reducing file size (Data shifting)..
    Delete simply puts 'H00' in place... And cut becomes non functional.. Paste will overwrite bytes according to the length of text in the clipboard.. Also included is a fill function..(Any hex Value)..

    Logic opperators i'm currently working on .. Hmmm .. Logic Not takes only one input so this is not posible.. And i dont fancy building a large logic gating system to allow out = not(X or (Y and Z)) ..

    With the Append to file.. I'm contemplating putting a menu item to select Current pos as end (Page can scroll to have almost 1K extra after last Byte..) and adding 1K pages at a time *** you need the space.. What do you think ???

    After the Logics are done i will repost the Project for you to review again..

    Thanks

    Gremmy...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  13. #13
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Well I managed to find some time today to carry on with the HEX editor..

    I've compleated most of it.. It still needs a bit if debugging.. found an issue with Ctrl+C and Ctrl+V screwing things around in the editor. For the moment I only trap and flush them.. (I may redirect them to the Copy and Paste routines at a later stage) Like i said before 99% debugged

    I've updated the file acces to use the Readfile and Writefile API's (Small but noticable speed difference). tweeked a few things and got a good working base for the editor..

    But now i'm stumped on the Find in File code... I've got a form to enter up to 100 charaters to find(Hex or Ascii).. I search the current Page of Hex data and if found, show it(I'm using Instr to search).. but now i'm not sure what direction to go..Some help and advice here please

    Also i'm sure that some of the Popup menu code can be Tweeked to perform a bit faster, without loosing any of the functionality. (Ie. Colour highlighting, updating hex and Ascii fields).

    The Paste code stops at the end of the Ascii block loaded.. I not sure what direction to take here.. (Prompt to write current block to file, and continue or move the begining of the block to the first Position and starting the Paste from there).

    Also has anyone got any advice (or Code snips) for the Image decoder idea.. I'm still not to sure where to start with this..


    Thanks

    Gremmy.....

    ----- WOW 18 Downloads... New file in later Post...
    Last edited by GremlinSA; January 22nd, 2006 at 03:22 PM.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  14. #14
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    I've been looking forward to this update

    As for searching multiple pages, I seem to recall that what I did was to simply move the ScrollBar. The scroll event fired and did the rest.

    For pasting past the end of the page, the first thing that comes to mind is to require the data be written to file, then it will already be there when scrolling. Binary mode doesn't set the EOF marker, so that's no problem. Optionally I suppose you could use a temp file. Other things will likely come to mind after I click submit

    Checking for an image file header **shouldn't** be too difficult. I think I ran into a code snippet on PSC for detecting a number of header types, though it's probably gonna need some tweaks too.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  15. #15
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    One thing I meant to ask you before is why you use the Hex_2_Byte function to get the value of a hex string? Wouldn't it work to just use Val("&H" & HexString)?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

Page 1 of 5 1234 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured