Beispiel #1
0
        private bool ReadMethodDataSection(ReaderContext ctxt, BlobReader reader, Func <OpCode, Row, object> resolveRow)
        {
            reader.Align(4);
            var flags = (CorILMethodSect)reader.ReadByte();

            if ((flags & CorILMethodSect.EHTable) == 0)
            {
                throw new PEException("unrecognised method data section");
            }

            var isFat = (flags & CorILMethodSect.FatFormat) != 0;
            var count = default(uint);

            if (isFat)
            {
                var size = reader.ReadUInt24();
                if (size < 4 || (size - 4) % 24 != 0)
                {
                    throw new InvalidOperationException("invalid method data section");
                }
                count = (size - 4) / 24;
            }
            else
            {
                var size = (uint)reader.ReadByte();
                // NOTE: Looks live VB emits size without including the 4 byte header...
                if (size < 4 || (size - 4) % 12 != 0)
                {
                    throw new InvalidOperationException("invalid method data section");
                }
                var padding = reader.ReadUInt16();
                if (padding != 0)
                {
                    throw new PEException("unexpected data");
                }
                count = (size - 4) / 12;
            }

            for (var i = 0; i < count; i++)
            {
                var c = new ExceptionHandlingClause();
                c.Read(ctxt, reader, isFat, resolveRow);
                ExceptionHandlingClauses.Add(c);
            }

            return((flags & CorILMethodSect.MoreSects) != 0);
        }
Beispiel #2
0
        private bool ReadMethodDataSection(ReaderContext ctxt, BlobReader reader, Func<OpCode, Row, object> resolveRow)
        {
            reader.Align(4);
            var flags = (CorILMethodSect)reader.ReadByte();
            if ((flags & CorILMethodSect.EHTable) == 0)
                throw new PEException("unrecognised method data section");

            var isFat = (flags & CorILMethodSect.FatFormat) != 0;
            var count = default(uint);
            if (isFat)
            {
                var size = reader.ReadUInt24();
                if (size < 4 || (size - 4) % 24 != 0)
                    throw new InvalidOperationException("invalid method data section");
                count = (size - 4) / 24;
            }
            else
            {
                var size = (uint)reader.ReadByte();
                // NOTE: Looks live VB emits size without including the 4 byte header...
                if (size < 4 || (size - 4) % 12 != 0)
                    throw new InvalidOperationException("invalid method data section");
                var padding = reader.ReadUInt16();
                if (padding != 0)
                    throw new PEException("unexpected data");
                count = (size - 4) / 12;
            }

            for (var i = 0; i < count; i++)
            {
                var c = new ExceptionHandlingClause();
                c.Read(ctxt, reader, isFat, resolveRow);
                ExceptionHandlingClauses.Add(c);
            }

            return (flags & CorILMethodSect.MoreSects) != 0;
        }