Beispiel #1
0
 public void WriteStringTest()
 {
     Assert.IsTrue(TrashMem.WriteString(STATIC_ADDRESS_STRING, "ShittyMcUlow", Encoding.ASCII));
     Assert.AreEqual("ShittyMcUlow", TrashMem.ReadString(STATIC_ADDRESS_STRING, Encoding.ASCII, 12));
     Assert.IsTrue(TrashMem.WriteString(STATIC_ADDRESS_STRING, "ShittyMcUlox", Encoding.ASCII));
     Assert.AreEqual("ShittyMcUlox", TrashMem.ReadString(STATIC_ADDRESS_STRING, Encoding.ASCII, 12));
     Assert.IsTrue(TrashMem.WriteString(STATIC_ADDRESS_STRING, "ShittyMcUlow", Encoding.ASCII));
     Assert.AreEqual("ShittyMcUlow", TrashMem.ReadString(STATIC_ADDRESS_STRING, Encoding.ASCII, 12));
 }
Beispiel #2
0
        private void ButtonWriteData_Click(object sender, RoutedEventArgs e)
        {
            if (TrashMem != null && listboxAllocations.SelectedItem != null)
            {
                uint address = ((MemoryAllocation)listboxAllocations.SelectedItem).Address;
                int  size    = ((MemoryAllocation)listboxAllocations.SelectedItem).Size;

                switch ((string)comboboxDataType.SelectedItem)
                {
                case "Bytes":
                    byte[] bytes = Encoding.ASCII.GetBytes(textboxData.Text);
                    if (bytes.Length <= size)
                    {
                        TrashMem.WriteBytes(address, bytes);
                    }
                    break;

                case "Char":
                    if (char.TryParse(textboxData.Text, out char charValue))
                    {
                        TrashMem.Write(address, charValue);
                    }
                    break;

                case "Int16":
                    if (short.TryParse(textboxData.Text, out short shortValue))
                    {
                        TrashMem.Write(address, shortValue);
                    }
                    break;

                case "Int32":
                    if (int.TryParse(textboxData.Text, out int intValue))
                    {
                        TrashMem.Write(address, intValue);
                    }
                    break;

                case "Int64":
                    if (long.TryParse(textboxData.Text, out long longValue))
                    {
                        TrashMem.Write(address, longValue);
                    }
                    break;

                case "Float":
                    if (float.TryParse(textboxData.Text, out float floatValue))
                    {
                        TrashMem.Write(address, floatValue);
                    }
                    break;

                case "Double":
                    if (double.TryParse(textboxData.Text, out double doubleValue))
                    {
                        TrashMem.Write(address, doubleValue);
                    }
                    break;

                case "ASCII String":
                    TrashMem.WriteString(address, textboxData.Text, Encoding.ASCII);
                    break;
                }

                UpdateByteViews(address, size);
            }
        }