// Estas leyendo...

CSHARP

Editor de archivos generico en C#

Descargar-editor-v10
Hola a todos aqui les dejo un codigo de un editor de archivos generico que permite alterar las variables de cualquier archivo ya compilado
lo unico que necesitamos es la posicion de la variable dentro del archivo (Offset) Esto se consigue con un editor hexadeciaml como hexworkshop
Ahi les dejo el codigo para que lo analizen asi como el ejecutable.

public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
            listBox1.Visible = false;
            label8.Visible = false;
        }
        static string a;
        static string b;
        static long c;

        byte[] g;
        System.IO.BinaryWriter mifile;

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            a = openFileDialog1.FileName;
            label4.Text = a;

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
            {
                if ((textBox1.Text == "") || (a == null) || (textBox2.Text == ""))
                {
                    MessageBox.Show("Error no has seleccionado un archivo o agregado un valor ");
                    return;
                }
                else
                {
                    b = textBox1.Text;
                    try
                    {
                        c = long.Parse(textBox2.Text);
                    }
                    catch (Exception)
                    {

                        MessageBox.Show("El valor del offset debe ser numerico decimal");
                        return;
                    }
                    MessageBox.Show("Desea agregar este valor ?" + b);

                    g = new byte[b.Length * 2];
                    for (int i = 0; i < b.Length; i++)
                    {
                        g[i + i] = (byte)b[i];
                        g[i + i + 1] = 0×00;
                    }
                    foreach (byte h in g)
                    {
                        listBox1.Items.Add(h + " = " + (char)h);
                    }
                    listBox1.Visible = true;
                    label8.Visible = true;
                }

                mifile = new BinaryWriter(File.Open(a, FileMode.Open, FileAccess.ReadWrite));
                mifile.BaseStream.Seek(c, SeekOrigin.Begin);
                mifile.Write(g);
                mifile.Close();
            }
            else
            {
                if ((textBox1.Text == "") || (a == null) || (textBox2.Text == ""))
                {
                    MessageBox.Show("Error no has seleccionado un archivo o agregado un valor ");
                    return;
                }
                else
                {
                    b = textBox1.Text;
                    try
                    {
                        c = long.Parse(textBox2.Text);
                    }
                    catch (Exception)
                    {

                        MessageBox.Show("El valor del offset debe ser numerico decimal");
                        return;
                    }
                    MessageBox.Show("Desea agregar este valor ?" + b);

                    g = new byte[b.Length];
                    for (int i = 0; i < b.Length; i++)
                    {
                        g[i] = (byte)b[i];

                    }
                    foreach (byte h in g)
                    {
                        listBox1.Items.Add(h + " = " + (char)h);
                    }
                    listBox1.Visible = true;
                    label8.Visible = true;
                }

                mifile = new BinaryWriter(File.Open(a, FileMode.Open, FileAccess.ReadWrite));
                mifile.BaseStream.Seek(c, SeekOrigin.Begin);
                mifile.Write(g);
                mifile.Close();
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("La seleccion del tipo de archivo depende del lenguaje en que se creo dicho archivo");
            MessageBox.Show("El offset es la posicion dentro del archivo a escribir");
            MessageBox.Show("El valor del offset se obtiene al abrir el archivo a modificar con un editor hexadecimal por ejemplo Hexworkshop");
        }

    }

Comentarios

3 comments para “Editor de archivos generico en C#”

  1. Joder esto es lo que andaba buscando me funciono perfectamente vos no tenes un codigo similar en c++?

    Posted by Andreita | Junio 18, 2008, 5:48
  2. Claro, pronto agregaremos el codigo en c++

    salu2

    Posted by octalh | Junio 18, 2008, 14:32
  3. gracias amigo por tu aporte , sigue asin , que le sacaras la lengua al billgate

    Posted by el papamovil | Noviembre 11, 2008, 2:41

Deja un comentario