Esempio n. 1
0
 /// <summary>
 /// Creates a new string value.
 /// </summary>
 /// <param name="stringType">The string type signature.</param>
 /// <param name="contents">The raw contents of the string.</param>
 /// <exception cref="ArgumentException">
 /// Occurs when the memory block referenced by <paramref name="contents"/> is of an invalid size.
 /// </exception>
 public StringValue(TypeSignature stringType, MemoryPointerValue contents)
 {
     Type      = stringType ?? throw new ArgumentNullException(nameof(stringType));
     _contents = contents ?? throw new ArgumentNullException(nameof(contents));
     if (contents.Length % sizeof(char) != 0)
     {
         throw new ArgumentException($"Length of raw string memory must be a multiple of two.");
     }
 }
Esempio n. 2
0
        public void ReadInteger64()
        {
            using var memoryOwner = MemoryPool <byte> .Shared.Rent(8);

            using var bitmaskOwner = MemoryPool <byte> .Shared.Rent(8);

            var ptrValue = new MemoryPointerValue(memoryOwner.Memory, bitmaskOwner.Memory, true);

            var value = new Integer32Value("00001111????0011001100??00??0101");

            ptrValue.WriteInteger32(0, value);
            Assert.Equal(value, ptrValue.ReadInteger32(0));
        }
Esempio n. 3
0
        public void ReadWriteFloat64()
        {
            using var memoryOwner = MemoryPool <byte> .Shared.Rent(8);

            using var bitmaskOwner = MemoryPool <byte> .Shared.Rent(8);

            var ptrValue = new MemoryPointerValue(memoryOwner.Memory, bitmaskOwner.Memory, true);

            var value = new Float64Value(0.12345678d);

            ptrValue.WriteFloat64(0, value);
            Assert.Equal(value.F64, ptrValue.ReadFloat64(0).F64);
        }
Esempio n. 4
0
        public void WriteInteger16ShouldBeLittleEndian()
        {
            using var memoryOwner = MemoryPool <byte> .Shared.Rent(2);

            using var bitmaskOwner = MemoryPool <byte> .Shared.Rent(2);

            var ptrValue = new MemoryPointerValue(memoryOwner.Memory, bitmaskOwner.Memory, true);

            var value = new Integer16Value("00001111????0000");

            ptrValue.WriteInteger16(0, value);

            Assert.Equal(new Integer8Value("????0000"), ptrValue.ReadInteger8(0));
            Assert.Equal(new Integer8Value("00001111"), ptrValue.ReadInteger8(1));
        }
Esempio n. 5
0
        public void WriteInteger64ShouldBeLittleEndian()
        {
            using var memoryOwner = MemoryPool <byte> .Shared.Rent(8);

            using var bitmaskOwner = MemoryPool <byte> .Shared.Rent(8);

            var ptrValue = new MemoryPointerValue(memoryOwner.Memory, bitmaskOwner.Memory, true);

            var value = new Integer64Value("00000000" + "11111111" + "????????" + "00001111" +
                                           "????0000" + "01010101" + "0?0?0?0?" + "01010?0?");

            ptrValue.WriteInteger64(0, value);

            Assert.Equal(new Integer8Value("01010?0?"), ptrValue.ReadInteger8(0));
            Assert.Equal(new Integer8Value("0?0?0?0?"), ptrValue.ReadInteger8(1));
            Assert.Equal(new Integer8Value("01010101"), ptrValue.ReadInteger8(2));
            Assert.Equal(new Integer8Value("????0000"), ptrValue.ReadInteger8(3));
            Assert.Equal(new Integer8Value("00001111"), ptrValue.ReadInteger8(4));
            Assert.Equal(new Integer8Value("????????"), ptrValue.ReadInteger8(5));
            Assert.Equal(new Integer8Value("11111111"), ptrValue.ReadInteger8(6));
            Assert.Equal(new Integer8Value("00000000"), ptrValue.ReadInteger8(7));
        }
Esempio n. 6
0
 /// <summary>
 /// Creates a new low level emulated object.
 /// </summary>
 /// <param name="memoryAllocator">The object responsible for memory management in the virtual machine.</param>
 /// <param name="valueType">The type of the object.</param>
 /// <param name="contents">The raw contents of the object.</param>
 public LleObjectValue(IMemoryAllocator memoryAllocator, TypeSignature valueType, MemoryPointerValue contents)
 {
     Type             = valueType;
     _memoryAllocator = memoryAllocator ?? throw new ArgumentNullException(nameof(memoryAllocator));
     Contents         = contents ?? throw new ArgumentNullException(nameof(contents));
 }
Esempio n. 7
0
 /// <summary>
 /// Creates a new structure value.
 /// </summary>
 /// <param name="memoryAllocator">The object responsible for memory management in the virtual machine.</param>
 /// <param name="valueType">The type of the object.</param>
 /// <param name="contents">The raw contents of the structure.</param>
 public StructValue(IMemoryAllocator memoryAllocator, TypeSignature valueType, MemoryPointerValue contents)
     : base(memoryAllocator, valueType, contents)
 {
 }