private void Hakchi_OnConnected(ISystemShell caller)
        {
            this.Invoke(new Action(() =>
            {
                this.pictureBox1.Image = Resources.sign_check;
                this.hasReconnected    = true;
                timer1.Enabled         = false;

                progressBarEx1.Value = 100;
                timer1.Interval      = 1000;
                timer1.Enabled       = true;
            }));
        }
Exemple #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    LifetimeScope.Dispose();
                }

                Settings   = null;
                Descriptor = null;
                Blueprint  = null;
                Shell      = null;

                _disposed = true;
            }
        }
Exemple #3
0
        public static void Shell_OnConnected(ISystemShell caller)
        {
            // set calling shell as current used shell and disable others
            Shell = caller;
            shells.ForEach(shell => { if (shell != caller)
                                      {
                                          shell.Enabled = false;
                                      }
                           });
            try
            {
                Connected = Shell.IsOnline;
                if (!Shell.IsOnline)
                {
                    throw new IOException("Shell connection should be online!");
                }

                MinimalMemboot = Shell.Execute("source /hakchi/config; [ \"$cf_memboot\" = \"y\" ]") == 0;

                // detect unique id
                UniqueID = Shell.ExecuteSimple("echo \"`devmem 0x01C23800``devmem 0x01C23804``devmem 0x01C23808``devmem 0x01C2380C`\"").Trim().Replace("0x", "");
                Debug.WriteLine($"Detected device unique ID: {UniqueID}");

                // execution stops here for a minimal memboot
                if (!MinimalMemboot)
                {
                    // detect running/mounted firmware
                    string board  = Shell.ExecuteSimple("cat /etc/clover/boardtype", 3000, true);
                    string region = Shell.ExecuteSimple("cat /etc/clover/REGION", 3000, true);
                    DetectedConsoleType = translateConsoleType(board, region);
                    if (DetectedConsoleType == ConsoleType.Unknown)
                    {
                        throw new IOException("Unable to determine mounted firmware");
                    }
                    var customFirmwareLoaded = Shell.ExecuteSimple("hakchi currentFirmware");
                    CustomFirmwareLoaded = customFirmwareLoaded != "_nand_";
                    Debug.WriteLine(string.Format("Detected mounted board: {0}, region: {1}, firmware: {2}", board, region, customFirmwareLoaded));

                    // detect running versions
                    var versions = Shell.ExecuteSimple("source /var/version && echo \"$bootVersion $kernelVersion $hakchiVersion\"", 500, true).Split(' ');
                    BootVersion   = versions[0];
                    KernelVersion = versions[1];
                    ScriptVersion = versions[2];
                    Debug.WriteLine($"Detected versions: boot {BootVersion}, kernel {KernelVersion}, script {ScriptVersion}");
                    CanInteract = !SystemRequiresReflash() && !SystemRequiresRootfsUpdate();

                    // only do more interaction if safe to do so
                    if (CanInteract)
                    {
                        // detect basic paths
                        RemoteGameSyncPath = Shell.ExecuteSimple("hakchi findGameSyncStorage", 2000, true).Trim();
                        SystemCode         = Shell.ExecuteSimple("hakchi eval 'echo \"$sftype-$sfregion\"'", 2000, true).Trim();
                        OriginalGamesPath  = Shell.ExecuteSimple("hakchi get gamepath", 2000, true).Trim();
                        RootFsPath         = Shell.ExecuteSimple("hakchi get rootfs", 2000, true).Trim();
                        SquashFsPath       = Shell.ExecuteSimple("hakchi get squashfs", 2000, true).Trim();

                        // load config
                        ConfigIni.SetConfigDictionary(LoadConfig());

                        // calculate stats
                        MemoryStats.Refresh();
                    }
                }

                // chain to other OnConnected events
                OnConnected(caller);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message + ex.StackTrace);
                CanInteract    = false;
                MinimalMemboot = false;
            }
        }
