… | |
… | |
19 | # along with this program. If not, see <https://www.gnu.org/licenses/>. |
19 | # along with this program. If not, see <https://www.gnu.org/licenses/>. |
20 | # |
20 | # |
21 | |
21 | |
22 | use 5.016; # numerous features need 5.14, __SUB__ needs 5.16 |
22 | use 5.016; # numerous features need 5.14, __SUB__ needs 5.16 |
23 | |
23 | |
24 | our $VERSION = '1.4'; |
24 | our $VERSION = '1.5'; |
25 | our $JSON_VERSION = 3; # the version of the json objects generated by this program |
25 | our $JSON_VERSION = 3; # the version of the json objects generated by this program |
26 | |
26 | |
27 | our $CHANGELOG = <<EOF; |
27 | our $CHANGELOG = <<EOF; |
28 | |
28 | |
|
|
29 | 1.5 Mon Nov 25 15:54:34 CET 2019 |
|
|
30 | - add "del" edit instruction. |
29 | - work around lsblk bug sometimes giving dos pttype for gpt partitions. |
31 | - work around lsblk bug sometimes giving "dos" pttype for gpt partitions. |
30 | - bootmenupolicy in synopsis must be set to 0 for text menu. |
32 | - bootmenupolicy in synopsis must be set to 0 to get the text menu. |
|
|
33 | - minor doc fxes. |
|
|
34 | - disable use of perldoc for help, doesn't work well. |
31 | |
35 | |
32 | 1.4 Thu Aug 22 10:48:22 CEST 2019 |
36 | 1.4 Thu Aug 22 10:48:22 CEST 2019 |
33 | - new "create" subcommand. |
37 | - new "create" subcommand. |
34 | - "create" and "edit" try to save and restore ownership/permissions |
38 | - "create" and "edit" try to save and restore ownership/permissions |
35 | of bcd hives when writing the new file. |
39 | of bcd hives when writing the new file. |
… | |
… | |
329 | |
333 | |
330 | =head2 The C<meta> key |
334 | =head2 The C<meta> key |
331 | |
335 | |
332 | The C<meta> key is not stored in the BCD data store but is used only |
336 | The C<meta> key is not stored in the BCD data store but is used only |
333 | by PBCDEDIT. It is always generated when exporting, and importing will |
337 | by PBCDEDIT. It is always generated when exporting, and importing will |
334 | be refused when it exists and the version stored inside doesn't store |
338 | be refused when it exists and the version stored inside doesn't match |
335 | the JSON schema version of PBCDEDIT. This ensures that different and |
339 | the JSON schema version of PBCDEDIT. This ensures that different and |
336 | incompatible versions of PBCDEDIT will not read and misinterpret each |
340 | incompatible versions of PBCDEDIT will not read and misinterpret each |
337 | others data. |
341 | others data. |
338 | |
342 | |
339 | =head2 The object keys |
343 | =head2 The object keys |
… | |
… | |
348 | |
352 | |
349 | Some of these GUIDs are fixed well known GUIDs which PBCDEDIT will decode |
353 | Some of these GUIDs are fixed well known GUIDs which PBCDEDIT will decode |
350 | into human-readable strings such as C<{globalsettings}>, which is the same |
354 | into human-readable strings such as C<{globalsettings}>, which is the same |
351 | as C<{7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}>. |
355 | as C<{7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}>. |
352 | |
356 | |
353 | Each BCD, object has an associated type. For example, |
357 | Each BCD object has an associated type. For example, |
354 | C<application::osloader> for objects loading Windows via F<winload.exe>, |
358 | C<application::osloader> for objects loading Windows via F<winload.exe>, |
355 | C<application::bootsector> for real mode applications and so on. |
359 | C<application::bootsector> for real mode applications and so on. |
356 | |
360 | |
357 | The type of a object is stored in the pseudo BCD element C<type> (see next |
361 | The type of a object is stored in the pseudo BCD element C<type> (see next |
358 | section). |
362 | section). |
… | |
… | |
509 | [{GUID}]type[<flags>][=arg,arg...] |
513 | [{GUID}]type[<flags>][=arg,arg...] |
510 | |
514 | |
511 | Here are some examples: |
515 | Here are some examples: |
512 | |
516 | |
513 | boot |
517 | boot |
514 | {b097d29f-bc00-11e9-8a9a-525400123456}block=file,<boot>,\\EFI" |
518 | {b097d29f-bc00-11e9-8a9a-525400123456}block=file,<boot>,\EFI |
515 | locate=<null>,element,systemroot |
519 | locate=<null>,element,systemroot |
516 | partition=<null>,harddisk,mbr,47cbc08a,1048576 |
520 | partition=<null>,harddisk,mbr,47cbc08a,1048576 |
517 | partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,76d39e5f-ad1b-407e-9c05-c81eb83b57dd |
521 | partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,76d39e5f-ad1b-407e-9c05-c81eb83b57dd |
518 | block<1>=ramdisk,<partition=<null>,harddisk,mbr,47cbc08a,68720525312>,0,0,0,\Recovery\b097d29e-bc00-11e9-8a9a-525400123456\Winre.wim |
522 | block<1>=ramdisk,<partition=<null>,harddisk,mbr,47cbc08a,68720525312>,0,0,0,\Recovery\b097d29e-bc00-11e9-8a9a-525400123456\Winre.wim |
519 | block=file,<partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,ee3a393a-f0de-4057-9946-88584245ed48>,\ |
523 | block=file,<partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,ee3a393a-f0de-4057-9946-88584245ed48>,\ |
… | |
… | |
709 | |
713 | |
710 | Probably not yet implemented. Tell me of your needs... |
714 | Probably not yet implemented. Tell me of your needs... |
711 | |
715 | |
712 | =back |
716 | =back |
713 | |
717 | |
|
|
718 | =back |
|
|
719 | |
714 | =head4 Examples |
720 | =head4 Examples |
715 | |
721 | |
716 | This concludes the syntax overview for device elements, but probably |
722 | This concludes the syntax overview for device elements, but probably |
717 | leaves many questions open. I can't help with most of them, as I also have |
723 | leaves many questions open. I can't help with most of them, as I also have |
718 | many questions, but I can walk you through some actual examples using more |
724 | many questions, but I can walk you through some actual examples using more |
719 | complex aspects. |
725 | complex aspects. |
|
|
726 | |
|
|
727 | =over |
720 | |
728 | |
721 | =item C<< locate=<block=vhd,<block=file,<locate=<null>,path,\disk.vhdx>,\disk.vhdx>>,element,path >> |
729 | =item C<< locate=<block=vhd,<block=file,<locate=<null>,path,\disk.vhdx>,\disk.vhdx>>,element,path >> |
722 | |
730 | |
723 | Just like with C declarations, you best treat device descriptors as |
731 | Just like with C declarations, you best treat device descriptors as |
724 | instructions to find your device and work your way from the inside out: |
732 | instructions to find your device and work your way from the inside out: |
… | |
… | |
796 | I don't know what the purpose of the C<< <1> >> flag value is, but it |
804 | I don't know what the purpose of the C<< <1> >> flag value is, but it |
797 | seems to be always there on this kind of entry. |
805 | seems to be always there on this kind of entry. |
798 | |
806 | |
799 | If you have some good examples to add here, feel free to mail me. |
807 | If you have some good examples to add here, feel free to mail me. |
800 | |
808 | |
|
|
809 | =back |
|
|
810 | |
801 | |
811 | |
802 | =head1 EDITING BCD STORES |
812 | =head1 EDITING BCD STORES |
803 | |
813 | |
804 | The C<edit> and C<parse> subcommands allow you to read a BCD data store |
814 | The C<edit> and C<parse> subcommands allow you to read a BCD data store |
805 | and modify it or extract data from it. This is done by executing a series |
815 | and modify it or extract data from it. This is done by executing a series |
… | |
… | |
824 | |
834 | |
825 | Example: change the bootmgr default too |
835 | Example: change the bootmgr default too |
826 | C<{b097d2ad-bc00-11e9-8a9a-525400123456}>: |
836 | C<{b097d2ad-bc00-11e9-8a9a-525400123456}>: |
827 | |
837 | |
828 | pbcdedit edit BCD set "{bootmgr}" default "{b097d2ad-bc00-11e9-8a9a-525400123456}" |
838 | pbcdedit edit BCD set "{bootmgr}" default "{b097d2ad-bc00-11e9-8a9a-525400123456}" |
|
|
839 | |
|
|
840 | =item C<del> I<object> I<element> |
|
|
841 | |
|
|
842 | Similar to C<get>, but removed the BCD element from the specified BCD object. |
829 | |
843 | |
830 | =item C<eval> I<perlcode> |
844 | =item C<eval> I<perlcode> |
831 | |
845 | |
832 | This takes the next argument, interprets it as Perl code and |
846 | This takes the next argument, interprets it as Perl code and |
833 | evaluates it. This allows you to do more complicated modifications or |
847 | evaluates it. This allows you to do more complicated modifications or |
… | |
… | |
2468 | |
2482 | |
2469 | $object = $object eq "{default}" ? $default : dec_wguid enc_wguid $object; |
2483 | $object = $object eq "{default}" ? $default : dec_wguid enc_wguid $object; |
2470 | |
2484 | |
2471 | $bcd->{$object}{$elem} = $value; |
2485 | $bcd->{$object}{$elem} = $value; |
2472 | |
2486 | |
|
|
2487 | } elsif ($insn eq "del") { |
|
|
2488 | my $object = shift @insns; |
|
|
2489 | my $elem = shift @insns; |
|
|
2490 | |
|
|
2491 | $object = $object eq "{default}" ? $default : dec_wguid enc_wguid $object; |
|
|
2492 | |
|
|
2493 | delete $bcd->{$object}{$elem}; |
|
|
2494 | |
2473 | } elsif ($insn eq "eval") { |
2495 | } elsif ($insn eq "eval") { |
2474 | my $perl = shift @insns; |
2496 | my $perl = shift @insns; |
2475 | bcd_edit_eval "#line 1 'eval'\n$perl"; |
2497 | bcd_edit_eval "#line 1 'eval'\n$perl"; |
2476 | |
2498 | |
2477 | } elsif ($insn eq "do") { |
2499 | } elsif ($insn eq "do") { |
2478 | my $path = shift @insns; |
2500 | my $path = shift @insns; |
2479 | my $file = file_load $path; |
2501 | my $file = file_load $path; |
2480 | bcd_edit_eval "#line 1 '$path'\n$file"; |
2502 | bcd_edit_eval "#line 1 '$path'\n$file"; |
2481 | |
2503 | |
2482 | } else { |
2504 | } else { |
2483 | die "$insn: not a recognized instruction for edit/parse\n"; |
2505 | die "$insn: not a recognized instruction for create/edit/parse\n"; |
2484 | } |
2506 | } |
2485 | } |
2507 | } |
2486 | |
2508 | |
2487 | } |
2509 | } |
2488 | |
2510 | |
… | |
… | |
2551 | # command line parser |
2573 | # command line parser |
2552 | |
2574 | |
2553 | our %CMD = ( |
2575 | our %CMD = ( |
2554 | help => sub { |
2576 | help => sub { |
2555 | require Pod::Usage; |
2577 | require Pod::Usage; |
2556 | Pod::Usage::pod2usage (-verbose => 2); |
2578 | Pod::Usage::pod2usage (-verbose => 2, -quotes => "none", -noperldoc => 1); |
2557 | }, |
2579 | }, |
2558 | |
2580 | |
2559 | objects => sub { |
2581 | objects => sub { |
2560 | my %rbcd_types = reverse %bcd_types; |
2582 | my %rbcd_types = reverse %bcd_types; |
2561 | $_ = sprintf "%08x", $_ for values %rbcd_types; |
2583 | $_ = sprintf "%08x", $_ for values %rbcd_types; |