public IORet Seek(long pos, SeekOrigin origin) { switch (origin) { case SeekOrigin.Begin: discPosition = pos; break; case SeekOrigin.Current: discPosition += pos; break; case SeekOrigin.End: discPosition = disc.size + pos; break; } disc.GetLBAPosAndSectorOffset(discPosition, out deviceLBA, out offset, out wbfsSectorLBA); return(context.Seek(deviceLBA << device.hdSectorSize_s)); }
public IORet Seek(long pos, SeekOrigin origin) { switch (origin) { case SeekOrigin.Begin: discPosition = pos; break; case SeekOrigin.Current: discPosition += pos; break; case SeekOrigin.End: discPosition = context.Length + pos; break; } deviceLBA = discPosition / sectorSize; //Divisão de inteiros offset = (uint)(discPosition % sectorSize); return(context.Seek(deviceLBA * sectorSize)); }
//--------------------------- Retorna as informações da iso de Wii public static Int32 SetIsoInformation(String file, string code, string name) { IIOContext context = IOManager.CreateIOContext("ISWIIISO", file, FileAccess.ReadWrite, FileShare.Read, 0, FileMode.Open, EFileAttributes.None); if (context.Result != (int)IORet.RET_IO_OK) { //Loga erro return(context.Result); } else { int r = (int)context.Lock(); if (r != (int)IORet.RET_IO_OK) { //Loga erro context.Close(); return(r); } Byte[] header = new Byte[256]; if (context.Read(header, 256) != IORet.RET_IO_OK) { //Loga erro r = context.Result; context.Unlock(); context.Close(); return(r); } uint magic = _be32(header, 24); if (magic != 0x5D1C9EA3) { context.Unlock(); context.Close(); header = null; return((int)WBFSRet.RET_WBFS_NOTAWIIDISC); } header = null; // if (code.Length != 0) { if (code.Length != WBFSDevice.IsoCodeLen) { if (code.Length < WBFSDevice.IsoCodeLen) { while (code.Length < WBFSDevice.IsoCodeLen) { code += '0'; } } else { code = code.Substring(0, WBFSDevice.IsoCodeLen); //Eu preciso fazer isso para o GetDiscByCode() } } context.Seek(WBFSDevice.IsoCodePos); context.Write(code, false); } if (name.Length != 0) { if (name.Length > WBFSDevice.IsoNameLen) { name = name.Substring(0, WBFSDevice.IsoNameLen); } context.Seek(WBFSDevice.IsoNamePos); context.Write(name, false); for (int i = name.Length; i < WBFSDevice.IsoNameLen; i++) { context.Write((byte)0); } } // context.Unlock(); context.Close(); return(0); } }