本文整理汇总了C#中IImageStream.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# IImageStream.ReadByte方法的具体用法?C# IImageStream.ReadByte怎么用?C# IImageStream.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImageStream
的用法示例。
在下文中一共展示了IImageStream.ReadByte方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Populate
void Populate(IImageStream reader) {
var chars = new char[0x200];
reader.Position = 1;
while (reader.Position < reader.Length) {
uint offset = (uint)reader.Position;
uint len;
if (!reader.ReadCompressedUInt32(out len)) {
if (offset == reader.Position)
reader.Position++;
continue;
}
if (len == 0 || reader.Position + len > reader.Length)
continue;
int stringLen = (int)len / 2;
if (stringLen > chars.Length)
Array.Resize(ref chars, stringLen);
for (int i = 0; i < stringLen; i++)
chars[i] = (char)reader.ReadUInt16();
if ((len & 1) != 0)
reader.ReadByte();
var s = new string(chars, 0, stringLen);
if (!cachedDict.ContainsKey(s))
cachedDict[s] = offset;
}
}
示例2: ReadString
static string ReadString(IImageStream reader, int maxLen, bool verify) {
var origPos = reader.Position;
var sb = new StringBuilder(maxLen);
int i;
for (i = 0; i < maxLen; i++) {
byte b = reader.ReadByte();
if (b == 0)
break;
sb.Append((char)b);
}
if (verify && i == maxLen)
throw new BadImageFormatException("Invalid stream name string");
if (i != maxLen)
reader.Position = origPos + ((i + 1 + 3) & ~3);
return sb.ToString();
}
示例3: Populate
void Populate(IImageStream reader) {
reader.Position = 1;
while (reader.Position < reader.Length) {
uint offset = (uint)reader.Position;
var bytes = reader.ReadBytesUntilByte(0);
if (bytes == null)
break;
reader.ReadByte(); // terminating zero
if (bytes.Length == 0)
continue;
var s = new UTF8String(bytes);
if (!cachedDict.ContainsKey(s))
cachedDict[s] = offset;
}
}
示例4: ReadString
static string ReadString(IImageStream reader, uint maxLength) {
long endPos = reader.Position + maxLength;
if (endPos < reader.Position || endPos > reader.Length)
throw new BadImageFormatException("Invalid MD version string");
byte[] utf8Bytes = new byte[maxLength];
uint i;
for (i = 0; i < maxLength; i++) {
byte b = reader.ReadByte();
if (b == 0)
break;
utf8Bytes[i] = b;
}
reader.Position = endPos;
return Encoding.UTF8.GetString(utf8Bytes, 0, (int)i);
}
示例5: MetaDataHeader
/// <summary>
/// Constructor
/// </summary>
/// <param name="reader">PE file reader pointing to the start of this section</param>
/// <param name="verify">Verify section</param>
/// <exception cref="BadImageFormatException">Thrown if verification fails</exception>
public MetaDataHeader(IImageStream reader, bool verify) {
SetStartOffset(reader);
this.signature = reader.ReadUInt32();
if (verify && this.signature != 0x424A5342)
throw new BadImageFormatException("Invalid MetaData header signature");
this.majorVersion = reader.ReadUInt16();
this.minorVersion = reader.ReadUInt16();
if (verify && !((majorVersion == 1 && minorVersion == 1) || (majorVersion == 0 && minorVersion >= 19)))
throw new BadImageFormatException(string.Format("Unknown MetaData header version: {0}.{1}", majorVersion, minorVersion));
this.reserved1 = reader.ReadUInt32();
this.stringLength = reader.ReadUInt32();
this.versionString = ReadString(reader, stringLength);
this.offset2ndPart = (uint)(reader.Position - startOffset);
this.flags = (StorageFlags)reader.ReadByte();
if (verify && this.flags != 0)
throw new BadImageFormatException(string.Format("Storage flags != 0 ({0})", this.flags));
this.reserved2 = reader.ReadByte();
this.streams = reader.ReadUInt16();
this.streamHeaders = new StreamHeader[streams];
for (int i = 0; i < streamHeaders.Count; i++)
streamHeaders[i] = new StreamHeader(reader, verify);
SetEndoffset(reader);
}
示例6: ImageOptionalHeader32
/// <summary>
/// Constructor
/// </summary>
/// <param name="reader">PE file reader pointing to the start of this section</param>
/// <param name="totalSize">Total size of this optional header (from the file header)</param>
/// <param name="verify">Verify section</param>
/// <exception cref="BadImageFormatException">Thrown if verification fails</exception>
public ImageOptionalHeader32(IImageStream reader, uint totalSize, bool verify) {
if (totalSize < 0x60)
throw new BadImageFormatException("Invalid optional header size");
if (verify && reader.Position + totalSize > reader.Length)
throw new BadImageFormatException("Invalid optional header size");
SetStartOffset(reader);
this.magic = reader.ReadUInt16();
this.majorLinkerVersion = reader.ReadByte();
this.minorLinkerVersion = reader.ReadByte();
this.sizeOfCode = reader.ReadUInt32();
this.sizeOfInitializedData = reader.ReadUInt32();
this.sizeOfUninitializedData = reader.ReadUInt32();
this.addressOfEntryPoint = (RVA)reader.ReadUInt32();
this.baseOfCode = (RVA)reader.ReadUInt32();
this.baseOfData = (RVA)reader.ReadUInt32();
this.imageBase = reader.ReadUInt32();
this.sectionAlignment = reader.ReadUInt32();
this.fileAlignment = reader.ReadUInt32();
this.majorOperatingSystemVersion = reader.ReadUInt16();
this.minorOperatingSystemVersion = reader.ReadUInt16();
this.majorImageVersion = reader.ReadUInt16();
this.minorImageVersion = reader.ReadUInt16();
this.majorSubsystemVersion = reader.ReadUInt16();
this.minorSubsystemVersion = reader.ReadUInt16();
this.win32VersionValue = reader.ReadUInt32();
this.sizeOfImage = reader.ReadUInt32();
this.sizeOfHeaders = reader.ReadUInt32();
this.checkSum = reader.ReadUInt32();
this.subsystem = (Subsystem)reader.ReadUInt16();
this.dllCharacteristics = (DllCharacteristics)reader.ReadUInt16();
this.sizeOfStackReserve = reader.ReadUInt32();
this.sizeOfStackCommit = reader.ReadUInt32();
this.sizeOfHeapReserve = reader.ReadUInt32();
this.sizeOfHeapCommit = reader.ReadUInt32();
this.loaderFlags = reader.ReadUInt32();
this.numberOfRvaAndSizes = reader.ReadUInt32();
for (int i = 0; i < dataDirectories.Length; i++) {
uint len = (uint)(reader.Position - startOffset);
if (len + 8 <= totalSize)
dataDirectories[i] = new ImageDataDirectory(reader, verify);
else
dataDirectories[i] = new ImageDataDirectory();
}
reader.Position = (long)startOffset + totalSize;
SetEndoffset(reader);
}
示例7: ReadFiles
void ReadFiles(PdbReader reader, Dictionary<long, DbiDocument> documents, IImageStream stream, long end)
{
var begin = stream.Position;
while (stream.Position < end) {
var id = stream.Position - begin;
var nameId = stream.ReadUInt32();
var len = stream.ReadByte();
/*var type = */stream.ReadByte();
var doc = reader.GetDocument(nameId);
documents.Add(id, doc);
stream.Position += len;
stream.Position = (stream.Position + 3) & (~3);
}
}