Exemple #1
0
    void AddPoints(MountType inType, Transform trans)
    {
        string typeData = "";

        foreach (string str in fileStrings)
        {
            if (str.Length > 0)
            {
                string str2 = str.Substring(0, str.IndexOf(']'));
                if (str.Substring(0, str.IndexOf(']')) == inType.ToString())
                {
                    typeData = str;
                }
            }
        }
        string[] filePoints = typeData.Split(':');
        for (int i = 1; i < filePoints.Length; i++)
        {
            string[] xyz = filePoints[i].Split(',');
            float    x;
            float.TryParse(xyz[0], out x);
            float y;
            float.TryParse(xyz[1], out y);
            float z;
            float.TryParse(xyz[2], out z);
            int type;
            int.TryParse(xyz[3], out type);
            mounting.parentMountType = inType;
            mounting.AddPoint(new Vector3(x, y, z));
            mounting.AddMountType((MountType)type);
        }
    }
Exemple #2
0
        private void MountClicked(object sender, RoutedEventArgs e)
        {
            if (ComboBox.SelectedItem == null)
            {
                return;
            }

            MountType     mountType   = (MountType)ComboBox.SelectedItem;
            NcaFormatType sectionType = NcaFormatType.Romfs;

            switch (mountType)
            {
            case MountType.Exefs:
                sectionType = NcaFormatType.Pfs0;
                break;

            case MountType.Romfs:
                sectionType = NcaFormatType.Romfs;
                break;
            }
            List <IFileSystem> filesystems = new List <IFileSystem>();
            IEnumerable <Tuple <SwitchFsNca, int> > list = Indexed[sectionType];

            TaskManagerPage.Current.Queue.Submit(new RunTask("Opening filesystems to mount...", new Task(() =>
            {
                foreach (Tuple <SwitchFsNca, int> t in list)
                {
                    SwitchFsNca nca     = t.Item1;
                    NcaFsHeader section = t.Item1.Nca.Header.GetFsHeader(t.Item2);
                    int index           = t.Item2;

                    /*IStorage inStorage = nca.OpenStorage(index, IntegrityCheckLevel.ErrorOnInvalid);
                     * IFile outFile = new LocalFile("./tmp.bin", OpenMode.Write | OpenMode.AllowAppend);
                     * IStorage outStorage = outFile.AsStorage();
                     * inStorage.GetSize(out long size);
                     * long buffLen = 0x10000;
                     * for (int i = 0; i < (int)Math.Min(Math.Ceiling((double)size / buffLen), 5); i++)
                     * {
                     *  long off = i * buffLen;
                     *  long left = size - off;
                     *  long toRead = Math.Min(buffLen, left);
                     *
                     *  byte[] buff = new byte[toRead];
                     *
                     *  inStorage.Read(off, buff);
                     *  outStorage.Write(off, buff);
                     * }
                     * //inStorage.Dispose();
                     * outFile.Dispose();*/

                    filesystems.Add(nca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid));
                }
                filesystems.Reverse();
                LayeredFileSystem fs = new LayeredFileSystem(filesystems);
                string typeString    = sectionType.ToString();
                MountService.Mount(new MountableFileSystem(fs, $"Mounted {mountType.ToString().ToLower()}", typeString, OpenMode.Read));
            })));
        }
        public override void OnStart()
        {
            // This reports problems, and stops BT processing if there was a problem with attributes...
            // We had to defer this action, as the 'profile line number' is not available during the element's
            // constructor call.
            OnStart_HandleAttributeProblem();

            // If the quest is complete, this behavior is already done...
            // So we don't want to falsely inform the user of things that will be skipped.
            if (!IsDone)
            {
                TreeRoot.GoalText = "Mounting for " + MountType.ToString() + " travel";
            }
        }
