Exemple #1
0
        //--------------------------- Fecha o disco e destrava o Contexto
        public void Close()
        {
            //Se o contexto não estava trancado, o contexto deve ser fechado pela rotina que o criou
            if (!isfileopen)
            {
                file.Unlock();
            }

            file             = null;
            TempBuffer       = null;
            TempBuffer2      = null;
            SectorUsageTable = null;
            HeaderCopy       = null;
            DiscKey          = null;

            if (Partitions != null)
            {
                for (int i = 0; i < Partitions.Length; i++)
                {
                    Partitions[i].Files = null;
                }
            }

            Partitions = null;
        }
Exemple #2
0
        //--------------------------- 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);
            }
        }
Exemple #3
0
        //---------------------------- 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();
        }
Exemple #4
0
        //-------------- Rotinas

        public DVDRomReader(Char drive)
        {
            context = IOManager.CreateIOContext("DVD-ROM " + drive, @"\\.\" + drive + ':', FileAccess.Read, FileShare.Read, 0,
                                                FileMode.Open, EFileAttributes.NoBuffering);

            context.Lock();

            DISK_GEOMETRY dg = context.GetDiskGeometry();

            sectorSize = (int)dg.BytesPerSector;

            PARTITION_INFORMATION pi = context.GetPartitionInformation();

            size = pi.PartitionLength;

            context.Unlock();
        }
Exemple #5
0
 public IORet Unlock()
 {
     return(context.Unlock());
 }
Exemple #6
0
        //--------------------------- 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);
            }
        }
Exemple #7
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);
            }
        }