• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UtilityDataStructures.MemoryReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Cci.UtilityDataStructures.MemoryReader的典型用法代码示例。如果您正苦于以下问题:C# MemoryReader类的具体用法?C# MemoryReader怎么用?C# MemoryReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MemoryReader类属于Microsoft.Cci.UtilityDataStructures命名空间,在下文中一共展示了MemoryReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AssemblyOSTableReader

     internal AssemblyOSTableReader(
   uint numberOfRows,
   byte* buffer
 )
     {
         this.NumberOfRows = numberOfRows;
           this.OSPlatformIdOffset = 0;
           this.OSMajorVersionIdOffset = this.OSPlatformIdOffset + sizeof(UInt32);
           this.OSMinorVersionIdOffset = this.OSMajorVersionIdOffset + sizeof(UInt32);
           this.RowSize = this.OSMinorVersionIdOffset + sizeof(UInt32);
           this.AssemblyOSTableMemoryReader = new MemoryReader(buffer, (int)(this.RowSize * numberOfRows));
     }
开发者ID:harib,项目名称:Afterthought,代码行数:12,代码来源:PEFileReader.cs


示例2: FieldSignatureConverter

 internal FieldSignatureConverter(PEFileToObjectModel peFileToObjectModel, MetadataObject moduleField, MemoryReader signatureMemoryReader)
     : base(peFileToObjectModel, signatureMemoryReader, moduleField)
 {
     //^ base;
       //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary.
       this.FirstByte = this.SignatureMemoryReader.ReadByte();
       if (!SignatureHeader.IsFieldSignature(this.FirstByte)) {
     //  Error...
       }
       bool isPinned;
       this.customModifiers = this.GetCustomModifiers(out isPinned);
       this.TypeReference = this.GetTypeReference();
 }
开发者ID:riverar,项目名称:devtools,代码行数:13,代码来源:PEFileToObjectModel.cs


