本文整理汇总了C#中IKVM.Reflection.Reader.ModuleReader.GetStream方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleReader.GetStream方法的具体用法?C# ModuleReader.GetStream怎么用?C# ModuleReader.GetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKVM.Reflection.Reader.ModuleReader
的用法示例。
在下文中一共展示了ModuleReader.GetStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MethodBody
internal MethodBody(ModuleReader module, int rva, IGenericContext context)
{
const byte CorILMethod_TinyFormat = 0x02;
const byte CorILMethod_FatFormat = 0x03;
const byte CorILMethod_MoreSects = 0x08;
const byte CorILMethod_InitLocals = 0x10;
const byte CorILMethod_Sect_EHTable = 0x01;
const byte CorILMethod_Sect_FatFormat = 0x40;
const byte CorILMethod_Sect_MoreSects = 0x80;
List<ExceptionHandlingClause> exceptionClauses = new List<ExceptionHandlingClause>();
List<LocalVariableInfo> locals = new List<LocalVariableInfo>();
Stream stream = module.GetStream();
module.SeekRVA(rva);
BinaryReader br = new BinaryReader(stream);
byte b = br.ReadByte();
if ((b & 3) == CorILMethod_TinyFormat)
{
initLocals = true;
body = br.ReadBytes(b >> 2);
maxStack = 8;
}
else if ((b & 3) == CorILMethod_FatFormat)
{
initLocals = (b & CorILMethod_InitLocals) != 0;
short flagsAndSize = (short)(b | (br.ReadByte() << 8));
if ((flagsAndSize >> 12) != 3)
{
throw new BadImageFormatException("Fat format method header size should be 3");
}
maxStack = br.ReadUInt16();
int codeLength = br.ReadInt32();
localVarSigTok = br.ReadInt32();
body = br.ReadBytes(codeLength);
if ((b & CorILMethod_MoreSects) != 0)
{
stream.Position = (stream.Position + 3) & ~3;
int hdr = br.ReadInt32();
if ((hdr & CorILMethod_Sect_MoreSects) != 0 || (hdr & CorILMethod_Sect_EHTable) == 0)
{
throw new NotImplementedException();
}
else if ((hdr & CorILMethod_Sect_FatFormat) != 0)
{
int count = ComputeExceptionCount((hdr >> 8) & 0xFFFFFF, 24);
for (int i = 0; i < count; i++)
{
int flags = br.ReadInt32();
int tryOffset = br.ReadInt32();
int tryLength = br.ReadInt32();
int handlerOffset = br.ReadInt32();
int handlerLength = br.ReadInt32();
int classTokenOrFilterOffset = br.ReadInt32();
exceptionClauses.Add(new ExceptionHandlingClause(module, flags, tryOffset, tryLength, handlerOffset, handlerLength, classTokenOrFilterOffset, context));
}
}
else
{
int count = ComputeExceptionCount((hdr >> 8) & 0xFF, 12);
for (int i = 0; i < count; i++)
{
int flags = br.ReadUInt16();
int tryOffset = br.ReadUInt16();
int tryLength = br.ReadByte();
int handlerOffset = br.ReadUInt16();
int handlerLength = br.ReadByte();
int classTokenOrFilterOffset = br.ReadInt32();
exceptionClauses.Add(new ExceptionHandlingClause(module, flags, tryOffset, tryLength, handlerOffset, handlerLength, classTokenOrFilterOffset, context));
}
}
}
if (localVarSigTok != 0)
{
ByteReader sig = module.GetStandAloneSig((localVarSigTok & 0xFFFFFF) - 1);
Signature.ReadLocalVarSig(module, sig, context, locals);
}
}
else
{
throw new BadImageFormatException();
}
this.exceptionClauses = exceptionClauses.AsReadOnly();
this.locals = locals.AsReadOnly();
}