本文整理汇总了C#中FileOffset类的典型用法代码示例。如果您正苦于以下问题:C# FileOffset类的具体用法?C# FileOffset怎么用?C# FileOffset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileOffset类属于命名空间,在下文中一共展示了FileOffset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetOffset
/// <inheritdoc/>
public void SetOffset(FileOffset offset, RVA rva) {
this.offset = offset;
this.rva = rva;
padding = rva.AlignUp(4) - rva + 2;
length = padding + 6;
}
示例2: ToImageSectionHeader
/// <summary>
/// Returns the first <see cref="ImageSectionHeader"/> that has data at file offset
/// <paramref name="offset"/>
/// </summary>
/// <param name="offset">The file offset</param>
/// <returns></returns>
public ImageSectionHeader ToImageSectionHeader(FileOffset offset) {
foreach (var section in imageSectionHeaders) {
if ((long)offset >= section.PointerToRawData && (long)offset < section.PointerToRawData + section.SizeOfRawData)
return section;
}
return null;
}
示例3: 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;
}
}
示例4: MemoryImageStream
/// <summary>
/// Constructor
/// </summary>
/// <param name="fileOffset">File offset of data</param>
/// <param name="data">The data</param>
/// <param name="dataOffset">Start offset in <paramref name="data"/></param>
/// <param name="dataLength">Length of data</param>
public MemoryImageStream(FileOffset fileOffset, byte[] data, int dataOffset, int dataLength) {
this.fileOffset = fileOffset;
this.data = data;
this.dataOffset = dataOffset;
this.dataEnd = dataOffset + dataLength;
this.position = dataOffset;
}
示例5: SetOffset
/// <inheritdoc/>
public void SetOffset(FileOffset offset, RVA rva) {
setOffsetCalled = true;
this.offset = offset;
this.rva = rva;
tinyMethodsDict = null;
fatMethodsDict = null;
var rva2 = rva;
foreach (var mb in tinyMethods) {
mb.SetOffset(offset, rva2);
uint len = mb.GetFileLength();
rva2 += len;
offset += len;
}
foreach (var mb in fatMethods) {
if (alignFatBodies) {
uint padding = (uint)rva2.AlignUp(FAT_BODY_ALIGNMENT) - (uint)rva2;
rva2 += padding;
offset += padding;
}
mb.SetOffset(offset, rva2);
uint len = mb.GetFileLength();
rva2 += len;
offset += len;
}
length = (uint)rva2 - (uint)rva;
}
示例6: UnmanagedMemoryImageStream
/// <summary>
/// Constructor
/// </summary>
/// <param name="owner">Owner of memory</param>
/// <param name="fileOffset">File offset of data</param>
/// <param name="baseAddr">Address of data</param>
/// <param name="length">Length of data</param>
public unsafe UnmanagedMemoryImageStream(UnmanagedMemoryStreamCreator owner, FileOffset fileOffset, long baseAddr, long length) {
this.fileOffset = fileOffset;
this.startAddr = baseAddr;
this.endAddr = baseAddr + length;
this.currentAddr = this.startAddr;
this.owner = owner;
}
示例7: Create
/// <inheritdoc/>
public unsafe IImageStream Create(FileOffset offset, long length) {
if ((long)offset < 0 || length < 0)
return MemoryImageStream.CreateEmpty();
long offs = Math.Min(Length, (long)offset);
long len = Math.Min(Length - offs, length);
return new UnmanagedMemoryImageStream(owner, (FileOffset)((long)fileOffset + (long)offset), startAddr + (long)offs, len);
}
示例8: SetOffset
/// <inheritdoc/>
public void SetOffset(FileOffset offset, RVA rva) {
this.offset = offset;
this.rva = rva;
length = HEADER_SIZE;
if (data != null) // Could be null if dontWriteAnything is true
length += (uint)data.Length;
}
示例9: Create
/// <inheritdoc/>
public IImageStream Create(FileOffset offset, long length) {
if (offset < 0 || length < 0)
return MemoryImageStream.CreateEmpty();
int offs = (int)Math.Min((long)dataLength, (long)offset);
int len = (int)Math.Min((long)dataLength - offs, length);
return new MemoryImageStream(offset, data, dataOffset + offs, len);
}
示例10: SetOffset
/// <inheritdoc/>
public void SetOffset(FileOffset offset, RVA rva) {
setOffsetCalled = true;
this.offset = offset;
this.rva = rva;
foreach (var resource in resources) {
resource.SetOffset(offset + 4, rva + 4);
uint len = 4 + resource.GetFileLength();
offset = (offset + len).AlignUp(alignment);
rva = (rva + len).AlignUp(alignment);
}
}
示例11: CilBodyOptions
public CilBodyOptions(CilBody body, RVA rva, FileOffset fileOffset)
{
this.KeepOldMaxStack = body.KeepOldMaxStack;
this.InitLocals = body.InitLocals;
this.MaxStack = body.MaxStack;
this.LocalVarSigTok = body.LocalVarSigTok;
this.RVA = rva;
this.FileOffset = fileOffset;
this.Instructions.AddRange(body.Instructions);
this.ExceptionHandlers.AddRange(body.ExceptionHandlers);
this.Locals.AddRange(body.Variables);
this.Scope = body.Scope;
}
示例12: GetFileOffsetAndRvaOf
/// <summary>
/// Returns the <see cref="FileOffset"/> and <see cref="RVA"/> of a
/// <see cref="ResourceDirectoryEntry"/>. <see cref="SetOffset"/> must have been called.
/// </summary>
/// <param name="dirEntry">A <see cref="ResourceDirectoryEntry"/></param>
/// <param name="fileOffset">Updated with the file offset</param>
/// <param name="rva">Updated with the RVA</param>
/// <returns><c>true</c> if <paramref name="dirEntry"/> is valid and
/// <paramref name="fileOffset"/> and <paramref name="rva"/> have been updated. <c>false</c>
/// if <paramref name="dirEntry"/> is not part of the Win32 resources.</returns>
public bool GetFileOffsetAndRvaOf(ResourceDirectoryEntry dirEntry, out FileOffset fileOffset, out RVA rva) {
var dir = dirEntry as ResourceDirectory;
if (dir != null)
return GetFileOffsetAndRvaOf(dir, out fileOffset, out rva);
var dataHeader = dirEntry as ResourceData;
if (dataHeader != null)
return GetFileOffsetAndRvaOf(dataHeader, out fileOffset, out rva);
fileOffset = 0;
rva = 0;
return false;
}
示例13: CilBodyOptions
public CilBodyOptions(CilBody body, RVA headerRva, FileOffset headerFileOffset, RVA rva, FileOffset fileOffset) {
KeepOldMaxStack = body.KeepOldMaxStack;
InitLocals = body.InitLocals;
HeaderSize = body.HeaderSize;
MaxStack = body.MaxStack;
LocalVarSigTok = body.LocalVarSigTok;
HeaderRVA = headerRva;
HeaderFileOffset = headerFileOffset;
RVA = rva;
FileOffset = fileOffset;
Instructions.AddRange(body.Instructions);
ExceptionHandlers.AddRange(body.ExceptionHandlers);
Locals.AddRange(body.Variables);
Scope = body.Scope;
}
示例14: SetOffset
/// <inheritdoc/>
public void SetOffset(FileOffset offset, RVA rva) {
this.offset = offset;
this.rva = rva;
length = 0x28;
importLookupTableRVA = rva + length;
length += 8;
stringsPadding = (int)(rva.AlignUp(STRINGS_ALIGNMENT) - rva);
length += (uint)stringsPadding;
corXxxMainRVA = rva + length;
length += 0xE;
mscoreeDllRVA = rva + length;
length += 0xC;
length++;
}
示例15: AddReadToIndexInformation
/// <summary>
/// Add a read being parsed to the index
/// </summary>
/// <param name="alignedSequence"></param>
/// <param name="offset"></param>
internal void AddReadToIndexInformation(SAM.SAMAlignedSequence alignedSequence, FileOffset offset)
{
if (offset < FirstOffSetSeen) { FirstOffSetSeen = offset; }
else if (offset > LastOffSetSeen) { LastOffSetSeen = offset; }
//update meta-data
if (alignedSequence.Pos < 1 || (alignedSequence.Flag&SAMFlags.UnmappedQuery)==SAMFlags.UnmappedQuery)
{
UnMappedReadsCount++;
return;
}
else
{
MappedReadsCount++;
}
//update linear index
LinearIndexMaker.UpdateLinearArrayIndex(alignedSequence, offset);
}