예제 #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);
        }
예제 #2
0
파일: Structures.cs 프로젝트: klumsy/IL2JS
 public void Read(ReaderContext ctxt, BlobReader reader)
 {
     Page = reader.ReadUInt32();
     if ((Page & 0xfff) != 0)
         throw new PEException("invalid FixupBlock.Page");
     var blockSize = reader.ReadUInt32();
     var numFixupEntries = (blockSize - 8)/ FixupEntry.Size;
     Entries = new FixupEntry[(int)numFixupEntries];
     for (var i = 0; i < numFixupEntries; i++)
         Entries[i].Read(ctxt, reader);
     reader.Align(4);
 }
예제 #3
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;
        }