public ResultsWindow(int PID)
        {
            InitializeComponent();
            this.AddEscapeToClose();
            this.SetTopMost();

            listResults.SetDoubleBuffered(true);
            listResults.SetTheme("explorer");

            Thread.CurrentThread.Priority = ThreadPriority.Highest;

            _pid = PID;

            _id = Program.ResultsIds.Pop();

            Program.ResultsWindows.Add(Id, this);

            this.Text = Program.ProcessProvider.Dictionary[_pid].Name + " (PID " + _pid.ToString() +
                ") - Results - " + _id;

            labelText.Text = "Ready.";

            _so = new SearchOptions(_pid, SearchType.String);

            listResults.AddShortcuts(this.listResults_RetrieveVirtualItem);
        }
        public ResultsWindow(int pid)
        {
            InitializeComponent();
            this.AddEscapeToClose();
            this.SetTopMost();

            Thread.CurrentThread.Priority = ThreadPriority.Highest;

            _pid = pid;

            _id = Program.ResultsIds.Pop();

            Program.ResultsWindows.Add(Id, this);

            if (Program.ProcessProvider.Dictionary.ContainsKey(_pid))
            {
                this.Text = Program.ProcessProvider.Dictionary[_pid].Name + " (PID " + _pid.ToString() +
                    ") - Results - " + _id.ToString();
            }
            else
            {
                this.Text = "PID " + _pid.ToString() + " - Results - " + _id.ToString();
            }

            labelText.Text = "Ready.";

            _so = new SearchOptions(_pid, SearchType.String);

            listResults.AddShortcuts(this.listResults_RetrieveVirtualItem);
        }
        public SearchWindow(int PID, SearchOptions so)
        {
            InitializeComponent();

            this.AddEscapeToClose();
            this.SetTopMost();

            foreach (string s in Program.Structs.Keys)
                listStructName.Items.Add(s);

            if (listStructName.Items.Count > 0)
                listStructName.SelectedItem = listStructName.Items[0];

            _pid = PID;

            hexBoxSearch.ByteProvider = new Be.Windows.Forms.DynamicByteProvider((byte[])so.Searcher.Params["text"]);
            textRegex.Text = (string)so.Searcher.Params["regex"];
            textStringMS.Text = (string)so.Searcher.Params["s_ms"];
            checkUnicode.Checked = (bool)so.Searcher.Params["unicode"];
            textHeapMS.Text = (string)so.Searcher.Params["h_ms"];
            checkNoOverlap.Checked = (bool)so.Searcher.Params["nooverlap"];
            checkIgnoreCase.Checked = (bool)so.Searcher.Params["ignorecase"];
            checkPrivate.Checked = (bool)so.Searcher.Params["private"];
            checkImage.Checked = (bool)so.Searcher.Params["image"];
            checkMapped.Checked = (bool)so.Searcher.Params["mapped"];
            listStructName.SelectedItem = so.Searcher.Params["struct"];
            textStructAlign.Text = (string)so.Searcher.Params["struct_align"];

            switch (so.Type)
            {
                case SearchType.Literal:
                    tabControl.SelectedTab = tabLiteral;
                    break;
                case SearchType.Regex:
                    tabControl.SelectedTab = tabRegex;
                    break;
                case SearchType.String:
                    tabControl.SelectedTab = tabString;
                    break;
                case SearchType.Heap:
                    tabControl.SelectedTab = tabHeap;
                    break;
                case SearchType.Struct:
                    tabControl.SelectedTab = tabStruct;
                    break;
            }

            _oldresults = so.Searcher.Results;

            FocusTab();
        }
        public DialogResult EditSearch(SearchType type, System.Drawing.Point location, System.Drawing.Size size)
        {
            DialogResult dr = DialogResult.Cancel;

            _so.Type = type;

            SearchWindow sw = new SearchWindow(_pid, _so);

            sw.StartPosition = FormStartPosition.Manual;
            sw.Location = new System.Drawing.Point(
                location.X + (size.Width - sw.Width) / 2,
                location.Y + (size.Height - sw.Height) / 2);

            Rectangle newRect = Utils.FitRectangle(new Rectangle(sw.Location, sw.Size), Screen.GetWorkingArea(sw));

            sw.Location = newRect.Location;
            sw.Size = newRect.Size;

            if ((dr = sw.ShowDialog()) == DialogResult.OK)
            {
                _so = sw.SearchOptions;
            }

            return dr;
        }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            byte[] text = new byte[hexBoxSearch.ByteProvider.Length];

            for (int i = 0; i < hexBoxSearch.ByteProvider.Length; i++)
                text[i] = hexBoxSearch.ByteProvider.ReadByte(i);

            if (tabControl.SelectedTab == tabLiteral)
            {
                _so = new SearchOptions(_pid, SearchType.Literal);
            }
            else if (tabControl.SelectedTab == tabRegex)
            {
                _so = new SearchOptions(_pid, SearchType.Regex);
            }
            else if (tabControl.SelectedTab == tabString)
            {
                _so = new SearchOptions(_pid, SearchType.String);
            }
            else if (tabControl.SelectedTab == tabHeap)
            {
                _so = new SearchOptions(_pid, SearchType.Heap);
            }
            else if (tabControl.SelectedTab == tabStruct)
            {
                _so = new SearchOptions(_pid, SearchType.Struct);
            }

            _so.Searcher.Params["text"] = text;
            _so.Searcher.Params["regex"] = textRegex.Text;
            _so.Searcher.Params["s_ms"] = textStringMS.Text;
            _so.Searcher.Params["unicode"] = checkUnicode.Checked;
            _so.Searcher.Params["h_ms"] = textHeapMS.Text;
            _so.Searcher.Params["nooverlap"] = checkNoOverlap.Checked;
            _so.Searcher.Params["ignorecase"] = checkIgnoreCase.Checked;
            _so.Searcher.Params["private"] = checkPrivate.Checked;
            _so.Searcher.Params["image"] = checkImage.Checked;
            _so.Searcher.Params["mapped"] = checkMapped.Checked;
            if (listStructName.SelectedItem != null)
                _so.Searcher.Params["struct"] = listStructName.SelectedItem.ToString();
            _so.Searcher.Params["struct_align"] = textStructAlign.Text;

            _so.Searcher.Results = _oldresults;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }