コード例 #1
0
        public void ReadTStruct()
        {
            MemoryBufferAddressSpace dataSource = new MemoryBufferAddressSpace(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 });
            Reader       reader = new Reader(dataSource);
            SimpleStruct s      = reader.Read <SimpleStruct>(1);

            Assert.Equal(0x05040302, s.X);
            Assert.Equal(0x0706, s.Y);
        }
コード例 #2
0
        public void EnumTStructTest()
        {
            MemoryBufferAddressSpace dataSource = new MemoryBufferAddressSpace(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
            Reader     reader = new Reader(dataSource);
            EnumStruct s      = reader.Read <EnumStruct>(1);

            Assert.Equal(FooEnum.ThreeTwo, s.E);
            Assert.Equal(0x09080706, s.X);
        }
コード例 #3
0
ファイル: PrimitiveTypes.cs プロジェクト: mikem8361/symstore
        public void IntTest()
        {
            MemoryBufferAddressSpace dt = new MemoryBufferAddressSpace(new byte[] { 200, 12, 19, 139, 0, 0, 0, 0 });

            Assert.Equal((139 - 256) * 256 * 256 * 256 + 19 * 256 * 256 + 12 * 256 + 200, new Int32Layout(false).Read(dt, 0));
            Assert.Equal(0, new Int32Layout(false).Read(dt, 4));
            Assert.Equal((200 - 256) * 256 * 256 * 256 + 12 * 256 * 256 + 19 * 256 + 139, new Int32Layout(true).Read(dt, 0));
            Assert.Equal(0, new Int32Layout(true).Read(dt, 4));
        }
コード例 #4
0
        public void ReadPrimitives()
        {
            MemoryBufferAddressSpace dataSource = new MemoryBufferAddressSpace(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 });
            Reader reader = new Reader(dataSource);

            Assert.Equal(0x0201, reader.Read <ushort>(0));
            Assert.Equal(0x5, reader.Read <byte>(4));
            Assert.Equal((uint)0x08070605, reader.Read <uint>(4));
        }
コード例 #5
0
ファイル: PrimitiveTypes.cs プロジェクト: mikem8361/symstore
        public void UIntTest()
        {
            MemoryBufferAddressSpace dt = new MemoryBufferAddressSpace(new byte[] { 200, 12, 19, 139, 0, 0, 0, 0 });

            Assert.Equal((uint)139 * 256 * 256 * 256 + 19 * 256 * 256 + 12 * 256 + 200, new UInt32Layout(false).Read(dt, 0));
            Assert.Equal((uint)0, new UInt32Layout(false).Read(dt, 4));
            Assert.Equal((uint)200 * 256 * 256 * 256 + 12 * 256 * 256 + 19 * 256 + 139, new UInt32Layout(true).Read(dt, 0));
            Assert.Equal((uint)0, new UInt32Layout(true).Read(dt, 4));
        }
コード例 #6
0
ファイル: PrimitiveTypes.cs プロジェクト: mikem8361/symstore
        public void ShortTest()
        {
            MemoryBufferAddressSpace dt = new MemoryBufferAddressSpace(new byte[] { 200, 12, 0, 0 });

            Assert.Equal(12 * 256 + 200, (short)new Int16Layout(false).Read(dt, 0));
            Assert.Equal(0, (short)new Int16Layout(false).Read(dt, 2));
            Assert.Equal(-56 * 256 + 12, (short)new Int16Layout(true).Read(dt, 0));
            Assert.Equal(0, (short)new Int16Layout(true).Read(dt, 2));
        }
