diff --git a/src/CxbxDebugger/CheatEngineManager.cs b/src/CxbxDebugger/CheatEngineManager.cs
deleted file mode 100644
index 29a60cd1c..000000000
--- a/src/CxbxDebugger/CheatEngineManager.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-// Written by x1nixmzeng for the Cxbx-Reloaded project
-//
-
-using System;
-using System.Collections.Generic;
-using CxbxDebugger.CheatEngine;
-
-namespace CxbxDebugger
-{
- class CheatEngineManager
- {
- public CheatTable Cheats;
-
- public bool RefreshAll(DebuggerProcess Process)
- {
- bool Changed = false;
-
- for (int i = 0; i < Cheats.CheatEntries.Count; ++i)
- {
- CheatEntry Entry = Cheats.CheatEntries[i];
-
- //if (Entry.LastState.Activated)
- {
- string last = Entry.LastState.Value;
- Entry.LastState.Value = Read(Process, i);
-
- if(Entry.LastState.Value != last )
- {
- Changed = true;
- }
-
- Cheats.CheatEntries[i] = Entry;
- }
- }
-
-
- return Changed;
- }
-
- public string Read(DebuggerProcess Process, int CheatIndex)
- {
- string printed_value = "??";
- CheatEntry entry = Cheats.CheatEntries[CheatIndex];
-
- int addr = 0;
- if (!ReadHexInt(entry.Address, ref addr))
- {
- return printed_value;
- }
-
- switch (entry.VariableType)
- {
- case Variable.Byte:
- {
- var data = Process.ReadMemoryBlock(new IntPtr(addr), 1);
-
- if (data != null)
- {
- if (entry.ShowAsHex)
- {
- printed_value = string.Format("0x{0:x}", data[0]);
- }
- else
- {
- printed_value = string.Format("{0}", data[0]);
- }
-
- }
- break;
- }
-
- case Variable.Bytes2:
- {
- var data = Process.ReadMemoryBlock(new IntPtr(addr), 2);
-
- if (data != null)
- {
- ushort val = BitConverter.ToUInt16(data, 0);
-
- if (entry.ShowAsHex)
- {
- printed_value = string.Format("0x{0:x}", val);
- }
- else
- {
- printed_value = string.Format("{0}", val);
- }
-
- }
- break;
- }
-
- case Variable.Bytes4:
- {
- var data = Process.ReadMemoryBlock(new IntPtr(addr), 4);
-
- if (data != null)
- {
- uint val = BitConverter.ToUInt32(data, 0);
-
- if (entry.ShowAsHex)
- {
- printed_value = string.Format("0x{0:x}", val);
- }
- else
- {
- printed_value = string.Format("{0}", val);
- }
-
- }
- break;
- }
-
- case Variable.Float:
- {
- var data = Process.ReadMemoryBlock(new IntPtr(addr), 4);
- if (data != null)
- {
- if (entry.ShowAsHex)
- {
- uint val = BitConverter.ToUInt32(data, 0);
- printed_value = string.Format("{0:x8}", val);
- }
- else
- {
- float flt = BitConverter.ToSingle(data, 0);
- printed_value = string.Format("{0}", flt);
- }
-
- }
- break;
- }
- }
-
- return printed_value;
- }
-
- public void Write(DebuggerProcess Process, int CheatIndex, string Value)
- {
- CheatEntry entry = Cheats.CheatEntries[CheatIndex];
-
- int addr = 0;
- if (!ReadHexInt(entry.Address, ref addr))
- {
- return;
- }
-
- switch (entry.VariableType)
- {
- case Variable.Byte:
- {
- uint byte_val = 0;
- ReadAddress(Value, ref byte_val);
-
- byte val = (byte)(byte_val & 0xFF);
- Process.WriteMemory(new IntPtr(addr), val);
-
- break;
- }
-
- case Variable.Float:
- {
- float flt_val = 0.0f;
- ReadFloat(Value, ref flt_val);
-
- Process.WriteMemory(new IntPtr(addr), flt_val);
-
- break;
- }
- }
- }
-
- static private bool ReadHexInt(string HexSource, ref int Out)
- {
- if (int.TryParse(HexSource, System.Globalization.NumberStyles.HexNumber, null, out Out))
- {
- return true;
- }
-
- return false;
- }
-
- static private bool ReadAddress(string Source, ref uint Out)
- {
- try
- {
- if (Source.StartsWith("0x"))
- {
- Out = Convert.ToUInt32(Source.Substring(2), 16);
- return true;
- }
- else
- {
- if (uint.TryParse(Source, out Out))
- {
- return true;
- }
- }
- }
- catch (Exception) { }
-
- return false;
- }
-
- static private bool ReadFloat(string Source, ref float Out)
- {
- return float.TryParse(Source, out Out);
- }
- }
-}
diff --git a/src/CxbxDebugger/CxbxDebugger.csproj b/src/CxbxDebugger/CxbxDebugger.csproj
index aa2f92583..9d9fe71ee 100644
--- a/src/CxbxDebugger/CxbxDebugger.csproj
+++ b/src/CxbxDebugger/CxbxDebugger.csproj
@@ -67,7 +67,6 @@
-
@@ -93,6 +92,7 @@
+
diff --git a/src/CxbxDebugger/Debugger/DebuggerProcess.cs b/src/CxbxDebugger/Debugger/DebuggerProcess.cs
index a6df70d42..4789b91eb 100644
--- a/src/CxbxDebugger/Debugger/DebuggerProcess.cs
+++ b/src/CxbxDebugger/Debugger/DebuggerProcess.cs
@@ -225,6 +225,18 @@ namespace CxbxDebugger
Data = new byte[] { (byte)GenericValue };
break;
+ case TypeCode.Int16:
+ Data = BitConverter.GetBytes((short)GenericValue);
+ break;
+
+ case TypeCode.UInt16:
+ Data = BitConverter.GetBytes((ushort)GenericValue);
+ break;
+
+ case TypeCode.Int32:
+ Data = BitConverter.GetBytes((int)GenericValue);
+ break;
+
case TypeCode.UInt32:
Data = BitConverter.GetBytes((uint)GenericValue);
break;
@@ -242,5 +254,13 @@ namespace CxbxDebugger
WriteMemoryInternal(Address, Data);
}
}
+
+ public bool WriteMemoryBlock(IntPtr Address, byte[] Data)
+ {
+ if (Address == IntPtr.Zero)
+ return false;
+
+ return WriteMemoryInternal(Address, Data);
+ }
}
}
diff --git a/src/CxbxDebugger/DebuggerExtras/CheatTable.cs b/src/CxbxDebugger/DebuggerExtras/CheatTable.cs
index c2078dfff..e7f06cc4f 100644
--- a/src/CxbxDebugger/DebuggerExtras/CheatTable.cs
+++ b/src/CxbxDebugger/DebuggerExtras/CheatTable.cs
@@ -17,13 +17,11 @@ namespace CxbxDebugger
public enum Variable
{
Unsupported,
- Binary,
Byte,
Bytes2,
Bytes4,
Float,
Double,
- String,
}
public struct CheatEntry
@@ -43,9 +41,9 @@ namespace CxbxDebugger
public uint Address;
public string ModuleName;
public uint ModuleNameOffset;
- public byte[] Before;
- public byte[] Actual;
- public byte[] After;
+ public byte[] Before; // 5 bytes before 'Actual'
+ public byte[] Actual; // with a length of the opcode
+ public byte[] After; // 5 bytes after 'Actual'
};
public class CheatTable
@@ -61,5 +59,29 @@ namespace CxbxDebugger
CodeEntires = new List();
}
};
+
+ class Helpers
+ {
+ public static int VariableSize(Variable Var)
+ {
+ switch (Var)
+ {
+ case Variable.Unsupported:
+ return 0;
+ case Variable.Byte:
+ return 1;
+ case Variable.Bytes2:
+ return 2;
+ case Variable.Bytes4:
+ return 4;
+ case Variable.Float:
+ return 4;
+ case Variable.Double:
+ return 8;
+ }
+
+ return 0;
+ }
+ }
}
}
diff --git a/src/CxbxDebugger/Form1.Designer.cs b/src/CxbxDebugger/Form1.Designer.cs
index 71dcd698d..d83b95ac4 100644
--- a/src/CxbxDebugger/Form1.Designer.cs
+++ b/src/CxbxDebugger/Form1.Designer.cs
@@ -46,11 +46,13 @@
this.tabContainer = new System.Windows.Forms.TabControl();
this.tabDisassembly = new System.Windows.Forms.TabPage();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
+ this.btnToMemory = new System.Windows.Forms.Button();
this.btnNext = new System.Windows.Forms.Button();
this.btnPrev = new System.Windows.Forms.Button();
this.btnGo = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.cbDisAddr = new System.Windows.Forms.ComboBox();
+ this.txDisassembly = new CxbxDebugger.RicherTextBox();
this.tabBreakpoints = new System.Windows.Forms.TabPage();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.groupBox4 = new System.Windows.Forms.GroupBox();
@@ -74,43 +76,42 @@
this.splitContainer4 = new System.Windows.Forms.SplitContainer();
this.txMemoryDump = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.textBox2 = new System.Windows.Forms.TextBox();
+ this.label8 = new System.Windows.Forms.Label();
+ this.cbDataFormat = new System.Windows.Forms.ComboBox();
+ this.btnAddWatch = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.btnDumpMemory = new System.Windows.Forms.Button();
this.txAddress = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.btnReadMemory = new System.Windows.Forms.Button();
this.txSize = new System.Windows.Forms.TextBox();
- this.tabOutput = new System.Windows.Forms.TabPage();
- this.splitContainer5 = new System.Windows.Forms.SplitContainer();
- this.txFilter = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.lbDebug = new System.Windows.Forms.ListBox();
this.tabTweaks = new System.Windows.Forms.TabPage();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.label7 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.button2 = new System.Windows.Forms.Button();
this.tabCEContainer = new System.Windows.Forms.TabControl();
this.tabSubData = new System.Windows.Forms.TabPage();
+ this.splitContainer6 = new System.Windows.Forms.SplitContainer();
+ this.btnRefresh = new System.Windows.Forms.Button();
+ this.btnLoadCT = new System.Windows.Forms.Button();
+ this.btnApply = new System.Windows.Forms.Button();
+ this.txNewValue = new System.Windows.Forms.TextBox();
this.lvCEMemory = new System.Windows.Forms.ListView();
- this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tabSubAssembly = new System.Windows.Forms.TabPage();
this.lvCEAssembly = new System.Windows.Forms.ListView();
this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.tabOutput = new System.Windows.Forms.TabPage();
+ this.splitContainer5 = new System.Windows.Forms.SplitContainer();
+ this.txFilter = new System.Windows.Forms.TextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.lbDebug = new System.Windows.Forms.ListBox();
this.diagSaveMemory = new System.Windows.Forms.SaveFileDialog();
this.diagBrowseCT = new System.Windows.Forms.OpenFileDialog();
- this.btnAddWatch = new System.Windows.Forms.Button();
- this.cbDataFormat = new System.Windows.Forms.ComboBox();
- this.btnToMemory = new System.Windows.Forms.Button();
- this.label8 = new System.Windows.Forms.Label();
- this.txDisassembly = new CxbxDebugger.RicherTextBox();
this.toolStrip1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.statusBar.SuspendLayout();
@@ -138,26 +139,29 @@
this.splitContainer4.Panel2.SuspendLayout();
this.splitContainer4.SuspendLayout();
this.groupBox2.SuspendLayout();
+ this.tabTweaks.SuspendLayout();
+ this.tabCEContainer.SuspendLayout();
+ this.tabSubData.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer6)).BeginInit();
+ this.splitContainer6.Panel1.SuspendLayout();
+ this.splitContainer6.Panel2.SuspendLayout();
+ this.splitContainer6.SuspendLayout();
+ this.tabSubAssembly.SuspendLayout();
this.tabOutput.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer5)).BeginInit();
this.splitContainer5.Panel1.SuspendLayout();
this.splitContainer5.Panel2.SuspendLayout();
this.splitContainer5.SuspendLayout();
- this.tabTweaks.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.tabCEContainer.SuspendLayout();
- this.tabSubData.SuspendLayout();
- this.tabSubAssembly.SuspendLayout();
this.SuspendLayout();
//
// lbConsole
//
this.lbConsole.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbConsole.FormattingEnabled = true;
- this.lbConsole.Location = new System.Drawing.Point(3, 228);
+ this.lbConsole.Location = new System.Drawing.Point(3, 231);
this.lbConsole.Name = "lbConsole";
this.lbConsole.ScrollAlwaysVisible = true;
- this.lbConsole.Size = new System.Drawing.Size(756, 50);
+ this.lbConsole.Size = new System.Drawing.Size(728, 51);
this.lbConsole.TabIndex = 2;
//
// toolStrip1
@@ -176,7 +180,7 @@
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
- this.toolStrip1.Size = new System.Drawing.Size(762, 25);
+ this.toolStrip1.Size = new System.Drawing.Size(734, 25);
this.toolStrip1.TabIndex = 7;
this.toolStrip1.Text = "toolStrip1";
//
@@ -257,7 +261,7 @@
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel3.Size = new System.Drawing.Size(762, 302);
+ this.tableLayoutPanel3.Size = new System.Drawing.Size(734, 306);
this.tableLayoutPanel3.TabIndex = 9;
//
// statusBar
@@ -265,9 +269,9 @@
this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill;
this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.lblStatus});
- this.statusBar.Location = new System.Drawing.Point(0, 281);
+ this.statusBar.Location = new System.Drawing.Point(0, 285);
this.statusBar.Name = "statusBar";
- this.statusBar.Size = new System.Drawing.Size(762, 21);
+ this.statusBar.Size = new System.Drawing.Size(734, 21);
this.statusBar.TabIndex = 10;
this.statusBar.Text = "statusStrip1";
//
@@ -283,14 +287,14 @@
this.tabContainer.Controls.Add(this.tabBreakpoints);
this.tabContainer.Controls.Add(this.tabWatch);
this.tabContainer.Controls.Add(this.tabMemory);
- this.tabContainer.Controls.Add(this.tabOutput);
this.tabContainer.Controls.Add(this.tabTweaks);
+ this.tabContainer.Controls.Add(this.tabOutput);
this.tabContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabContainer.Location = new System.Drawing.Point(3, 3);
this.tabContainer.Multiline = true;
this.tabContainer.Name = "tabContainer";
this.tabContainer.SelectedIndex = 0;
- this.tabContainer.Size = new System.Drawing.Size(756, 219);
+ this.tabContainer.Size = new System.Drawing.Size(728, 222);
this.tabContainer.TabIndex = 3;
//
// tabDisassembly
@@ -299,7 +303,7 @@
this.tabDisassembly.Location = new System.Drawing.Point(4, 22);
this.tabDisassembly.Name = "tabDisassembly";
this.tabDisassembly.Padding = new System.Windows.Forms.Padding(3);
- this.tabDisassembly.Size = new System.Drawing.Size(748, 193);
+ this.tabDisassembly.Size = new System.Drawing.Size(720, 196);
this.tabDisassembly.TabIndex = 0;
this.tabDisassembly.Text = "Disassembly";
this.tabDisassembly.UseVisualStyleBackColor = true;
@@ -325,16 +329,27 @@
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.txDisassembly);
- this.splitContainer2.Size = new System.Drawing.Size(742, 187);
+ this.splitContainer2.Size = new System.Drawing.Size(714, 190);
this.splitContainer2.SplitterDistance = 34;
this.splitContainer2.TabIndex = 2;
//
+ // btnToMemory
+ //
+ this.btnToMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnToMemory.Location = new System.Drawing.Point(452, 3);
+ this.btnToMemory.Name = "btnToMemory";
+ this.btnToMemory.Size = new System.Drawing.Size(119, 23);
+ this.btnToMemory.TabIndex = 4;
+ this.btnToMemory.Text = "View Memory";
+ this.btnToMemory.UseVisualStyleBackColor = true;
+ this.btnToMemory.Click += new System.EventHandler(this.button6_Click);
+ //
// btnNext
//
this.btnNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btnNext.Location = new System.Drawing.Point(690, 3);
+ this.btnNext.Location = new System.Drawing.Point(647, 3);
this.btnNext.Name = "btnNext";
- this.btnNext.Size = new System.Drawing.Size(49, 23);
+ this.btnNext.Size = new System.Drawing.Size(64, 23);
this.btnNext.TabIndex = 3;
this.btnNext.Text = "Next";
this.btnNext.UseVisualStyleBackColor = true;
@@ -343,7 +358,7 @@
// btnPrev
//
this.btnPrev.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btnPrev.Location = new System.Drawing.Point(620, 3);
+ this.btnPrev.Location = new System.Drawing.Point(577, 3);
this.btnPrev.Name = "btnPrev";
this.btnPrev.Size = new System.Drawing.Size(64, 23);
this.btnPrev.TabIndex = 2;
@@ -354,11 +369,11 @@
// btnGo
//
this.btnGo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btnGo.Location = new System.Drawing.Point(450, 3);
+ this.btnGo.Location = new System.Drawing.Point(327, 3);
this.btnGo.Name = "btnGo";
- this.btnGo.Size = new System.Drawing.Size(75, 23);
+ this.btnGo.Size = new System.Drawing.Size(119, 23);
this.btnGo.TabIndex = 1;
- this.btnGo.Text = "Go";
+ this.btnGo.Text = "Disassemble";
this.btnGo.UseVisualStyleBackColor = true;
this.btnGo.Click += new System.EventHandler(this.button2_Click);
//
@@ -378,18 +393,33 @@
this.cbDisAddr.FormattingEnabled = true;
this.cbDisAddr.Location = new System.Drawing.Point(132, 5);
this.cbDisAddr.Name = "cbDisAddr";
- this.cbDisAddr.Size = new System.Drawing.Size(312, 21);
+ this.cbDisAddr.Size = new System.Drawing.Size(189, 21);
this.cbDisAddr.TabIndex = 0;
this.cbDisAddr.SelectedIndexChanged += new System.EventHandler(this.cbDisAddr_SelectedIndexChanged);
this.cbDisAddr.KeyDown += new System.Windows.Forms.KeyEventHandler(this.comboBox1_KeyDown);
//
+ // txDisassembly
+ //
+ this.txDisassembly.BackColor = System.Drawing.SystemColors.Window;
+ this.txDisassembly.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ this.txDisassembly.Cursor = System.Windows.Forms.Cursors.Default;
+ this.txDisassembly.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.txDisassembly.Font = new System.Drawing.Font("Lucida Console", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.txDisassembly.Location = new System.Drawing.Point(0, 0);
+ this.txDisassembly.Name = "txDisassembly";
+ this.txDisassembly.ReadOnly = true;
+ this.txDisassembly.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
+ this.txDisassembly.Size = new System.Drawing.Size(714, 152);
+ this.txDisassembly.TabIndex = 1;
+ this.txDisassembly.Text = "";
+ //
// tabBreakpoints
//
this.tabBreakpoints.Controls.Add(this.splitContainer3);
this.tabBreakpoints.Location = new System.Drawing.Point(4, 22);
this.tabBreakpoints.Name = "tabBreakpoints";
this.tabBreakpoints.Padding = new System.Windows.Forms.Padding(3);
- this.tabBreakpoints.Size = new System.Drawing.Size(748, 193);
+ this.tabBreakpoints.Size = new System.Drawing.Size(720, 196);
this.tabBreakpoints.TabIndex = 1;
this.tabBreakpoints.Text = "Breakpoints";
this.tabBreakpoints.UseVisualStyleBackColor = true;
@@ -408,17 +438,20 @@
// splitContainer3.Panel2
//
this.splitContainer3.Panel2.Controls.Add(this.clbBreakpoints);
- this.splitContainer3.Size = new System.Drawing.Size(742, 187);
- this.splitContainer3.SplitterDistance = 247;
+ this.splitContainer3.Size = new System.Drawing.Size(714, 190);
+ this.splitContainer3.SplitterDistance = 237;
this.splitContainer3.TabIndex = 5;
//
// groupBox4
//
+ this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.cbBreakpointAll);
this.groupBox4.Controls.Add(this.cbBreakpointCxbx);
this.groupBox4.Location = new System.Drawing.Point(2, 112);
this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(241, 72);
+ this.groupBox4.Size = new System.Drawing.Size(233, 75);
this.groupBox4.TabIndex = 5;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Interrupts";
@@ -447,6 +480,8 @@
//
// groupBox1
//
+ this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.cbAction);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label4);
@@ -454,18 +489,20 @@
this.groupBox1.Controls.Add(this.tbFilter);
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(247, 106);
+ this.groupBox1.Size = new System.Drawing.Size(234, 106);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "File Watch";
//
// cbAction
//
+ this.cbAction.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
this.cbAction.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbAction.FormattingEnabled = true;
- this.cbAction.Location = new System.Drawing.Point(95, 45);
+ this.cbAction.Location = new System.Drawing.Point(89, 45);
this.cbAction.Name = "cbAction";
- this.cbAction.Size = new System.Drawing.Size(146, 21);
+ this.cbAction.Size = new System.Drawing.Size(139, 21);
this.cbAction.TabIndex = 6;
//
// label5
@@ -488,9 +525,11 @@
//
// btnAddFileBp
//
- this.btnAddFileBp.Location = new System.Drawing.Point(95, 72);
+ this.btnAddFileBp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnAddFileBp.Location = new System.Drawing.Point(89, 72);
this.btnAddFileBp.Name = "btnAddFileBp";
- this.btnAddFileBp.Size = new System.Drawing.Size(146, 23);
+ this.btnAddFileBp.Size = new System.Drawing.Size(139, 23);
this.btnAddFileBp.TabIndex = 4;
this.btnAddFileBp.Text = "Add";
this.btnAddFileBp.UseVisualStyleBackColor = true;
@@ -498,9 +537,11 @@
//
// tbFilter
//
- this.tbFilter.Location = new System.Drawing.Point(95, 19);
+ this.tbFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tbFilter.Location = new System.Drawing.Point(89, 19);
this.tbFilter.Name = "tbFilter";
- this.tbFilter.Size = new System.Drawing.Size(146, 20);
+ this.tbFilter.Size = new System.Drawing.Size(139, 20);
this.tbFilter.TabIndex = 2;
//
// clbBreakpoints
@@ -509,7 +550,7 @@
this.clbBreakpoints.FormattingEnabled = true;
this.clbBreakpoints.Location = new System.Drawing.Point(0, 0);
this.clbBreakpoints.Name = "clbBreakpoints";
- this.clbBreakpoints.Size = new System.Drawing.Size(491, 187);
+ this.clbBreakpoints.Size = new System.Drawing.Size(473, 190);
this.clbBreakpoints.TabIndex = 0;
this.clbBreakpoints.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.clbBreakpoints_ItemCheck);
this.clbBreakpoints.KeyDown += new System.Windows.Forms.KeyEventHandler(this.clbBreakpoints_KeyDown);
@@ -520,9 +561,9 @@
this.tabWatch.Location = new System.Drawing.Point(4, 22);
this.tabWatch.Name = "tabWatch";
this.tabWatch.Padding = new System.Windows.Forms.Padding(3);
- this.tabWatch.Size = new System.Drawing.Size(748, 193);
+ this.tabWatch.Size = new System.Drawing.Size(720, 196);
this.tabWatch.TabIndex = 2;
- this.tabWatch.Text = "File Watch";
+ this.tabWatch.Text = "File Watcher";
this.tabWatch.UseVisualStyleBackColor = true;
//
// splitContainer1
@@ -538,8 +579,8 @@
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.lbOpenedFiles);
- this.splitContainer1.Size = new System.Drawing.Size(742, 187);
- this.splitContainer1.SplitterDistance = 522;
+ this.splitContainer1.Size = new System.Drawing.Size(714, 190);
+ this.splitContainer1.SplitterDistance = 501;
this.splitContainer1.TabIndex = 3;
//
// lvFileDetails
@@ -553,7 +594,7 @@
this.lvFileDetails.HideSelection = false;
this.lvFileDetails.Location = new System.Drawing.Point(0, 0);
this.lvFileDetails.Name = "lvFileDetails";
- this.lvFileDetails.Size = new System.Drawing.Size(522, 187);
+ this.lvFileDetails.Size = new System.Drawing.Size(501, 190);
this.lvFileDetails.TabIndex = 2;
this.lvFileDetails.UseCompatibleStateImageBehavior = false;
this.lvFileDetails.View = System.Windows.Forms.View.Details;
@@ -579,7 +620,7 @@
this.lbOpenedFiles.FormattingEnabled = true;
this.lbOpenedFiles.Location = new System.Drawing.Point(0, 0);
this.lbOpenedFiles.Name = "lbOpenedFiles";
- this.lbOpenedFiles.Size = new System.Drawing.Size(216, 187);
+ this.lbOpenedFiles.Size = new System.Drawing.Size(209, 190);
this.lbOpenedFiles.TabIndex = 0;
//
// tabMemory
@@ -588,9 +629,9 @@
this.tabMemory.Location = new System.Drawing.Point(4, 22);
this.tabMemory.Name = "tabMemory";
this.tabMemory.Padding = new System.Windows.Forms.Padding(3);
- this.tabMemory.Size = new System.Drawing.Size(748, 193);
+ this.tabMemory.Size = new System.Drawing.Size(720, 196);
this.tabMemory.TabIndex = 4;
- this.tabMemory.Text = "Memory";
+ this.tabMemory.Text = "Memory Viewer";
this.tabMemory.UseVisualStyleBackColor = true;
//
// splitContainer4
@@ -606,8 +647,8 @@
// splitContainer4.Panel2
//
this.splitContainer4.Panel2.Controls.Add(this.groupBox2);
- this.splitContainer4.Size = new System.Drawing.Size(742, 187);
- this.splitContainer4.SplitterDistance = 391;
+ this.splitContainer4.Size = new System.Drawing.Size(714, 190);
+ this.splitContainer4.SplitterDistance = 376;
this.splitContainer4.TabIndex = 7;
//
// txMemoryDump
@@ -621,11 +662,12 @@
this.txMemoryDump.Name = "txMemoryDump";
this.txMemoryDump.ReadOnly = true;
this.txMemoryDump.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.txMemoryDump.Size = new System.Drawing.Size(391, 187);
+ this.txMemoryDump.Size = new System.Drawing.Size(376, 190);
this.txMemoryDump.TabIndex = 0;
//
// groupBox2
//
+ this.groupBox2.Controls.Add(this.textBox2);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.cbDataFormat);
this.groupBox2.Controls.Add(this.btnAddWatch);
@@ -638,11 +680,53 @@
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox2.Location = new System.Drawing.Point(0, 0);
this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(347, 187);
+ this.groupBox2.Size = new System.Drawing.Size(334, 190);
this.groupBox2.TabIndex = 8;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "View or Dump Memory";
//
+ // textBox2
+ //
+ this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBox2.Location = new System.Drawing.Point(213, 129);
+ this.textBox2.Name = "textBox2";
+ this.textBox2.Size = new System.Drawing.Size(115, 20);
+ this.textBox2.TabIndex = 10;
+ //
+ // label8
+ //
+ this.label8.AutoSize = true;
+ this.label8.Location = new System.Drawing.Point(6, 134);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(65, 13);
+ this.label8.TabIndex = 9;
+ this.label8.Text = "Data Format";
+ //
+ // cbDataFormat
+ //
+ this.cbDataFormat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.cbDataFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbDataFormat.FormattingEnabled = true;
+ this.cbDataFormat.Location = new System.Drawing.Point(88, 130);
+ this.cbDataFormat.Name = "cbDataFormat";
+ this.cbDataFormat.Size = new System.Drawing.Size(119, 21);
+ this.cbDataFormat.TabIndex = 8;
+ this.cbDataFormat.SelectionChangeCommitted += new System.EventHandler(this.cbDataFormat_SelectionChangeCommitted);
+ //
+ // btnAddWatch
+ //
+ this.btnAddWatch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnAddWatch.Location = new System.Drawing.Point(88, 157);
+ this.btnAddWatch.Name = "btnAddWatch";
+ this.btnAddWatch.Size = new System.Drawing.Size(240, 23);
+ this.btnAddWatch.TabIndex = 7;
+ this.btnAddWatch.Text = "Add to Editor...";
+ this.btnAddWatch.UseVisualStyleBackColor = true;
+ this.btnAddWatch.Click += new System.EventHandler(this.button5_Click);
+ //
// label1
//
this.label1.AutoSize = true;
@@ -654,19 +738,23 @@
//
// btnDumpMemory
//
- this.btnDumpMemory.Location = new System.Drawing.Point(88, 101);
+ this.btnDumpMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnDumpMemory.Location = new System.Drawing.Point(88, 100);
this.btnDumpMemory.Name = "btnDumpMemory";
- this.btnDumpMemory.Size = new System.Drawing.Size(204, 23);
+ this.btnDumpMemory.Size = new System.Drawing.Size(240, 23);
this.btnDumpMemory.TabIndex = 6;
- this.btnDumpMemory.Text = "Dump Memory (to File)";
+ this.btnDumpMemory.Text = "Dump Memory to File...";
this.btnDumpMemory.UseVisualStyleBackColor = true;
this.btnDumpMemory.Click += new System.EventHandler(this.btnDumpMemory_Click);
//
// txAddress
//
- this.txAddress.Location = new System.Drawing.Point(88, 19);
+ this.txAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.txAddress.Location = new System.Drawing.Point(88, 18);
this.txAddress.Name = "txAddress";
- this.txAddress.Size = new System.Drawing.Size(204, 20);
+ this.txAddress.Size = new System.Drawing.Size(240, 20);
this.txAddress.TabIndex = 1;
//
// label2
@@ -680,9 +768,11 @@
//
// btnReadMemory
//
- this.btnReadMemory.Location = new System.Drawing.Point(88, 72);
+ this.btnReadMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnReadMemory.Location = new System.Drawing.Point(88, 71);
this.btnReadMemory.Name = "btnReadMemory";
- this.btnReadMemory.Size = new System.Drawing.Size(204, 23);
+ this.btnReadMemory.Size = new System.Drawing.Size(240, 23);
this.btnReadMemory.TabIndex = 2;
this.btnReadMemory.Text = "Read Memory";
this.btnReadMemory.UseVisualStyleBackColor = true;
@@ -690,11 +780,190 @@
//
// txSize
//
- this.txSize.Location = new System.Drawing.Point(88, 46);
+ this.txSize.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.txSize.Location = new System.Drawing.Point(88, 45);
this.txSize.Name = "txSize";
- this.txSize.Size = new System.Drawing.Size(204, 20);
+ this.txSize.Size = new System.Drawing.Size(240, 20);
this.txSize.TabIndex = 3;
- this.txSize.Text = "256";
+ this.txSize.Text = "32";
+ //
+ // tabTweaks
+ //
+ this.tabTweaks.Controls.Add(this.tabCEContainer);
+ this.tabTweaks.Location = new System.Drawing.Point(4, 22);
+ this.tabTweaks.Name = "tabTweaks";
+ this.tabTweaks.Padding = new System.Windows.Forms.Padding(3);
+ this.tabTweaks.Size = new System.Drawing.Size(720, 196);
+ this.tabTweaks.TabIndex = 5;
+ this.tabTweaks.Text = "Memory Editor";
+ this.tabTweaks.UseVisualStyleBackColor = true;
+ //
+ // tabCEContainer
+ //
+ this.tabCEContainer.Controls.Add(this.tabSubData);
+ this.tabCEContainer.Controls.Add(this.tabSubAssembly);
+ this.tabCEContainer.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabCEContainer.Location = new System.Drawing.Point(3, 3);
+ this.tabCEContainer.Name = "tabCEContainer";
+ this.tabCEContainer.SelectedIndex = 0;
+ this.tabCEContainer.Size = new System.Drawing.Size(714, 190);
+ this.tabCEContainer.TabIndex = 5;
+ //
+ // tabSubData
+ //
+ this.tabSubData.Controls.Add(this.splitContainer6);
+ this.tabSubData.Location = new System.Drawing.Point(4, 22);
+ this.tabSubData.Name = "tabSubData";
+ this.tabSubData.Padding = new System.Windows.Forms.Padding(3);
+ this.tabSubData.Size = new System.Drawing.Size(706, 164);
+ this.tabSubData.TabIndex = 0;
+ this.tabSubData.Text = "Edit Data";
+ this.tabSubData.UseVisualStyleBackColor = true;
+ //
+ // splitContainer6
+ //
+ this.splitContainer6.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.splitContainer6.Location = new System.Drawing.Point(3, 3);
+ this.splitContainer6.Name = "splitContainer6";
+ this.splitContainer6.Orientation = System.Windows.Forms.Orientation.Horizontal;
+ //
+ // splitContainer6.Panel1
+ //
+ this.splitContainer6.Panel1.Controls.Add(this.btnRefresh);
+ this.splitContainer6.Panel1.Controls.Add(this.btnLoadCT);
+ this.splitContainer6.Panel1.Controls.Add(this.btnApply);
+ this.splitContainer6.Panel1.Controls.Add(this.txNewValue);
+ //
+ // splitContainer6.Panel2
+ //
+ this.splitContainer6.Panel2.Controls.Add(this.lvCEMemory);
+ this.splitContainer6.Size = new System.Drawing.Size(700, 158);
+ this.splitContainer6.SplitterDistance = 34;
+ this.splitContainer6.TabIndex = 2;
+ //
+ // btnRefresh
+ //
+ this.btnRefresh.Location = new System.Drawing.Point(132, 3);
+ this.btnRefresh.Name = "btnRefresh";
+ this.btnRefresh.Size = new System.Drawing.Size(123, 23);
+ this.btnRefresh.TabIndex = 6;
+ this.btnRefresh.Text = "Refresh";
+ this.btnRefresh.UseVisualStyleBackColor = true;
+ this.btnRefresh.Click += new System.EventHandler(this.button1_Click_1);
+ //
+ // btnLoadCT
+ //
+ this.btnLoadCT.Location = new System.Drawing.Point(3, 3);
+ this.btnLoadCT.Name = "btnLoadCT";
+ this.btnLoadCT.Size = new System.Drawing.Size(123, 23);
+ this.btnLoadCT.TabIndex = 5;
+ this.btnLoadCT.Text = "Load .CT";
+ this.btnLoadCT.UseVisualStyleBackColor = true;
+ this.btnLoadCT.Click += new System.EventHandler(this.button2_Click_2);
+ //
+ // btnApply
+ //
+ this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnApply.Location = new System.Drawing.Point(574, 3);
+ this.btnApply.Name = "btnApply";
+ this.btnApply.Size = new System.Drawing.Size(123, 23);
+ this.btnApply.TabIndex = 4;
+ this.btnApply.Text = "Apply";
+ this.btnApply.UseVisualStyleBackColor = true;
+ this.btnApply.Click += new System.EventHandler(this.button3_Click_1);
+ //
+ // txNewValue
+ //
+ this.txNewValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.txNewValue.Location = new System.Drawing.Point(261, 5);
+ this.txNewValue.Name = "txNewValue";
+ this.txNewValue.Size = new System.Drawing.Size(307, 20);
+ this.txNewValue.TabIndex = 2;
+ //
+ // lvCEMemory
+ //
+ this.lvCEMemory.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.columnHeader7,
+ this.columnHeader4,
+ this.columnHeader6,
+ this.columnHeader5});
+ this.lvCEMemory.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.lvCEMemory.FullRowSelect = true;
+ this.lvCEMemory.Location = new System.Drawing.Point(0, 0);
+ this.lvCEMemory.Name = "lvCEMemory";
+ this.lvCEMemory.Size = new System.Drawing.Size(700, 120);
+ this.lvCEMemory.TabIndex = 1;
+ this.lvCEMemory.UseCompatibleStateImageBehavior = false;
+ this.lvCEMemory.View = System.Windows.Forms.View.Details;
+ //
+ // columnHeader7
+ //
+ this.columnHeader7.Text = "Address";
+ this.columnHeader7.Width = 120;
+ //
+ // columnHeader4
+ //
+ this.columnHeader4.Text = "Description";
+ this.columnHeader4.Width = 200;
+ //
+ // columnHeader6
+ //
+ this.columnHeader6.Text = "Size";
+ this.columnHeader6.Width = 100;
+ //
+ // columnHeader5
+ //
+ this.columnHeader5.Text = "Value";
+ this.columnHeader5.Width = 200;
+ //
+ // tabSubAssembly
+ //
+ this.tabSubAssembly.Controls.Add(this.lvCEAssembly);
+ this.tabSubAssembly.Location = new System.Drawing.Point(4, 22);
+ this.tabSubAssembly.Name = "tabSubAssembly";
+ this.tabSubAssembly.Padding = new System.Windows.Forms.Padding(3);
+ this.tabSubAssembly.Size = new System.Drawing.Size(706, 164);
+ this.tabSubAssembly.TabIndex = 1;
+ this.tabSubAssembly.Text = "Edit Assembly";
+ this.tabSubAssembly.UseVisualStyleBackColor = true;
+ //
+ // lvCEAssembly
+ //
+ this.lvCEAssembly.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.columnHeader10,
+ this.columnHeader11,
+ this.columnHeader8,
+ this.columnHeader9});
+ this.lvCEAssembly.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.lvCEAssembly.FullRowSelect = true;
+ this.lvCEAssembly.Location = new System.Drawing.Point(3, 3);
+ this.lvCEAssembly.Name = "lvCEAssembly";
+ this.lvCEAssembly.Size = new System.Drawing.Size(700, 158);
+ this.lvCEAssembly.TabIndex = 4;
+ this.lvCEAssembly.UseCompatibleStateImageBehavior = false;
+ this.lvCEAssembly.View = System.Windows.Forms.View.Details;
+ //
+ // columnHeader10
+ //
+ this.columnHeader10.Text = "Address";
+ this.columnHeader10.Width = 120;
+ //
+ // columnHeader11
+ //
+ this.columnHeader11.Text = "Description";
+ this.columnHeader11.Width = 200;
+ //
+ // columnHeader8
+ //
+ this.columnHeader8.Text = "Original";
+ this.columnHeader8.Width = 150;
+ //
+ // columnHeader9
+ //
+ this.columnHeader9.Text = "Patched";
+ this.columnHeader9.Width = 150;
//
// tabOutput
//
@@ -702,7 +971,7 @@
this.tabOutput.Location = new System.Drawing.Point(4, 22);
this.tabOutput.Name = "tabOutput";
this.tabOutput.Padding = new System.Windows.Forms.Padding(3);
- this.tabOutput.Size = new System.Drawing.Size(748, 193);
+ this.tabOutput.Size = new System.Drawing.Size(720, 196);
this.tabOutput.TabIndex = 3;
this.tabOutput.Text = "Debug Output";
this.tabOutput.UseVisualStyleBackColor = true;
@@ -724,7 +993,7 @@
// splitContainer5.Panel2
//
this.splitContainer5.Panel2.Controls.Add(this.lbDebug);
- this.splitContainer5.Size = new System.Drawing.Size(742, 187);
+ this.splitContainer5.Size = new System.Drawing.Size(714, 190);
this.splitContainer5.SplitterDistance = 26;
this.splitContainer5.TabIndex = 6;
//
@@ -735,7 +1004,7 @@
this.txFilter.Enabled = false;
this.txFilter.Location = new System.Drawing.Point(41, 3);
this.txFilter.Name = "txFilter";
- this.txFilter.Size = new System.Drawing.Size(698, 20);
+ this.txFilter.Size = new System.Drawing.Size(670, 20);
this.txFilter.TabIndex = 4;
//
// label3
@@ -755,185 +1024,9 @@
this.lbDebug.Location = new System.Drawing.Point(0, 0);
this.lbDebug.Name = "lbDebug";
this.lbDebug.ScrollAlwaysVisible = true;
- this.lbDebug.Size = new System.Drawing.Size(742, 157);
+ this.lbDebug.Size = new System.Drawing.Size(714, 160);
this.lbDebug.TabIndex = 3;
//
- // tabTweaks
- //
- this.tabTweaks.Controls.Add(this.groupBox3);
- this.tabTweaks.Controls.Add(this.tabCEContainer);
- this.tabTweaks.Location = new System.Drawing.Point(4, 22);
- this.tabTweaks.Name = "tabTweaks";
- this.tabTweaks.Padding = new System.Windows.Forms.Padding(3);
- this.tabTweaks.Size = new System.Drawing.Size(748, 193);
- this.tabTweaks.TabIndex = 5;
- this.tabTweaks.Text = "Cheat Engine";
- this.tabTweaks.UseVisualStyleBackColor = true;
- //
- // groupBox3
- //
- this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox3.Controls.Add(this.button4);
- this.groupBox3.Controls.Add(this.button3);
- this.groupBox3.Controls.Add(this.label7);
- this.groupBox3.Controls.Add(this.textBox1);
- this.groupBox3.Controls.Add(this.button2);
- this.groupBox3.Location = new System.Drawing.Point(5, 6);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(135, 184);
- this.groupBox3.TabIndex = 6;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "Controls";
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(6, 48);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(123, 23);
- this.button4.TabIndex = 5;
- this.button4.Text = "Refresh";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click_1);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(6, 117);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(123, 23);
- this.button3.TabIndex = 4;
- this.button3.Text = "Apply";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click_1);
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(6, 75);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(37, 13);
- this.label7.TabIndex = 3;
- this.label7.Text = "Value:";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(6, 91);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(123, 20);
- this.textBox1.TabIndex = 2;
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(6, 19);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(123, 23);
- this.button2.TabIndex = 0;
- this.button2.Text = "Load .CT";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click_1);
- //
- // tabCEContainer
- //
- this.tabCEContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.tabCEContainer.Controls.Add(this.tabSubData);
- this.tabCEContainer.Controls.Add(this.tabSubAssembly);
- this.tabCEContainer.Location = new System.Drawing.Point(144, 6);
- this.tabCEContainer.Name = "tabCEContainer";
- this.tabCEContainer.SelectedIndex = 0;
- this.tabCEContainer.Size = new System.Drawing.Size(598, 184);
- this.tabCEContainer.TabIndex = 5;
- //
- // tabSubData
- //
- this.tabSubData.Controls.Add(this.lvCEMemory);
- this.tabSubData.Location = new System.Drawing.Point(4, 22);
- this.tabSubData.Name = "tabSubData";
- this.tabSubData.Padding = new System.Windows.Forms.Padding(3);
- this.tabSubData.Size = new System.Drawing.Size(590, 158);
- this.tabSubData.TabIndex = 0;
- this.tabSubData.Text = "Memory";
- this.tabSubData.UseVisualStyleBackColor = true;
- //
- // lvCEMemory
- //
- this.lvCEMemory.CheckBoxes = true;
- this.lvCEMemory.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnHeader8,
- this.columnHeader4,
- this.columnHeader7,
- this.columnHeader6,
- this.columnHeader5});
- this.lvCEMemory.Dock = System.Windows.Forms.DockStyle.Fill;
- this.lvCEMemory.FullRowSelect = true;
- this.lvCEMemory.Location = new System.Drawing.Point(3, 3);
- this.lvCEMemory.Name = "lvCEMemory";
- this.lvCEMemory.Size = new System.Drawing.Size(584, 152);
- this.lvCEMemory.TabIndex = 1;
- this.lvCEMemory.UseCompatibleStateImageBehavior = false;
- this.lvCEMemory.View = System.Windows.Forms.View.Details;
- //
- // columnHeader8
- //
- this.columnHeader8.Text = "Active";
- this.columnHeader8.Width = 50;
- //
- // columnHeader4
- //
- this.columnHeader4.Text = "Description";
- this.columnHeader4.Width = 150;
- //
- // columnHeader7
- //
- this.columnHeader7.Text = "Address";
- this.columnHeader7.Width = 150;
- //
- // columnHeader6
- //
- this.columnHeader6.Text = "Type";
- this.columnHeader6.Width = 80;
- //
- // columnHeader5
- //
- this.columnHeader5.Text = "Value";
- this.columnHeader5.Width = 150;
- //
- // tabSubAssembly
- //
- this.tabSubAssembly.Controls.Add(this.lvCEAssembly);
- this.tabSubAssembly.Location = new System.Drawing.Point(4, 22);
- this.tabSubAssembly.Name = "tabSubAssembly";
- this.tabSubAssembly.Padding = new System.Windows.Forms.Padding(3);
- this.tabSubAssembly.Size = new System.Drawing.Size(590, 158);
- this.tabSubAssembly.TabIndex = 1;
- this.tabSubAssembly.Text = "Assembly";
- this.tabSubAssembly.UseVisualStyleBackColor = true;
- //
- // lvCEAssembly
- //
- this.lvCEAssembly.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnHeader10,
- this.columnHeader11});
- this.lvCEAssembly.Dock = System.Windows.Forms.DockStyle.Fill;
- this.lvCEAssembly.FullRowSelect = true;
- this.lvCEAssembly.Location = new System.Drawing.Point(3, 3);
- this.lvCEAssembly.Name = "lvCEAssembly";
- this.lvCEAssembly.Size = new System.Drawing.Size(584, 152);
- this.lvCEAssembly.TabIndex = 4;
- this.lvCEAssembly.UseCompatibleStateImageBehavior = false;
- this.lvCEAssembly.View = System.Windows.Forms.View.Details;
- //
- // columnHeader10
- //
- this.columnHeader10.Text = "Address";
- this.columnHeader10.Width = 200;
- //
- // columnHeader11
- //
- this.columnHeader11.Text = "Name";
- this.columnHeader11.Width = 200;
- //
// diagSaveMemory
//
this.diagSaveMemory.Filter = "Any Type|*.*";
@@ -944,65 +1037,11 @@
this.diagBrowseCT.Filter = "Cheat Engine Tables (*.CT)|*.ct";
this.diagBrowseCT.Title = "Load cheat table";
//
- // btnAddWatch
- //
- this.btnAddWatch.Location = new System.Drawing.Point(88, 158);
- this.btnAddWatch.Name = "btnAddWatch";
- this.btnAddWatch.Size = new System.Drawing.Size(204, 23);
- this.btnAddWatch.TabIndex = 7;
- this.btnAddWatch.Text = "Add Cheat Engine Watch";
- this.btnAddWatch.UseVisualStyleBackColor = true;
- this.btnAddWatch.Click += new System.EventHandler(this.button5_Click);
- //
- // cbDataFormat
- //
- this.cbDataFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.cbDataFormat.FormattingEnabled = true;
- this.cbDataFormat.Location = new System.Drawing.Point(88, 131);
- this.cbDataFormat.Name = "cbDataFormat";
- this.cbDataFormat.Size = new System.Drawing.Size(204, 21);
- this.cbDataFormat.TabIndex = 8;
- //
- // btnToMemory
- //
- this.btnToMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btnToMemory.Location = new System.Drawing.Point(531, 3);
- this.btnToMemory.Name = "btnToMemory";
- this.btnToMemory.Size = new System.Drawing.Size(83, 23);
- this.btnToMemory.TabIndex = 4;
- this.btnToMemory.Text = "Memory View";
- this.btnToMemory.UseVisualStyleBackColor = true;
- this.btnToMemory.Click += new System.EventHandler(this.button6_Click);
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(6, 134);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(65, 13);
- this.label8.TabIndex = 9;
- this.label8.Text = "Data Format";
- //
- // txDisassembly
- //
- this.txDisassembly.BackColor = System.Drawing.SystemColors.Window;
- this.txDisassembly.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.txDisassembly.Cursor = System.Windows.Forms.Cursors.Default;
- this.txDisassembly.Dock = System.Windows.Forms.DockStyle.Fill;
- this.txDisassembly.Font = new System.Drawing.Font("Lucida Console", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.txDisassembly.Location = new System.Drawing.Point(0, 0);
- this.txDisassembly.Name = "txDisassembly";
- this.txDisassembly.ReadOnly = true;
- this.txDisassembly.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
- this.txDisassembly.Size = new System.Drawing.Size(742, 149);
- this.txDisassembly.TabIndex = 1;
- this.txDisassembly.Text = "";
- //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(762, 327);
+ this.ClientSize = new System.Drawing.Size(734, 331);
this.Controls.Add(this.tableLayoutPanel3);
this.Controls.Add(this.toolStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@@ -1044,18 +1083,21 @@
this.splitContainer4.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
+ this.tabTweaks.ResumeLayout(false);
+ this.tabCEContainer.ResumeLayout(false);
+ this.tabSubData.ResumeLayout(false);
+ this.splitContainer6.Panel1.ResumeLayout(false);
+ this.splitContainer6.Panel1.PerformLayout();
+ this.splitContainer6.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer6)).EndInit();
+ this.splitContainer6.ResumeLayout(false);
+ this.tabSubAssembly.ResumeLayout(false);
this.tabOutput.ResumeLayout(false);
this.splitContainer5.Panel1.ResumeLayout(false);
this.splitContainer5.Panel1.PerformLayout();
this.splitContainer5.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer5)).EndInit();
this.splitContainer5.ResumeLayout(false);
- this.tabTweaks.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.tabCEContainer.ResumeLayout(false);
- this.tabSubData.ResumeLayout(false);
- this.tabSubAssembly.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -1119,7 +1161,6 @@
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnPrev;
private System.Windows.Forms.TabPage tabTweaks;
- private System.Windows.Forms.Button button2;
private System.Windows.Forms.OpenFileDialog diagBrowseCT;
private System.Windows.Forms.ListView lvCEMemory;
private System.Windows.Forms.ColumnHeader columnHeader4;
@@ -1128,22 +1169,24 @@
private System.Windows.Forms.ColumnHeader columnHeader10;
private System.Windows.Forms.ColumnHeader columnHeader11;
private System.Windows.Forms.ColumnHeader columnHeader7;
- private System.Windows.Forms.ColumnHeader columnHeader8;
private System.Windows.Forms.TabControl tabCEContainer;
private System.Windows.Forms.TabPage tabSubData;
private System.Windows.Forms.TabPage tabSubAssembly;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.Button btnApply;
+ private System.Windows.Forms.TextBox txNewValue;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.CheckBox cbBreakpointAll;
private System.Windows.Forms.CheckBox cbBreakpointCxbx;
- private System.Windows.Forms.Button button4;
private System.Windows.Forms.ComboBox cbDataFormat;
private System.Windows.Forms.Button btnAddWatch;
private System.Windows.Forms.Button btnToMemory;
private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.ColumnHeader columnHeader8;
+ private System.Windows.Forms.ColumnHeader columnHeader9;
+ private System.Windows.Forms.SplitContainer splitContainer6;
+ private System.Windows.Forms.Button btnLoadCT;
+ private System.Windows.Forms.Button btnRefresh;
+ private System.Windows.Forms.TextBox textBox2;
}
}
diff --git a/src/CxbxDebugger/Form1.cs b/src/CxbxDebugger/Form1.cs
index 6317d0894..67e2ba2b4 100644
--- a/src/CxbxDebugger/Form1.cs
+++ b/src/CxbxDebugger/Form1.cs
@@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using cs_x86;
-using CxbxDebugger.CheatEngine;
namespace CxbxDebugger
{
@@ -23,10 +22,11 @@ namespace CxbxDebugger
List DebugThreads = new List();
List DebugModules = new List();
+ DebuggerProcess MainProcess = null;
FileWatchManager fileWatchMan;
DebugOutputManager debugStrMan;
- CheatEngineManager cheatMan;
+ PatchManager patchMan;
List FileHandles = new List();
@@ -65,17 +65,17 @@ namespace CxbxDebugger
cbAction.SelectedIndex = 0;
- foreach (string VariableEnum in Enum.GetNames(typeof(Variable)))
+ foreach (string VariableEnum in Enum.GetNames(typeof(PatchType)))
{
cbDataFormat.Items.Add(VariableEnum);
}
-
- // Default to byte
- cbDataFormat.SelectedIndex = 2;
+
+ cbDataFormat.SelectedIndex = 0;
+ InvokePatchTypeChange();
fileWatchMan = new FileWatchManager(clbBreakpoints);
debugStrMan = new DebugOutputManager(lbDebug);
- cheatMan = new CheatEngineManager();
+ patchMan = new PatchManager();
}
private void OnDisassemblyNavigation(object sender, InlineLinkClickedEventArgs e)
@@ -105,6 +105,7 @@ namespace CxbxDebugger
// Create debugger instance
DebuggerInst = new Debugger(CachedArgs);
DebuggerInst.RegisterEventInterfaces(DebugEvents);
+ DebuggerInst.RegisterEventInterfaces(patchMan);
// Setup new debugger thread
DebuggerWorkerThread = new Thread(x =>
@@ -124,7 +125,7 @@ namespace CxbxDebugger
{
cbItems.Items.Clear();
- uint AutoThreadId= DebugThreads[0].OwningProcess.MainThread.ThreadID;
+ uint AutoThreadId = DebugThreads[0].OwningProcess.MainThread.ThreadID;
if (FocusThread != null)
AutoThreadId = FocusThread.ThreadID;
@@ -292,7 +293,8 @@ namespace CxbxDebugger
Text = string.Format("{0} - Cxbx-Reloaded Debugger", CachedTitle);
- LoadCheatTable(string.Format("{0}.ct", CachedTitle));
+ // This is done too late - modules are already loaded
+ //LoadCheatTable(string.Format("{0}.ct", CachedTitle));
}));
}
@@ -378,6 +380,7 @@ namespace CxbxDebugger
public void OnProcessCreate(DebuggerProcess Process)
{
frm.DebugModules.Add(Process);
+ frm.MainProcess = Process;
}
public void OnProcessExit(DebuggerProcess Process, uint ExitCode)
@@ -609,6 +612,11 @@ namespace CxbxDebugger
static private bool ReadHexInt(string HexSource, ref int Out)
{
+ if (HexSource.StartsWith("0x"))
+ {
+ HexSource = HexSource.Substring(2);
+ }
+
if (int.TryParse(HexSource, System.Globalization.NumberStyles.HexNumber, null, out Out))
{
return true;
@@ -1052,48 +1060,68 @@ namespace CxbxDebugger
HandleDisasmGo();
}
- private static System.Drawing.Color MakeColor(uint RGB)
- {
- int r = (int)(RGB & 0xFF);
- int g = (int)((RGB >> 8) & 0xFF);
- int b = (int)((RGB >> 16) & 0xFF);
-
- return System.Drawing.Color.FromArgb(r, g, b);
- }
-
- private void RefreshCheatTableDisplay()
+ private void RefreshPatches()
{
lvCEMemory.BeginUpdate();
lvCEMemory.Items.Clear();
- foreach (var code in cheatMan.Cheats.CheatEntries)
+ foreach (Patch DataPatch in patchMan.Data)
{
- var li = lvCEMemory.Items.Add("");
- li.SubItems.Add(code.Description);
- li.SubItems.Add(string.Format("{0:x8}", code.Address));
- li.SubItems.Add(code.VariableType.ToString());
- li.SubItems.Add(code.LastState.Value);
-
- li.Checked = code.LastState.Activated;
- li.ForeColor = MakeColor(code.Color);
+ var li = lvCEMemory.Items.Add(string.Format("{0} 0x{1:x}", DataPatch.Module, DataPatch.Offset));
+ li.SubItems.Add(DataPatch.Name);
+ li.SubItems.Add(string.Format("{0} byte(s)", DataPatch.Patched.Length));
+ if (MainProcess != null)
+ {
+ li.SubItems.Add(patchMan.Read(MainProcess, DataPatch));
+ }
+ else
+ {
+ li.SubItems.Add("??");
+ }
}
lvCEMemory.EndUpdate();
- // Code entries are not supported at the moment
-
lvCEAssembly.BeginUpdate();
lvCEAssembly.Items.Clear();
- foreach (var code in cheatMan.Cheats.CodeEntires)
+ foreach (Patch patch in patchMan.Assembly)
{
- var li = lvCEAssembly.Items.Add(string.Format("{0} +{1:X}", code.ModuleName, code.ModuleNameOffset));
- li.SubItems.Add(code.Description);
+ var li = lvCEAssembly.Items.Add(string.Format("{0} 0x{1:x}", patch.Module, patch.Offset));
+ li.SubItems.Add(patch.Name);
+ li.SubItems.Add(PrettyPrint(patch.Original));
+ li.SubItems.Add(PrettyPrint(patch.Patched));
}
lvCEAssembly.EndUpdate();
}
+ static private byte[] Fill(int Count, byte Val)
+ {
+ List ByteList = new List(Count);
+ for (int i = 0; i < Count; ++i) ByteList.Add(Val);
+ return ByteList.ToArray();
+ }
+
+ static private byte[] Nops(int Count)
+ {
+ return Fill(Count, 0x90);
+ }
+
+ static private string PrettyPrint(byte[] Bytes)
+ {
+ if (Bytes == null)
+ return "??";
+
+ string Str = "";
+ int Max = Math.Min(5, Bytes.Length);
+ for (int i = 0; i < Max; ++i)
+ {
+ Str += string.Format("{0:X2} ", Bytes[i]);
+ }
+ return Str;
+ }
+
private void LoadCheatTable(string filename)
{
string path = Directory.GetCurrentDirectory();
@@ -1101,73 +1129,81 @@ namespace CxbxDebugger
if (File.Exists(filename))
{
DebugLog(string.Format("Attempting to load \"{0}\"", filename));
-
- CheatTable ct_data = CheatTableReader.FromFile(filename);
+
+ CheatEngine.CheatTable ct_data = CheatEngine.CheatTableReader.FromFile(filename);
if (ct_data != null)
{
- cheatMan.Cheats = ct_data;
+ foreach(CheatEngine.CheatEntry Entry in ct_data.CheatEntries)
+ {
+ int addr = 0;
+ if(ReadHexInt(Entry.Address, ref addr))
+ {
+ Patch DataPatch = new Patch();
+
+ DataPatch.DisplayAs = PatchType.Array;
+ DataPatch.Name = Entry.Description;
+ DataPatch.Module = "";
+ DataPatch.Offset = (uint)addr;
+ DataPatch.Original = null;
+ DataPatch.Patched = Nops(CheatEngine.Helpers.VariableSize(Entry.VariableType));
+
+ patchMan.Data.Add(DataPatch);
+ }
+ }
+
+ foreach(CheatEngine.CodeEntry Entry in ct_data.CodeEntires)
+ {
+ Patch DataPatch = new Patch();
+
+ DataPatch.DisplayAs = PatchType.Array;
+ DataPatch.Name = Entry.Description;
+ DataPatch.Module = Entry.ModuleName;
+ DataPatch.Offset = Entry.ModuleNameOffset;
+ DataPatch.Original = Entry.Actual;
+ DataPatch.Patched = Nops(Entry.Actual.Length);
+
+ patchMan.Assembly.Add(DataPatch);
+ }
+
+ DebugLog(string.Format("Loaded {0} auto-assembler entries", ct_data.CodeEntires.Count));
+ DebugLog(string.Format("Loaded {0} cheat entries", ct_data.CheatEntries.Count));
+
+ RefreshPatches();
}
}
}
-
- private void button2_Click_1(object sender, EventArgs e)
- {
- if( diagBrowseCT.ShowDialog() == DialogResult.OK)
- {
- string filename = diagBrowseCT.FileNames[0];
- LoadCheatTable(filename);
- }
- }
-
- private void RefreshCEMemory()
- {
- if (DebugThreads.Count == 0)
- return;
-
- if (cheatMan.RefreshAll(DebugThreads[0].OwningProcess))
- {
- RefreshCheatTableDisplay();
- }
- }
-
- private void button3_Click_1(object sender, EventArgs e)
- {
- if (DebugThreads.Count == 0)
- return;
-
- if (lvCEMemory.SelectedIndices.Count == 1)
- {
- int selected = lvCEMemory.SelectedIndices[0];
-
- cheatMan.Write(DebugThreads[0].OwningProcess, selected, textBox1.Text);
- }
- }
-
- private void button4_Click_1(object sender, EventArgs e)
- {
- RefreshCEMemory();
- }
-
+
private void button5_Click(object sender, EventArgs e)
{
- CheatEntry ce = new CheatEntry();
+ PatchType PatchType = (PatchType)cbDataFormat.SelectedIndex;
- ce.ID = 0;
- ce.Description = "Automatic";
- ce.ShowAsHex = false;
- ce.LastState.Activated = false;
- ce.LastState.RealAddress = 0;
- ce.LastState.Value = "";
- ce.VariableType = (Variable)cbDataFormat.SelectedIndex;
-
- if(txAddress.Text.StartsWith("0x"))
+ int PatchSize = PatchManager.PatchTypeLength(PatchType);
+ if(PatchSize == 0 )
{
- ce.Address = txAddress.Text.Substring(2);
- }
+ if (!ReadInt(textBox2, ref PatchSize))
+ return;
- cheatMan.Cheats.CheatEntries.Add(ce);
+ if (PatchSize < 0)
+ return;
+ }
- RefreshCEMemory();
+ int addr = 0;
+ if(ReadHexInt(txAddress.Text, ref addr))
+ {
+ Patch DataPatch = new Patch();
+
+ DataPatch.DisplayAs = PatchType;
+ DataPatch.Name = string.Format("Patched {0}", cbDataFormat.SelectedText);
+ DataPatch.Module = "";
+ DataPatch.Offset = (uint)addr;
+
+ // TODO: Read original memory at this location
+ DataPatch.Original = Nops(PatchSize);
+ DataPatch.Patched = Nops(PatchSize);
+ patchMan.Data.Add(DataPatch);
+
+ RefreshPatches();
+ }
}
private void button6_Click(object sender, EventArgs e)
@@ -1179,5 +1215,48 @@ namespace CxbxDebugger
tabContainer.SelectedTab = tabMemory;
}
}
+
+ private void button2_Click_2(object sender, EventArgs e)
+ {
+ if (diagBrowseCT.ShowDialog() == DialogResult.OK)
+ {
+ string filename = diagBrowseCT.FileNames[0];
+ LoadCheatTable(filename);
+ }
+ }
+
+ private void button1_Click_1(object sender, EventArgs e)
+ {
+ RefreshPatches();
+ }
+
+ private void InvokePatchTypeChange()
+ {
+ PatchType Type = (PatchType)cbDataFormat.SelectedIndex;
+
+ textBox2.Text = PatchManager.PatchTypeLength(Type).ToString();
+ textBox2.Enabled = (Type == PatchType.Array);
+ }
+
+ private void cbDataFormat_SelectionChangeCommitted(object sender, EventArgs e)
+ {
+ InvokePatchTypeChange();
+ }
+
+ private void button3_Click_1(object sender, EventArgs e)
+ {
+ if (lvCEMemory.SelectedIndices.Count != 1)
+ return;
+
+ string Value = txNewValue.Text;
+ if(Value.Length != 0 )
+ {
+ Patch DataPatch = patchMan.Data[lvCEMemory.SelectedIndices[0]];
+ if( patchMan.Write(MainProcess, DataPatch, Value))
+ {
+ RefreshPatches();
+ }
+ }
+ }
}
}
diff --git a/src/CxbxDebugger/PatchManager.cs b/src/CxbxDebugger/PatchManager.cs
new file mode 100644
index 000000000..7be709afd
--- /dev/null
+++ b/src/CxbxDebugger/PatchManager.cs
@@ -0,0 +1,165 @@
+// Written by x1nixmzeng for the Cxbx-Reloaded project
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace CxbxDebugger
+{
+ enum PatchType
+ {
+ Byte,
+ Short,
+ UShort,
+ Int,
+ UInt,
+ Float,
+ Array
+ };
+
+ struct Patch
+ {
+ public PatchType DisplayAs { get; set; }
+ public string Name { get; set; }
+ public string Module { get; set; }
+ public uint Offset { get; set; }
+ public byte[] Original { get; set; }
+ public byte[] Patched { get; set; }
+ };
+
+ class PatchManager : IDebuggerProcessEvents, IDebuggerModuleEvents
+ {
+ public List Data = new List();
+ public List Assembly = new List();
+
+ public void OnProcessCreate(DebuggerProcess Process)
+ {
+ // TODO: apply pending patches
+ }
+
+ public void OnProcessExit(DebuggerProcess Process, uint ExitCode) { }
+
+ public void OnModuleLoaded(DebuggerModule Module)
+ {
+ // TODO: apply pending patches
+ }
+
+ public void OnModuleUnloaded(DebuggerModule Module) { }
+
+ static int PatchSize(Patch PatchItem)
+ {
+ if (PatchItem.Original != null)
+ return PatchItem.Original.Length;
+
+ if (PatchItem.Patched != null)
+ return PatchItem.Patched.Length;
+
+ return PatchTypeLength(PatchItem.DisplayAs);
+ }
+
+ private static string Format(PatchType Type, byte[] Data)
+ {
+ string Result = "";
+
+ switch (Type)
+ {
+ case PatchType.Byte:
+ {
+ Result = string.Format("{0}", Data[0]);
+ }
+ break;
+ case PatchType.Short:
+ {
+ var Value = BitConverter.ToInt16(Data, 0);
+ Result = string.Format("{0}", Value);
+ }
+ break;
+ case PatchType.UShort:
+ {
+ var Value = BitConverter.ToUInt16(Data, 0);
+ Result = string.Format("{0}", Value);
+ }
+ break;
+ case PatchType.Int:
+ {
+ var Value = BitConverter.ToInt32(Data, 0);
+ Result = string.Format("{0}", Value);
+ }
+ break;
+ case PatchType.UInt:
+ {
+ var Value = BitConverter.ToUInt32(Data, 0);
+ Result = string.Format("{0}", Value);
+ }
+ break;
+ case PatchType.Float:
+ {
+ var Value = BitConverter.ToSingle(Data, 0);
+ Result = string.Format("{0}", Value);
+ }
+ break;
+ case PatchType.Array:
+ {
+ foreach (byte B in Data)
+ {
+ Result += string.Format("{0:X2} ", B);
+ }
+ }
+ break;
+ }
+
+ return Result;
+ }
+
+ public string Read(DebuggerProcess OwningProcess, Patch PatchItem)
+ {
+ int Size = PatchSize(PatchItem);
+ if (Size == 0)
+ return "";
+
+ byte[] Current = OwningProcess.ReadMemoryBlock(new IntPtr(PatchItem.Offset), (uint)Size);
+ return Format(PatchItem.DisplayAs, Current);
+ }
+
+ public bool Write(DebuggerProcess OwningProcess, Patch PatchItem, string NewValue)
+ {
+ switch (PatchItem.DisplayAs)
+ {
+ case PatchType.Byte:
+ {
+ byte Value;
+ if( byte.TryParse(NewValue, out Value) )
+ {
+ OwningProcess.WriteMemory(new IntPtr(PatchItem.Offset), Value);
+ return true;
+ }
+ break;
+ }
+ }
+
+ return false;
+ }
+
+ static public int PatchTypeLength(PatchType Type)
+ {
+ switch (Type)
+ {
+ case PatchType.Byte:
+ return 1;
+ case PatchType.Short:
+ return 2;
+ case PatchType.UShort:
+ return 2;
+ case PatchType.Int:
+ return 4;
+ case PatchType.UInt:
+ return 4;
+ case PatchType.Float:
+ return 4;
+ }
+
+ return 0;
+ }
+ }
+}