02-14-2010, 06:01 PM
I have this program I am working on and So far it does everything but write the hex values to the offset in the file. I am having trouble with it since, the hex values I want to replace are in 3 different consecutive offsets. I wonder if there is a way to do it so it would take the code for instance and separate it into 3 bytes so it would be written into the 3 offsets as 65 B7 10.
Here is my code so far.
Code:
65B710
Here is my code so far.
Code:
Imports System.IO
Imports System.IO.FileStream
Imports System.IO.BinaryWriter
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Hex()
Dim decValue As Integer = TextBox2.Text
Dim hexValue As String = decValue.ToString("X")
TextBox3.Text = hexValue
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Hex()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOpen.Click
OFD1.ShowDialog()
TextBox1.Text = OFD1.FileName
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMod.Click
Dim OpenMe As New OpenFileDialog
Dim fs As System.IO.FileStream
Dim bw As System.IO.BinaryWriter
fs = New System.IO.FileStream(OFD1.FileName, IO.FileMode.OpenOrCreate) 'Uses the file you just opened
bw = New System.IO.BinaryWriter(fs) 'tells the binary writer to write to the file you opened
fs.Position = &H7B6805 And &H7BA805 'offset to write (i told it to start at the beginning of the file.)
bw.Write(TextBox3.Text) 'value to write. if you want to write a hex value, make sure you have "&H" before it.
fs.Close()
bw.Close()
MsgBox("Injected", MsgBoxStyle.Information, "Success")
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OFD1.FileOk
End Sub
End Class