本文整理汇总了C#中RVA类的典型用法代码示例。如果您正苦于以下问题:C# RVA类的具体用法?C# RVA怎么用?C# RVA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RVA类属于命名空间,在下文中一共展示了RVA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindSection
public ImageSectionHeader FindSection(RVA rva) {
foreach (var section in peImage.ImageSectionHeaders) {
if (section.VirtualAddress <= rva && rva < section.VirtualAddress + Math.Max(section.VirtualSize, section.SizeOfRawData))
return section;
}
return null;
}
示例2: SetOffset
/// <inheritdoc/>
public void SetOffset(FileOffset offset, RVA rva) {
this.offset = offset;
this.rva = rva;
padding = rva.AlignUp(4) - rva + 2;
length = padding + 6;
}
示例3: ToImageSectionHeader
/// <summary>
/// Returns the first <see cref="ImageSectionHeader"/> that has data at RVA
/// <paramref name="rva"/>
/// </summary>
/// <param name="rva">The RVA</param>
/// <returns></returns>
public ImageSectionHeader ToImageSectionHeader(RVA rva) {
foreach (var section in imageSectionHeaders) {
if (rva >= section.VirtualAddress && rva < section.VirtualAddress + Math.Max(section.VirtualSize, section.SizeOfRawData))
return section;
}
return null;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
}
示例7: FieldDefOptions
public FieldDefOptions(FieldDef field) {
this.Attributes = field.Attributes;
this.Name = field.Name;
this.FieldSig = field.FieldSig;
this.FieldOffset = field.FieldOffset;
this.MarshalType = field.MarshalType;
this.RVA = field.RVA;
this.InitialValue = field.InitialValue;
this.ImplMap = field.ImplMap;
this.Constant = field.Constant;
this.CustomAttributes.AddRange(field.CustomAttributes);
}
示例8: FieldDefOptions
public FieldDefOptions(FieldDef field) {
Attributes = field.Attributes;
Name = field.Name;
FieldSig = field.FieldSig;
FieldOffset = field.FieldOffset;
MarshalType = field.MarshalType;
RVA = field.RVA;
InitialValue = field.InitialValue;
ImplMap = field.ImplMap;
Constant = field.Constant;
CustomAttributes.AddRange(field.CustomAttributes);
}
示例9: 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;
}
示例10: 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;
}
示例11: MethodDefOptions
public MethodDefOptions(MethodDef method) {
ImplAttributes = method.ImplAttributes;
Attributes = method.Attributes;
SemanticsAttributes = method.SemanticsAttributes;
RVA = method.RVA;
Name = method.Name;
MethodSig = method.MethodSig;
ImplMap = method.ImplMap;
CustomAttributes.AddRange(method.CustomAttributes);
DeclSecurities.AddRange(method.DeclSecurities);
ParamDefs.AddRange(method.ParamDefs);
GenericParameters.AddRange(method.GenericParameters);
Overrides.AddRange(method.Overrides);
}
示例12: 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;
}
示例13: 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++;
}
示例14: Align
static void Align(ref FileOffset offset, ref RVA rva) {
offset = offset.AlignUp(HH_ALIGNMENT);
rva = rva.AlignUp(HH_ALIGNMENT);
}
示例15: ReadCilBody
/// <summary>
/// Reads a CIL method body
/// </summary>
/// <param name="parameters">Method parameters</param>
/// <param name="rva">RVA</param>
/// <param name="gpContext">Generic parameter context</param>
/// <returns>A new <see cref="CilBody"/> instance. It's empty if RVA is invalid (eg. 0 or
/// it doesn't point to a CIL method body)</returns>
public CilBody ReadCilBody(IList<Parameter> parameters, RVA rva, GenericParamContext gpContext)
{
if (rva == 0)
return new CilBody();
// Create a full stream so position will be the real position in the file. This
// is important when reading exception handlers since those must be 4-byte aligned.
// If we create a partial stream starting from rva, then position will be 0 and always
// 4-byte aligned. All fat method bodies should be 4-byte aligned, but the CLR doesn't
// seem to verify it. We must parse the method exactly the way the CLR parses it.
using (var reader = metaData.PEImage.CreateFullStream()) {
reader.Position = (long)metaData.PEImage.ToFileOffset(rva);
return MethodBodyReader.CreateCilBody(this, reader, parameters, gpContext);
}
}