EXE Edit

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts Page 1 of 1
Contributors
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

EXE Edit
M1z23R
Ok, so i wan't to be able to change certain text - String in my .exe file using stream reader/writer, but i don't want my app to get messed up !
User avatar
Napster1488
VIP - Donator
VIP - Donator
Posts: 524
Joined: Fri Jan 07, 2011 8:41 pm

Re: EXE Edit
Napster1488
Maybe try it with Hex Edit,there is a Lib to use HexEdit in VB.
Name is HexBox.
YouTube Downloader v3.0
Image
Image
Image
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: EXE Edit
smashapps
hex editors are of course good for this as napster has said

off topic: Napster talk on Dropbox want to talk to you
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: EXE Edit
mandai
If you know the offset of the text, you can use a FileStream to change or shorten the text.
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: EXE Edit
M1z23R
How can i use file stream ? I know exactly what text is "in" exe file, i just want to be able to change it !
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: EXE Edit
mandai
You could change it with this:
Code: Select all
        Dim fs As FileStream = New FileStream("test.exe", FileMode.Open)

        fs.Position = &HFFA0 'an example offset of the text

        Dim changed As String = "new text" 'must be equal or shorter than the original text
        ' ASCII encoding is assumed
        For i As Integer = 0 To changed.Length - 1
            fs.WriteByte(Asc(changed(i)))
        Next
        fs.Close()
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: EXE Edit
M1z23R
tnx man, but how can i do some thing like this ?
Dim rfs = Read file stream
rfs = rfs.replace(oldstr,newstr)

?
If you can understand me it would be great :D
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: EXE Edit
mandai
There are many methods for finding a string in a stream. You could use this to find the offset:
Code: Select all
        Dim input As Byte() = File.ReadAllBytes("file.txt")

        Dim lookFor As Byte() = Encoding.ASCII.GetBytes("old text")

        Dim temp(lookFor.Length - 1) As Byte

        Dim offset As Integer = -1
        For i As Integer = 0 To input.Length - lookFor.Length
            System.Buffer.BlockCopy(input, i, temp, 0, lookFor.Length)

            If temp.SequenceEqual(lookFor) Then
                Dim dr As DialogResult = MessageBox.Show("Found 'old text' at offset " & i & ", finish search?", "", MessageBoxButtons.YesNo)
                If dr = Windows.Forms.DialogResult.Yes Then
                    offset = i
                    Exit For
                End If
                'else keep looking
            End If
        Next
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: EXE Edit
M1z23R
how can i edit it when i find it ?
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: EXE Edit
mandai
The first code block deals with changing the original string.
10 posts Page 1 of 1
Return to “Tutorial Requests”