Esempio n. 1
0
        /// <summary>
        /// Attempts to automatically calibrate the <see cref="FindLocation" /> method.
        /// </summary>
        /// <returns>The calibrated memory location -or- 0 if it could not be found.</returns>
        public static void Calibrate(CalibrationInfo[] info)
        {
            m_LocationPointer = null;

            ProcessStream pc = ProcessStream;

            if (pc == null)
            {
                return;
            }

            int ptrX = 0, sizeX = 0;
            int ptrY = 0, sizeY = 0;
            int ptrZ = 0, sizeZ = 0;
            int ptrF = 0, sizeF = 0;

            for (int i = 0; i < info.Length; ++i)
            {
                CalibrationInfo ci = info[i];

                int ptr = Search(pc, ci.Mask, ci.Vals);

                if (ptr == 0)
                {
                    continue;
                }

                if (ptrX == 0 && ci.DetX.Length > 0)
                {
                    GetCoordDetails(pc, ptr, ci.DetX, out ptrX, out sizeX);
                }

                if (ptrY == 0 && ci.DetY.Length > 0)
                {
                    GetCoordDetails(pc, ptr, ci.DetY, out ptrY, out sizeY);
                }

                if (ptrZ == 0 && ci.DetZ.Length > 0)
                {
                    GetCoordDetails(pc, ptr, ci.DetZ, out ptrZ, out sizeZ);
                }

                if (ptrF == 0 && ci.DetF.Length > 0)
                {
                    GetCoordDetails(pc, ptr, ci.DetF, out ptrF, out sizeF);
                }

                if (ptrX != 0 && ptrY != 0 && ptrZ != 0 && ptrF != 0)
                {
                    break;
                }
            }

            if (ptrX != 0 || ptrY != 0 || ptrZ != 0 || ptrF != 0)
            {
                m_LocationPointer = new LocationPointer(ptrX, ptrY, ptrZ, ptrF, sizeX, sizeY, sizeZ, sizeF);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }