Seek() public method

public Seek ( long offset, SeekOrigin origin ) : long
offset long
origin SeekOrigin
return long
Beispiel #1
0
        public static bool FindLocation(ref int x, ref int y, ref int z, ref int facet)
        {
            LocationPointer locationPointer = Client.LocationPointer;
            ProcessStream   processStream   = Client.ProcessStream;

            if (processStream == null || locationPointer == null)
            {
                return(false);
            }
            processStream.BeginAccess();
            if (locationPointer.PointerX > 0)
            {
                processStream.Seek((long)locationPointer.PointerX, SeekOrigin.Begin);
                x = Client.Read(processStream, locationPointer.SizeX);
            }
            if (locationPointer.PointerY > 0)
            {
                processStream.Seek((long)locationPointer.PointerY, SeekOrigin.Begin);
                y = Client.Read(processStream, locationPointer.SizeY);
            }
            if (locationPointer.PointerZ > 0)
            {
                processStream.Seek((long)locationPointer.PointerZ, SeekOrigin.Begin);
                z = Client.Read(processStream, locationPointer.SizeZ);
            }
            if (locationPointer.PointerF > 0)
            {
                processStream.Seek((long)locationPointer.PointerF, SeekOrigin.Begin);
                facet = Client.Read(processStream, locationPointer.SizeF);
            }
            processStream.EndAccess();
            return(true);
        }
Beispiel #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];
 }
Beispiel #3
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];
        }
Beispiel #4
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);
        }
Beispiel #5
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];
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #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);
        }
Beispiel #9
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);
        }