Ejemplo n.º 1
0
        public static void Calibrate(CalibrationInfo[] info)
        {
            Client.m_LocationPointer = (LocationPointer)null;
            ProcessStream processStream = Client.ProcessStream;

            if (processStream == null)
            {
                return;
            }
            int coordPointer1 = 0;
            int coordSize1    = 0;
            int coordPointer2 = 0;
            int coordSize2    = 0;
            int coordPointer3 = 0;
            int coordSize3    = 0;
            int coordPointer4 = 0;
            int coordSize4    = 0;

            for (int index = 0; index < info.Length; ++index)
            {
                CalibrationInfo calibrationInfo = info[index];
                int             ptr             = Client.Search(processStream, calibrationInfo.Mask, calibrationInfo.Vals);
                if (ptr != 0)
                {
                    if (coordPointer1 == 0 && calibrationInfo.DetX.Length > 0)
                    {
                        Client.GetCoordDetails(processStream, ptr, calibrationInfo.DetX, out coordPointer1, out coordSize1);
                    }
                    if (coordPointer2 == 0 && calibrationInfo.DetY.Length > 0)
                    {
                        Client.GetCoordDetails(processStream, ptr, calibrationInfo.DetY, out coordPointer2, out coordSize2);
                    }
                    if (coordPointer3 == 0 && calibrationInfo.DetZ.Length > 0)
                    {
                        Client.GetCoordDetails(processStream, ptr, calibrationInfo.DetZ, out coordPointer3, out coordSize3);
                    }
                    if (coordPointer4 == 0 && calibrationInfo.DetF.Length > 0)
                    {
                        Client.GetCoordDetails(processStream, ptr, calibrationInfo.DetF, out coordPointer4, out coordSize4);
                    }
                    if (coordPointer1 != 0 && coordPointer2 != 0 && (coordPointer3 != 0 && coordPointer4 != 0))
                    {
                        break;
                    }
                }
            }
            if (coordPointer1 == 0 && coordPointer2 == 0 && (coordPointer3 == 0 && coordPointer4 == 0))
            {
                return;
            }
            Client.m_LocationPointer = new LocationPointer(coordPointer1, coordPointer2, coordPointer3, coordPointer4, coordSize1, coordSize2, coordSize3, coordSize4);
        }
Ejemplo n.º 2
0
 private static void GetCoordDetails(ProcessStream pc, int ptr, byte[] dets, out int coordPointer, out int coordSize)
 {
     pc.Seek((long)(ptr + (int)dets[0]), SeekOrigin.Begin);
     coordPointer = Client.Read(pc, (int)dets[1]);
     if ((int)dets[2] < (int)byte.MaxValue)
     {
         pc.Seek((long)coordPointer, SeekOrigin.Begin);
         coordPointer = Client.Read(pc, (int)dets[2]);
     }
     if ((int)dets[3] < (int)byte.MaxValue)
     {
         pc.Seek((long)(ptr + (int)dets[3]), SeekOrigin.Begin);
         coordPointer += Client.Read(pc, (int)dets[4]);
     }
     coordSize = (int)dets[5];
 }
Ejemplo n.º 3
0
        public static int Search(ProcessStream pc, byte[] mask, byte[] values)
        {
            if (mask.Length != values.Length)
            {
                // TODO: maybe we need better exception here?
                throw new Exception();
            }

            const int chunkSize = 4096;
            int       readSize  = chunkSize + mask.Length;

            pc.BeginAccess();

            var read = new byte[readSize];

            for (int i = 0; ; ++i)
            {
                pc.Seek(0x400000 + (i * chunkSize), SeekOrigin.Begin);
                int count = pc.Read(read, 0, readSize);

                if (count != readSize)
                {
                    break;
                }

                for (int j = 0; j < chunkSize; ++j)
                {
                    bool ok = true;

                    for (int k = 0; ok && k < mask.Length; ++k)
                    {
                        ok = ((read[j + k] & mask[k]) == values[k]);
                    }

                    if (ok)
                    {
                        pc.EndAccess();
                        return(0x400000 + (i * chunkSize) + j);
                    }
                }
            }

            pc.EndAccess();
            return(0);
        }
