コード例 #1
0
 private string GetPath()
 {
     //return string.Format(@"Controls\{0}.bin", TitleID.ToString("X16"));
     return(MainForm.TEMP_PATH + TitleID.ToString("X16") + ".bin");
 }
コード例 #2
0
ファイル: NSP.cs プロジェクト: Adran-Marit/nspack
        public void generate(string Out)
        {
            if (Contents.Count <= 0)
            {
                return;
            }
            string outdir = Utils.TemporaryDirectory + "\\gen\\" + TitleID;

            if (Directory.Exists(outdir))
            {
                Directory.Delete(outdir, true);
            }
            Directory.CreateDirectory(outdir);
            List <NCAType> types  = new List <NCAType>();
            byte           keygen = Contents[0].KeyGeneration;

            foreach (NCA cnt in Contents)
            {
                if (cnt.TitleID != TitleID)
                {
                    continue;
                }
                types.Add(cnt.Type);
                cnt.generate(outdir + "\\" + cnt.Type.ToString());
            }
            NCA cnmt = new NCA(KeyFile);

            cnmt.TitleID           = TitleID;
            cnmt.KeyGeneration     = keygen;
            cnmt.Type              = NCAType.CNMT;
            cnmt.TitleID           = TitleID;
            cnmt.Options.TitleType = CNMTTitleType.Application;
            foreach (NCAType t in types)
            {
                string[] ncas = Directory.GetFiles(outdir + "\\" + t.ToString());
                if (ncas.Length <= 0)
                {
                    continue;
                }
                string curnca = ncas[0];
                switch (t)
                {
                case NCAType.Control:
                    cnmt.Options.ControlNCA = curnca;
                    break;

                case NCAType.Data:
                    cnmt.Options.DataNCA = curnca;
                    break;

                case NCAType.LegalInformation:
                    cnmt.Options.LegalInformationNCA = curnca;
                    break;

                case NCAType.OfflineHTML:
                    cnmt.Options.OfflineHTMLNCA = curnca;
                    break;

                case NCAType.Program:
                    cnmt.Options.ProgramNCA = curnca;
                    break;
                }
            }
            cnmt.generate(outdir);
            foreach (NCAType t in types)
            {
                string[] ncas = Directory.GetFiles(outdir + "\\" + t.ToString());
                if (ncas.Length <= 0)
                {
                    continue;
                }
                string curnca = ncas[0];
                File.Move(curnca, outdir + "\\" + Path.GetFileName(curnca));
            }
            string hacpack = "--type nsp";

            hacpack += " -k \"\"" + KeyFile + "\"\"";
            hacpack += " --tempdir \"\"" + Utils.TemporaryDirectory + "\\bin\\temp\"\"";
            hacpack += " -o \"\"" + outdir + "\"\"";
            hacpack += " --keygeneration " + keygen.ToString();
            hacpack += " --titleid " + TitleID.ToString();
            hacpack += " --ncadir \"\"" + outdir + "\"\"";
            Console.WriteLine(hacpack);
            try
            {
                Utils.executeCommand(Utils.TemporaryDirectory + "\\bin\\hacpack.exe", hacpack, true);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Error processing hacPack command", "Brew.NET - NSP build error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                Directory.Delete(outdir, true);
                return;
            }
            File.Move(outdir + "\\" + TitleID + ".nsp", Out);
            // Directory.Delete(outdir, true);
        }
