Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Create()

static MethodBodyBlock System.Reflection.Metadata.MethodBodyBlock.Create ( BlobReader reader)
inlinestatic

Definition at line 56 of file MethodBodyBlock.cs.

57 {
58 int offset = reader.Offset;
59 byte b = reader.ReadByte();
60 int num;
61 if ((b & 3) == 2)
62 {
63 num = b >> 2;
64 return new MethodBodyBlock(localVariablesInitialized: false, 8, default(StandaloneSignatureHandle), reader.GetMemoryBlockAt(0, num), ImmutableArray<ExceptionRegion>.Empty, 1 + num);
65 }
66 if ((b & 3) != 3)
67 {
68 throw new BadImageFormatException(System.SR.Format(System.SR.InvalidMethodHeader1, b));
69 }
70 byte b2 = reader.ReadByte();
71 if (b2 >> 4 != 3)
72 {
73 throw new BadImageFormatException(System.SR.Format(System.SR.InvalidMethodHeader2, b, b2));
74 }
75 bool localVariablesInitialized = (b & 0x10) == 16;
76 bool flag = (b & 8) == 8;
77 ushort maxStack = reader.ReadUInt16();
78 num = reader.ReadInt32();
79 int num2 = reader.ReadInt32();
80 StandaloneSignatureHandle localSignatureHandle;
81 if (num2 == 0)
82 {
83 localSignatureHandle = default(StandaloneSignatureHandle);
84 }
85 else
86 {
87 if (((ulong)num2 & 0x7F000000uL) != 285212672)
88 {
89 throw new BadImageFormatException(System.SR.Format(System.SR.InvalidLocalSignatureToken, (uint)num2));
90 }
91 localSignatureHandle = StandaloneSignatureHandle.FromRowId(num2 & 0xFFFFFF);
92 }
93 MemoryBlock memoryBlockAt = reader.GetMemoryBlockAt(0, num);
94 reader.Offset += num;
95 ImmutableArray<ExceptionRegion> exceptionRegions;
96 if (flag)
97 {
98 reader.Align(4);
99 byte b3 = reader.ReadByte();
100 if ((b3 & 1) != 1)
101 {
102 throw new BadImageFormatException(System.SR.Format(System.SR.InvalidSehHeader, b3));
103 }
104 bool flag2 = (b3 & 0x40) == 64;
105 int num3 = reader.ReadByte();
106 if (flag2)
107 {
108 num3 += reader.ReadUInt16() << 8;
109 exceptionRegions = ReadFatExceptionHandlers(ref reader, num3 / 24);
110 }
111 else
112 {
113 reader.Offset += 2;
114 exceptionRegions = ReadSmallExceptionHandlers(ref reader, num3 / 12);
115 }
116 }
117 else
118 {
119 exceptionRegions = ImmutableArray<ExceptionRegion>.Empty;
120 }
121 return new MethodBodyBlock(localVariablesInitialized, maxStack, localSignatureHandle, memoryBlockAt, exceptionRegions, reader.Offset - offset);
122 }
static readonly ImmutableArray< T > Empty
static ImmutableArray< ExceptionRegion > ReadSmallExceptionHandlers(ref BlobReader memReader, int count)
MethodBodyBlock(bool localVariablesInitialized, ushort maxStack, StandaloneSignatureHandle localSignatureHandle, MemoryBlock il, ImmutableArray< ExceptionRegion > exceptionRegions, int size)
static ImmutableArray< ExceptionRegion > ReadFatExceptionHandlers(ref BlobReader memReader, int count)
static string InvalidSehHeader
Definition SR.cs:34
static string InvalidMethodHeader1
Definition SR.cs:28
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string InvalidLocalSignatureToken
Definition SR.cs:24
static string InvalidMethodHeader2
Definition SR.cs:30
Definition SR.cs:7
unsafe MemoryBlock GetMemoryBlockAt(int offset, int length)

References System.Reflection.Metadata.MethodBodyBlock.MethodBodyBlock(), System.Reflection.Metadata.BlobReader.Align(), System.Collections.Immutable.ImmutableArray< T >.Empty, System.SR.Format(), System.Reflection.Metadata.StandaloneSignatureHandle.FromRowId(), System.Reflection.Metadata.BlobReader.GetMemoryBlockAt(), System.SR.InvalidLocalSignatureToken, System.SR.InvalidMethodHeader1, System.SR.InvalidMethodHeader2, System.SR.InvalidSehHeader, System.offset, System.Reflection.Metadata.BlobReader.Offset, System.Reflection.Metadata.BlobReader.ReadByte(), System.Reflection.Metadata.MethodBodyBlock.ReadFatExceptionHandlers(), System.Reflection.Metadata.BlobReader.ReadInt32(), System.Reflection.Metadata.MethodBodyBlock.ReadSmallExceptionHandlers(), and System.Reflection.Metadata.BlobReader.ReadUInt16().

Referenced by System.Reflection.Metadata.PEReaderExtensions.GetMethodBody().