Ejemplo n.º 4
0
        private static void GetCoordDetails(ProcessStream pc, int ptr, byte[] dets, out int coordPointer, out int coordSize)
        {
            pc.Seek(ptr + dets[0], SeekOrigin.Begin);
            coordPointer = Read(pc, dets[1]);

            if (dets[2] < 0xFF)
            {
                pc.Seek(coordPointer, SeekOrigin.Begin);
                coordPointer = Read(pc, dets[2]);
            }

            if (dets[3] < 0xFF)
            {
                pc.Seek(ptr + dets[3], SeekOrigin.Begin);
                coordPointer += Read(pc, dets[4]);
            }

            coordSize = dets[5];
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Reads the current <paramref name="x" />, <paramref name="y" />, and <paramref name="z" /> from memory based on a <see cref="Calibrate">calibrated memory location</see>.
        /// <seealso cref="Calibrate" />
        /// <seealso cref="ProcessStream" />
        /// <returns>True if the location was found, false if not</returns>
        /// </summary>
        public static bool FindLocation(ref int x, ref int y, ref int z, ref int facet)
        {
            LocationPointer lp = LocationPointer;
            ProcessStream   pc = ProcessStream;

            if (pc == null || lp == null)
            {
                return(false);
            }

            pc.BeginAccess();

            if (lp.PointerX > 0)
            {
                pc.Seek(lp.PointerX, SeekOrigin.Begin);
                x = Read(pc, lp.SizeX);
            }

            if (lp.PointerY > 0)
            {
                pc.Seek(lp.PointerY, SeekOrigin.Begin);
                y = Read(pc, lp.SizeY);
            }

            if (lp.PointerZ > 0)
            {
                pc.Seek(lp.PointerZ, SeekOrigin.Begin);
                z = Read(pc, lp.SizeZ);
            }

            if (lp.PointerF > 0)
            {
                pc.Seek(lp.PointerF, SeekOrigin.Begin);
                facet = Read(pc, lp.SizeF);
            }

            pc.EndAccess();

            return(true);
        }
Ejemplo n.º 6
0
        public static int Search(ProcessStream pc, byte[] mask, byte[] vals)
        {
            if (mask.Length != vals.Length)
            {
                throw new Exception();
            }
            int count = 4096 + mask.Length;

            pc.BeginAccess();
            byte[] buffer = new byte[count];
            int    num    = 0;

            while (true)
            {
                pc.Seek((long)(4194304 + num * 4096), SeekOrigin.Begin);
                if (pc.Read(buffer, 0, count) == count)
                {
                    for (int index1 = 0; index1 < 4096; ++index1)
                    {
                        bool flag = true;
                        for (int index2 = 0; flag && index2 < mask.Length; ++index2)
                        {
                            flag = ((int)buffer[index1 + index2] & (int)mask[index2]) == (int)vals[index2];
                        }
                        if (flag)
                        {
                            pc.EndAccess();
                            return(4194304 + num * 4096 + index1);
                        }
                    }
                    ++num;
                }
                else
                {
                    break;
                }
            }
            pc.EndAccess();
            return(0);
        }
Ejemplo n.º 7
0
        private static void GetCoordDetails(ProcessStream pc, int ptr, byte[] dets, out int coordPointer, out int coordSize)
        {
            pc.Seek(ptr + dets[0], SeekOrigin.Begin);
            coordPointer = Read(pc, dets[1]);

            if (dets[2] < 0xFF)
            {
                pc.Seek(coordPointer, SeekOrigin.Begin);
                coordPointer = Read(pc, dets[2]);
            }

            if (dets[3] < 0xFF)
            {
                pc.Seek(ptr + dets[3], SeekOrigin.Begin);
                coordPointer += Read(pc, dets[4]);
            }

            /*
             * arul:
             *	The variable 'dets[6]' represents an offset into the struct that holds an info about players current location.
             *	Added not to break functionality with the older clients (I hope).
             *
             * The struct looks as follows:
             *
             *  DWORD fLoggedIn;
             *	DWORD Z;
             *  DWORD Y;
             *	DWORD X;
             *	DWORD Facet;
             *
             */

            if (dets.Length == 7 && dets[6] < 0xFF)
            {
                coordPointer += dets[6];
            }

            coordSize = dets[5];
        }
Ejemplo n.º 8
0
        public static int Search(ProcessStream pc, byte[] buffer)
        {
            const int chunkSize = 4096;
            int       readSize  = chunkSize + buffer.Length;

            pc.BeginAccess();

            byte[] read = new byte[readSize];

            for (int i = 0;; ++i)
            {
                pc.Seek(0x400000 + (i * chunkSize), SeekOrigin.Begin);
                int count = pc.Read(read, 0, readSize);

                if (count != readSize)
                {
                    break;
                }

                for (int j = 0; j < chunkSize; ++j)
                {
                    bool ok = true;

                    for (int k = 0; ok && k < buffer.Length; ++k)
                    {
                        ok = (buffer[k] == read[j + k]);
                    }

                    if (ok)
                    {
                        pc.EndAccess();
                        return(0x400000 + (i * chunkSize) + j);
                    }
                }
            }

            pc.EndAccess();
            return(0);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Attempts to calibrate the <see cref="FindLocation" /> method based on an input <paramref name="x" />, <paramref name="y" />, and <paramref name="z" />.
        /// <seealso cref="FindLocation" />
        /// <seealso cref="ProcessStream" />
        /// </summary>
        /// <returns>The calibrated memory location -or- 0 if it could not be found.</returns>
        public static void Calibrate(int x, int y, int z)
        {
            m_LocationPointer = null;

            ProcessStream pc = ProcessStream;

            if (pc == null)
            {
                return;
            }

            byte[] buffer = new byte[12];

            buffer[0] = (byte)z;
            buffer[1] = (byte)(z >> 8);
            buffer[2] = (byte)(z >> 16);
            buffer[3] = (byte)(z >> 24);

            buffer[4] = (byte)y;
            buffer[5] = (byte)(y >> 8);
            buffer[6] = (byte)(y >> 16);
            buffer[7] = (byte)(y >> 24);

            buffer[8]  = (byte)x;
            buffer[9]  = (byte)(x >> 8);
            buffer[10] = (byte)(x >> 16);
            buffer[11] = (byte)(x >> 24);

            int ptr = Search(pc, buffer);

            if (ptr == 0)
            {
                return;
            }

            m_LocationPointer = new LocationPointer(ptr + 8, ptr + 4, ptr, 0, 4, 4, 4, 0);
        }
Ejemplo n.º 10
0
        public static int Search(ProcessStream pc, byte[] buffer)
        {
            int count = 4096 + buffer.Length;

            pc.BeginAccess();
            byte[] buffer1 = new byte[count];
            int    num     = 0;

            while (true)
            {
                pc.Seek((long)(4194304 + num * 4096), SeekOrigin.Begin);
                if (pc.Read(buffer1, 0, count) == count)
                {
                    for (int index1 = 0; index1 < 4096; ++index1)
                    {
                        bool flag = true;
                        for (int index2 = 0; flag && index2 < buffer.Length; ++index2)
                        {
                            flag = (int)buffer[index2] == (int)buffer1[index1 + index2];
                        }
                        if (flag)
                        {
                            pc.EndAccess();
                            return(4194304 + num * 4096 + index1);
                        }
                    }
                    ++num;
                }
                else
                {
                    break;
                }
            }
            pc.EndAccess();
            return(0);
        }