Exemplo 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);
        }