Esempio n. 1
0
        private byte[] convertValue(decimal value, ValueType vtype)
        {
            object val  = null;
            int    size = 0;

            switch (vtype)
            {
            case ValueType.UINT_TYPE:
                size = 4;
                val  = Convert.ToUInt32(value); break;

            case ValueType.ULONG_TYPE:
                size = 8;
                val  = Convert.ToUInt64(value); break;

            case ValueType.USHORT_TYPE:
                size = 2;
                val  = Convert.ToUInt16(value); break;

            case ValueType.BYTE_TYPE:
                size = 1;
                val  = Convert.ToByte(value); break;
            }
            string str = String.Format("{0:X}", val);
            int    len = size * 2;

            str = str.PadLeft(len, '0');
            byte[] buff = MemoryHelper.string_to_hex_bytes(str);
            Array.Reverse(buff);
            return(buff);
        }
Esempio n. 2
0
        private void find_Click(object sender, EventArgs e)
        {
            FindOptions findOptions = new FindOptions();

            findOptions.Type = FindType.Hex;
            findOptions.Hex  = MemoryHelper.string_to_hex_bytes(input_box.Text);
            hexBox.Find(findOptions);
        }
Esempio n. 3
0
        public static byte[] HexToBytes(string hex)
        {
            int size = (hex.Length + 1) / 2 * 2;

            hex = hex.PadLeft(size, '0');
            byte[] data = MemoryHelper.string_to_hex_bytes(hex);
            Array.Reverse(data);
            return(data);
        }
Esempio n. 4
0
 private void find_Click(object sender, EventArgs e)
 {
     try
     {
         FindOptions findOptions = new FindOptions();
         findOptions.Type = FindType.Hex;
         findOptions.Hex  = MemoryHelper.string_to_hex_bytes(input_box.Text);
         hexBox.Find(findOptions);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, exception.Source, MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
 }
Esempio n. 5
0
        private byte[] GetData(int index, bool reset)
        {
            ulong     address = this.getAddress();
            BatchCode code    = Codes[index];

            byte[] data  = null;
            string value = code.value;

            if (reset)
            {
                value = code.reset;
            }
            ValueType vtype   = code.vtype;
            int       size    = code.size;
            int       psize   = size + code.skip;
            decimal   baseVal = 0;

            byte[] stepData = null;
            if (code.step != 0)
            {
                string hexStr = String.Format("{0:X}", code.step);
                stepData = NumberBytesHelper.HexToBytes(hexStr);
            }
            if (value.StartsWith("0x"))
            {
                string str = value.Substring(2);
                data = MemoryHelper.string_to_hex_bytes(str);
                if (size < 9)
                {
                    string[] strs = new string[str.Length / 2];
                    for (int i = 0; i < strs.Length; i++)
                    {
                        strs[i] = str.Substring(i * 2, 2);
                    }
                    Array.Reverse(strs);
                    str     = String.Join("", strs);
                    baseVal = ulong.Parse(str, NumberStyles.HexNumber);
                }
            }
            else
            {
                baseVal = Convert.ToDecimal(value);
                data    = this.convertValue(baseVal, vtype);
            }

            if (BatchType.VALUE.Equals(code.batchType))
            {
                return(data);
            }

            int dataSize = code.GetDataSize();
            int offset   = code.offset;

            address = address + (ulong)offset;
            byte[] buff = null;
            if (CheatList.IS_DEV)
            {
                buff = new byte[dataSize];
            }
            else
            {
                buff = MemoryHelper.ReadMemory(address, dataSize);
            }
            decimal        val      = baseVal;
            int            pos      = 0;
            NumberExcluder excluder = code.excluder;
            bool           ignore   = false;
            int            begin    = code.begin + 1;
            int            end      = code.target + 1;

            switch (code.batchType)
            {
            case BatchType.FOR:
                for (int i = begin; i < end; i++)
                {
                    if (excluder != null)
                    {
                        ignore = excluder.Match(i);
                    }
                    if (!ignore)
                    {
                        if (size < 9 && val != baseVal)
                        {
                            data = this.convertValue(val, vtype);
                        }
                        Buffer.BlockCopy(data, 0, buff, pos, code.size);
                        pos += psize;
                    }
                    if (!reset)
                    {
                        if (size < 9)
                        {
                            val += code.step;
                        }
                        else if (stepData != null)
                        {
                            data = NumberBytesHelper.Add(data, stepData);
                        }
                    }
                }
                break;
            }
            return(buff);
        }