コード例 #7
0
        public void ReadDerivedTStruct()
        {
            MemoryBufferAddressSpace dataSource = new MemoryBufferAddressSpace(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
            Reader        reader = new Reader(dataSource);
            DerivedStruct s      = reader.Read <DerivedStruct>(1);

            Assert.Equal(0x05040302, s.X);
            Assert.Equal(0x0706, s.Y);
            Assert.Equal(0x0d0c0b0a, s.Z);
        }
コード例 #8
0
ファイル: AddressSpace.cs プロジェクト: mikem8361/symstore
        public void GoodReads()
        {
            MemoryBufferAddressSpace buffer = new MemoryBufferAddressSpace(new byte[] { 1, 2, 3, 4, 5 });

            Assert.True(Enumerable.SequenceEqual(new byte[] { 1 }, buffer.Read(0, 1)));
            Assert.True(Enumerable.SequenceEqual(new byte[] { 3, 4 }, buffer.Read(2, 2)));
            Assert.True(Enumerable.SequenceEqual(new byte[] { 1, 2, 3, 4, 5 }, buffer.Read(0, 5)));
            Assert.True(Enumerable.SequenceEqual(new byte[0], buffer.Read(0, 0)));
            Assert.True(Enumerable.SequenceEqual(new byte[0], buffer.Read(4, 0)));
        }
コード例 #9
0
ファイル: PrimitiveTypes.cs プロジェクト: mikem8361/symstore
        public void LongTest()
        {
            MemoryBufferAddressSpace dt = new MemoryBufferAddressSpace(new byte[] { 200, 12, 19, 139, 192, 7, 1, 40, 0, 0, 0, 0, 0, 0, 0, 0 });

            Assert.Equal((40L << 56) + (1L << 48) + (7L << 40) + (192L << 32) + (139L << 24) + (19L << 16) + (12L << 8) + 200L,
                         new Int64Layout(false).Read(dt, 0));
            Assert.Equal(0L, new Int64Layout(false).Read(dt, 8));
            Assert.Equal((-56L << 56) + (12L << 48) + (19L << 40) + (139L << 32) + (192L << 24) + (7L << 16) + (1L << 8) + 40L,
                         new Int64Layout(true).Read(dt, 0));
            Assert.Equal(0L, new Int64Layout(true).Read(dt, 8));
        }
コード例 #10
0
ファイル: PrimitiveTypes.cs プロジェクト: mikem8361/symstore
        public void ULongTest()
        {
            MemoryBufferAddressSpace dt = new MemoryBufferAddressSpace(new byte[] { 200, 12, 19, 139, 192, 7, 1, 40, 0, 0, 0, 0, 0, 0, 0, 0 });

            Assert.Equal((40UL << 56) + (1UL << 48) + (7UL << 40) + (192UL << 32) + (139UL << 24) + (19UL << 16) + (12UL << 8) + 200UL,
                         new UInt64Layout(false).Read(dt, 0));
            Assert.Equal(0UL, new UInt64Layout(false).Read(dt, 8));
            Assert.Equal((200UL << 56) + (12UL << 48) + (19UL << 40) + (139UL << 32) + (192UL << 24) + (7UL << 16) + (1UL << 8) + 40UL,
                         new UInt64Layout(true).Read(dt, 0));
            Assert.Equal(0UL, new UInt64Layout(true).Read(dt, 8));
        }
コード例 #11
0
ファイル: PrimitiveTypes.cs プロジェクト: mikem8361/symstore
        public void SByteTest()
        {
            MemoryBufferAddressSpace dt = new MemoryBufferAddressSpace(new byte[] { 200, 12, 0 });

            Assert.Equal(-56, (sbyte)new Int8Layout(false).Read(dt, 0));
            Assert.Equal(12, (sbyte)new Int8Layout(false).Read(dt, 1));
            Assert.Equal(0, (sbyte)new Int8Layout(false).Read(dt, 2));
            Assert.Equal(-56, (sbyte)new Int8Layout(true).Read(dt, 0));
            Assert.Equal(12, (sbyte)new Int8Layout(true).Read(dt, 1));
            Assert.Equal(0, (sbyte)new Int8Layout(true).Read(dt, 2));
        }
コード例 #12
0
        public void ReadArrayTStructTest()
        {
            MemoryBufferAddressSpace dataSource = new MemoryBufferAddressSpace(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
            Reader      reader = new Reader(dataSource);
            ArrayStruct s      = reader.Read <ArrayStruct>(1);

            Assert.Equal(3, s.array.Length);
            Assert.Equal(0x0302, s.array[0]);
            Assert.Equal(0x0504, s.array[1]);
            Assert.Equal(0x0706, s.array[2]);
            Assert.Equal(0x0d0c0b0a, s.X);
        }
コード例 #13
0
        public void DefineTest()
        {
            MemoryBufferAddressSpace dataSource = new MemoryBufferAddressSpace(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
            LayoutManager            a          = new LayoutManager().AddPrimitives().AddTStructTypes(new string[] { "A" });
            Reader        readerA = new Reader(dataSource, a);
            OptionalField fA      = readerA.Read <OptionalField>(0);

            Assert.Equal(0x08070605, fA.Y);
            Assert.Equal(0x0c0b0a09, fA.Z);

            Reader        readerB = new Reader(dataSource);
            OptionalField fB      = readerB.Read <OptionalField>(0);

            Assert.Equal(0x0, fB.Y);
            Assert.Equal(0x08070605, fB.Z);
        }
コード例 #14
0
        public void PointerTStructTest()
        {
            MemoryBufferAddressSpace dataSource = new MemoryBufferAddressSpace(new byte[] { 4, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 });
            LayoutManager            mgr        = new LayoutManager().AddPrimitives().AddSizeT(4).AddPointerTypes().AddTStructTypes();
            Reader        reader = new Reader(dataSource, mgr);
            PointerStruct s      = reader.Read <PointerStruct>(0);

            Assert.Equal((ulong)0x4, s.P.Value);
            Assert.False(s.P.IsNull);
            Assert.Equal((uint)0x1, s.P.Dereference(dataSource));
            Assert.Equal((ulong)0x1, s.P32.Value);
            Assert.Equal((byte)0x0, s.P32.Dereference(dataSource));
            Assert.Equal((byte)0x1, s.P32.Element(dataSource, 3));
            Assert.Equal((ulong)0x2, s.P64.Value);
            Assert.Equal((ulong)0x0002000000010000, s.P64.Dereference(dataSource));
        }
コード例 #15
0
ファイル: AddressSpace.cs プロジェクト: mikem8361/symstore
        public void BadReads()
        {
            MemoryBufferAddressSpace buffer = new MemoryBufferAddressSpace(new byte[] { 1, 2, 3, 4, 5 });

            Assert.Throws <BadInputFormatException>(() =>
            {
                buffer.Read(5, 1);
            });
            Assert.Throws <BadInputFormatException>(() =>
            {
                buffer.Read(5, 0);
            });
            Assert.Throws <BadInputFormatException>(() =>
            {
                buffer.Read(3, 3);
            });
        }