Ejemplo n.º 1
0
        public async Task Deploy()
        {
            await phone.RemoveExistingWindowsPartitions();

            var options = optionsProvider.Options;

            await AllocateSpace(options.SizeReservedForWindows);

            var partitions = await CreatePartitions();

            await imageService.ApplyImage(await phone.GetWindowsVolume(), options.ImagePath, options.ImageIndex, options.UseCompact, progressObserver);

            await MakeBootable(partitions);
        }
Ejemplo n.º 2
0
        public async Task <string> Replace(string str)
        {
            IDictionary <string, Func <Task <string> > > mappings = new Dictionary <string, Func <Task <string> > >()
            {
                { @"\[EFIESP\]", async() =>
                  {
                      var volume = await phone.GetMainOsVolume();

                      return(Path.Combine(volume.Root, "EFIESP"));
                  } },
                { @"\[Windows\]", async() => (await phone.GetWindowsVolume()).Root },
                { @"\[MainOS\]", async() => (await phone.GetMainOsVolume()).Root },
                { @"\[System\]", async() => (await phone.GetSystemVolume()).Root },
            };

            foreach (var mapping in mappings)
            {
                if (Regex.IsMatch(str, mapping.Key))
                {
                    var mappingValue = await mapping.Value();

                    str = Regex.Replace(str, $"^{mapping.Key}", mappingValue, RegexOptions.IgnoreCase);
                    str = Regex.Replace(str, $@"\\+", @"\", RegexOptions.IgnoreCase);
                }
            }

            return(str);
        }
Ejemplo n.º 3
0
        public async Task <string> Replace(string str)
        {
            IDictionary <string, Func <Task <string> > > mappings = new Dictionary <string, Func <Task <string> > >()
            {
                { "EFIESP", async() => (await phone.GetEfiespVolume()).RootDir.Name },
                { "WindowsARM", async() => (await phone.GetWindowsVolume()).RootDir.Name },
            };

            var matching = mappings.Keys.FirstOrDefault(s => str.StartsWith(s, StringComparison.OrdinalIgnoreCase));

            if (matching != null)
            {
                var replacement = await mappings[matching]();
                var replaced    = Regex.Replace(str, $"^{matching}", replacement, RegexOptions.IgnoreCase);
                return(Regex.Replace(replaced, $@"\\+", @"\", RegexOptions.IgnoreCase));
            }

            return(str);
        }
        public async Task <string> Replace(string str)
        {
            IDictionary <string, Func <Task <string> > > mappings = new Dictionary <string, Func <Task <string> > >()
            {
                { @"\[EFIESP\]", async() => (await phone.GetVolumeByPartitionName(PartitionName.EfiEsp)).Root },
                { @"\[DPP\]", async() => (await phone.GetVolumeByPartitionName(PartitionName.Dpp)).Root },
                { @"\[Windows\]", async() => (await phone.GetWindowsVolume()).Root },
                { @"\[System\]", async() => (await phone.GetSystemVolume()).Root },
            };

            foreach (var mapping in mappings)
            {
                if (Regex.IsMatch(str, mapping.Key))
                {
                    var mappingValue = await mapping.Value();

                    str = Regex.Replace(str, $"^{mapping.Key}", mappingValue, RegexOptions.IgnoreCase);
                    str = Regex.Replace(str, $@"\\+", @"\", RegexOptions.IgnoreCase);
                }
            }

            return(str);
        }
        private async Task <WindowsVolumes> CreatePartitions()
        {
            Log.Verbose("Creating Windows partitions...");

            await(await phone.GetDeviceDisk()).CreateReservedPartition((ulong)ReservedPartitionSize.Bytes);

            var bootPartition = await(await phone.GetDeviceDisk()).CreatePartition((ulong)BootPartitionSize.Bytes);
            var bootVolume    = await bootPartition.GetVolume();

            await bootVolume.Mount();

            await bootVolume.Format(FileSystemFormat.Fat32, BootPartitionLabel);

            var windowsPartition = await(await phone.GetDeviceDisk()).CreatePartition(ulong.MaxValue);
            var winVolume        = await windowsPartition.GetVolume();

            await winVolume.Mount();

            await winVolume.Format(FileSystemFormat.Ntfs, WindowsPartitonLabel);

            Log.Verbose("Windows Partitions created successfully");

            return(new WindowsVolumes(await phone.GetBootVolume(), await phone.GetWindowsVolume()));
        }