当前位置: 首页>>代码示例>>C#>>正文


C# MemoryReader.ReadUTF8WithSize方法代码示例

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


在下文中一共展示了MemoryReader.ReadUTF8WithSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMarshallingInformation

 internal IMarshallingInformation GetMarshallingInformation(
   MetadataObject metadataObject
 ) {
   uint fieldMarshalRowId = this.PEFileReader.FieldMarshalTable.GetFieldMarshalRowId(metadataObject.TokenValue);
   if (fieldMarshalRowId == 0)
     return Dummy.MarshallingInformation;
   FieldMarshalRow fieldMarshalRow = this.PEFileReader.FieldMarshalTable[fieldMarshalRowId];
   MemoryBlock fieldMarshalMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(fieldMarshalRow.NativeType);
   MemoryReader memoryReader = new MemoryReader(fieldMarshalMemoryBlock);
   System.Runtime.InteropServices.UnmanagedType unmanagedType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
   if (memoryReader.NotEndOfBytes) {
     if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValArray) {
       uint numElements = (uint)memoryReader.ReadCompressedUInt32();
       System.Runtime.InteropServices.UnmanagedType elementType = System.Runtime.InteropServices.UnmanagedType.AsAny;
       if (memoryReader.NotEndOfBytes)
         elementType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
       return new ByValArrayMarshallingInformation(elementType, numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler) {
       string marshallerName;
       string marshallerArgument;
       memoryReader.ReadInt16(); //  Deliberate Skip...
       int byteLen = memoryReader.ReadCompressedUInt32();
       if (byteLen == -1 || byteLen == 0)
         marshallerName = string.Empty;
       else
         marshallerName = memoryReader.ReadUTF8WithSize(byteLen);
       ITypeReference/*?*/ marshaller = this.GetSerializedTypeNameAsTypeReference(marshallerName);
       if (marshaller == null) marshaller = Dummy.TypeReference;
       byteLen = memoryReader.ReadCompressedUInt32();
       if (byteLen == -1 || byteLen == 0)
         marshallerArgument = string.Empty;
       else
         marshallerArgument = memoryReader.ReadUTF8WithSize(byteLen);
       return new CustomMarshallingInformation(marshaller, marshallerArgument);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.LPArray) {
       System.Runtime.InteropServices.UnmanagedType elementType = (System.Runtime.InteropServices.UnmanagedType)memoryReader.ReadByte();
       int paramIndex = -1;
       uint flag = 0;
       uint numElements = 0;
       if (memoryReader.NotEndOfBytes)
         paramIndex = (int)memoryReader.ReadCompressedUInt32();
       if (memoryReader.NotEndOfBytes)
         numElements = (uint)memoryReader.ReadCompressedUInt32();
       if (memoryReader.NotEndOfBytes) {
         flag = (uint)memoryReader.ReadCompressedUInt32();
         if (flag == 0) {
           //TODO: check that paramIndex is 0
           paramIndex = -1; //paramIndex is just a place holder so that numElements can be present
         }
       }
       return new LPArrayMarshallingInformation(elementType, paramIndex, numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray) {
       System.Runtime.InteropServices.VarEnum elementType = (System.Runtime.InteropServices.VarEnum)memoryReader.ReadByte();
       string subType = string.Empty;
       if (memoryReader.NotEndOfBytes) {
         int byteLen = memoryReader.ReadCompressedUInt32();
         if (byteLen > 0)
           subType = memoryReader.ReadUTF8WithSize(byteLen);
       }
       ITypeReference/*?*/ subTypeRef = this.GetSerializedTypeNameAsTypeReference(subType);
       if (subTypeRef == null) subTypeRef = Dummy.TypeReference;
       return new SafeArrayMarshallingInformation(elementType, subTypeRef);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValTStr) {
       uint numElements = (uint)memoryReader.ReadCompressedUInt32();
       return new ByValTStrMarshallingInformation(numElements);
     } else if (unmanagedType == System.Runtime.InteropServices.UnmanagedType.Interface) {
       uint iidParameterIndex = (uint)memoryReader.ReadCompressedUInt32();
       return new IidParameterIndexMarshallingInformation(iidParameterIndex);
     } else {
       //TODO: error blob should not have extra info unless one of the above types.
     }
   }
   return new SimpleMarshallingInformation(unmanagedType);
 }
开发者ID:Biegal,项目名称:Afterthought,代码行数:74,代码来源:PEFileToObjectModel.cs


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