本文整理汇总了C#中Mono.Cecil.PE.Section类的典型用法代码示例。如果您正苦于以下问题:C# Section类的具体用法?C# Section怎么用?C# Section使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Section类属于Mono.Cecil.PE命名空间,在下文中一共展示了Section类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CodeReader
public CodeReader(Section section, MetadataReader reader, Dictionary<uint, DumpedMethod> dumpedMethods = null)
: base(section.Data)
{
this.code_section = section;
this.reader = reader;
this.dumpedMethods = dumpedMethods;
}
开发者ID:bladecoding,项目名称:cecil,代码行数:7,代码来源:CodeReader.cs
示例2: MoveTo
public void MoveTo (int rva)
{
if (!IsInSection (rva)) {
code_section = reader.image.GetSectionAtVirtualAddress ((uint) rva);
Reset (code_section.Data);
}
base.position = rva - (int) code_section.VirtualAddress;
}
开发者ID:0xb1dd1e,项目名称:cecil,代码行数:9,代码来源:CodeReader.cs
示例3: BuildSections
void BuildSections()
{
if (win32_resources != null || win32_resources_directory != null)
sections++;
text = CreateSection (".text", text_map.GetLength (), null);
var previous = text;
if (win32_resources != null) {
rsrc = CreateSection (".rsrc", (uint) win32_resources.length, previous);
PatchWin32Resources (win32_resources);
previous = rsrc;
} else if (win32_resources_directory != null) {
rsrc = CreateSection(".rsrc", previous);
WriteWin32ResourcesDirectory(win32_resources_directory);
SetSectionSize(rsrc, (uint) win32_resources.length);
previous = rsrc;
}
if (has_reloc)
reloc = CreateSection (".reloc", 12u, previous);
}
开发者ID:gluck,项目名称:cecil,代码行数:24,代码来源:ImageWriter.cs
示例4: MoveTo
public void MoveTo(int rva)
{
if (!IsInSection (rva)) {
var new_section = reader.image.GetSectionAtVirtualAddress ((uint) rva);
if (new_section == null)
throw new ArgumentException ();
code_section = new_section;
Reset (code_section.Data);
}
base.position = rva - (int) code_section.VirtualAddress;
}
开发者ID:bladecoding,项目名称:cecil,代码行数:12,代码来源:CodeReader.cs
示例5: MetadataStream
public MetadataStream(Section section, uint start, uint size, string name)
: base(section, start, size)
{
this.Name = name;
}
开发者ID:hjlfmy,项目名称:cecil,代码行数:5,代码来源:MetadataStream.cs
示例6: ReadSections
void ReadSections(ushort count)
{
var sections = new Section [count];
for (int i = 0; i < count; i++) {
var section = new Section ();
// Name
section.Name = ReadZeroTerminatedString (8);
// VirtualSize 4
Advance (4);
// VirtualAddress 4
section.VirtualAddress = ReadUInt32 ();
// SizeOfRawData 4
section.SizeOfRawData = ReadUInt32 ();
// PointerToRawData 4
section.PointerToRawData = ReadUInt32 ();
// PointerToRelocations 4
// PointerToLineNumbers 4
// NumberOfRelocations 2
// NumberOfLineNumbers 2
// Characteristics 4
Advance (16);
sections [i] = section;
ReadSectionData (section);
}
image.Sections = sections;
}
开发者ID:rfcclub,项目名称:cecil,代码行数:34,代码来源:ImageReader.cs
示例7: ReadMetadataStream
void ReadMetadataStream(Section section)
{
// Offset 4
uint start = metadata.VirtualAddress - section.VirtualAddress + ReadUInt32 (); // relative to the section start
// Size 4
uint size = ReadUInt32 ();
var name = ReadAlignedString (16);
switch (name) {
case "#~":
case "#-":
image.TableHeap = new TableHeap (section, start, size);
break;
case "#Strings":
image.StringHeap = new StringHeap (section, start, size);
break;
case "#Blob":
image.BlobHeap = new BlobHeap (section, start, size);
break;
case "#GUID":
image.GuidHeap = new GuidHeap (section, start, size);
break;
case "#US":
image.UserStringHeap = new UserStringHeap (section, start, size);
break;
}
}
开发者ID:rfcclub,项目名称:cecil,代码行数:28,代码来源:ImageReader.cs
示例8: BlobHeap
public BlobHeap(Section section, uint start, uint size)
: base(section, start, size)
{
}
开发者ID:sillsdev,项目名称:mono-basic,代码行数:4,代码来源:BlobHeap.cs
示例9: WriteSection
void WriteSection(Section section, uint characteristics)
{
var name = new byte [8];
var sect_name = section.Name;
for (int i = 0; i < sect_name.Length; i++)
name [i] = (byte) sect_name [i];
WriteBytes (name);
WriteUInt32 (section.VirtualSize);
WriteUInt32 (section.VirtualAddress);
WriteUInt32 (section.SizeOfRawData);
WriteUInt32 (section.PointerToRawData);
WriteUInt32 (0); // PointerToRelocations
WriteUInt32 (0); // PointerToLineNumbers
WriteUInt16 (0); // NumberOfRelocations
WriteUInt16 (0); // NumberOfLineNumbers
WriteUInt32 (characteristics);
}
开发者ID:buraksarica,项目名称:cecil,代码行数:18,代码来源:ImageWriter.cs
示例10: MoveToRVA
void MoveToRVA(Section section, RVA rva)
{
BaseStream.Seek (section.PointerToRawData + rva - section.VirtualAddress, SeekOrigin.Begin);
}
开发者ID:buraksarica,项目名称:cecil,代码行数:4,代码来源:ImageWriter.cs
示例11: BuildSections
void BuildSections()
{
var has_win32_resources = win32_resources != null;
if (has_win32_resources)
sections++;
text = CreateSection (".text", text_map.GetLength (), null);
var previous = text;
if (has_win32_resources) {
rsrc = CreateSection (".rsrc", (uint) win32_resources.length, previous);
PatchWin32Resources (win32_resources);
previous = rsrc;
}
if (has_reloc)
reloc = CreateSection (".reloc", 12u, previous);
}
开发者ID:buraksarica,项目名称:cecil,代码行数:19,代码来源:ImageWriter.cs
示例12: ResizeSection
internal void ResizeSection(Section section, uint newSize, bool update)
{
section.VirtualSize = newSize;
section.SizeOfRawData = Align (newSize, file_alignment);
byte[] newDat = new byte[section.SizeOfRawData];
if (newDat.Length > section.Data.Length)
Buffer.BlockCopy(section.Data, 0, newDat, 0, section.Data.Length);
else
Buffer.BlockCopy(section.Data, 0, newDat, 0, newDat.Length);
section.Data = newDat;
int sectIndex = sections.IndexOf(section);
if (sectIndex != -1 && update)
for (int i = sectIndex + 1; i < sections.Count; i++)
{
sections[i].VirtualAddress = sections[i - 1].VirtualAddress + Align (sections[i - 1].VirtualSize, section_alignment);
sections[i].PointerToRawData = sections[i - 1].PointerToRawData + sections[i - 1].SizeOfRawData;
}
}
开发者ID:n017,项目名称:Confuser,代码行数:19,代码来源:ImageWriter.cs
示例13: CreateSection
internal Section CreateSection(string name, uint size, uint characteristics, Section previous)
{
return new Section {
Name = name,
VirtualAddress = previous != null
? previous.VirtualAddress + Align (previous.VirtualSize, section_alignment)
: text_rva,
VirtualSize = size,
PointerToRawData = previous != null
? previous.PointerToRawData + previous.SizeOfRawData
: 0,
SizeOfRawData = Align (size, file_alignment),
Data = new byte[Align(size, file_alignment)],
Characteristics = characteristics
};
}
开发者ID:n017,项目名称:Confuser,代码行数:16,代码来源:ImageWriter.cs
示例14: PatchResourceDirectoryTable
static void PatchResourceDirectoryTable(ByteBuffer resources, Section old, Section @new)
{
resources.Advance(12);
int num = resources.ReadUInt16() + resources.ReadUInt16();
for (int i = 0; i < num; i++)
{
PatchResourceDirectoryEntry(resources, old, @new);
}
}
开发者ID:n017,项目名称:Confuser,代码行数:9,代码来源:Packer.cs
示例15: PatchResourceDirectoryEntry
static void PatchResourceDirectoryEntry(ByteBuffer resources, Section old, Section @new)
{
resources.Advance(4);
uint num = resources.ReadUInt32();
int position = resources.Position;
resources.Position = ((int)num) & 0x7fffffff;
if ((num & 0x80000000) != 0)
{
PatchResourceDirectoryTable(resources, old, @new);
}
else
{
PatchResourceDataEntry(resources, old, @new);
}
resources.Position = position;
}
开发者ID:n017,项目名称:Confuser,代码行数:16,代码来源:Packer.cs
示例16: PatchResourceDataEntry
static void PatchResourceDataEntry(ByteBuffer resources, Section old, Section @new)
{
uint num = resources.ReadUInt32();
resources.Position -= 4;
resources.WriteUInt32(num - old.VirtualAddress + @new.VirtualAddress);
}
开发者ID:n017,项目名称:Confuser,代码行数:6,代码来源:Packer.cs
示例17: ProtectStub
protected string[] ProtectStub(AssemblyDefinition asm)
{
string tmp = Path.GetTempPath() + "\\" + Path.GetRandomFileName() + "\\";
Directory.CreateDirectory(tmp);
ModuleDefinition modDef = this.cr.settings.Single(_ => _.IsMain).Assembly.MainModule;
asm.MainModule.TimeStamp = modDef.TimeStamp;
byte[] mvid = new byte[0x10];
Random.NextBytes(mvid);
asm.MainModule.Mvid = new Guid(mvid);
MetadataProcessor psr = new MetadataProcessor();
Section oldRsrc = null;
foreach (Section s in modDef.GetSections())
if (s.Name == ".rsrc") { oldRsrc = s; break; }
if (oldRsrc != null)
{
psr.ProcessImage += accessor =>
{
Section sect = null;
foreach (Section s in accessor.Sections)
if (s.Name == ".rsrc") { sect = s; break; }
if (sect == null)
{
sect = new Section()
{
Name = ".rsrc",
Characteristics = 0x40000040
};
foreach (Section s in accessor.Sections)
if (s.Name == ".text") { accessor.Sections.Insert(accessor.Sections.IndexOf(s) + 1, sect); break; }
}
sect.VirtualSize = oldRsrc.VirtualSize;
sect.SizeOfRawData = oldRsrc.SizeOfRawData;
int idx = accessor.Sections.IndexOf(sect);
sect.VirtualAddress = accessor.Sections[idx - 1].VirtualAddress + ((accessor.Sections[idx - 1].VirtualSize + 0x2000U - 1) & ~(0x2000U - 1));
sect.PointerToRawData = accessor.Sections[idx - 1].PointerToRawData + accessor.Sections[idx - 1].SizeOfRawData;
for (int i = idx + 1; i < accessor.Sections.Count; i++)
{
accessor.Sections[i].VirtualAddress = accessor.Sections[i - 1].VirtualAddress + ((accessor.Sections[i - 1].VirtualSize + 0x2000U - 1) & ~(0x2000U - 1));
accessor.Sections[i].PointerToRawData = accessor.Sections[i - 1].PointerToRawData + accessor.Sections[i - 1].SizeOfRawData;
}
ByteBuffer buff = new ByteBuffer(oldRsrc.Data);
PatchResourceDirectoryTable(buff, oldRsrc, sect);
sect.Data = buff.GetBuffer();
};
}
psr.Process(asm.MainModule, tmp + Path.GetFileName(modDef.FullyQualifiedName), new WriterParameters()
{
StrongNameKeyPair = this.cr.sn,
WriteSymbols = this.cr.param.Project.Debug
});
Confuser cr = new Confuser();
ConfuserProject proj = new ConfuserProject();
proj.Seed = Random.Next().ToString();
proj.Debug = this.cr.param.Project.Debug;
foreach (var i in this.cr.param.Project.Rules)
proj.Rules.Add(i);
proj.Add(new ProjectAssembly()
{
Path = tmp + Path.GetFileName(modDef.FullyQualifiedName)
});
proj.OutputPath = tmp;
foreach (var i in this.cr.param.Project.Plugins) proj.Plugins.Add(i);
proj.SNKeyPath = this.cr.param.Project.SNKeyPath;
ConfuserParameter par = new ConfuserParameter();
par.Project = proj;
par.ProcessMetadata = PostProcessMetadata;
par.ProcessImage = PostProcessImage;
cr.Confuse(par);
return Directory.GetFiles(tmp);
}
开发者ID:n017,项目名称:Confuser,代码行数:74,代码来源:Packer.cs
示例18: CreateSection
Section CreateSection(string name, uint size, Section previous)
{
return new Section {
Name = name,
VirtualAddress = previous != null
? previous.VirtualAddress + Align (previous.VirtualSize, section_alignment)
: text_rva,
VirtualSize = size,
PointerToRawData = previous != null
? previous.PointerToRawData + previous.SizeOfRawData
: Align (GetHeaderSize (), file_alignment),
SizeOfRawData = Align (size, file_alignment)
};
}
开发者ID:buraksarica,项目名称:cecil,代码行数:14,代码来源:ImageWriter.cs
示例19: CreateSection
Section CreateSection(string name, uint size, Section previous)
{
var ret = CreateSection(name, previous);
SetSectionSize(ret, size);
return ret;
}
开发者ID:gluck,项目名称:cecil,代码行数:6,代码来源:ImageWriter.cs
示例20: PrepareSection
void PrepareSection(Section section)
{
MoveTo (section.PointerToRawData);
const int buffer_size = 4096;
if (section.SizeOfRawData <= buffer_size) {
Write (new byte [section.SizeOfRawData]);
MoveTo (section.PointerToRawData);
return;
}
var written = 0;
var buffer = new byte [buffer_size];
while (written != section.SizeOfRawData) {
var write_size = System.Math.Min((int) section.SizeOfRawData - written, buffer_size);
Write (buffer, 0, write_size);
written += write_size;
}
MoveTo (section.PointerToRawData);
}
开发者ID:buraksarica,项目名称:cecil,代码行数:22,代码来源:ImageWriter.cs
注:本文中的Mono.Cecil.PE.Section类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论