本文整理汇总了C#中Microsoft.Cci.UtilityDataStructures.MemoryReader.ReadInt16方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryReader.ReadInt16方法的具体用法?C# MemoryReader.ReadInt16怎么用?C# MemoryReader.ReadInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci.UtilityDataStructures.MemoryReader
的用法示例。
在下文中一共展示了MemoryReader.ReadInt16方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: ReadCOFFFileHeader
bool ReadCOFFFileHeader(
ref MemoryReader memReader
)
//^ requires this.ReaderState >= ReaderState.Initialized;
{
if (memReader.RemainingBytes < PEFileConstants.SizeofCOFFFileHeader) {
this.ErrorContainer.AddBinaryError(memReader.Offset, MetadataReaderErrorKind.COFFHeaderTooSmall);
return false;
}
this.COFFFileHeader.Machine = (Machine)memReader.ReadUInt16();
this.COFFFileHeader.NumberOfSections = memReader.ReadInt16();
this.COFFFileHeader.TimeDateStamp = memReader.ReadInt32();
this.COFFFileHeader.PointerToSymbolTable = memReader.ReadInt32();
this.COFFFileHeader.NumberOfSymbols = memReader.ReadInt32();
this.COFFFileHeader.SizeOfOptionalHeader = memReader.ReadInt16();
this.COFFFileHeader.Characteristics = (Characteristics)memReader.ReadUInt16();
return true;
}
示例4: GetDefaultValue
internal IMetadataConstant GetDefaultValue(
MetadataObject metadataObject
) {
uint constRowId = this.PEFileReader.ConstantTable.GetConstantRowId(metadataObject.TokenValue);
if (constRowId == 0)
return Dummy.Constant;
ConstantRow constRow = this.PEFileReader.ConstantTable[constRowId];
MemoryBlock constValueMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(constRow.Value);
MemoryReader memoryReader = new MemoryReader(constValueMemoryBlock);
switch (constRow.Type) {
case ElementType.Boolean: {
byte val = memoryReader.ReadByte();
return new ConstantExpression(this.PlatformType.SystemBoolean, val != 0);
}
case ElementType.Char:
return new ConstantExpression(this.PlatformType.SystemChar, memoryReader.ReadChar());
case ElementType.Int8:
return new ConstantExpression(this.PlatformType.SystemInt8, memoryReader.ReadSByte());
case ElementType.Int16:
return new ConstantExpression(this.PlatformType.SystemInt16, memoryReader.ReadInt16());
case ElementType.Int32:
return new ConstantExpression(this.PlatformType.SystemInt32, memoryReader.ReadInt32());
case ElementType.Int64:
return new ConstantExpression(this.PlatformType.SystemInt64, memoryReader.ReadInt64());
case ElementType.UInt8:
return new ConstantExpression(this.PlatformType.SystemUInt8, memoryReader.ReadByte());
case ElementType.UInt16:
return new ConstantExpression(this.PlatformType.SystemUInt16, memoryReader.ReadUInt16());
case ElementType.UInt32:
return new ConstantExpression(this.PlatformType.SystemUInt32, memoryReader.ReadUInt32());
case ElementType.UInt64:
return new ConstantExpression(this.PlatformType.SystemUInt64, memoryReader.ReadUInt64());
case ElementType.Single:
return new ConstantExpression(this.PlatformType.SystemFloat32, memoryReader.ReadSingle());
case ElementType.Double:
return new ConstantExpression(this.PlatformType.SystemFloat64, memoryReader.ReadDouble());
case ElementType.String: {
int byteLen = memoryReader.Length;
string/*?*/ value;
if (byteLen == -1) {
value = null;
} else if (byteLen == 0) {
value = string.Empty;
} else {
value = memoryReader.ReadUTF16WithSize(byteLen);
}
return new ConstantExpression(this.PlatformType.SystemString, value);
}
case ElementType.Class:
return new ConstantExpression(this.PlatformType.SystemObject, null);
}
// MDError...
return Dummy.Constant;
}