Exemplo n.º 1
0
        public ComparerThread(ProcessManager processManager, MemoryHelper memoryHelper, List <byte[]> bufferQueue,
                              string value_0, string value_1, BackgroundWorker worker, Semaphore consumerMutex, Semaphore producerMutex, Mutex workerMutex)
        {
            this.processManager = processManager;
            this.memoryHelper   = memoryHelper;
            this.buffer_queue   = bufferQueue;

            this.consumer_idx    = 0;
            this.default_value_0 = memoryHelper.StringToBytes(value_0);
            this.default_value_1 = memoryHelper.StringToBytes(value_1);
            this.worker          = worker;
            this.consumer_mutex  = consumerMutex;
            this.producer_mutex  = producerMutex;
            this.worker_mutex    = workerMutex;
        }
Exemplo n.º 2
0
        public byte[] GetRuntime(int idx)
        {
            byte[] left_buf = new byte[MemoryHelper.Length];
            Buffer.BlockCopy(Left.Get(), 0, left_buf, 0, MemoryHelper.Length);
            byte[] right_buf = new byte[MemoryHelper.Length];
            Buffer.BlockCopy(Right.Get(), 0, right_buf, 0, MemoryHelper.Length);
            ulong left   = BitConverter.ToUInt64(left_buf, 0);
            ulong right  = BitConverter.ToUInt64(right_buf, 0);
            ulong result = 0;

            switch (ArithmeticType)
            {
            case ArithmeticType.ADD_TYPE:
                result = left + right;
                break;

            case ArithmeticType.SUB_TYPE:
                result = left - right;
                break;

            case ArithmeticType.MUL_TYPE:
                result = left * right;
                break;

            case ArithmeticType.DIV_TYPE:
                result = left / right;
                break;

            default:
                throw new Exception("ArithmeticType!!!");
            }
            return(MemoryHelper.StringToBytes(result.ToString()));
        }
Exemplo n.º 3
0
 public override bool Parse(string[] cheat_elements, ref int start_idx, bool simple_format)
 {
     ValueType  = MemoryHelper.GetValueTypeByString(cheat_elements[start_idx + DATA_TYPE]);
     data       = MemoryHelper.StringToBytes(cheat_elements[start_idx + DATA]);
     start_idx += 2;
     return(true);
 }
Exemplo n.º 4
0
        public override bool Parse(string[] cheat_elements, ref int start_idx, bool simple_format)
        {
            string[] strs    = cheat_elements[start_idx].Split(' ');
            string   str     = strs[0];
            string   addrStr = str.Substring(5);

            addrStr     += strs[1];
            this.address = UInt32.Parse(addrStr, NumberStyles.HexNumber);
            address     += CONSTANT.START_ADDRESS;
            data         = MemoryHelper.StringToBytes(strs[2]);
            start_idx   += 1;
            return(true);
        }
Exemplo n.º 5
0
        public AddressList getFilteredAddressList(ProcessManager processManager, MemoryHelper memoryHelper,
                                                  string value, BackgroundWorker worker, ref ulong percent_len, int start, float percent)
        {
            AddressList filtered_list = new AddressList();

            worker.ReportProgress(start);

            if (!Check)
            {
                return(filtered_list);
            }

            ulong address = this.Start;
            int   length  = this.Length;

            const int block_length = 1024 * 1024 * 128;

            while (length != 0)
            {
                int cur_length = block_length;

                if (cur_length > length)
                {
                    cur_length = length;
                    length     = 0;
                }
                else
                {
                    length -= cur_length;
                }

                percent_len += (ulong)cur_length;
                worker.ReportProgress(start + (int)(((float)percent_len / processManager.TotalMemorySize) * 100 * percent));

                byte[] buffer = MemoryHelper.ReadMemory(address, (int)cur_length);

                byte[] match_value = memoryHelper.StringToBytes(value);

                memoryHelper.CompareWithFilterList(match_value, address, buffer, filtered_list);

                address += (ulong)cur_length;
            }
            return(filtered_list);
        }
Exemplo n.º 6
0
        public override void Refresh()
        {
            MemoryHelper memoryHelper = new MemoryHelper();

            memoryHelper.InitMemoryHandler(Type, CompareType.NONE);

            memoryHelper.SetBytesByType(ulong.Parse(Address, NumberStyles.HexNumber), memoryHelper.StringToBytes(value_));
            value_ = memoryHelper.BytesToString(memoryHelper.GetBytesByType(ulong.Parse(Address, NumberStyles.HexNumber)));
        }
Exemplo n.º 7
0
        public void UpdateResultList(ProcessManager processManager, MemoryHelper memoryHelper,
                                     string default_value_0_str, string default_value_1_str, bool is_hex, bool newScan, int thread_id)
        {
            if (!Check)
            {
                ResultList = null;
                return;
            }

            ResultList new_result_list = new ResultList(memoryHelper.Length, memoryHelper.Alignment);

            ulong address      = this.Start;
            uint  base_address = 0;
            int   length       = this.Length;

            const int buffer_length = 1024 * 1024 * 128;

            while (length != 0)
            {
                int cur_length = buffer_length;

                if (cur_length > length)
                {
                    cur_length = length;
                    length     = 0;
                }
                else
                {
                    length -= cur_length;
                }

                byte[] buffer = memoryHelper.ReadMemory(address, (int)cur_length, thread_id);

                byte[] default_value_0 = null;
                if (memoryHelper.ParseFirstValue)
                {
                    if (is_hex)
                    {
                        default_value_0 = memoryHelper.HexStringToBytes(default_value_0_str);
                    }
                    else
                    {
                        default_value_0 = memoryHelper.StringToBytes(default_value_0_str);
                    }
                }

                byte[] default_value_1 = null;
                if (memoryHelper.ParseSecondValue)
                {
                    if (is_hex)
                    {
                        default_value_1 = memoryHelper.HexStringToBytes(default_value_1_str);
                    }
                    else
                    {
                        default_value_1 = memoryHelper.StringToBytes(default_value_1_str);
                    }
                }

                if (newScan)
                {
                    memoryHelper.CompareWithMemoryBufferNewScanner(default_value_0, default_value_1, buffer, new_result_list, base_address);
                }
                else
                {
                    memoryHelper.CompareWithMemoryBufferNextScanner(default_value_0, default_value_1, buffer, ResultList, new_result_list);
                }

                address      += (ulong)cur_length;
                base_address += (uint)cur_length;
            }
            ResultList = new_result_list;
        }
Exemplo n.º 8
0
 public void Set(string data)
 {
     this.data = MemoryHelper.StringToBytes(data);
 }
Exemplo n.º 9
0
 public DataCheatOperator(string data, ValueType valueType, ProcessManager processManager)
     : base(valueType, processManager)
 {
     this.data         = MemoryHelper.StringToBytes(data);
     CheatOperatorType = CheatOperatorType.DATA_TYPE;
 }