本文整理汇总了C#中System.Reflection.Metadata.BlobBuilder.WriteUTF8方法的典型用法代码示例。如果您正苦于以下问题:C# BlobBuilder.WriteUTF8方法的具体用法?C# BlobBuilder.WriteUTF8怎么用?C# BlobBuilder.WriteUTF8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Metadata.BlobBuilder
的用法示例。
在下文中一共展示了BlobBuilder.WriteUTF8方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteCodeViewData
private static int WriteCodeViewData(BlobBuilder builder, string pdbPath, Guid pdbGuid)
{
int start = builder.Count;
builder.WriteByte((byte)'R');
builder.WriteByte((byte)'S');
builder.WriteByte((byte)'D');
builder.WriteByte((byte)'S');
// PDB id:
builder.WriteGuid(pdbGuid);
// age
builder.WriteUInt32(1);
// UTF-8 encoded zero-terminated path to PDB
int pathStart = builder.Count;
builder.WriteUTF8(pdbPath, allowUnpairedSurrogates: true);
builder.WriteByte(0);
return builder.Count - start;
}
示例2: WriteDebugTable
private readonly static byte[] zeroStamp = new byte[4]; // four bytes of zero
/// <summary>
/// Write the entire "Debug Directory (Image Only)" along with data that it points to.
/// </summary>
internal void WriteDebugTable(BlobBuilder builder, PESectionLocation textSectionLocation, ContentId nativePdbContentId, ContentId portablePdbContentId)
{
Debug.Assert(builder.Count == 0);
int tableSize = ImageDebugDirectoryBaseSize;
Debug.Assert(tableSize != 0);
Debug.Assert(nativePdbContentId.IsDefault || portablePdbContentId.IsDefault);
Debug.Assert(!EmitPdb || (nativePdbContentId.IsDefault ^ portablePdbContentId.IsDefault));
int dataSize = ComputeSizeOfDebugDirectoryData();
if (EmitPdb)
{
const int IMAGE_DEBUG_TYPE_CODEVIEW = 2; // from PE spec
uint dataOffset = (uint)(ComputeOffsetToDebugTable() + tableSize);
WriteDebugTableEntry(builder,
stamp: nativePdbContentId.Stamp ?? portablePdbContentId.Stamp,
version: portablePdbContentId.IsDefault ? (uint)0 : ('P' << 24 | 'M' << 16 | 0x01 << 8 | 0x00),
debugType: IMAGE_DEBUG_TYPE_CODEVIEW,
sizeOfData: (uint)dataSize,
addressOfRawData: (uint)textSectionLocation.RelativeVirtualAddress + dataOffset, // RVA of the data
pointerToRawData: (uint)textSectionLocation.PointerToRawData + dataOffset); // position of the data in the PE stream
}
if (IsDeterministic)
{
const int IMAGE_DEBUG_TYPE_NO_TIMESTAMP = 16; // from PE spec
WriteDebugTableEntry(builder,
stamp: zeroStamp,
version: 0,
debugType: IMAGE_DEBUG_TYPE_NO_TIMESTAMP,
sizeOfData: 0,
addressOfRawData: 0,
pointerToRawData: 0);
}
// We should now have written all and precisely the data we said we'd write for the table entries.
Debug.Assert(builder.Count == tableSize);
// ====================
// The following is additional data beyond the debug directory at the offset `dataOffset`
// pointed to by the ImageDebugTypeCodeView entry.
if (EmitPdb)
{
builder.WriteByte((byte)'R');
builder.WriteByte((byte)'S');
builder.WriteByte((byte)'D');
builder.WriteByte((byte)'S');
// PDB id:
builder.WriteBytes(nativePdbContentId.Guid ?? portablePdbContentId.Guid);
// age
builder.WriteUInt32(1); // TODO: allow specify for native PDBs
// UTF-8 encoded zero-terminated path to PDB
int pathStart = builder.Count;
builder.WriteUTF8(PdbPathOpt, allowUnpairedSurrogates: true);
builder.WriteByte(0);
// padding:
builder.WriteBytes(0, Math.Max(0, MinPdbPath - (builder.Count - pathStart)));
}
// We should now have written all and precisely the data we said we'd write for the table and its data.
Debug.Assert(builder.Count == tableSize + dataSize);
}