// Token: 0x0600010F RID: 271 RVA: 0x0000E37C File Offset: 0x0000C57C protected void Init(string strName) { if (!System.IO.File.Exists(strName)) { throw new Exception("未找到文件"); } FileInfo fileInfo = new FileInfo(strName); this.m_FileSize = fileInfo.Length; this.m_fHandle = this.File.Open(strName); if (strName.Length > 0) { this.m_hSharedMemoryFile = ShareMemory.CreateFileMapping(this.m_fHandle, IntPtr.Zero, 2u, 0u, (uint)this.m_FileSize, "mdata"); if (this.m_hSharedMemoryFile == IntPtr.Zero) { this.m_bAlreadyExist = false; this.m_bInit = false; throw new Exception("CreateFileMapping失败LastError=" + ShareMemory.GetLastError().ToString()); } this.m_bInit = true; if ((ulong)this.m_MemSize > (ulong)this.m_FileSize) { this.m_MemSize = (uint)this.m_FileSize; } this.m_pwData = ShareMemory.MapViewOfFile(this.m_hSharedMemoryFile, 4u, 0u, 0u, this.m_MemSize); if (this.m_pwData == IntPtr.Zero) { this.m_bInit = false; throw new Exception("m_hSharedMemoryFile失败LastError=" + ShareMemory.GetLastError().ToString() + " " + new Win32Exception(ShareMemory.GetLastError()).Message); } } }
// Token: 0x06000114 RID: 276 RVA: 0x0000E5BA File Offset: 0x0000C7BA public void Close() { if (this.m_bInit) { ShareMemory.UnmapViewOfFile(this.m_pwData); ShareMemory.CloseHandle(this.m_hSharedMemoryFile); this.File.Close(); } }
// Token: 0x06000115 RID: 277 RVA: 0x0000E5E8 File Offset: 0x0000C7E8 public void Read(ref byte[] bytData, int lngAddr, int lngSize, bool Unmap) { if ((long)(lngAddr + lngSize) > (long)((ulong)this.m_MemSize)) { throw new Exception("Read操作超出数据区"); } if (this.m_bInit) { Marshal.Copy(this.m_pwData, bytData, lngAddr, lngSize); if (Unmap) { bool flag = ShareMemory.UnmapViewOfFile(this.m_pwData); if (flag) { this.m_pwData = IntPtr.Zero; } } return; } throw new Exception("文件未初始化"); }
// Token: 0x06000112 RID: 274 RVA: 0x0000E4CC File Offset: 0x0000C6CC public uint GetNextblock() { if (!this.m_bInit) { throw new Exception("文件未初始化。"); } uint memberSize = this.GetMemberSize(); if (memberSize == 0u) { return(memberSize); } this.m_MemSize = memberSize; this.m_pwData = ShareMemory.MapViewOfFile(this.m_hSharedMemoryFile, 4u, ShareMemory.GetHighWord((ulong)this.m_offsetBegin), ShareMemory.GetLowWord((ulong)this.m_offsetBegin), memberSize); if (this.m_pwData == IntPtr.Zero) { this.m_bInit = false; throw new Exception("映射文件块失败" + ShareMemory.GetLastError().ToString()); } this.m_offsetBegin += (long)((ulong)memberSize); return(memberSize); }
// Token: 0x0600010B RID: 267 RVA: 0x0000E290 File Offset: 0x0000C490 public static uint GetPartitionsize() { ShareMemory.SYSTEM_INFO system_INFO; ShareMemory.GetSystemInfo(out system_INFO); return(system_INFO.allocationGranularity); }