Ejemplo n.º 1
0
        public string PerformPatch()
        {
            SafeDirectory.SetCurrentDirectory(MiscUtils.WORKING_FOLDER);

            UpdateProgress(0);

            IEnumerable <string> commands = GetCommands(_commandsText);

            foreach (var command in commands)
            {
                ExecuteCommand(command);
            }

            var fullOutputFileName = Path.Combine(SafeDirectory.GetCurrentDirectory(), MiscUtils.OUTPUT_FIRMWARE_NAME);

            SafeDirectory.SetCurrentDirectory(MiscUtils.OUTPUT_FOLDER_NAME);

            string currentDirectory = SafeDirectory.GetCurrentDirectory();

            ArchiveUtils.CreateSample(fullOutputFileName, null, MiscUtils.GetAllFileInFodler(currentDirectory));

            UpdateProgress(300);

            return(fullOutputFileName);
        }
Ejemplo n.º 2
0
        public override ICommandResult Execute(IDictionary <string, string> vars, params string[] args)
        {
            if (args.Length < 1)
            {
                return(Error("exec command can't be used without arguments (at least tool name must be specified)"));
            }

            SubstituteVariables(vars, args);

            var    exePath          = Path.Combine(@".\bin\", args[0]);
            string argsString       = string.Join(" ", args.Skip(1).ToArray());
            var    processStartInfo = new ProcessStartInfo()
            {
                FileName         = exePath,
                Arguments        = argsString,
                WindowStyle      = ProcessWindowStyle.Hidden,
                WorkingDirectory = SafeDirectory.GetCurrentDirectory(),
            };

            LogUtil.LogEvent(string.Format("Running process: {0}, args: {1} ", processStartInfo.FileName, processStartInfo.Arguments));
            var p = WinProcessUtil.StartNewProcess(processStartInfo);

            p.WaitForExit();
            if (p.ExitCode != 0)
            {
                return(Error(string.Format("Process: {0}, args: {1} exited with non-zero code", p.StartInfo.FileName, p.StartInfo.Arguments)));
            }

            return(Success());
        }
Ejemplo n.º 3
0
        public override ICommandResult Execute(IDictionary <string, string> vars, params string[] args)
        {
            if (args.Length != 2)
            {
                return(ArgsCountError(2, args));
            }

            SubstituteVariables(vars, args);

            string from = args[0];
            string to   = args[1];

            if (string.IsNullOrWhiteSpace(from))
            {
                return(Error("the source path was empty or white space"));
            }
            if (string.IsNullOrWhiteSpace(to))
            {
                return(Error("the destination path was empty or white space"));
            }

            SafeFile.Copy(Path.Combine(SafeDirectory.GetCurrentDirectory(), from),
                          Path.Combine(SafeDirectory.GetCurrentDirectory(), to));

            return(Success());
        }
 private void InitVersionsList()
 {
     KnownVersions = new List <FirmwareVersion>();
     string[] directories = SafeDirectory.GetDirectories(MiscUtils.PATCHES_DIRECTORY);
     foreach (var dir in directories)
     {
         string          commandsPath = Path.Combine(dir + @"\", MiscUtils.COMMANDS_FILE_NAME);
         FirmwareVersion version      = GetFirmwareVersion(commandsPath);
         KnownVersions.Add(version);
     }
 }
Ejemplo n.º 5
0
        private void RunTether()
        {
            RestoreDfuAndTetherFiles();

            SafeDirectory.SetCurrentDirectory(MiscUtils.BIN_DIRECTORY);

            LogUtil.LogEvent("Tether process starting");

            var p = WinProcessUtil.StartNewProcess();

            p.StartInfo.FileName = @"tether.exe";

            var files = new List <string>();

            if (File.Exists(MiscUtils.IBSS_FILE_NAME))
            {
                files.Add(MiscUtils.IBSS_FILE_NAME);
            }
            if (File.Exists(MiscUtils.IBEC_FILE_NAME))
            {
                files.Add(MiscUtils.IBEC_FILE_NAME);
            }
            if (File.Exists(MiscUtils.KERNEL_CACHE_FILE_NAME))
            {
                files.Add(MiscUtils.KERNEL_CACHE_FILE_NAME);
            }
            string arguments = string.Join(" ", files);

            p.StartInfo.Arguments = arguments;

            p.StartInfo.UseShellExecute  = false;
            p.StartInfo.CreateNoWindow   = true;
            p.StartInfo.WorkingDirectory = SafeDirectory.GetCurrentDirectory();

            p.StartInfo.RedirectStandardError  = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.OutputDataReceived += (sender, e) => HandleOutputData(e.Data);
            p.ErrorDataReceived  += (sender, e) => HandleOutputData(e.Data);

            p.Start();

            p.BeginOutputReadLine();
            p.BeginErrorReadLine();

            p.WaitForExit();

            if (p.ExitCode != 0)
            {
                var errorString = string.Format("Process: {0}, args: {1} exited with non-zero code", p.StartInfo.FileName, p.StartInfo.Arguments);
                LogUtil.LogEvent(errorString);
                throw new InvalidOperationException(errorString);
            }
        }
Ejemplo n.º 6
0
        private static void InitDocumentsHome()
        {
            if (!SafeDirectory.Exists(MiscUtils.DOCUMENTS_HOME))
            {
                SafeDirectory.CreateDirectory(MiscUtils.DOCUMENTS_HOME);
            }

            var downloadsFolder = Path.Combine(MiscUtils.DOCUMENTS_HOME, "Downloads");

            if (!SafeDirectory.Exists(downloadsFolder))
            {
                SafeDirectory.CreateDirectory(downloadsFolder);
            }
        }
Ejemplo n.º 7
0
        public string PerformPatch()
        {
            SafeDirectory.SetCurrentDirectory(MiscUtils.WORKING_FOLDER);

            UpdateProgress(0);

            var commands = GetCommands(_commandsText).ToList();

            foreach (var command in commands)
            {
                try
                {
                    var commandToExecute = command;

                    //TODO: this is strange but it fixes not being able to find the file for 5.3
                    if (command.Contains(@"$firmware.ipsw"))
                    {
                        commandToExecute = command.Replace("$", string.Empty);
                    }

                    ExecuteCommand(commandToExecute);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            var fullOutputFileName = Path.Combine(SafeDirectory.GetCurrentDirectory(), MiscUtils.OUTPUT_FIRMWARE_NAME);

            SafeDirectory.SetCurrentDirectory(MiscUtils.OUTPUT_FOLDER_NAME);

            string currentDirectory = SafeDirectory.GetCurrentDirectory();

            ArchiveUtils.CreateSample(fullOutputFileName, null, MiscUtils.GetAllFileInFodler(currentDirectory));

            UpdateProgress(300);

            return(fullOutputFileName);
        }
Ejemplo n.º 8
0
        private void RunDFU()
        {
            RestoreDFUFile();

            SafeDirectory.SetCurrentDirectory(MiscUtils.BIN_DIRECTORY);

            var files = new List <string>();

            if (SafeFile.Exists(MiscUtils.IBSS_FILE_NAME))
            {
                files.Add(MiscUtils.IBSS_FILE_NAME);
            }
            if (SafeFile.Exists(MiscUtils.IBEC_FILE_NAME))
            {
                files.Add(MiscUtils.IBEC_FILE_NAME);
            }
            string arguments = string.Join(" ", files);

            LogUtil.LogEvent(string.Format("DFU process starting for {0}", arguments));
            RunDFUProcess(arguments);
        }