Пример #1
0
        public void Append <T>(T value, bool littleEndian = false)
        {
            Type t = typeof(T);

            if (!IsValidType(t))
            {
                throw new Exception("msg_t.AppendMessage: Invalid type!");
            }

            if (t == typeof(bool))
            {
                xbc.WriteInt32(DataBuffer + MessageLength, ((bool)(object)value == true) ? 1 : 0);
                MessageLength += 4;
            }
            else if (t == typeof(string))
            {
                xbc.WriteString
                xbc.WriteString(DataBuffer + MessageLength, (string)(object)value, false);

                MessageLength += (uint)Encoding.UTF8.GetBytes((string)(object)value).Length;
            }
            else if (t == typeof(byte[]))
            {
                byte[] bytes = (byte[])(object)value;
                xbc.SetMemory(DataBuffer + MessageLength, bytes);
                MessageLength += (uint)bytes.Length;
            }
            else if (t == typeof(byte))
            {
                xbc.WriteByte(DataBuffer + MessageLength, (byte)(object)value);
                MessageLength += 1;
            }
            else
            {
                var bytes = typeof(BitConverter)
                            .GetMethod("GetBytes", new Type[] { value.GetType() })
                            .Invoke(null, new object[] { value });

                byte[] data = (byte[])(object)bytes;
                if (!littleEndian)
                {
                    Array.Reverse(data);
                }

                xbc.SetMemory(DataBuffer + MessageLength, data);
                MessageLength += (uint)data.Length;
            }

            UpdateOverflowedBoolean();
        }
Пример #2
0
        public static void SetMemory(uint v1, byte[] v2)
        {
            try

            {
                if (connected == true)
                {
                    Serenity.SetMemory(v1, v2);
                }
                else
                {
                    MessageBox.Show("Not Connected");
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #3
0
 public static void SetMemoryDump(uint offset, byte[] data)
 {
     jtag.SetMemory(offset, data);
 }
Пример #4
0
 private void redbox_CheckedChanged(object sender, EventArgs e)
 {
     if (redbox.Checked)
     {
         Console.SetMemory(offsets.redboxes, new byte[] { 0x60, 0x00, 0x00, 0x00 });
     }
     else
     {
         Console.SetMemory(offsets.redboxes, new byte[] { 0x41, 0x9A, 0x00, 0x0C });
     }
 }