Ejemplo n.º 1
0
        private void update_result_list_view(BackgroundWorker worker, bool refresh, int start, float percent)
        {
            worker.ReportProgress(start);

            List <ListViewItem> listViewItems = new List <ListViewItem>();

            bool[] mappedSectionCheckeSet = new bool[processManager.MappedSectionList.Count];

            ulong  totalResultCount = processManager.MappedSectionList.TotalResultCount();
            ulong  curResultCount   = 0;
            string value_type       = MemoryHelper.GetStringOfValueType(memoryHelper.ValueType);

            const int MAX_RESULTS_NUM = 0x1000;

            for (int idx = 0; idx < processManager.MappedSectionList.Count; ++idx)
            {
                MappedSection mapped_section = processManager.MappedSectionList[idx];
                ResultList    result_list    = mapped_section.ResultList;
                if (result_list == null)
                {
                    continue;
                }
                if (!mapped_section.Check)
                {
                    continue;
                }

                mappedSectionCheckeSet[idx] = result_list.Count > 0;

                for (result_list.Begin(); !result_list.End(); result_list.Next())
                {
                    if (curResultCount >= MAX_RESULTS_NUM)
                    {
                        break;
                    }

                    uint   memory_address_offset = 0;
                    byte[] memory_value          = null;

                    result_list.Get(ref memory_address_offset, ref memory_value);

                    curResultCount++;
                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = String.Format("{0:X}", memory_address_offset + mapped_section.Start);

                    if (refresh && !worker.CancellationPending)
                    {
                        memory_value = memoryHelper.GetBytesByType(memory_address_offset + mapped_section.Start);
                        result_list.Set(memory_value);
                        worker.ReportProgress(start + (int)(100.0f * curResultCount / MAX_RESULTS_NUM));
                    }

                    lvi.SubItems.Add(value_type);
                    lvi.SubItems.Add(memoryHelper.BytesToString(memory_value));
                    lvi.SubItems.Add(memoryHelper.BytesToHexString(memory_value));
                    lvi.SubItems.Add(processManager.MappedSectionList.GetSectionName(idx));

                    listViewItems.Add(lvi);
                }
            }

            WorkerReturn workerReturn = new WorkerReturn();

            workerReturn.ListViewItems          = listViewItems;
            workerReturn.MappedSectionCheckeSet = mappedSectionCheckeSet;
            workerReturn.Results = totalResultCount;

            worker.ReportProgress(start + (int)(100 * percent), workerReturn);
        }
Ejemplo n.º 2
0
        public void ResultListOfNextScan()
        {
            long  processed_memory_len = 0;
            ulong total_memory_size    = processManager.MappedSectionList.TotalMemorySize + 1;

            for (int section_idx = 0; section_idx < processManager.MappedSectionList.Count; ++section_idx)
            {
                if (worker.CancellationPending)
                {
                    break;
                }
                MappedSection mappedSection = processManager.MappedSectionList[section_idx];

                if (!mappedSection.Check)
                {
                    mappedSection.ResultList = null;
                    continue;
                }

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

                ulong address             = mappedSection.Start;
                uint  base_address_offset = 0;
                int   length = mappedSection.Length;

                ResultList old_result_list = mappedSection.ResultList;
                old_result_list.Begin();

                while (length != 0)
                {
                    int cur_length = CONSTANT.PEEK_BUFFER_LENGTH;

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

                    if (worker.CancellationPending)
                    {
                        break;
                    }

                    consumer_mutex.WaitOne();

                    int element_alignment = memoryHelper.Alignment;
                    int element_length    = memoryHelper.Length;

                    byte[] buffer     = buffer_queue[consumer_idx];
                    int    buffer_len = buffer.Length;
                    Byte[] new_value  = new byte[element_length];

                    if (default_value_0.Length == 0)
                    {
                        for (; !old_result_list.End(); old_result_list.Next())
                        {
                            uint   address_offset = 0;
                            Byte[] old_value      = null;
                            old_result_list.Get(ref address_offset, ref old_value);

                            if (address_offset - base_address_offset + length >= buffer_len)
                            {
                                break;
                            }

                            Buffer.BlockCopy(buffer, (int)(address_offset - base_address_offset), new_value, 0, length);
                            if (memoryHelper.Comparer(default_value_0, default_value_1, old_value, new_value))
                            {
                                new_result_list.Add(address_offset, new_value);
                            }
                        }
                    }

                    consumer_idx = (consumer_idx + 1) % CONSTANT.MAX_PEEK_QUEUE;
                    producer_mutex.Release();

                    address             += (ulong)cur_length;
                    base_address_offset += (uint)cur_length;
                }

                mappedSection.ResultList = new_result_list;
                if (mappedSection.Check)
                {
                    processed_memory_len += mappedSection.Length;
                }
                worker.ReportProgress((int)(((float)processed_memory_len / total_memory_size) * 80));
            }
        }