Exemple #1
0
 public IORet Write(string s, bool unicode)
 {
     return(context.Write(s, unicode));
 }
Exemple #2
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);
            }
        }