private void button1_Click(object sender, EventArgs e) { try { Description = textBoxDesc.Text; WMInfo = new WrittenMemoryInfo(); WMInfo.Address = Convert.ToUInt32(textBoxAddress.Text, 16); WMInfo.Type = (MemoryDataType)comboBoxType.SelectedIndex; switch (WMInfo.Type) { case MemoryDataType.Byte: WMInfo.ByteArray = new byte[] { byte.Parse(textBoxValue.Text) }; break; case MemoryDataType.Short: WMInfo.ByteArray = BitConverter.GetBytes(short.Parse(textBoxValue.Text)); break; case MemoryDataType.Integer: WMInfo.ByteArray = BitConverter.GetBytes(int.Parse(textBoxValue.Text)); break; case MemoryDataType.Float: WMInfo.ByteArray = BitConverter.GetBytes(float.Parse(textBoxValue.Text)); break; case MemoryDataType.Long: WMInfo.ByteArray = BitConverter.GetBytes(long.Parse(textBoxValue.Text)); break; case MemoryDataType.Double: WMInfo.ByteArray = BitConverter.GetBytes(double.Parse(textBoxValue.Text)); break; case MemoryDataType.String: WMInfo.ByteArray = Encoding.Default.GetBytes(textBoxValue.Text); break; case MemoryDataType.ByteArray: string[] bytes = textBoxValue.Text.Split(','); WMInfo.ByteArray = new byte[bytes.Length]; for (int i = 0; i < bytes.Length; i++) { WMInfo.ByteArray[i] = Convert.ToByte(bytes[i], 16); } break; default: WMInfo.ByteArray = null; break; } DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DisasmForm(WrittenMemoryInfo wmInfo, bool extend = false) { InitializeComponent(); this.wmInfo = wmInfo; this.extend = extend; if (extend) { hProcess = OpenProcess(this.wmInfo.Target, ProcessAccessFlags.All); AddressUpDown.Enabled = true; LengthUpDown.Enabled = true; DisAsmListView.MouseWheel += DisAsmListView_MouseWheel; this.wmInfo.ByteArray = new byte[this.wmInfo.ByteArray.Length + 50]; AddressUpDown.Value = this.wmInfo.Address - 25; } else { AddressUpDown.Enabled = false; LengthUpDown.Enabled = false; AddressUpDown.Value = this.wmInfo.Address; } LengthUpDown.Value = this.wmInfo.ByteArray.Length; lastWidth = Width; lastHeight = Height; }