Beispiel #1
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();
        }
Beispiel #2
0
        //--------------------------- Abre o disco e trava o Contexto
        public int Open()
        {
            //Verifica se o Contexto já está trancado, se não, abra
            isfileopen = file.Locked;
            if (!isfileopen)
            {
                int l = (int)file.Lock();
                if (l != (int)IORet.RET_IO_OK)
                {
                    return(l);
                }
            }

            TempBuffer  = new byte[0x8000];
            TempBuffer2 = new byte[0x8000];

            return(0);
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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();
        }
Beispiel #5
0
 public IORet Lock()
 {
     return(context.Lock());
 }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }