本文整理汇总了C#中BlobBuilder.PadTo方法的典型用法代码示例。如果您正苦于以下问题:C# BlobBuilder.PadTo方法的具体用法?C# BlobBuilder.PadTo怎么用?C# BlobBuilder.PadTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlobBuilder
的用法示例。
在下文中一共展示了BlobBuilder.PadTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteRelocSection
private void WriteRelocSection(Stream peStream, SectionHeader relocSection, int entryPointAddress)
{
peStream.Position = relocSection.PointerToRawData;
var writer = new BlobBuilder(relocSection.SizeOfRawData);
writer.WriteUInt32((((uint)entryPointAddress + 2) / 0x1000) * 0x1000);
writer.WriteUInt32(_properties.Requires64bits && !_properties.RequiresAmdInstructionSet ? 14u : 12u);
uint offsetWithinPage = ((uint)entryPointAddress + 2) % 0x1000;
uint relocType = _properties.Requires64bits ? 10u : 3u;
ushort s = (ushort)((relocType << 12) | offsetWithinPage);
writer.WriteUInt16(s);
if (_properties.Requires64bits && !_properties.RequiresAmdInstructionSet)
{
writer.WriteUInt32(relocType << 12);
}
writer.WriteUInt16(0); // next chunk's RVA
writer.PadTo(relocSection.SizeOfRawData);
writer.WriteContentTo(peStream);
}
示例2: WriteAlignPad
public void WriteAlignPad()
{
var writer = new BlobBuilder(4);
writer.WriteByte(0x01);
writer.PadTo(2);
writer.WriteByte(0x02);
writer.Align(4);
writer.Align(4);
writer.WriteByte(0x03);
writer.Align(4);
writer.WriteByte(0x04);
writer.WriteByte(0x05);
writer.Align(8);
writer.WriteByte(0x06);
writer.Align(2);
writer.Align(1);
AssertEx.Equal(new byte[]
{
0x01, 0x00, 0x02, 0x00,
0x03, 0x00, 0x00, 0x00,
0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00
}, writer.ToArray());
}