Results 1 to 8 of 8

Thread: Binary analysis tool

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2016
    Posts
    12

    Smile Binary analysis tool

    This is a Binary Analysis Tool. It is used to analyse binary data visually. In this case these are 8x8 blocks. The buttons have quick identifiers, since the plan was to add graphical icons. Here is a quick run down, though after use it is self-explanatory.

    First of all, in the small window on the top left, you can create a pattern with the left mouse button. With the right mouse button, you can move the reference point, which is something you can use to quickly keep track of rotations and shifts in your head. So for example if you have the reference point on a true square and you rotate right and the end result is a false square, you can quickly see the X and Y coordinate under it. At the same time, you can quickly note that the pattern needs to be shifted left right up or down for a true square and then you add or subtract from x and y. This sounds complicated, but it basically means there is no algorithm implied. That means you can use whatever algorithm you create to do the calculation in your head in real time. This can aid in visual recognition. Think abacus.

    Here are the main buttons

    r_L = rotate left
    r_R = rotate right

    s_U = shift up
    s_D = shift down
    s_L = shift left
    s_R = shift right

    f_UD = flip up-down
    f_LR = flip left-right

    Checkbox R = Reset. If you move the patterns to the Set, they will overdraw in the Set table. If this is checked, then the table will be reset every time.

    So to keep things simple, move from left to right.


    Draw Bin pattern(s)
    place in Hex box
    move Hex box to Set box


    The program could be further extended by adding additional useful tools, but this quickly gives you a chance to work with binary data. I hope someone finds this useful, if not for the program itself, then for the code snippets inside. The rotations all act on a 2D array and are very simplified. These can be used in graphics applications. There is a draw over in the Bin box. which means, that if you have the mouse down then it draws the color (true/false) you selected last and it won't over draw that color until you have a mouse up. This is convenient and also useful in graphics applications.

    There is a sample.txt file in the project directory. Make sure it stays there if you import the forms manually, since it has a small example set in it. It is not necessary to use it, but it can give you a better view of what a simple session can look like.

    Please let me know if this was helpful or useful in your projects. If you feel you can add some features, please do and let me know.

    BA_Tool.zip

    *UPDATED* minor bug fix as recommended BA_Tool.zip
    Last edited by isarch; Aug 26th, 2016 at 11:58 AM.

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Binary analysis tool 0.1

    Well, there will probably be plenty of areas for code improvement, if nothing else.
    I don't have the time to go through it thoroughly, but a couple of things jump out.
    Rather than use the legacy Hex function, I think .Net mavens would prefer .Net method
    Code:
      '  txtHex.Text = Hex(Convert.ToInt64(s, 2)).PadLeft(16, "0"c)
      txtHex.Text = Convert.ToInt64(s, 2).ToString("X16")
    That isn't a big deal.
    A much bigger deal is that normally if you create an IDisposable item (e.g. a Pen, a Brush, a Graphics object, etc...) you should dispose of it when done.
    You can dispose of it by calling the .Dispose method, or you can use "Using object As objectType" line when creating the object and "End Using" when done with it.
    Code:
      Dim blackBrush As New SolidBrush(Color.FromArgb(0, 0, 0))
    
      For x As Integer = 0 To 7
          g_bmSet.FillRectangle(blackBrush, x, y, 24, 24)
      Next
    
      blackBrush.Dispose
    
    '===== or ======
      Using blackBrush As New SolidBrush(Color.FromArgb(0, 0, 0))
    
          For x As Integer = 0 To 7
              g_bmSet.FillRectangle(blackBrush, x, y, 24, 24)
          Next
    
      End Using
    You definitely shouldn't be creating disposable objects as a parameter to a method call, since you have no way to dispose of it yourself, and it is especially bad if that parameter is a method that is called in a loop.
    In the code below, you have the potential to be creating that brush up to 65536 times.
    Since the color doesn't change, if you have to create a brush it should be done outside the loop once, and the brush created used in the loop, as in the above example.
    Code:
        Private Sub HexToSet()
            Dim i As Integer = 0
    
            For set_y As Integer = 0 To 31
                For set_x As Integer = 0 To 31
                    If i < lstHex.Items.Count Then
                        For y As Integer = 0 To 7
                            For x As Integer = 0 To 7
                                If Convert.ToString(Convert.ToInt64(lstHex.Items(i).ToString, 16), 2).PadLeft(64, "0"c).Substring(x + (y * 8), 1) = "1" Then
                                    g_bmSet.FillRectangle(New SolidBrush(Color.FromArgb(0, 0, 0)), (set_x * 24) + (x * 3), (set_y * 24) + (y * 3), 3, 3)
                                End If
                            Next
                        Next
                        i += 1
                    End If
                Next
            Next
    
        End Sub
    Since creating a brush takes a bit of time, and properly disposing of the brush takes time, .Net provides already created pens and brushes for all the basic colors listed in the Colors properties so you can use them without having to create or dispose of them. I would change the code above to use the provided Black Brush, rather than create a black brush.
    Code:
         g_bmSet.FillRectangle(Brushes.Black, (set_x * 24) + (x * 3), (set_y * 24) + (y * 3), 3, 3)

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2016
    Posts
    12

    Re: Binary analysis tool 0.1

    Thanks for the corrections. I had some hard to find bugs, where after running the application a few times, it did not close properly. I think there is a possibility that not disposing might have been the cause of the problem. I will ask some additional questions regarding disposing of objects in the main forum.

    I will post an updated version of the program with your recommendations, but I will not increment the version from 0.1, since I should not have numbered such a simple example anyway.

  4. #4
    Junior Member
    Join Date
    Jun 2017
    Posts
    16

    Wink Re: Binary analysis tool

    Hi, everyone. I am posting an update to the BA Tool. This is also a wip, but it is much more consistent then the first iteration. It's much more robust and it is very much usable. I moved the SET component to a TAB, so I can allow additional TABS to be added. To give an example, I will post 2 examples. The 2nd example, has an Animation tab that works, but it is not protected from errors. So don't put in a frame count that is higher than the number of frames you have. Also, that example is more buggy. If you decide to incorporate code from the second example in this post, be sure to add it to the first example which is better. As a side note, I used to have an email and account "isarch", but I lost access to the account after I made changes to my online accounts. Somewhere along the line, I changed addresses and etc. To put a long story short, I could not recover my password for isarch, so I am posting this with my new account. Sorry if that causes a mix up, but I think it should not matter. If you have any questions, feel free to send me a message.

    To continue... I added a test.txt file, which has some hex numbers to load. In the second example, Load the hex file, switch to the animation tab. Type 5 in the "To" text box, click R and the animation will render into bitmaps. Then hit P for Play at the bottom and it should flip through at the default 100ms delay. Don't forget, that the idea behind the BA tool is to be able to analyze blocks of data. I block is 8x8 square or 64 bits if you were to use it as a binary place holder. There are many uses for this and if anyone finds it useful, it would be interesting to see if you can post your results.

    Again, feel free to copy the code and use it any way you want. I found a lot of great help in this community, thank you.
    Attached Files Attached Files

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Binary analysis tool

    Quote Originally Posted by fd288 View Post
    Hi, everyone. I am posting an update to the BA Tool.
    Is this the same person that posted the OP ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6
    New Member
    Join Date
    Nov 2019
    Posts
    2

    Cool Re: Binary analysis tool

    This is the final update to BATool. I apologize for the past uploads. I was a beginning programmer. I recently looked over this old project and cleaned it up with somewhat more experience now. I added an MIT license, to make it an official last release. Feel free to use it any way. It should be bug free, but I did not conduct a thorough test. The source code of course is in the zip file, as well as a help.txt file that explains basic usage. I can now call this a complete program and it was a fun learning experience with Visual Basic. I had to do this simply because after looking at the previous uploads I noticed how rough and buggy the upload was; I could not let myself leave here with no excuse for such bad programming. This corrected project has a correctly working animation component as well. I hope someone can put it to good use. As for myself, ... as it turns out. Software engineering is not on my list of successes, so it is now more or less a hobby. If anyone has questions regarding this, the best help you can get is here in the forum. This is my final post here. Thank you for all the great help. I can't even remember my past usernames anymore.
    Attached Files Attached Files

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Binary analysis tool

    Thanks for sharing.

    For those who are wondering (as Niya was), I can confirm that based on IP addresses there is good reason to suspect that the three users (isarch, fd288, and bitcrystal) are all the same person (all the IP addresses are the same city and the same internet provider).

  8. #8
    New Member
    Join Date
    Nov 2019
    Posts
    2

    Re: Binary analysis tool

    Correct, I had a serisous account issue with my emails not related to vbforums. I sent you guys an email asking to close the past accounts. As a matter of fact, this is not a personal issue, as there was never a problem with vbforums. I explained in the email that I apoligize for the misunderstanding. The issue is resolved and it is safe to close any of those accounts and including this one, as I will not be coming back except occasionally browsing the forums. Again, this was not an issue with vbforums and I am sorry for the misunderstanding. Since there was a reply in email from vbforums a little while back I won't discuss the content of the email for privacy reasons. The issue is resolved and other than the listed usernames by si_the_geek, there is one more username and it is also safe to close it. Thank you guys for all the great help here and keep up the good work.

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