Aprendiendo a leer y escribir

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;

namespace ProjectoN
{
    public partial class Form1 : Form
    {
        long BattleListStart = 0x642E28;//9.0
        long PlayerExperience = 0x642D90;//9.0
        long StepCreatures = 0xAC;//9.0
        long MaxCreatures = 1300;//9.0
        long Password = 0x7CC278;//9.0
        long AccountNumber = 0x7CC298;//9.0
        long Nivel = 0x642D88;//9.0
        long StatusChar = 0x7CC2BC;//9.0
        long SearchForMC = 0x10CF44;//9.0
        long FollowMode = 0x7c9144;
        public Form1()
        {
            InitializeComponent();
        }

        [DllImport("kernel32.dll")]
        public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,[InOut] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
        [DllImport("kernel32.dll")]
        public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,[InOut] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);

        public static byte[] ReadBytes(IntPtr handle, long address, uint bytesToRead)
        {
            IntPtr ptrBytesRead;
            byte[] buffer = new byte[bytesToRead];

            ReadProcessMemory(handle, new IntPtr(address), buffer, bytesToRead, out ptrBytesRead);

            return buffer;
        }
     
        public static byte ReadByte(IntPtr handle, long address)
        {
            return ReadBytes(handle, address, 1)[0];
        }

        public static string ReadString(IntPtr handle, long address, uint length)
        {
            if (length > 0)
            {
                byte[] buffer;
                buffer = ReadBytes(handle, address, length);
                return System.Text.ASCIIEncoding.Default.GetString(buffer).Split(new Char())[0];
            }
            else
            {
                string s = "";
                byte temp = ReadByte(handle, address++);
                while (temp != 0)
                {
                    s += (char)temp;
                    temp = ReadByte(handle, address++);
                }
                return s;
            }
        }

        public static bool WriteBytes(IntPtr handle, long address, byte[] bytes, uint length)
        {
            IntPtr bytesWritten;

            // Write to memory
            int result = WriteProcessMemory(handle, new IntPtr(address), bytes, length, out bytesWritten);

            return result != 0;
        }


        public static bool WriteString(IntPtr handle, long address, string str)
        {
            str += '\0';
            byte[] bytes = System.Text.ASCIIEncoding.Default.GetBytes(str);
            return WriteBytes(handle, address, bytes, (uint)bytes.Length);
        }

        public static int ReadInt32(IntPtr handle, long address)
        {
            return BitConverter.ToInt32(ReadBytes(handle, address, 4)0);
        }

        public static bool WriteInt32(IntPtr handle, long address, int value)
        {
            return WriteBytes(handle, address, BitConverter.GetBytes(value)4);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
     
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Process[] processList = null;
                Process targetProcess = null;
                String processName = "Tibia";
                processList = Process.GetProcessesByName(processName);
                if (processList == null || processList.Length == 0)
                {
                    return;
                }
                else
                {
                    long BattleListEnd = BattleListStart + (StepCreatures * MaxCreatures);
                    long PlayerId = PlayerExperience + 16;
                    long attackMode = FollowMode + 4;
                    targetProcess = processList[0];
                    listBox1.Items.Add(ReadInt32(targetProcess.Handle, Nivel).ToString());
                    listBox1.Items.Add(ReadString(targetProcess.Handle, AccountNumber, 32));
                    listBox1.Items.Add(ReadString(targetProcess.Handle, Password, 32));
                    listBox1.Items.Add(ReadInt32(targetProcess.Handle, StatusChar).ToString());
                    ReadInt32(targetProcess.Handle, PlayerId);

                    for (long i = BattleListStart; i <= BattleListEnd; i += StepCreatures)
                    {
                        if (ReadInt32(targetProcess.Handle, PlayerId) == ReadInt32(targetProcess.Handle, i))
                        {
                            listBox1.Items.Add(ReadString(targetProcess.Handle, i + 432));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

    }
}

5 comentarios:

Unknown dijo...

ese es el hack no?

BlackDawn dijo...

No es ni la mitad del codigo.

Anónimo dijo...

en q nos ayuda pq yo creo que la mayoria no entiende un carajo xD

BlackDawn dijo...

Supongo que a alguien le puede ser util. Aveces solo hago entradas para mi xD, asi si se me olvida ya se donde lo tengo.

Anónimo dijo...

jajajajaja bueno, pero no sera mejor hacer un block de texto, dejar en borrador, pero bueno cada uno con lo sullo, no?

Publicar un comentario

Aqui puedes publicar algun comentario, duda, sugerencia, problema, agradecimiento o lo que quieras. Ten en cuenta que el comentario será moderado antes de salir publico.