本文整理汇总了C#中IImageStream类的典型用法代码示例。如果您正苦于以下问题:C# IImageStream类的具体用法?C# IImageStream怎么用?C# IImageStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IImageStream类属于命名空间,在下文中一共展示了IImageStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImageStreamIStream
/// <summary>
/// Constructor
/// </summary>
/// <param name="stream">Source stream</param>
/// <param name="name">Name of original file or <c>null</c> if unknown.</param>
public ImageStreamIStream(IImageStream stream, string name)
{
if (stream == null)
throw new ArgumentNullException("stream");
this.stream = stream;
this.name = name ?? string.Empty;
}
示例2: 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;
}
}
示例3: AddToFavorites
public void AddToFavorites(IImageStream stream)
{
// TODO:
// make an autopersistable stream feature
var dirStream = stream as DirectoryImageStream;
if (dirStream != null)
{
var db = DAL.DatabaseService.GetInstance();
using (var transaction = db.BeginTransaction())
{
var folderRef = new DAL.FolderRefEntity();
folderRef.Path = dirStream.Path;
DAL.DatabaseService.FolderRefRepository.Write(folderRef);
var fav_item = new DAL.FavoritesStreamReference();
fav_item.id = folderRef.Key;
fav_item.TableName = "folder_refs";
DAL.DatabaseService.FavoritesRepository.Write(fav_item);
db.CommitTransaction();
}
}
}
示例4: Create
/// <summary>
/// Creates a <see cref="HotStream"/> instance
/// </summary>
/// <param name="version">Hot heap version</param>
/// <param name="imageStream">Heap stream</param>
/// <param name="streamHeader">Stream header info</param>
/// <param name="fullStream">Stream for the full PE file</param>
/// <param name="baseOffset">Offset in <paramref name="fullStream"/> where the data starts</param>
/// <returns>A <see cref="HotStream"/> instance or <c>null</c> if <paramref name="version"/>
/// is invalid</returns>
public static HotStream Create(HotHeapVersion version, IImageStream imageStream, StreamHeader streamHeader, IImageStream fullStream, FileOffset baseOffset) {
switch (version) {
case HotHeapVersion.CLR20: return new HotStreamCLR20(imageStream, streamHeader, fullStream, baseOffset);
case HotHeapVersion.CLR40: return new HotStreamCLR40(imageStream, streamHeader, fullStream, baseOffset);
default: return null;
}
}
示例5: ReadLines
void ReadLines(PdbReader reader, IImageStream stream) {
var docs = new Dictionary<long, DbiDocument>();
stream.Position = 0;
while (stream.Position < stream.Length) {
var sig = (ModuleStreamType)stream.ReadUInt32();
var size = stream.ReadUInt32();
var begin = stream.Position;
var end = (begin + size + 3) & ~3;
if (sig == ModuleStreamType.FileInfo)
ReadFiles(reader, docs, stream, end);
stream.Position = end;
}
var sortedFuncs = new DbiFunction[Functions.Count];
Functions.CopyTo(sortedFuncs, 0);
Array.Sort(sortedFuncs, (a, b) => a.Address.CompareTo(b.Address));
stream.Position = 0;
while (stream.Position < stream.Length) {
var sig = (ModuleStreamType)stream.ReadUInt32();
var size = stream.ReadUInt32();
var begin = stream.Position;
var end = begin + size;
if (sig == ModuleStreamType.Lines)
ReadLines(sortedFuncs, docs, stream, end);
stream.Position = end;
}
}
示例6: Add
/// <summary>
/// Adds a resource
/// </summary>
/// <param name="stream">The resource data</param>
/// <returns>The resource data</returns>
public ByteArrayChunk Add(IImageStream stream) {
if (setOffsetCalled)
throw new InvalidOperationException("SetOffset() has already been called");
var rawData = stream.ReadAllBytes();
length = Utils.AlignUp(length + 4 + (uint)rawData.Length, alignment);
var data = new ByteArrayChunk(rawData);
resources.Add(data);
return data;
}
示例7: CreateImageOptionalHeader
/// <summary>
/// Creates an IImageOptionalHeader
/// </summary>
/// <param name="reader">PE file reader pointing to the start of the optional header</param>
/// <param name="verify">Verify section</param>
/// <returns>The created IImageOptionalHeader</returns>
/// <exception cref="BadImageFormatException">Thrown if verification fails</exception>
IImageOptionalHeader CreateImageOptionalHeader(IImageStream reader, bool verify) {
ushort magic = reader.ReadUInt16();
reader.Position -= 2;
switch (magic) {
case 0x010B: return new ImageOptionalHeader32(reader, imageFileHeader.SizeOfOptionalHeader, verify);
case 0x020B: return new ImageOptionalHeader64(reader, imageFileHeader.SizeOfOptionalHeader, verify);
default: throw new BadImageFormatException("Invalid optional header magic");
}
}
示例8: ImageNTHeaders
/// <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 ImageNTHeaders(IImageStream reader, bool verify) {
SetStartOffset(reader);
this.signature = reader.ReadUInt32();
if (verify && this.signature != 0x4550)
throw new BadImageFormatException("Invalid NT headers signature");
this.imageFileHeader = new ImageFileHeader(reader, verify);
this.imageOptionalHeader = CreateImageOptionalHeader(reader, verify);
SetEndoffset(reader);
}
示例9: StreamHeader
/// <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 StreamHeader(IImageStream reader, bool verify) {
SetStartOffset(reader);
this.offset = reader.ReadUInt32();
this.streamSize = reader.ReadUInt32();
this.name = ReadString(reader, 32, verify);
SetEndoffset(reader);
if (verify && offset + size < offset)
throw new BadImageFormatException("Invalid stream header");
}
示例10: ImageDosHeader
/// <summary>
/// Constructor
/// </summary>
/// <param name="reader">PE file reader</param>
/// <param name="verify">Verify section</param>
/// <exception cref="BadImageFormatException">Thrown if verification fails</exception>
public ImageDosHeader(IImageStream reader, bool verify) {
SetStartOffset(reader);
ushort sig = reader.ReadUInt16();
if (verify && sig != 0x5A4D)
throw new BadImageFormatException("Invalid DOS signature");
reader.Position = (long)startOffset + 0x3C;
this.ntHeadersOffset = reader.ReadUInt32();
SetEndoffset(reader);
}
示例11: MsfStream
public MsfStream(IImageStream[] pages, uint length) {
byte[] buf = new byte[length];
int offset = 0;
foreach (var page in pages) {
page.Position = 0;
int len = Math.Min((int)page.Length, (int)(length - offset));
offset += page.Read(buf, offset, len);
}
Content = new MemoryImageStream(0, buf, 0, buf.Length);
}
示例12: LoadFunctions
public void LoadFunctions(PdbReader reader, IImageStream stream) {
stream.Position = 0;
using (var substream = stream.Create(stream.FileOffset + stream.Position, cbSyms))
ReadFunctions(substream);
if (Functions.Count > 0) {
stream.Position += cbSyms + cbOldLines;
using (var substream = stream.Create(stream.FileOffset + stream.Position, cbLines))
ReadLines(reader, substream);
}
}
示例13: GetReader_NoLock
int GetReader_NoLock(uint offset, out IImageStream reader) {
reader = null;
if (!IsValidOffset(offset))
return -1;
reader = GetReader_NoLock(offset);
uint length;
if (!reader.ReadCompressedUInt32(out length))
return -1;
if (reader.Position + length < length || reader.Position + length > reader.Length)
return -1;
return (int)length; // length <= 0x1FFFFFFF so this cast does not make it negative
}
示例14: ImageFileHeader
/// <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 ImageFileHeader(IImageStream reader, bool verify) {
SetStartOffset(reader);
this.machine = (Machine)reader.ReadUInt16();
this.numberOfSections = reader.ReadUInt16();
this.timeDateStamp = reader.ReadUInt32();
this.pointerToSymbolTable = reader.ReadUInt32();
this.numberOfSymbols = reader.ReadUInt32();
this.sizeOfOptionalHeader = reader.ReadUInt16();
this.characteristics = (Characteristics)reader.ReadUInt16();
SetEndoffset(reader);
if (verify && this.sizeOfOptionalHeader == 0)
throw new BadImageFormatException("Invalid SizeOfOptionalHeader");
}
示例15: Read
public void Read(IImageStream stream) {
stream.Position = 0;
Language = new Guid(stream.ReadBytes(0x10));
LanguageVendor = new Guid(stream.ReadBytes(0x10));
DocumentType = new Guid(stream.ReadBytes(0x10));
CheckSumAlgorithmId = new Guid(stream.ReadBytes(0x10));
var len = stream.ReadInt32();
if (stream.ReadUInt32() != 0)
throw new PdbException("Unexpected value");
CheckSum = stream.ReadBytes(len);
}