Exemplo n.º 1
0
        private async Task MakeBootable(WindowsVolumes volumes, RaspberryPi phone)
        {
            Log.Information("Making Windows installation bootable...");

            var bcdPath         = Path.Combine(volumes.Boot.RootDir.Name, "EFI", "Microsoft", "Boot", "BCD");
            var bcd             = new BcdInvoker(bcdPath);
            var windowsPath     = Path.Combine(volumes.Windows.RootDir.Name, "Windows");
            var bootDriveLetter = volumes.Boot.Letter;

            if (!bootDriveLetter.HasValue)
            {
                throw new DeploymentException("The Boot volume letter isn't accessible");
            }

            await ProcessUtils.RunProcessAsync(BcdBootPath, $@"{windowsPath} /f UEFI /s {bootDriveLetter}:");

            bcd.Invoke("/set {default} testsigning on");
            bcd.Invoke("/set {default} nointegritychecks on");
            await volumes.Boot.Partition.SetGptType(PartitionType.Esp);

            var updatedBootVolume = await phone.GetBootVolume();

            Log.Verbose("Updated Boot Volume: {@Volume}", new { updatedBootVolume.Label, updatedBootVolume.Partition, });
            if (!Equals(updatedBootVolume.Partition.PartitionType, PartitionType.Esp))
            {
                Log.Warning("The system partition should be {Esp}, but it's {ActualType}", PartitionType.Esp, updatedBootVolume.Partition.PartitionType);
            }
        }
Exemplo n.º 2
0
        private async Task MakeBootable(WindowsVolumes volumes, Phone phone, InstallOptions options)
        {
            Log.Information("Making Windows installation bootable...");

            var bcdPath         = Path.Combine(volumes.Boot.RootDir.Name, "EFI", "Microsoft", "Boot", "BCD");
            var bcd             = new BcdInvoker(bcdPath);
            var windowsPath     = Path.Combine(volumes.Windows.RootDir.Name, "Windows");
            var bootDriveLetter = volumes.Boot.Letter;
            await ProcessUtils.RunProcessAsync(BcdBootPath, $@"{windowsPath} /f UEFI /s {bootDriveLetter}:");

            bcd.Invoke("/set {default} testsigning on");
            bcd.Invoke("/set {default} nointegritychecks on");

            await PatchBootIfNecessary(volumes.Boot, options);

            await volumes.Boot.Partition.SetGptType(PartitionType.Esp);

            var updatedBootVolume = await phone.GetBootVolume();

            if (updatedBootVolume != null)
            {
                Log.Verbose("We shouldn't be able to get a reference to the Boot volume.");
                Log.Verbose("Updated Boot Volume: {@Volume}", new { updatedBootVolume.Label, updatedBootVolume.Partition, });
                if (!Equals(updatedBootVolume.Partition.PartitionType, PartitionType.Esp))
                {
                    Log.Warning("The system partition should be {Esp}, but it's {ActualType}", PartitionType.Esp, updatedBootVolume.Partition.PartitionType);
                }
            }
        }
Exemplo n.º 3
0
        private async Task EnableDualBoot()
        {
            Log.Verbose("Enabling Dual Boot...");

            await this.EnsureBootPartitionIs(PartitionType.Basic);

            var volume = await GetEfiespVolume();

            var bcdInvoker = new BcdInvoker(volume.GetBcdFullFilename());

            bcdInvoker.Invoke($@"/set {{{WinPhoneBcdGuid}}} description ""Windows 10 Phone""");
            bcdInvoker.Invoke($@"/displayorder {{{WinPhoneBcdGuid}}} /addfirst");
            bcdInvoker.Invoke($@"/default {{{WinPhoneBcdGuid}}}");

            Log.Verbose("Dual Boot enabled");
        }
Exemplo n.º 4
0
        private async Task EnableDualBoot()
        {
            Log.Information("Enabling Dual Boot...");

            var winPhoneBcdGuid = Guid.Parse("7619dcc9-fafe-11d9-b411-000476eba25f");

            var bootPartition = await GetBootPartition();

            await bootPartition.SetGptType(PartitionType.Basic);

            var volume = await GetEfiespVolume();

            var bcdInvoker = new BcdInvoker(volume.GetBcdFullFilename());

            bcdInvoker.Invoke($@"/set {{{winPhoneBcdGuid}}} description ""Windows 10 Phone""");
            bcdInvoker.Invoke($@"/displayorder {{{winPhoneBcdGuid}}} /addlast");

            Log.Information("Dual Boot enabled");
        }
Exemplo n.º 5
0
        private async Task DisableDualBoot()
        {
            Log.Verbose("Disabling Dual Boot...");

            await this.EnsureBootPartitionIs(PartitionType.Esp);

            var bcdInvoker = new BcdInvoker((await GetEfiespVolume()).GetBcdFullFilename());

            bcdInvoker.Invoke($@"/displayorder {{{WinPhoneBcdGuid}}} /remove");

            Log.Verbose("Dual Boot disabled");
        }
Exemplo n.º 6
0
        public async Task RemoveWindowsPhoneBcdEntry()
        {
            Log.Verbose("Removing Windows Phone BCD entry...");

            var efiespVolume = await GetEfiespVolume();

            var bcdInvoker = new BcdInvoker(efiespVolume.GetBcdFullFilename());

            bcdInvoker.Invoke($@"/displayorder {{{Phone.WinPhoneBcdGuid}}} /remove");

            Log.Verbose("Windows Phone BCD entry removed");
        }
Exemplo n.º 7
0
        private async Task DisableDualBoot()
        {
            Log.Information("Disabling Dual Boot...");

            var bootVolume = await GetBootVolume();

            await bootVolume.Partition.SetGptType(PartitionType.Esp);

            var bcdInvoker = new BcdInvoker((await GetEfiespVolume()).GetBcdFullFilename());

            bcdInvoker.Invoke($@"/displayorder {{{WinPhoneBcdGuid}}} /remove");

            Log.Information("Dual Boot disabled");
        }
Exemplo n.º 8
0
        private async Task AddDeveloperMenu(Volume efiespVolume)
        {
            Log.Information("Adding Development Menu...");

            var bcdInvoker = new BcdInvoker(efiespVolume.GetBcdFullFilename());

            new BcdConfigurator(bcdInvoker, efiespVolume).SetupBcd();

            var rootDir = efiespVolume.RootDir.Name;

            var destination = Path.Combine(rootDir, "Windows", "System32", "BOOT");
            await FileUtils.CopyDirectory(new DirectoryInfo(Path.Combine(rootFilesPath, "Developer Menu")), new DirectoryInfo(destination));

            var guid = FormattingUtils.GetGuid(bcdInvoker.Invoke(@"/create /d ""Developer Menu"" /application BOOTAPP"));

            bcdInvoker.Invoke($@"/set {{{guid}}} path \Windows\System32\BOOT\developermenu.efi");
            bcdInvoker.Invoke($@"/set {{{guid}}} device partition={rootDir}");
            bcdInvoker.Invoke($@"/set {{{guid}}} testsigning on");
            bcdInvoker.Invoke($@"/set {{{guid}}} nointegritychecks on");
            bcdInvoker.Invoke($@"/displayorder {{{guid}}} /addlast");
        }