示例3: PopulateCilInstructions

 bool PopulateCilInstructions() {
   MethodBodyDocument document = new MethodBodyDocument(this.MethodDefinition);
   MemoryReader memReader = new MemoryReader(this.MethodIL.EncodedILMemoryBlock);
   var numInstructions = CountCilInstructions(memReader);
   if (numInstructions == 0) return true;
   CilInstruction[] instrList = new CilInstruction[numInstructions];
   int instructionNumber = 0;
   while (memReader.NotEndOfBytes) {
     object/*?*/ value = null;
     uint offset = (uint)memReader.Offset;
     OperationCode cilOpCode = memReader.ReadOpcode();
     switch (cilOpCode) {
       case OperationCode.Nop:
       case OperationCode.Break:
         break;
       case OperationCode.Ldarg_0:
       case OperationCode.Ldarg_1:
       case OperationCode.Ldarg_2:
       case OperationCode.Ldarg_3:
         value = this.GetParameter((uint)(cilOpCode - OperationCode.Ldarg_0));
         break;
       case OperationCode.Ldloc_0:
       case OperationCode.Ldloc_1:
       case OperationCode.Ldloc_2:
       case OperationCode.Ldloc_3:
         value = this.GetLocal((uint)(cilOpCode - OperationCode.Ldloc_0));
         break;
       case OperationCode.Stloc_0:
       case OperationCode.Stloc_1:
       case OperationCode.Stloc_2:
       case OperationCode.Stloc_3:
         value = this.GetLocal((uint)(cilOpCode - OperationCode.Stloc_0));
         break;
       case OperationCode.Ldarg_S:
       case OperationCode.Ldarga_S:
       case OperationCode.Starg_S:
         value = this.GetParameter(memReader.ReadByte());
         break;
       case OperationCode.Ldloc_S:
       case OperationCode.Ldloca_S:
       case OperationCode.Stloc_S:
         value = this.GetLocal(memReader.ReadByte());
         break;
       case OperationCode.Ldnull:
       case OperationCode.Ldc_I4_M1:
       case OperationCode.Ldc_I4_0:
       case OperationCode.Ldc_I4_1:
       case OperationCode.Ldc_I4_2:
       case OperationCode.Ldc_I4_3:
       case OperationCode.Ldc_I4_4:
       case OperationCode.Ldc_I4_5:
       case OperationCode.Ldc_I4_6:
       case OperationCode.Ldc_I4_7:
       case OperationCode.Ldc_I4_8:
         break;
       case OperationCode.Ldc_I4_S:
         value = (int)memReader.ReadSByte();
         break;
       case OperationCode.Ldc_I4:
         value = memReader.ReadInt32();
         break;
       case OperationCode.Ldc_I8:
         value = memReader.ReadInt64();
         break;
       case OperationCode.Ldc_R4:
         value = memReader.ReadSingle();
         break;
       case OperationCode.Ldc_R8:
         value = memReader.ReadDouble();
         break;
       case OperationCode.Dup:
       case OperationCode.Pop:
         break;
       case OperationCode.Jmp:
         value = this.GetMethod(memReader.ReadUInt32());
         break;
       case OperationCode.Call: {
           IMethodReference methodReference = this.GetMethod(memReader.ReadUInt32());
           IArrayTypeReference/*?*/ arrayType = methodReference.ContainingType as IArrayTypeReference;
           if (arrayType != null) {
             // For Get(), Set() and Address() on arrays, the runtime provides method implementations.
             // Hence, CCI2 replaces these with pseudo instrcutions Array_Set, Array_Get and Array_Addr.
             // All other methods on arrays will not use pseudo instruction and will have methodReference as their operand. 
             if (methodReference.Name.UniqueKey == this.PEFileToObjectModel.NameTable.Set.UniqueKey) {
               cilOpCode = OperationCode.Array_Set;
               value = arrayType;
             } else if (methodReference.Name.UniqueKey == this.PEFileToObjectModel.NameTable.Get.UniqueKey) {
               cilOpCode = OperationCode.Array_Get;
               value = arrayType;
             } else if (methodReference.Name.UniqueKey == this.PEFileToObjectModel.NameTable.Address.UniqueKey) {
               cilOpCode = OperationCode.Array_Addr;
               value = arrayType;
             } else {
               value = methodReference;
             }
           } else {
             value = methodReference;
           }
         }
         break;
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:101,代码来源:ILReader.cs


示例4: LoadLocalSignature

 bool LoadLocalSignature() {
   uint locVarRID = this.MethodIL.LocalSignatureToken & TokenTypeIds.RIDMask;
   if (locVarRID != 0x00000000) {
     StandAloneSigRow sigRow = this.PEFileToObjectModel.PEFileReader.StandAloneSigTable[locVarRID];
     //  TODO: error checking offset in range
     MemoryBlock signatureMemoryBlock = this.PEFileToObjectModel.PEFileReader.BlobStream.GetMemoryBlockAt(sigRow.Signature);
     //  TODO: Error checking enough space in signature memoryBlock.
     MemoryReader memoryReader = new MemoryReader(signatureMemoryBlock);
     //  TODO: Check if this is really local var signature there.
     LocalVariableSignatureConverter locVarSigConv = new LocalVariableSignatureConverter(this.PEFileToObjectModel, this.MethodBody, memoryReader);
     this.MethodBody.SetLocalVariables(locVarSigConv.LocalVariables);
   }
   return true;
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:14,代码来源:ILReader.cs


示例5: LocalVariableSignatureConverter

 internal LocalVariableSignatureConverter(
   PEFileToObjectModel peFileToObjectModel,
   MethodBody owningMethodBody,
   MemoryReader signatureMemoryReader
 )
   : base(peFileToObjectModel, signatureMemoryReader, owningMethodBody.MethodDefinition) {
   this.OwningMethodBody = owningMethodBody;
   byte firstByte = this.SignatureMemoryReader.ReadByte();
   if (!SignatureHeader.IsLocalVarSignature(firstByte)) {
     //  MDError
   }
   int locVarCount = this.SignatureMemoryReader.ReadCompressedUInt32();
   LocalVariableDefinition[] locVarArr = new LocalVariableDefinition[locVarCount];
   for (int i = 0; i < locVarCount; ++i) {
     locVarArr[i] = this.GetLocalVariable((uint)i);
   }
   this.LocalVariables = locVarArr;
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:18,代码来源:ILReader.cs


示例6: CustomAttributeDecoder

 internal CustomAttributeDecoder(PEFileToObjectModel peFileToObjectModel, MemoryReader signatureMemoryReader, uint customAttributeRowId,
   IMethodReference attributeConstructor)
   : base(peFileToObjectModel, signatureMemoryReader) {
   this.CustomAttribute = Dummy.CustomAttribute;
   ushort prolog = this.SignatureMemoryReader.ReadUInt16();
   if (prolog != SerializationType.CustomAttributeStart) return;
   int len = attributeConstructor.ParameterCount;
   IMetadataExpression[]/*?*/ exprList = len == 0 ? null : new IMetadataExpression[len];
   int i = 0;
   foreach (var parameter in attributeConstructor.Parameters) {
     var parameterType = parameter.Type;
     if (parameterType is Dummy) {
       //  Error...
       return;
     }
     ExpressionBase/*?*/ argument = this.ReadSerializedValue(parameterType);
     if (argument == null) {
       //  Error...
       this.decodeFailed = true;
       return;
     }
     exprList[i++] = argument;
   }
   IMetadataNamedArgument[]/*?*/ namedArgumentArray = null;
   if (2 <= (int)this.SignatureMemoryReader.RemainingBytes) {
     ushort numOfNamedArgs = this.SignatureMemoryReader.ReadUInt16();
     if (numOfNamedArgs > 0) {
       namedArgumentArray = new IMetadataNamedArgument[numOfNamedArgs];
       for (i = 0; i < numOfNamedArgs; ++i) {
         if (0 >= (int)this.SignatureMemoryReader.RemainingBytes) break;
         bool isField = this.SignatureMemoryReader.ReadByte() == SerializationType.Field;
         ITypeReference/*?*/ memberType = this.GetFieldOrPropType();
         if (memberType == null) {
           //  Error...
           return;
         }
         string/*?*/ memberStr = this.GetSerializedString();
         if (memberStr == null)
           return;
         IName memberName = this.PEFileToObjectModel.NameTable.GetNameFor(memberStr);
         ExpressionBase/*?*/ value = this.ReadSerializedValue(memberType);
         if (value == null) {
           //  Error...
           return;
         }
         ITypeReference/*?*/ moduleTypeRef = attributeConstructor.ContainingType;
         if (moduleTypeRef == null) {
           //  Error...
           return;
         }
         FieldOrPropertyNamedArgumentExpression namedArg = new FieldOrPropertyNamedArgumentExpression(memberName, moduleTypeRef, isField, memberType, value);
         namedArgumentArray[i] = namedArg;
       }
     }
   }
   this.CustomAttribute = peFileToObjectModel.ModuleReader.metadataReaderHost.Rewrite(peFileToObjectModel.Module,
     new CustomAttribute(peFileToObjectModel, customAttributeRowId, attributeConstructor, exprList, namedArgumentArray));
 }
开发者ID:RUB-SysSec,项目名称:Probfuscator,代码行数:58,代码来源:Attributes.cs


示例7: DeclSecurityTableReader

 internal DeclSecurityTableReader(
   uint numberOfRows,
   int hasDeclSecurityRefSize,
   int blobHeapRefSize,
   byte* buffer
 ) {
   this.NumberOfRows = numberOfRows;
   this.IsHasDeclSecurityRefSizeSmall = hasDeclSecurityRefSize == 2;
   this.IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
   this.ActionOffset = 0;
   this.ParentOffset = this.ActionOffset + sizeof(UInt16);
   this.PermissionSetOffset = this.ParentOffset + hasDeclSecurityRefSize;
   this.RowSize = this.PermissionSetOffset + blobHeapRefSize;
   this.DeclSecurityTableMemoryReader = new MemoryReader(buffer, (int)(this.RowSize * numberOfRows));
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:15,代码来源:PEFileReader.cs


示例8: CustomAttributeTableReader

 internal CustomAttributeTableReader(
   uint numberOfRows,
   int hasCustomAttributeRefSize,
   int customAttributeTypeRefSize,
   int blobHeapRefSize,
   byte* buffer
 ) {
   this.NumberOfRows = numberOfRows;
   this.IsHasCustomAttributeRefSizeSmall = hasCustomAttributeRefSize == 2;
   this.IsCustomAttriubuteTypeRefSizeSmall = customAttributeTypeRefSize == 2;
   this.IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
   this.ParentOffset = 0;
   this.TypeOffset = this.ParentOffset + hasCustomAttributeRefSize;
   this.ValueOffset = this.TypeOffset + customAttributeTypeRefSize;
   this.RowSize = this.ValueOffset + blobHeapRefSize;
   this.CustomAttributeTableMemoryReader = new MemoryReader(buffer, (int)(this.RowSize * numberOfRows));
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:17,代码来源:PEFileReader.cs


示例9: GetFatSEHEntries

 internal static SEHTableEntry[] GetFatSEHEntries(
   MemoryReader memReader,
   int numEntries
 ) {
   SEHTableEntry[] retSEHEntries = new SEHTableEntry[numEntries];
   for (int i = 0; i < numEntries; ++i) {
     SEHFlags sehFlags = (SEHFlags)memReader.ReadUInt32();
     uint tryOffset = memReader.ReadUInt32();
     uint tryLength = memReader.ReadUInt32();
     uint handlerOffset = memReader.ReadUInt32();
     uint handlerLength = memReader.ReadUInt32();
     uint classTokenOrFilterOffset = memReader.ReadUInt32();
     retSEHEntries[i] = new SEHTableEntry(sehFlags, tryOffset, tryLength, handlerOffset, handlerLength, classTokenOrFilterOffset);
   }
   return retSEHEntries;
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:16,代码来源:PEFileReader.cs


示例10: ReadMetadataLevelData

 bool ReadMetadataLevelData()
   //^ requires this.ReaderState >= ReaderState.CORModule;
 {
   MemoryReader memReader = new MemoryReader(this.MetadataTableStream);
   if (
     !this.ReadMetadataTableInformation(ref memReader)
     || !this.ProcessAndCacheMetadataTableBlocks(memReader.RemainingMemoryBlock)
   ) {
     return false;
   }
   if (this.ModuleTable.NumberOfRows != 1)
     return false;
   this.ReaderState = ReaderState.Metadata;
   return true;
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:15,代码来源:PEFileReader.cs


示例11: FieldPtrTableReader

 internal FieldPtrTableReader(
   uint numberOfRows,
   int fieldTableRowRefSize,
   byte* buffer
 ) {
   this.NumberOfRows = numberOfRows;
   this.IsFieldTableRowRefSizeSmall = fieldTableRowRefSize == 2;
   this.FieldOffset = 0;
   this.RowSize = this.FieldOffset + fieldTableRowRefSize;
   this.FieldPtrTableMemoryReader = new MemoryReader(buffer, (int)(this.RowSize * numberOfRows));
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:11,代码来源:PEFileReader.cs


示例12: ReadMetadataTableInformation

 bool ReadMetadataTableInformation(
   ref MemoryReader memReader
 )
   //^ requires this.ReaderState >= ReaderState.CORModule;
 {
   if (memReader.RemainingBytes < MetadataStreamConstants.SizeOfMetadataTableHeader) {
     this.ErrorContainer.AddMetadataStreamError(this.MetadataStreamName, 0, MetadataReaderErrorKind.MetadataTableHeaderTooSmall);
     return false;
   }
   this.MetadataTableHeader.Reserved = memReader.ReadUInt32();
   this.MetadataTableHeader.MajorVersion = memReader.ReadByte();
   this.MetadataTableHeader.MinorVersion = memReader.ReadByte();
   this.MetadataTableHeader.HeapSizeFlags = (HeapSizeFlag)memReader.ReadByte();
   this.MetadataTableHeader.RowId = memReader.ReadByte();
   this.MetadataTableHeader.ValidTables = (TableMask)memReader.ReadUInt64();
   this.MetadataTableHeader.SortedTables = (TableMask)memReader.ReadUInt64();
   ulong presentTables = (ulong)this.MetadataTableHeader.ValidTables;
   ulong validTablesForVersion = 0;
   int version = this.MetadataTableHeader.MajorVersion << 16 | this.MetadataTableHeader.MinorVersion;
   switch (version) {
     case 0x00010000:
       validTablesForVersion = (ulong)TableMask.V1_0_TablesMask;
       break;
     case 0x00010001:
       validTablesForVersion = (ulong)TableMask.V1_1_TablesMask;
       break;
     case 0x00020000:
       validTablesForVersion = (ulong)TableMask.V2_0_TablesMask;
       break;
     default:
       this.ErrorContainer.AddMetadataStreamError(this.MetadataStreamName, 4, MetadataReaderErrorKind.UnknownVersionOfMetadata);
       return false;
   }
   if ((presentTables & ~validTablesForVersion) != 0) {
     this.ErrorContainer.AddMetadataStreamError(this.MetadataStreamName, 8, MetadataReaderErrorKind.UnknownTables);
     return false;
   }
   if (this.MetadataStreamKind == MetadataStreamKind.Compressed && (presentTables & (ulong)TableMask.CompressedStreamNotAllowedMask) != 0) {
     this.ErrorContainer.AddMetadataStreamError(this.MetadataStreamName, 8, MetadataReaderErrorKind.IllegalTablesInCompressedMetadataStream);
     return false;
   }
   ulong requiredSortedTables = presentTables & validTablesForVersion & (ulong)TableMask.SortedTablesMask;
   if ((requiredSortedTables & (ulong)this.MetadataTableHeader.SortedTables) != requiredSortedTables) {
     this.ErrorContainer.AddMetadataStreamError(this.MetadataStreamName, 16, MetadataReaderErrorKind.SomeRequiredTablesNotSorted);
     //Carry on regardless. There are/were compiler out there that sort the required tables, but fail to set the bit in SortedTables.
   }
   int numberOfTables = this.MetadataTableHeader.GetNumberOfTablesPresent();
   if (memReader.RemainingBytes < numberOfTables * sizeof(Int32)) {
     this.ErrorContainer.AddMetadataStreamError(this.MetadataStreamName, memReader.Offset, MetadataReaderErrorKind.TableRowCountSpaceTooSmall);
     return false;
   }
   this.MetadataTableRowCount = new uint[numberOfTables];
   uint[] metadataTableRowCount = this.MetadataTableRowCount;
   for (int i = 0; i < numberOfTables; ++i) {
     metadataTableRowCount[i] = memReader.ReadUInt32();
   }
   return true;
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:58,代码来源:PEFileReader.cs


示例13: ReadCORModuleLevelData

 bool ReadCORModuleLevelData()
   //^ requires this.ReaderState >= ReaderState.PEFile;
 {
   if (!this.ReadCOR20Header()) {
     return false;
   }
   MemoryBlock metadataRoot = this.DirectoryToMemoryBlock(this.COR20Header.MetaDataDirectory);
   if (metadataRoot.Length < this.COR20Header.MetaDataDirectory.Size) {
     this.ErrorContainer.AddDirectoryError(Directories.Cor20HeaderMetaData, 0, MetadataReaderErrorKind.NotEnoughSpaceForMetadataDirectory);
     return false;
   }
   MemoryReader memReader = new MemoryReader(metadataRoot);
   if (
     !this.ReadMetadataHeader(ref memReader)
     || !this.ReadStorageHeader(ref memReader)
     || !this.ReadStreamHeaders(ref memReader)
     || !this.ProcessAndCacheStreams(ref metadataRoot)
   ) {
     return false;
   }
   this.ReaderState = ReaderState.CORModule;
   this.ResourceMemoryReader = new MemoryReader(this.DirectoryToMemoryBlock(this.COR20Header.ResourcesDirectory));
   this.StrongNameSignature = this.DirectoryToMemoryBlock(this.COR20Header.StrongNameSignatureDirectory);
   return true;
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:25,代码来源:PEFileReader.cs


示例14: ReadStreamHeaders

 bool ReadStreamHeaders(
   ref MemoryReader memReader
 )
   //^ requires this.ReaderState >= ReaderState.PEFile;
 {
   int numberOfStreams = this.StorageHeader.NumberOfStreams;
   this.StreamHeaders = new StreamHeader[numberOfStreams];
   StreamHeader[] streamHeaders = this.StreamHeaders;
   for (int i = 0; i < numberOfStreams; ++i) {
     if (memReader.RemainingBytes < COR20Constants.MinimumSizeofStreamHeader) {
       this.ErrorContainer.AddDirectoryError(Directories.Cor20HeaderMetaData, memReader.Offset, MetadataReaderErrorKind.StreamHeaderTooSmall);
       return false;
     }
     streamHeaders[i].Offset = memReader.ReadUInt32();
     streamHeaders[i].Size = memReader.ReadInt32();
     //  Review: Oh well there is no way i can test if we will read correctly. However we can check it after reading and aligning...
     streamHeaders[i].Name = memReader.ReadASCIINullTerminated();
     memReader.Align(4);
     if (memReader.RemainingBytes < 0) {
       this.ErrorContainer.AddDirectoryError(Directories.Cor20HeaderMetaData, memReader.Offset, MetadataReaderErrorKind.NotEnoughSpaceForStreamHeaderName);
       return false;
     }
   }
   return true;
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:25,代码来源:PEFileReader.cs


示例15: ReadStorageHeader

 bool ReadStorageHeader(
   ref MemoryReader memReader
 )
   //^ requires this.ReaderState >= ReaderState.PEFile;
 {
   if (memReader.RemainingBytes < COR20Constants.SizeofStorageHeader) {
     this.ErrorContainer.AddDirectoryError(Directories.Cor20HeaderMetaData, memReader.Offset, MetadataReaderErrorKind.StorageHeaderTooSmall);
     return false;
   }
   this.StorageHeader.Flags = memReader.ReadUInt16();
   this.StorageHeader.NumberOfStreams = memReader.ReadInt16();
   return true;
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:13,代码来源:PEFileReader.cs


示例16: MemberRefTableReader

 internal MemberRefTableReader(
   uint numberOfRows,
   int memberRefParentRefSize,
   int stringHeapRefSize,
   int blobHeapRefSize,
   byte* buffer
 ) {
   this.NumberOfRows = numberOfRows;
   this.IsMemberRefParentRefSizeSmall = memberRefParentRefSize == 2;
   this.IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
   this.IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
   this.ClassOffset = 0;
   this.NameOffset = this.ClassOffset + memberRefParentRefSize;
   this.SignatureOffset = this.NameOffset + stringHeapRefSize;
   this.RowSize = this.SignatureOffset + blobHeapRefSize;
   this.MemberRefTableMemoryReader = new MemoryReader(buffer, (int)(this.RowSize * numberOfRows));
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:17,代码来源:PEFileReader.cs


示例17: ConstantTableReader

 internal ConstantTableReader(
   uint numberOfRows,
   int hasConstantRefSize,
   int blobHeapRefSize,
   byte* buffer
 ) {
   this.NumberOfRows = numberOfRows;
   this.IsHasConstantRefSizeSmall = hasConstantRefSize == 2;
   this.IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
   this.TypeOffset = 0;
   this.ParentOffset = this.TypeOffset + sizeof(Byte) + 1; //  Alignment here (+1)...
   this.ValueOffset = this.ParentOffset + hasConstantRefSize;
   this.RowSize = this.ValueOffset + blobHeapRefSize;
   this.ConstantTableMemoryReader = new MemoryReader(buffer, (int)(this.RowSize * numberOfRows));
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:15,代码来源:PEFileReader.cs


示例18: GetMethodIL

 internal MethodIL/*?*/ GetMethodIL(
   uint methodDefRowId
 ) {
   MethodRow methodRow = this.MethodTable[methodDefRowId];
   if (
     (methodRow.ImplFlags & MethodImplFlags.CodeTypeMask) != MethodImplFlags.ILCodeType
     || methodRow.RVA == 0
   ) {
     return null;
   }
   MemoryBlock memBlock = this.RVAToMemoryBlock(methodRow.RVA);
   //  Error need to check if the Memory Block is empty. This is calse for all the calls...
   MemoryReader memReader = new MemoryReader(memBlock);
   byte headByte = memReader.ReadByte();
   if ((headByte & CILMethodFlags.ILFormatMask) == CILMethodFlags.ILTinyFormat) {
     int size = headByte >> CILMethodFlags.ILTinyFormatSizeShift;
     return new MethodIL(
       true,
       8,
       0x00000000,
       memReader.GetMemoryBlockAt(0, size),
       null
     );
   } else if ((headByte & CILMethodFlags.ILFormatMask) != CILMethodFlags.ILFatFormat) {
     //  PEFileFormat Error...
     return null;
   }
   //  FatILFormat
   byte headByte2 = memReader.ReadByte();
   if ((headByte2 >> CILMethodFlags.ILFatFormatHeaderSizeShift) != CILMethodFlags.ILFatFormatHeaderSize) {
     //  PEFile Format Error...
     return null;
   }
   bool localVarInited = (headByte & CILMethodFlags.ILInitLocals) == CILMethodFlags.ILInitLocals;
   bool moreSectsPresent = (headByte & CILMethodFlags.ILMoreSects) == CILMethodFlags.ILMoreSects;
   ushort maxStack = memReader.ReadUInt16();
   int codeSize = memReader.ReadInt32();
   uint localSignatureToken = memReader.ReadUInt32();
   MemoryBlock ilCodeMemBlock = memReader.GetMemoryBlockAt(0, codeSize);
   SEHTableEntry[]/*?*/ sehTableEntries = null;
   if (moreSectsPresent) {
     memReader.SkipBytes(codeSize);
     memReader.Align(4);
     byte sectHeader = memReader.ReadByte();
     if ((sectHeader & CILMethodFlags.SectEHTable) != CILMethodFlags.SectEHTable) {
       //  PEFile Format Error...
       return null;
     }
     bool sectFatFormat = (sectHeader & CILMethodFlags.SectFatFormat) == CILMethodFlags.SectFatFormat;
     int dataSize = memReader.ReadByte();
     if (sectFatFormat) {
       dataSize += (int)memReader.ReadUInt16() << 8;
       sehTableEntries = PEFileReader.GetFatSEHEntries(memReader, dataSize / 24);
     } else {
       memReader.SkipBytes(2); //skip over reserved field
       sehTableEntries = PEFileReader.GetSmallSEHEntries(memReader, dataSize / 12);
     }
   }
   return new MethodIL(
     localVarInited,
     maxStack,
     localSignatureToken,
     ilCodeMemBlock,
     sehTableEntries
   );
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:66,代码来源:PEFileReader.cs


示例19: FieldMarshalTableReader

 internal FieldMarshalTableReader(
   uint numberOfRows,
   int hasFieldMarshalRefSize,
   int blobHeapRefSize,
   byte* buffer
 ) {
   this.NumberOfRows = numberOfRows;
   this.IsHasFieldMarshalRefSizeSmall = hasFieldMarshalRefSize == 2;
   this.IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
   this.ParentOffset = 0;
   this.NativeTypeOffset = this.ParentOffset + hasFieldMarshalRefSize;
   this.RowSize = this.NativeTypeOffset + blobHeapRefSize;
   this.FieldMarshalTableMemoryReader = new MemoryReader(buffer, (int)(this.RowSize * numberOfRows));
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:14,代码来源:PEFileReader.cs


示例20: FieldTableReader

 internal FieldTableReader(
   uint numberOfRows,
   int stringHeapRefSize,
   int blobHeapRefSize,
   byte* buffer
 ) {
   this.NumberOfRows = numberOfRows;
   this.IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
   this.IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
   this.FlagsOffset = 0;
   this.NameOffset = this.FlagsOffset + sizeof(UInt16);
   this.SignatureOffset = this.NameOffset + stringHeapRefSize;
   this.RowSize = this.SignatureOffset + blobHeapRefSize;
   this.FieldTableMemoryReader = new MemoryReader(buffer, (int)(this.RowSize * numberOfRows));
 }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:15,代码来源:PEFileReader.cs



注:本文中的Microsoft.Cci.UtilityDataStructures.MemoryReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CodeAnalysis.AdhocWorkspace类代码示例发布时间:2022-05-26
下一篇:
C# Pdb.BitAccess类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap