C#, Ah what a language!
Ok, create a new windows form application in C# 2008 .NET.

The first thing I like to do is set up my form properties. What I do is the following settings:
- Maximize Box = false.
- Form Border Style = Fixed Single.
- Change the text of my form.
Now we throw a button and label it open along with a textbox.
Now, we will learn the basic terminology to open a file.
- Double click your button to bring up the code.
- Type the following
OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "All Files|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { textBox1.Text = ofd.FileName; } else { }
Explanation of code - The ofd is giving the OpenFileDialog a nickname. We can now refer to it as ofd. The ofd.Filter is the type of files we can select. In this instance we want all files. Now, the if statement is basically saying "if a user selects a file and clicks ok, this will happen. The else statement is telling what happens if they cancel or X out. In this instance nothing special happens. When the OK is selected, the textbox will display the file path of the file selected so now the application knows what file to access.
Now your form should look like the following:

Go ahead and debug your app (by clicking the play button [circled in blue])
Now time for the real code after the file is loaded. So, navigate to the namespace (see below) and add the following code:
using System.IO;
Explanation of code - Adding the System.IO will give you more features into your app for Binary Reading/Writing (hex editing).
Ok, now that you have set that up we will create a setup on how to display the image in the CON header into a picturebox. So, add a button and name it Show Image, and add a picturebox onto your form. Change the picturebox's properties to 'Stretch Image'.
Now double click on the Show Image button so we can add some code. This is where I may lose you in the tutorial, if you don't understand something, read the explanation below.
Add the following code, I will explain it after you add it:
FileStream fs = File.OpenRead(textBox1.Text); BinaryReader br = new BinaryReader(fs); br.BaseStream.Position = 0x171A; Stream image = new MemoryStream(br.ReadBytes(16000)); pictureBox1.Image = Image.FromStream(image); fs.Close(); br.Close();
Explanation of code:
- The fs is creating a filestream or 'file browser'. What it does is will "open and read" the hex data of the file we selected.
- The textBox1.Text is the file location.
- BinaryReader is what reads the hex data we want.
- The BaseStream.Position is where we want to set the 'cursor' at so we can begin our read.
- The Memory Stream is reading 16000 (enough) bytes (which is the image's hex) and sending it to memory so we can later use it.
- Then the picturebox is showing the stream of the image so we can show it.
- The Close(); is just closing all our Streams and Readers so we don't get an error later that the file is in use with another process.
Now, go debug you app and test it out. Open a file then show image. It will show the game's image. This is just a small step and soon when I get more time I will create on how to find and edit data in a save. Good luck and happy coding.
Result:
Edited by yungbol, 15 March 2009 - 03:54 PM.