Exemplo n.º 1
0
 public FileMapping(string fileName)
 {
     this.m_fileName    = fileName;
     this.m_fileHandle  = System.Reflection.Adds.NativeMethods.SafeOpenFile(fileName);
     this.m_fileLength  = System.Reflection.Adds.NativeMethods.FileSize(this.m_fileHandle);
     this.m_filePath    = System.IO.Path.GetFullPath(this.m_fileName);
     this.m_fileMapping = System.Reflection.Adds.NativeMethods.CreateFileMapping(this.m_fileHandle, IntPtr.Zero, System.Reflection.Adds.NativeMethods.PageProtection.Readonly, 0, 0, null);
     if (this.m_fileMapping.IsInvalid)
     {
         Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
     }
     this.m_View = System.Reflection.Adds.NativeMethods.MapViewOfFile(this.m_fileMapping, 4, 0, 0, IntPtr.Zero);
     if (this.m_View.IsInvalid)
     {
         Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
     }
 }
Exemplo n.º 2
0
 public static extern System.Reflection.Adds.NativeMethods.SafeMapViewHandle MapViewOfFile(System.Reflection.Adds.NativeMethods.SafeWin32Handle hFileMappingObject, uint dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, IntPtr dwNumberOfBytesToMap);