コード例 #3
0
ファイル: NCA.cs プロジェクト: Adran-Marit/nspack
        public void generate(string OutDir)
        {
            string hacpack = "--type nca";

            hacpack += " -k \"\"" + KeyFile + "\"\"";
            hacpack += " --tempdir \"\"" + Utils.TemporaryDirectory + "\\bin\\temp\"\"";
            hacpack += " -o \"\"" + OutDir + "\"\"";
            hacpack += " --keygeneration " + KeyGeneration.ToString();
            hacpack += " --titleid " + TitleID.ToString();
            switch (Type)
            {
            case NCAType.CNMT:
                hacpack += " --ncatype meta";
                switch (Options.TitleType)
                {
                case CNMTTitleType.AddOn:
                    hacpack += " --titletype addon";
                    break;

                case CNMTTitleType.Application:
                    hacpack += " --titletype application";
                    break;
                }
                hacpack += " --titleversion 0";
                if (!string.IsNullOrEmpty(Options.ProgramNCA))
                {
                    hacpack += " --programnca \"\"" + Options.ProgramNCA + "\"\"";
                }
                if (!string.IsNullOrEmpty(Options.ControlNCA))
                {
                    hacpack += " --controlnca \"\"" + Options.ControlNCA + "\"\"";
                }
                if (!string.IsNullOrEmpty(Options.LegalInformationNCA))
                {
                    hacpack += " --legalnca \"\"" + Options.LegalInformationNCA + "\"\"";
                }
                if (!string.IsNullOrEmpty(Options.OfflineHTMLNCA))
                {
                    hacpack += " --htmldocnca \"\"" + Options.OfflineHTMLNCA + "\"\"";
                }
                if (!string.IsNullOrEmpty(Options.DataNCA))
                {
                    hacpack += " --datanca \"\"" + Options.DataNCA + "\"\"";
                }
                break;

            case NCAType.Control:
                hacpack += " --ncatype control";
                hacpack += " --romfsdir \"\"" + RomFS + "\"\"";
                break;

            case NCAType.LegalInformation:
            case NCAType.OfflineHTML:
                hacpack += " --ncatype manual";
                hacpack += " --romfsdir \"\"" + RomFS + "\"\"";
                break;

            case NCAType.Data:
                hacpack += " --ncatype data";
                hacpack += " --romfsdir \"\"" + RomFS + "\"\"";
                break;

            case NCAType.PublicData:
                hacpack += " --ncatype publicdata";
                hacpack += " --romfsdir \"\"" + RomFS + "\"\"";
                break;

            case NCAType.Program:
                hacpack += " --ncatype program";
                hacpack += " --exefsdir \"\"" + ExeFS + "\"\"";
                if (!string.IsNullOrEmpty(RomFS))
                {
                    hacpack += " --romfsdir \"\"" + RomFS + "\"\"";
                }
                if (!string.IsNullOrEmpty(Logo))
                {
                    hacpack += " --logodir \"\"" + Logo + "\"\"";
                }
                break;
            }
            try
            {
                Utils.executeCommand(Utils.TemporaryDirectory + "\\bin\\hacpack.exe", hacpack, true);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Error processing hacPack command", "Brew.NET - NCA build error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
        }
コード例 #4
0
        private void UserInfo()
        {
            string Name;
            string Surname;
            string PhoneNumber;
            string EmailAddress;
            string UserName;
            string UserPassword;
            int    PrivilegeID;
            int    GenderID;
            int    TitleID;
            string GenderDescription;
            int    UserTypeID;
            string PrivilegeDescription;
            string UserTypeDescription;
            string TitleDescription;


            SqlConnection sqlcon = new SqlConnection(Globals.ConnectionString);

            sqlcon.Open();
            string        cmd    = "SELECT * FROM Users Where UserID ='" + Globals.SelectedUserID.ToString() + "'";
            SqlCommand    sqlcom = new SqlCommand(cmd, sqlcon);
            SqlDataReader dr     = sqlcom.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    //    try
                    //    {
                    Name         = (dr["Name"].ToString());
                    Surname      = (dr["Surname"].ToString());
                    PhoneNumber  = (dr["PhoneNumber"].ToString());
                    UserName     = (dr["UserName"].ToString());
                    UserPassword = (dr["UserPassword"].ToString());
                    PrivilegeID  = Convert.ToInt32((dr["PrivilegeID"]));
                    GenderID     = Convert.ToInt32((dr["GenderID"]));
                    TitleID      = Convert.ToInt32((dr["TitleID"]));
                    UserTypeID   = Convert.ToInt32((dr["UserTypeID"]));
                    EmailAddress = (dr["EmailAddress"].ToString());

                    txtName.Text         = Name;
                    txtSurname.Text      = Surname;
                    txtPhoneNumber.Text  = PhoneNumber;
                    txtUsername.Text     = UserName;
                    txtPassword.Text     = UserPassword;
                    txtEmailAddress.Text = EmailAddress;

                    //Get Gender
                    SqlConnection sqlcon2 = new SqlConnection(Globals.ConnectionString);
                    sqlcon2.Open();
                    string        cmd2    = "SELECT GenderDescription FROM Gender WHERE GenderID ='" + GenderID.ToString() + "'";
                    SqlCommand    sqlcom2 = new SqlCommand(cmd2, sqlcon2);
                    SqlDataReader dr2;
                    dr2 = sqlcom2.ExecuteReader();
                    if (dr2.HasRows)
                    {
                        while (dr2.Read())
                        {
                            GenderDescription = (dr2["GenderDescription"].ToString());
                            cbxGender.Text    = GenderDescription;
                        }
                    }
                    dr2.Close();
                    sqlcon2.Close();

                    //Get Title
                    SqlConnection sqlcon3 = new SqlConnection(Globals.ConnectionString);
                    sqlcon3.Open();
                    string        cmd3    = "SELECT TitleDescription FROM Title WHERE TitleID ='" + TitleID.ToString() + "'";
                    SqlCommand    sqlcom3 = new SqlCommand(cmd3, sqlcon3);
                    SqlDataReader dr3;
                    dr3 = sqlcom3.ExecuteReader();
                    if (dr3.HasRows)
                    {
                        while (dr3.Read())
                        {
                            TitleDescription = (dr3["TitleDescription"].ToString());
                            cbxTitle.Text    = TitleDescription;
                        }
                    }
                    dr3.Close();
                    sqlcon3.Close();

                    //Get Privilege
                    SqlConnection sqlcon4 = new SqlConnection(Globals.ConnectionString);
                    sqlcon4.Open();
                    string        cmd4    = "SELECT PrivilegeDescription FROM Privilege WHERE PrivilegeID ='" + PrivilegeID.ToString() + "'";
                    SqlCommand    sqlcom4 = new SqlCommand(cmd4, sqlcon4);
                    SqlDataReader dr4;
                    dr4 = sqlcom4.ExecuteReader();
                    if (dr4.HasRows)
                    {
                        while (dr4.Read())
                        {
                            PrivilegeDescription  = (dr4["PrivilegeDescription"].ToString());
                            cbxPrivilegeType.Text = PrivilegeDescription;
                        }
                    }
                    dr4.Close();
                    sqlcon4.Close();

                    //Get UserType
                    SqlConnection sqlcon5 = new SqlConnection(Globals.ConnectionString);
                    sqlcon5.Open();
                    string        cmd5    = "SELECT UserDescription FROM UserType WHERE UserTypeID ='" + UserTypeID.ToString() + "'";
                    SqlCommand    sqlcom5 = new SqlCommand(cmd5, sqlcon5);
                    SqlDataReader dr5;
                    dr5 = sqlcom5.ExecuteReader();
                    if (dr5.HasRows)
                    {
                        while (dr5.Read())
                        {
                            UserTypeDescription = (dr5["UserDescription"].ToString());
                            cbxUserType.Text    = UserTypeDescription;
                        }
                    }
                    dr5.Close();
                    sqlcon5.Close();
                    //     }
                    //    catch
                    //    {


                    //   }
                }
            }
            dr.Close();
            sqlcon.Close();
        }