//--------------------------- Retorna as informações da iso de Wii public static Int32 GetIsoInformation(String file, out string code, out string name, out int region, out long used) { code = ""; name = ""; region = -1; used = 0; IIOContext context = IOManager.CreateIOContext("ISWIIISO", file, FileAccess.Read, FileShare.ReadWrite, 0, FileMode.Open, EFileAttributes.None); if (context.Result != (int)IORet.RET_IO_OK) { //Loga erro return(context.Result); } int r = 0; WiiDisc d = new WiiDisc(context, false); d.Open(); r = d.BuildDisc(PartitionSelection.OnlyGamePartition); if (r == 0) { name = d.name; code = d.code; used = d.UsedSectors; Byte[] bregion = new byte[4]; if (context.Read(bregion, WBFSDevice.IsoRegionPos, 4) != IORet.RET_IO_OK) { //Loga erro region = -1; } else { region = (int)System.Net.IPAddress.NetworkToHostOrder((int)BitConverter.ToUInt32(bregion, 0)); } bregion = null; d.Close(); context.Close(); return(0); } else { d.Close(); context.Close(); return(r); } }
//--------------------------- Retorna as informações da iso de Wii public static Int32 GetIsoInformation(String file, out string code, out string name, out long used) { code = ""; name = ""; used = 0; IIOContext context = IOManager.CreateIOContext("ISWIIISO", file, FileAccess.Read, FileShare.ReadWrite, 0, FileMode.Open, EFileAttributes.None); if (context.Result != (int)IORet.RET_IO_OK) { //Loga erro return(context.Result); } int r = 0; WiiDisc d = new WiiDisc(context, false); d.Open(); r = d.BuildDisc(PartitionSelection.OnlyGamePartition); if (r == 0) { name = d.name; code = d.code; used = d.UsedSectors; d.Close(); context.Close(); return(0); } else { d.Close(); context.Close(); return(r); } }
//--------------------------- Verifica se o arquivo é uma iso de Wii public static Int32 IsWiiIso(String file) { IIOContext context = IOManager.CreateIOContext("ISWIIISO", file, FileAccess.Read, FileShare.ReadWrite, 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); } r = IsWiiIso(header); context.Unlock(); context.Close(); return(r); } }
//---------------------------- Rotinas public MBRReader(string device) { IIOContext pdrive = IOManager.CreateIOContext("PDRIVE\\" + device, device, FileAccess.Read, FileShare.Read, 0, FileMode.Open, EFileAttributes.NoBuffering); if (pdrive.Result != 0) { result = pdrive.Result; return; } if (pdrive.Lock() != IORet.RET_IO_OK) { //Loga a informação result = pdrive.Result; return; } Byte[] mbr = new byte[512]; if (pdrive.Read(mbr, 512) != IORet.RET_IO_OK) { result = pdrive.Result; pdrive.Unlock(); pdrive.Close(); return; } //----------------- //MBRReader(byte[] mbr) //----------------- pdrive.Unlock(); pdrive.Close(); }
public IORet Close() { return(context.Close()); }
//--------------------------- 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); } }
//--------------------------- Retorna as informações da iso de Wii public static Int32 GetIsoInformation(String file, out string code, out string name, out int region) { code = ""; name = ""; region = -1; IIOContext context = IOManager.CreateIOContext("ISWIIISO", file, FileAccess.Read, FileShare.ReadWrite, 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(); header = null; return(r); } uint magic = _be32(header, 24); if (magic != 0x5D1C9EA3) { context.Unlock(); context.Close(); header = null; return((int)WBFSRet.RET_WBFS_NOTAWIIDISC); } //Lê o código do jogo de 6 caracteres int j = WBFSDevice.IsoCodePos; byte c = 0; for (j = WBFSDevice.IsoCodePos; j < WBFSDevice.IsoCodePos + WBFSDevice.IsoCodeLen; j++) { code += (char)header[j]; } //Lê o nome do jogo j = WBFSDevice.IsoNamePos; while (((c = header[j++]) != 0) && (j < WBFSDevice.IsoNamePos + WBFSDevice.IsoNameLen)) { name += (char)c; } if (context.Read(header, WBFSDevice.IsoRegionPos, 4) != IORet.RET_IO_OK) { //Loga erro r = context.Result; context.Unlock(); context.Close(); header = null; return(r); } region = (int)System.Net.IPAddress.NetworkToHostOrder((int)BitConverter.ToUInt32(header, 0)); context.Unlock(); context.Close(); header = null; return(0); } }