Post: Reading Both Images and InjeCtion + Extraction of Images C#
02-07-2010, 07:29 PM #1
TehLynch
You talkin to me?
(adsbygoogle = window.adsbygoogle || []).push({}); Make your tool for Reading the images look simalar to this.

You must login or register to view this content.

You don't Really need the About Button
Now there is 2 picture boxes above the labels.
Make there Size 64x64
Once your Done with that go up to your Directives and add this

    using System.IO;


Once done with that You are going to wan't to add a public string and name it.

    public string fileLocation = "";


You can add this anywhere but not in a private void you will get an error
Now for Reading Both Images your Need to Paste in this code.

    private void showimage()
{
try
{
//Opens the Stream to Read file
FileStream fs = File.OpenRead(fileLocation);
BinaryReader br = new BinaryReader(fs);
//Finding Location of Image
br.BaseStream.Position = 0x171A;
//Telling it to Read 99999999 Bytes which is abit Overboard
Stream image = new MemoryStream(br.ReadBytes(99999999));
//Loads Image to Picture box
pictureBox1.Image = Image.FromStream(image);
fs.Close();
br.Close();
}
catch
{
}

}
private void showimage2()
{
try
{
FileStream fs = File.OpenRead(fileLocation);
BinaryReader br = new BinaryReader(fs);
br.BaseStream.Position = 0x571A;
Stream image = new MemoryStream(br.ReadBytes(16000));
pictureBox2.Image = Image.FromStream(image);
fs.Close();
br.Close();
}
catch
{

}
}


Now To assign your "Load Button " Button just Add this little Snippet of code

    OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = ("Put your Text Here");
ofd.ShowDialog();
fileLocation = ofd.FileName;
showimage();
showimage2();


Now for Saving the Images from the Picture Box (*Note this not Extract the Image form the acutal File just get the image from the picturebox and Then save it.)
For Picture Box 1.

    SaveFileDialog dlg2 = new SaveFileDialog();
dlg2.Title = "Save Picture";
dlg2.Filter = "Png Images(*.png)|*.png| Jpeg Images (*.jpeg)|*.jpeg";
dlg2.ShowDialog();
{
pictureBox1.Image.Save(dlg2.FileName);
}
MessageBox.Show("Picture Was Saved", "Congrats", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);


For PictureBox 2...

                SaveFileDialog dlg2 = new SaveFileDialog();
dlg2.Title = "Save Picture";
dlg2.Filter = "Png Images(*.png)|*.png| Jpeg Images (*.jpeg)|*.jpeg";
dlg2.ShowDialog();
{
pictureBox2.Image.Save(dlg2.FileName);

}
MessageBox.Show("Picture Was Saved", "Congrats", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);


Now For Injection Add this to your inject button for your First PictureBox.

    OpenFileDialog ofd1 = new OpenFileDialog();
ofd1.Filter = "Png Pictures (*.png)|*.png";
ofd1.Title = ("Load a Valid .png Picture");
ofd1.ShowDialog();
try
{
{
FileStream imageReader = File.OpenRead(ofd1.FileName);
byte[] imageLength = new byte[imageReader.Length];
BinaryReader br = new BinaryReader(imageReader);
int data = br.Read(imageLength, 0x0, imageLength.Length);
br.BaseStream.Position = 0x0;
byte[] image = br.ReadBytes(data);
br.Close();
imageReader.Close();
BinaryWriter bw = new BinaryWriter(new FileStream(fileLocation, FileMode.Open));
bw.BaseStream.Position = 0x171A;
while (bw.BaseStream.Position < 0x5710)
{
bw.BaseStream.WriteByte(0x00);
bw.BaseStream.Position++;
}
bw.BaseStream.Position = 0x171B;
while (bw.BaseStream.Position < 0x5710)
{
bw.BaseStream.WriteByte(0x00);
bw.BaseStream.Position++;
}
bw.BaseStream.Position = 0x171A;
bw.Write(image);
bw.Close();
showimage();
}
}
catch
{
}


This for your Second....

    OpenFileDialog ofd1 = new OpenFileDialog();
ofd1.Filter = "Png Pictures (*.png)|*.png";
ofd1.Title = ("Load a Valid .png Picture");
ofd1.ShowDialog();
try
{
{
FileStream imageReader = File.OpenRead(ofd1.FileName);
byte[] imageLength = new byte[imageReader.Length];
BinaryReader br = new BinaryReader(imageReader);
int data = br.Read(imageLength, 0x0, imageLength.Length);
br.BaseStream.Position = 0x0;
byte[] image = br.ReadBytes(data);
br.Close();
imageReader.Close();
BinaryWriter bw = new BinaryWriter(new FileStream(fileLocation, FileMode.Open));
bw.BaseStream.Position = 0x571A;
while (bw.BaseStream.Position < 0x5710)
{
bw.BaseStream.WriteByte(0x00);
bw.BaseStream.Position++;
}
bw.BaseStream.Position = 0x571B;
while (bw.BaseStream.Position < 0x5710)
{
bw.BaseStream.WriteByte(0x00);
bw.BaseStream.Position++;
}
bw.BaseStream.Position = 0x571A;
bw.Write(image);
bw.Close();
showimage2();
}

}
catch
{
}

You must login or register to view this content.
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo