Esempio n. 1
0
        public void ResultListOfNewScan()
        {
            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;

                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];

                    Byte[] new_value = new byte[element_length];
                    if (default_value_0.Length == 0)
                    {
                        for (int i = 0; i + element_length < buffer.LongLength; i += element_alignment)
                        {
                            Buffer.BlockCopy(buffer, i, new_value, 0, element_length);
                            if (memoryHelper.Comparer(default_value_0, default_value_1, null, new_value))
                            {
                                new_result_list.Add((uint)i + base_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));
            }
        }