File Dump Tool

This console application was made in VB.NET, it gets the hex dump, string dump, or creates a debug script to rebuild the file. The file to specify for building a debug script for it can only be file editable by notepad or a 16 bit application.

DOWNLOAD: http://www.mediafire.com/download.php?mddnmj54mzz

Call this program with these parameters:

dump [-h] [-r] [-s] "File"

-h   Outputs hex dump of file
-r   Outputs string reference dump of file
-s   Outputs debug script to re-assemble the file.


You may also use redirection operators to write the output to files since the program uses System.IO.TextWriter to write to the standard output stream instead of to the console. For example:

You have helloworld.bat:

@echo off
echo hello world
pause
exit

Use this command to create a debug script for this file then run it:

dump -s "helloworld.bat">>"helloworld_ds.bat"

Now helloworld.bat should contain this:

@echo off
color f0
set cf=%cd%
echo e 100 40 65 63 68 6F 20 6F 66 66 0D 0A 65 63 68 6F 20>>"buildhex"
echo e 110 68 65 6C 6C 6F 20 77 6F 72 6C 64 0D 0A 70 61 75>>"buildhex"
echo e 120 73 65 0D 0A 65 78 69 74>>"buildhex"
echo r cx>>"buildhex"
echo 20>>"buildhex"
echo n output>>"buildhex"
echo w>>"buildhex"
echo q>>"buildhex"
debugnul
exit

All you have to do is run it, then the batch file will make a script file containing commands for debug.exe to re-assemble hello.bat with a hex dump, then it will rename the output file back into hello.bat.

Dump.exe Console Application in VB.NET source code:

Module Module1

    Sub Main()
        Dim args = My.Application.CommandLineArgs
        Dim cout As System.IO.TextWriter = Console.Out
        Try
            If args.Count  2 Then Call help()
            If args(0) = "-h" Then
                Dim bytes() As Byte = System.IO.File.ReadAllBytes(args(1))
                Dim lcount As Integer = 0
                For Each b In bytes
                    Dim hexa = Hex(b).ToString
                    If hexa.Length < 2 Then hexa = "0" & hexa
                    cout.Write(hexa & " ")
                    lcount += 1
                    If lcount = 16 Then
                        cout.Write(vbNewLine)
                        lcount = 0
                    End If
                Next
            End If

            If args(0) = "-s" Then
                Dim total As String = ""
                Dim bytes() As Byte = System.IO.File.ReadAllBytes(args(1))
                For Each b In bytes
                    Dim hexa = Hex(b).ToString
                    If hexa.Length >""buildhex""" & vbNewLine
                        scount = 0
                        offset += 16
                        script += "echo e " & Hex(offset).ToString & " "
                    End If
                    script += h.ToString
                    scount += 1
                Next
                If scount >""buildhex""" & vbNewLine
                End If
                script += "echo r cx>>""buildhex""" & vbNewLine
                script += "echo " & Hex(offset - 256) & ">>""buildhex""" & vbNewLine
                script += "echo n output>>""buildhex""" & vbNewLine
                script += "echo w>>""buildhex""" & vbNewLine
                script += "echo q>>""buildhex""" & vbNewLine
                script += "debugnul" & vbNewLine
                script += "exit"
                script = script.Replace(" >>", ">>")
                cout.Write(script)
            End If

            If args(0) = "-r" Then
                Dim bytes() As Byte = System.IO.File.ReadAllBytes(args(1))
                Dim lcount As Integer = 0
                For Each b In bytes
                    Dim chare = Integer.Parse(Hex(b), Globalization.NumberStyles.HexNumber)
                    If chare  127 Then
                        cout.Write(".")
                    Else
                        cout.Write(Chr(chare))
                    End If
                    lcount += 1
                    If lcount = 16 Then
                        cout.Write(vbNewLine)
                        lcount = 0
                    End If
                Next

            End If

        Catch er As Exception
            cout.Write("Error: " & er.Message.ToString)
        End Try
    End Sub

    Sub help()
        Dim cout As System.IO.TextWriter = Console.Out
        cout.Write(vbNewLine)
        cout.WriteLine("Command: Dump")
        cout.WriteLine("Author: Jakash3")
        cout.WriteLine("Description: Creates a hex dump, string dump, or debug script of a file.")
        cout.Write(vbNewLine)
        cout.WriteLine("Usage:")
        cout.Write(vbNewLine)
        cout.WriteLine("dump [-h] [-r] [-s] ""File""")
        cout.Write(vbNewLine)
        cout.WriteLine("-h   Outputs hex dump of file")
        cout.WriteLine("-r   Outputs string reference dump of file")
        cout.WriteLine("-s   Outputs debug script to re-assemble the file.")
        cout.Write(vbNewLine)
    End Sub

End Module

One thought on “File Dump Tool

  1. When I try to compile the source from the command line I get this error message:

    ‘CommandLineArgs’ is not a member of ‘My.MyApplication’.

    Dim args = My.Application.CommandLineArgs
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: