Exemple #1
0
        // #US / #Blob
        public static uint ReadCompressedUInt32(HexBuffer buffer, ref HexPosition position)
        {
            byte b = buffer.ReadByte(position++);

            if ((b & 0x80) == 0)
            {
                return(b);
            }

            if ((b & 0xC0) == 0x80)
            {
                return((uint)((b & 0x3F) << 8) | buffer.ReadByte(position++));
            }

            // The encoding 111x isn't allowed but the CLR sometimes doesn't verify this
            // and just assumes it's 110x. Don't fail if it's 111x, just assume it's 110x.

            return((uint)(((b & 0x1F) << 24) | (buffer.ReadByte(position++) << 16) |
                          (buffer.ReadByte(position++) << 8) | buffer.ReadByte(position++)));
        }
Exemple #2
0
 static string GetString(StringBuilder sb, HexBuffer buffer, HexPosition position, int stringLength)
 {
     sb.Clear();
     for (int i = 0; i < stringLength; i++)
     {
         var b = buffer.ReadByte(position++);
         if (b == 0)
         {
             break;
         }
         sb.Append((char)b);
     }
     return(sb.ToString());
 }
        static int?Read7BitEncodedInt32(HexBuffer buffer, ref HexPosition position)
        {
            uint val  = 0;
            int  bits = 0;

            for (int i = 0; i < 5; i++)
            {
                byte b = buffer.ReadByte(position++);
                val |= (uint)(b & 0x7F) << bits;
                if ((b & 0x80) == 0)
                {
                    return((int)val);
                }
                bits += 7;
            }
            return(null);
        }
Exemple #4
0
 public ByteHexField(HexBuffer buffer, string parentName, string name, HexPosition start, bool useDecimal = false)
     : base(buffer, parentName, name, start, 1)
 {
     data = new ByteVM(buffer.ReadByte(start), a => UpdateValue(), useDecimal);
 }
Exemple #5
0
 public ByteFlagsHexField(HexBuffer buffer, string parentName, string name, HexPosition start)
     : base(buffer, parentName, name, start, 1)
 {
     data = new ByteVM(buffer.ReadByte(start), a => UpdateValue(), false);
 }