private void TestPatchWrite()
{
if (listPatternResults.Items.Count > 0)
{
MagicPatches.Patch tmpPatch = new MagicPatches.Patch
{
title = txtPatchTitle.Text,
author = txtPatchAuthor.Text,
description = txtPatchDescription.Text,
pattern = txtPatternBytesSearch.Text,
match = txtPatternMatch.Text,
offset = Convert.ToInt32(txtPatternOffset.Text),
patch = txtBytesToPatch.Text,
recursivePatch = chkPatchReplaceAll.Checked,
patchOnStartup = chkRunOnStartup.Checked,
patchBeforeStartup = chkPatchBeforeStartup.Checked
};
if (tmpPatch.recursivePatch)
{
if (MagicPatches.PatchRecursive(tmpPatch))
{
GoogleAnalyticsApi.TrackEvent("PatchEditor.cs", "TestPatchWrite", "Patch Successful");
MessageBox.Show("Patch Successful");
}
else
{
GoogleAnalyticsApi.TrackEvent("PatchEditor.cs", "TestPatchWrite", "Patch Failed.");
MessageBox.Show("Patch Failed.");
}
}
else
{
this.Invoke((MethodInvoker)delegate()
{
if (listPatternResults.SelectedItems.Count > 0)
{
string item = listPatternResults.SelectedItems[0].ToString();
CurrentPatchAddress = (IntPtr)Convert.ToInt32(item, 16);
MagicPatches.PatchSingleAddress(tmpPatch, CurrentPatchAddress);
}
else
{
MessageBox.Show("If you're not running a full run, you need to select an address in the patch test results.");
}
btnPatternScanStop.Enabled = false;
btnTestPatchWrite.Enabled = true;
btnTestPatchWrite.Text = "Test Patch";
});
}
}
else
{
MessageBox.Show("You need to run a pattern scan test before you can test writing.");
}
}