Files
mirror-processhacker/1.x/trunk/ProcessHacker.Native/Mfs/MemoryFileSystem.cs
T
wj32 8d9de0ae3e * started MFS
* UnicodeEncoding -> Encoding

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2418 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-12-15 11:39:05 +00:00

39 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using ProcessHacker.Native.Api;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
namespace ProcessHacker.Native.Mfs
{
public unsafe sealed class MemoryFileSystem
{
private const int MfsMagic = 0x0053464d;
private const string MfsMagicString = "MFS\0";
private const int MfsBlockSize = 0x10000;
private const int MfsCellSize = 0x400;
private Section _section;
private MfsFsHeader* _header;
public MemoryFileSystem(string fileName, bool readOnly)
{
using (var fhandle = FileHandle.CreateWin32(
fileName,
FileAccess.GenericRead | (!readOnly ? FileAccess.GenericWrite : 0),
FileShareMode.Read,
FileCreationDispositionWin32.OpenAlways
))
{
_section = new Section(fhandle, !readOnly ? MemoryProtection.ReadWrite : MemoryProtection.ReadOnly);
if (fhandle.GetSize() < MfsBlockSize)
throw new MfsInvalidFileSystemException();
}
}
}
}