mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
710682a5ab
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1526 21ef857c-d57f-4fe0-8362-d861dc6d29cd
73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using ProcessHacker.Native.Api;
|
|
using ProcessHacker.Native.Objects;
|
|
using ProcessHacker.Native.Security;
|
|
|
|
namespace ProcessHacker.Native
|
|
{
|
|
public sealed class Section : NativeObject<SectionHandle>
|
|
{
|
|
private MemoryProtection _originalProtection;
|
|
|
|
public Section(FileHandle fileHandle)
|
|
: this(fileHandle, MemoryProtection.ReadWrite)
|
|
{ }
|
|
|
|
public Section(FileHandle fileHandle, MemoryProtection protection)
|
|
: this(fileHandle, false, protection)
|
|
{ }
|
|
|
|
public Section(FileHandle fileHandle, bool image, MemoryProtection protection)
|
|
: this(null, fileHandle, image, protection)
|
|
{ }
|
|
|
|
public Section(string name, FileHandle fileHandle, bool image, MemoryProtection protection)
|
|
{
|
|
_originalProtection = protection;
|
|
this.Handle = SectionHandle.Create(
|
|
SectionAccess.All,
|
|
fileHandle.GetSize(),
|
|
image ? SectionAttributes.Image : SectionAttributes.Commit,
|
|
protection,
|
|
fileHandle
|
|
);
|
|
}
|
|
|
|
public Section(long maximumSize)
|
|
: this(maximumSize, MemoryProtection.ReadWrite)
|
|
{ }
|
|
|
|
public Section(long maximumSize, MemoryProtection protection)
|
|
: this(null, maximumSize, protection)
|
|
{ }
|
|
|
|
public Section(string name, long maximumSize, MemoryProtection protection)
|
|
{
|
|
_originalProtection = protection;
|
|
this.Handle = SectionHandle.Create(
|
|
SectionAccess.All,
|
|
maximumSize,
|
|
SectionAttributes.Commit,
|
|
protection
|
|
);
|
|
}
|
|
|
|
public void Extend(long newSize)
|
|
{
|
|
this.Handle.Extend(newSize);
|
|
}
|
|
|
|
public SectionView MapView(int size)
|
|
{
|
|
return this.MapView(size, _originalProtection);
|
|
}
|
|
|
|
public SectionView MapView(int size, MemoryProtection protection)
|
|
{
|
|
return this.Handle.MapView(size, protection);
|
|
}
|
|
}
|
|
}
|