Exemple #4
0
        public static void Shell_OnConnected(ISystemShell caller)
        {
            // set calling shell as current used shell and disable others
            Shell = caller;
            shells.ForEach(shell => { if (shell != caller)
                                      {
                                          shell.Enabled = false;
                                      }
                           });
            try
            {
                if (!Shell.IsOnline)
                {
                    throw new IOException("Shell connection should be online!");
                }
                DetectedConsoleType = ConsoleType.Unknown;

                MinimalMemboot = Shell.Execute("source /hakchi/config; [ \"$cf_memboot\" = \"y\" ]") == 0;
                UniqueID       = Shell.ExecuteSimple("hakchi hwid").Replace(" ", "");
                Trace.WriteLine($"Detected device unique ID: {UniqueID}");

                // execution stops here for a minimal memboot
                if (!MinimalMemboot)
                {
                    var versionExists = Shell.ExecuteSimple("[ -f /var/version ] && echo \"yes\"", 2000, true) == "yes";
                    if (versionExists)
                    {
                        var versions = Shell.ExecuteSimple("source /var/version && echo \"$bootVersion $kernelVersion $hakchiVersion\"", 2000, true).Split(' ');
                        RawBootVersion   = versions[0];
                        RawKernelVersion = versions[1];
                        RawScriptVersion = versions[2];
                        Trace.WriteLine($"Detected versions: boot {RawBootVersion}, kernel {RawKernelVersion}, script {RawScriptVersion}");

                        CanInteract = !SystemRequiresReflash() && !SystemRequiresRootfsUpdate();
                    }
                    else
                    {
                        RawBootVersion   = "1.0.0";
                        RawKernelVersion = "3.4.112-00";
                        RawScriptVersion = "v1.0.0-000";
                        Trace.WriteLine("Detected versions: severely outdated!");

                        CanInteract = false;
                    }

                    if (CanInteract)
                    {
                        // disable sync on legacy clovershell
                        CanSync = !(caller is ClovershellConnection);

                        // detect console firmware/type
                        SystemCode = Shell.ExecuteSimple("hakchi eval 'echo \"$sftype-$sfregion\"'", 2000, true).Trim();
                        if (SystemCodeToConsoleType.ContainsKey(SystemCode))
                        {
                            DetectedConsoleType = SystemCodeToConsoleType[SystemCode];
                        }
                        CustomFirmwareLoaded = Shell.ExecuteSimple("hakchi currentFirmware", 2000, true) != "_nand_";

                        // detect basic paths
                        RemoteGameSyncPath = Shell.ExecuteSimple("hakchi findGameSyncStorage", 2000, true).Trim();
                        OriginalGamesPath  = Shell.ExecuteSimple("hakchi get gamepath", 2000, true).Trim();
                        RootFsPath         = Shell.ExecuteSimple("hakchi get rootfs", 2000, true).Trim();
                        SquashFsPath       = Shell.ExecuteSimple("hakchi get squashfs", 2000, true).Trim();

                        // load config
                        ConfigIni.SetConfigDictionary(LoadConfig());

                        // calculate stats
                        MemoryStats.Refresh();
                    }
                }

                // chain to other OnConnected events
                Connected = Shell.IsOnline;
                OnConnected(caller);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message + ex.StackTrace);
                CanInteract    = false;
                MinimalMemboot = false;
            }
        }
 public void UpdateShell(ISystemShell shell)
 {
     this.shell = shell;
 }
 private NesMiniFileSystemHandler(string path, OS os, ISystemShell shell)
 {
     this.currentPath = path;
     this.os          = os;
     this.shell       = shell;
 }
 public NesMiniFileSystemHandler(ISystemShell shell)
     : this(shell, "/")
 {
 }
 public NesMiniFileSystemHandler(ISystemShell shell, string startPath)
 {
     os = OS.Unix;
     this.currentPath = startPath;
     this.shell       = shell;
 }
Exemple #9
0
 public void Shell_Connected(ISystemShell shell)
 {
     Visible = !hakchi.MinimalMemboot && hakchi.CanInteract && shell.Execute("which bluetoothctl") == 0;
 }