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

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    I've been looking forward to this update
    Thanks for the Compliment.

    Quote Originally Posted by WizBang
    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.
    Problem here is that i only read 1K of the file at a time.. (what you see on the form is whats loaded into the byte array) in order to try and keep away from the 'Out of memory error' you picked up previously. Although that was mostly because of the memory used by the 1024 textbox's

    So i will need to read the next block (and maybe include the last 100 bytes of the previous block) and search again..

    Quote Originally Posted by WizBang
    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
    Or after you logout..

    The thing here again is the 1K block of loaded data.. File additions will be in steps of 1K (Or 512 bytes if used in narrow mode) Also setting a new EOF earlier in the file (Cutting a file shorter) cannot work with out using a new temp file... But i'm not to sure if i need to go in that direction ??

    Quote Originally Posted by WizBang
    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.
    On my way there now...

    Thanks for your Valuable input Wizbang.. Your enthusiasm (<--- I know, my spelling is bad, But CG doen not have a 'F7' function,, Spellchecker ) with this little progect of mine has made it worth my while to write, when compleate I'm contemplating posting it on PSC.. So it can help 100's of others.. (Ahh CG users will have first option though)

    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.

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

    Re: Hex Viewer / Editor

    Quote Originally Posted by GremlinSA
    Problem here is that i only read 1K of the file at a time.. (what you see on the form is whats loaded into the byte array)...
    So i will need to read the next block (and maybe include the last 100 bytes of the previous block) and search again..
    I understand that, but mine also loaded in small blocks (I think it was 2k) to avoid overloading the textbox. Moving the position shouldn't be a problem. As it was a quick thing, I didn't bother to overlap the read, but you're correct on that. One thought is to load more than you display. Just don't load it all into the box at once.

    Loading more than 1k would solve the pasting past the end of the box issue 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?

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

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    I understand that, but mine also loaded in small blocks (I think it was 2k) to avoid overloading the textbox. Moving the position shouldn't be a problem. As it was a quick thing, I didn't bother to overlap the read, but you're correct on that. One thought is to load more than you display. Just don't load it all into the box at once.

    Loading more than 1k would solve the pasting past the end of the box issue too
    Thanks.. I think that after spending so much time if front of the same code, i must have developed 'Coders Block' . after a bit of CG, A quick trip to the store for something to drink and smokes. I think i'm ready to continue..

    Also i found this code snip on PSC, I think i may just be able to use this to pick out even the embeded files.. (Bmp or Gif embeded in a binary file, etc.)

    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.

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

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    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)?
    I built the hex_2_byte function to clean up the hex, and return a byte variable..
    if hexstring happend to be "100" using Val("&H" & HexString) would cause a overflow error with the byte array..

    Likewize with Hex_2_long, Val("&H" & "0000FFFF") returns -1 and not 65535.
    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. #20
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    As for searching multiple pages, Fixed up

    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. Fixed Up

    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.Implemented
    Okay i know it gets a bit fustrating when updates apears so quickly one after the other.. but this is not just surface updates, Its some what of majour surgery.. The search works 99% (Even added a search for next). Popup Paste now can paste text of any size (tested with a 18K clipboard). Ctrl + C calls the popup paste.. Auto File writing, added to the options menu..

    Also a few small issues repaired ...

    Gremmy.

    ---- New version in later post....
    Last edited by GremlinSA; January 22nd, 2006 at 02:59 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.

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

    Re: Hex Viewer / Editor

    Quote Originally Posted by GremlinSA
    I built the hex_2_byte function to clean up the hex, and return a byte variable..
    if hexstring happend to be "100" using Val("&H" & HexString) would cause a overflow error with the byte array..

    Likewize with Hex_2_long, Val("&H" & "0000FFFF") returns -1 and not 65535.
    Well, I haven't looked over your code enough to see when/if that can happen, but there is an easy fix for that too

    To limit a value to 8 bits, just use:
    Val("&H" & HexString) And 255
    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. #22
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Two bugs found:

    1) Using the logical edit doesn't enable the "Functions" menu.
    2) Typing non-numeric characters into the logical edit window textbox raises an error.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

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

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    Well, I haven't looked over your code enough to see when/if that can happen, but there is an easy fix for that too

    To limit a value to 8 bits, just use:
    Val("&H" & HexString) And 255
    I just found that Clng ("&HFFFF") gives 65535 and not -1 ..

    Modifing the looooooonnnnnngggg Hex to val codes to use this now ...

    Gremmy...

    ------- EDIT -----

    The hacks at M$... CCur does the same as Clng...
    Code:
    Quote = VB Books Online....
    Conver.	Converts an expression to
    function
    CByte	Byte
    CCur	Currency
    CDate	Date
    CDbl	Double
    CInt	Integer
    CLng	Long
    CSng	Single
    CStr	String
    CVar	Variant
    
    And ... 
    
    Currency (scaled integer)	8 bytes	-922,337,203,685,477.5808 to 922,337,203,685,477.5807
    But a Simple CCur ("&H1FFFFFFFF") Returns a OverFlow error ...

    I wont be surprised if CCur is the Clng code ....
    Last edited by GremlinSA; January 16th, 2006 at 04:14 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.

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

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    Two bugs found:

    1) Using the logical edit doesn't enable the "Functions" menu. Fixed This actully was not done in any of the popups..
    2) Typing non-numeric characters into the logical edit window textbox raises an error. Fixed
    Thanks for those .. I missed them.. Testing your own code you sometimes forget to check these things..

    Also .. If the file open Failed (Running exe or locked File) the editor kicked in with a blank form.. Fixed this problem too...

    Made a few other minour changes and fixes. Corrected the Application Caption, and added the open file name to it. Made default buttons on the Entry forms..

    Sorted out the Tabindex order into a logical Tab order..

    It runs pretty nicely now... (although i still would like to speed up some of the editing code... )

    AND.... This zip is a bit smaller because the code is quite a bit shorter using Clng, Cbyte and Cint .. Thanks for pointing me to that... I never knew that Val (And the others) translate Hex vals so easily... ( Well I never tried with "&H" prefix) ...

    Enjoy...

    Gremmy..

    PS.. next on my list of incomplete Projects is the IPLink App i posted Here ... But i will start a new thread for that one... when this one is done...


    a Little Nip and tuck on some code here and there...

    ----- NEW File on later post... -------
    Last edited by GremlinSA; January 17th, 2006 at 05:58 PM. Reason: Newer 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.

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

    Re: Hex Viewer / Editor

    Hate to burst your bubble, but the first thing I tried was "Find in File...". I typed a zero into the box, and got an error in the Hex_2_Byte function. I changed CByte to Val and no more error.

    Can you use the length of the input to determine the byte length? Then only one function would work for all.

    Another way might be to have a parameter for the length. The function below works either way. If you leave out the length param, it will use the length of the input hex value:
    Code:
    Public Function Hex_2_Number(ByVal Hexadecimal As String, Optional ByVal Length As Long) As Long
    Dim Tmp_Hex As String
    If Length = 0 Then Length = Len(Hexadecimal)
    Tmp_Hex = Right$(String$(Length, 48) & Hexadecimal, Length) ' split 2 digits for Byte...
    Hex_2_Number = Val("&H" & Tmp_Hex)
    End Function
    I didn't look at why more than 32 bits would need to be supported, but if it does you can return a Currency type. I've also used a string to prevent overflow when the number might get huge. It just depends on how you end up using it.
    Last edited by WizBang; January 17th, 2006 at 05:47 AM. Reason: typo
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

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

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    Hate to burst your bubble, but the first thing I tried was "Find in File...". I typed a zero into the box, and got an error in the Hex_2_Byte function. I changed CByte to Val and no more error.
    Where ???? ... I tried to duplicate this error... But to no avail.. works 100 % here...Could you maybe post a bit more info on this please..

    Quote Originally Posted by WizBang
    Code:
    Public Function Hex_2_Number(ByVal Hexadecimal As String, Optional ByVal Length As Long) As Long
    Dim Tmp_Hex As String
    If Length = 0 Then Length = Len(Hexadecimal)
    Tmp_Hex = Right$(String$(Length, 48) & Hexadecimal, Length) ' split 2 digits for Byte...
    Hex_2_Number = Val("&H" & Tmp_Hex)
    End Function
    the problem with Val is if you pass two bytes it treats it as an Integer, even if you preceed it with two 0 bytes.. try this in the immediate window..
    Code:
    Print Val("&H0000FFFF") ' Returns '-1' - In long its supposed to be 65535
    Print Val("&H00010000") ' Returns '65536' - correct..
    But what i did find is that a Search for &H 00 00, does not happen..???-- Currently looking into this...

    Thanks

    Gremmy....
    Last edited by GremlinSA; January 17th, 2006 at 02:02 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.

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

    Re: Hex Viewer / Editor

    OK. Now I get what you have been saying. There is an easy fix for that too, shown below.
    Code:
    Public Function Hex_2_Number(ByVal Hexadecimal As String, Optional ByVal Length As Long) As Long
    Dim Tmp_Hex As String
    If Length = 0 Then Length = Len(Hexadecimal)
    Tmp_Hex = Right$(String$(Length, 48) & Hexadecimal, Length) ' split 2 digits for Byte...
    Hex_2_Number = Val("&H" & Tmp_Hex & Chr$(38))
    End Function
    As for the error, I've attached a screenshot:
    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?

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

    Re: Hex Viewer / Editor

    Okay.. I do Belive you.. But strangly enough, It did not cause and error on my system.. ( i even downloaded the atachement and tried that)..

    So .. I step traced the Bugger, Found the problem, and fixed it....

    Also.... I found code to Set the EOF. You can now make files shorter. (Dont just play with this... IT IS DESTRUCTIVE.. Any thing after the New EOF, is now Lost... Forever... )

    + other minour fixup's and re-aranging.

    Gremmy..

    ----- Newer Version in later post.....
    Last edited by GremlinSA; January 22nd, 2006 at 03:01 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. #29
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Oh No .. Not another Update...

    But this one is worth while....

    Bug Fixes, Additions to this ver..

    1) Added a scrollbar to the right of the Form... (Works 99% <-- Again can never be sure of 100%..)

    2) In wide format can also make it long format, 32 * 48 characters...(1024 X 768 res required) (Scrollbar Auto adjusts to suit the selected mode )

    3) Search in file was deadly slow... Rearanged some of the code now searches a 128K File in Miliseconds, not seconds..

    4) Text entry in Search is now Drag 'n Drop + Copy 'n Paste Friendly.. (Std Rightclick menu enabled)

    5) some other small code changes...

    I think this is just about complete...

    To the ones that are down loading this app... Please post what you think of it.. (I know there are aleast 7 of you... )

    Thanks

    Gremmy....

    PS. If you keep downloading the new Vertions.. I'll keep trying to improve the quality of this little app...

    ------------- EDIT ------------------

    Newer file in Later Post (If your reading through this thread looking for the file Goto the Last post)
    Last edited by GremlinSA; January 31st, 2006 at 06:03 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.

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

    Re: Hex Viewer / Editor

    Nice to see an update on this

    I actually hadn't gotten to look at the last one I downloaded, but I just took a quick glance at this one. I did see a few things, but as usual, my coding style is so different from most others that I find it difficult to follow. I'm not at this moment sure what the usage is for all those binary/hex/decade functions. Maybe you can point some out for us/me? The ones I looked into seem to rely on each other in a maze of confusion...or I'm just lost...lol

    Anyway, I saw this in your BinaryToHex function:
    Code:
    Do
      sPart = Mid(sBinVal, iPos, 4)
      sHex = sHex & BinToHex(sPart)
      iPos = iPos + 4
      If iPos > ilg Then Exit Do
    Loop
    It doesn't take full advantage of the Do...Loop structure. Why not do it like this?:
    Code:
    Do
      sPart = Mid(sBinVal, iPos, 4)
      sHex = sHex & BinToHex(sPart)
      iPos = iPos + 4
    Loop Until iPos > ilg
    This eliminates the extra If...Then, which I'm sure must be faster. You can alternatively use Do While. The returned type of the function is also undefined, which means a Variant. That's gonna slow things down too, but I know it's just an oversight.

    Also found two bugs:
    1) If you click File >> Open... but cancel, the file you are looking at is no longer "enabled", and you have to open it again.
    2) The scrollbar (nice feature I've been waiting for) always seems to scroll past the end of the file until the valid part goes off the screen. Is that on purpose for some reason?

    I'll try to take a more in-depth look a bit later...keep up the good work!
    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 2 of 5 FirstFirst 12345 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