public ulong SeekAbsolute(ulong pos) { ulong res = 0; if ((uint)(pos / bytesPerSector) != bufferSector) { ulong closestSector = ((pos / (ulong)bytesPerSector) * (ulong)bytesPerSector); int positionLow = (int)closestSector; int positionHigh = (int)((closestSector & 0xFFFFFFFF00000000) >> 32); res = Exports.SetFilePointer(hFile, positionLow, ref positionHigh, Exports.EMoveMethod.Begin); int confirmPositionHigh = 0; ulong confirmRes = Exports.SetFilePointer(hFile, 0, ref confirmPositionHigh, Exports.EMoveMethod.Current); if (((ulong)confirmPositionHigh << 32 | res) != ((ulong)positionHigh << 32 | confirmRes)) { int value = Marshal.GetLastWin32Error(); throw new Exception("RUH ROH"); } bufferSector = (int)(closestSector / bytesPerSector); Exports.ReadFile(hFile, buffer, (uint)buffer.Length, ref bytesRead, IntPtr.Zero); } currentPos = (long)(pos % bytesPerSector); absolutePos = (long)pos; return(res); }