mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
5c469e9587
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@294 21ef857c-d57f-4fe0-8362-d861dc6d29cd
155 lines
5.3 KiB
C#
155 lines
5.3 KiB
C#
/*
|
|
* Process Hacker
|
|
*
|
|
* Copyright (C) 2008 wj32
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ProcessHacker
|
|
{
|
|
public partial class SearchWindow : Form
|
|
{
|
|
private SearchOptions _so;
|
|
private List<string[]> _oldresults;
|
|
private int _pid;
|
|
|
|
public SearchWindow(int PID, SearchOptions so)
|
|
{
|
|
InitializeComponent();
|
|
|
|
_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"];
|
|
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"];
|
|
|
|
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;
|
|
}
|
|
|
|
_oldresults = so.Searcher.Results;
|
|
|
|
FocusTab();
|
|
}
|
|
|
|
public SearchOptions SearchOptions
|
|
{
|
|
get { return _so; }
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
_so.Searcher.Params["text"] = text;
|
|
_so.Searcher.Params["regex"] = textRegex.Text;
|
|
_so.Searcher.Params["s_ms"] = textStringMS.Text;
|
|
_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;
|
|
|
|
_so.Searcher.Results = _oldresults;
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
FocusTab();
|
|
}
|
|
|
|
private void FocusTab()
|
|
{
|
|
if (tabControl.SelectedTab == tabLiteral)
|
|
{
|
|
hexBoxSearch.Select();
|
|
hexBoxSearch.Focus();
|
|
}
|
|
else if (tabControl.SelectedTab == tabRegex)
|
|
{
|
|
textRegex.Focus();
|
|
textRegex.Select();
|
|
textRegex.Select(textRegex.Text.Length, 0);
|
|
textRegex.Focus();
|
|
}
|
|
else if (tabControl.SelectedTab == tabString)
|
|
{
|
|
textStringMS.SelectAll();
|
|
textStringMS.Focus();
|
|
}
|
|
else if (tabControl.SelectedTab == tabHeap)
|
|
{
|
|
textHeapMS.SelectAll();
|
|
textHeapMS.Focus();
|
|
}
|
|
}
|
|
}
|
|
}
|