Exemple #4
0
        private void MountClicked(object sender, RoutedEventArgs e)
        {
            MountType     mountType   = (MountType)ComboBox.SelectedItem;
            NcaFormatType sectionType = NcaFormatType.Romfs;

            switch (mountType)
            {
            case MountType.Exefs:
                sectionType = NcaFormatType.Pfs0;
                break;

            case MountType.Romfs:
                sectionType = NcaFormatType.Romfs;
                break;
            }
            List <IFileSystem> filesystems = new List <IFileSystem>();
            IEnumerable <Tuple <SwitchFsNca, int> > list = Indexed[sectionType];

            TaskManagerPage.Current.Queue.Submit(new RunTask("Opening filesystems to mount...", new Task(() =>
            {
                foreach (Tuple <SwitchFsNca, int> t in list)
                {
                    SwitchFsNca nca     = t.Item1;
                    NcaFsHeader section = t.Item1.Nca.Header.GetFsHeader(t.Item2);
                    int index           = t.Item2;

                    if (section.IsPatchSection())
                    {
                        MainNca.BaseNca = nca.Nca;
                    }

                    filesystems.Add(nca.OpenFileSystem(index, IntegrityCheckLevel.ErrorOnInvalid));
                }
                filesystems.Reverse();
                LayeredFileSystem fs = new LayeredFileSystem(filesystems);
                string typeString    = sectionType.ToString();
                MountService.Mount(new MountableFileSystem(fs, $"Mounted {mountType.ToString().ToLower()}", typeString, OpenMode.Read));
            })));
        }
        //void PushFile();
        //void PullFile();
        /// <summary>
        /// Mounts connected Android device's file system as specified
        /// </summary>
        /// <param name="type">The desired <see cref="MountType"/> (RW or RO)</param>
        /// <returns>True if remount is successful, False if remount is unsuccessful</returns>
        /// <example>The following example shows how you can mount the file system as Read-Writable or Read-Only
        /// <code>
        /// // This example demonstrates mounting the Android device's file system as Read-Writable
        /// using System;
        /// using RegawMOD.Android;
        /// 
        /// class Program
        /// {
        ///     static void Main(string[] args)
        ///     {
        ///         AndroidController android = AndroidController.Instance;
        ///         Device device;
        ///         
        ///         Console.WriteLine("Waiting For Device...");
        ///         android.WaitForDevice(); //This will wait until a device is connected to the computer
        ///         device = android.ConnectedDevices[0]; //Sets device to the first Device in the collection
        ///
        ///         Console.WriteLine("Connected Device - {0}", device.SerialNumber);
        ///
        ///         Console.WriteLine("Mounting System as RW...");
        ///     	Console.WriteLine("Mount success? - {0}", device.RemountSystem(MountType.RW));
        ///     }
        /// }
        /// 
        ///	// The example displays the following output (if mounting is successful):
        ///	//		Waiting For Device...
        ///	//		Connected Device - {serial # here}
        ///	//		Mounting System as RW...
        ///	//		Mount success? - true
        /// </code>
        /// </example>
        public bool RemountSystem(MountType type)
        {
            if (!this.device.HasRoot)
                return false;

            AdbCommand adbCmd = Adb.FormAdbShellCommand(this.device, true, "mount", string.Format("-o remount,{0} -t yaffs2 {1} /system", type.ToString().ToLower(), this.systemMount.Block));
            Adb.ExecuteAdbCommandNoReturn(adbCmd);

            UpdateMountPoints();

            if (this.systemMount.MountType == type)
                return true;

            return false;
        }
Exemple #6
0
        //void PushFile();
        //void PullFile();

        /// <summary>
        /// Mounts connected Android device's file system as specified
        /// </summary>
        /// <param name="type">The desired <see cref="MountType"/> (RW or RO)</param>
        /// <returns>True if remount is successful, False if remount is unsuccessful</returns>
        /// <example>The following example shows how you can mount the file system as Read-Writable or Read-Only
        /// <code>
        /// // This example demonstrates mounting the Android device's file system as Read-Writable
        /// using System;
        /// using RegawMOD.Android;
        ///
        /// class Program
        /// {
        ///     static void Main(string[] args)
        ///     {
        ///         AndroidController android = AndroidController.Instance;
        ///         Device device;
        ///
        ///         Console.WriteLine("Waiting For Device...");
        ///         android.WaitForDevice(); //This will wait until a device is connected to the computer
        ///         device = android.ConnectedDevices[0]; //Sets device to the first Device in the collection
        ///
        ///         Console.WriteLine("Connected Device - {0}", device.SerialNumber);
        ///
        ///         Console.WriteLine("Mounting System as RW...");
        ///         Console.WriteLine("Mount success? - {0}", device.RemountSystem(MountType.RW));
        ///     }
        /// }
        ///
        ///	// The example displays the following output (if mounting is successful):
        ///	//		Waiting For Device...
        ///	//		Connected Device - {serial # here}
        ///	//		Mounting System as RW...
        ///	//		Mount success? - true
        /// </code>
        /// </example>
        public bool RemountSystem(MountType type)
        {
            if (!this.device.HasRoot)
            {
                return(false);
            }

            AdbCommand adbCmd = Adb.FormAdbShellCommand(this.device, true, "mount", string.Format("-o remount,{0} -t yaffs2 {1} /system", type.ToString().ToLower(), this.systemMount.Block));

            Adb.ExecuteAdbCommandNoReturn(adbCmd);

            UpdateMountPoints();

            if (this.systemMount.MountType == type)
            {
                return(true);
            }

            return(false);
        }