Jump to content

Hex to exe...help plz

- - - - -

  • Please log in to reply
1 reply to this topic

#1
kylelendo

kylelendo

    Newbie

  • Members
  • PipPip
  • 25 posts
Hii

I have been converting a file into its hex value.But cannot convert it back into same exe value

Let me get in detail

Here is the code


Imports System.IO

Sub Main()


 


        Dim fileName As String = "ABC.exe"


 


        Dim data As Byte() = File.ReadAllBytes(fileName)


 


        Dim fs As FileStream = File.OpenWrite(fileName & ".txt")


        Dim sw As StreamWriter = New StreamWriter(fs)


 


        Dim pos As Integer = 0


        Dim line As Integer = 0


 


        While pos < data.Length


            sw.Write(String.Format("{0}:", line.ToString("0000")))


 


            For i As Integer = 1 To 20


                sw.Write(String.Format(" {0:x2}", data(pos)))


                pos += 1


                If pos = data.Length Then


                    Exit For


                End If


            Next


 


            sw.WriteLine()


            line += 1


        End While


 


        sw.Flush()


        sw.Close()


        fs.Close()


    End Sub



Now,When i call the main method an text file called ABC.exe.txt is generated.

First of all instead of ABC.exe.txt can we have ABC.txt only

and secondly can how can i convert this hex values back to exe.. at least compile it in vb or any other language

Thank you for your time

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
What are you trying to accomplish? I mean, it looks like you're trying to emulate a primitive hex editor, but I'm not really sure. Modifying the hex for a .exe is almost guaranteed to result in a non-functioning program.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users