… | |
… | |
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.2'; |
24 | our $VERSION = '1.4'; |
25 | our $JSON_VERSION = 2; # 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 | |
|
|
29 | - work around lsblk bug sometimes giving "dos" pttype for gpt partitions. |
|
|
30 | - bootmenupolicy in synopsis must be set to 0 for text menu. |
|
|
31 | - minor doc fxes. |
|
|
32 | |
|
|
33 | 1.4 Thu Aug 22 10:48:22 CEST 2019 |
|
|
34 | - new "create" subcommand. |
|
|
35 | - "create" and "edit" try to save and restore ownership/permissions |
|
|
36 | of bcd hives when writing the new file. |
|
|
37 | - editorial fixes to the documentation. |
|
|
38 | - add mininmal hive creation example. |
|
|
39 | |
|
|
40 | 1.3 Sat Aug 17 07:04:15 CEST 2019 |
|
|
41 | - output of pbcdedit elements --json has changed, as it didn't |
|
|
42 | take the reorganisation by classes fully into account. |
|
|
43 | - json schema bumped to 3. |
|
|
44 | - new "bcd-device" and "bcd-legacy-device" subcommands. |
|
|
45 | - implement --json option for lsblk. |
|
|
46 | |
28 | 1.2 Fri Aug 16 00:20:41 CEST 2019 |
47 | 1.2 Fri Aug 16 00:20:41 CEST 2019 |
29 | - bcde element names now depend on the bcd object type they are in, |
48 | - bcd element names now depend on the bcd object type they are in, |
30 | also affects "elements" output. |
49 | also affects "elements" output. |
31 | - json schema bumped to 2. |
50 | - json schema bumped to 2. |
32 | - new version command. |
51 | - new version command. |
33 | - numerous minor bugfixes. |
52 | - numerous minor bugfixes. |
34 | |
53 | |
… | |
… | |
48 | pbcdedit edit path/to/BCD edit-instructions... |
67 | pbcdedit edit path/to/BCD edit-instructions... |
49 | |
68 | |
50 | pbcdedit objects # list all supported object aliases and types |
69 | pbcdedit objects # list all supported object aliases and types |
51 | pbcdedit elements # list all supported bcd element aliases |
70 | pbcdedit elements # list all supported bcd element aliases |
52 | |
71 | |
|
|
72 | # Example: enable text-based boot menu. |
|
|
73 | pbcdedit edit /my/BCD set '{default}' bootmenupolicy 0 |
|
|
74 | |
|
|
75 | # Example change system device to first partition containing winload. |
|
|
76 | pbcdedit edit /my/BCD \ |
|
|
77 | set '{default}' device 'locate=<null>,element,path' \ |
|
|
78 | set '{default}' osdevice 'locate=<null>,element,path' |
|
|
79 | |
|
|
80 | |
53 | =head1 DESCRIPTION |
81 | =head1 DESCRIPTION |
54 | |
82 | |
55 | This program allows you to create, read and modify Boot Configuration Data |
83 | This program allows you to create, read and modify Boot Configuration Data |
56 | (BCD) stores used by Windows Vista and newer versions of Windows. |
84 | (BCD) stores used by Windows Vista and newer versions of Windows. |
57 | |
85 | |
… | |
… | |
136 | =item C<parse> F<path> I<instructions...> |
164 | =item C<parse> F<path> I<instructions...> |
137 | |
165 | |
138 | Same as C<edit>, above, except it doesn't save the data store again. Can |
166 | Same as C<edit>, above, except it doesn't save the data store again. Can |
139 | be useful to extract some data from it. |
167 | be useful to extract some data from it. |
140 | |
168 | |
141 | =item C<lsblk> |
169 | =item C<create> F<path> I<instructions...> |
|
|
170 | |
|
|
171 | Same as C<edit>, above, except it creates a new data store from scratch if |
|
|
172 | needed. An existing store will be emptied completely. |
|
|
173 | |
|
|
174 | =item C<lsblk> [C<--json>] |
142 | |
175 | |
143 | On a GNU/Linux system, you can get a list of partition device descriptors |
176 | On a GNU/Linux system, you can get a list of partition device descriptors |
144 | using this command - the external C<lsblk> command is required, as well as |
177 | using this command - the external C<lsblk> command is required, as well as |
145 | a mounted C</sys> file system. |
178 | a mounted C</sys> file system. |
146 | |
179 | |
147 | The output will be a list of all partitions in the system and C<partition> |
180 | The output will be a list of all partitions in the system and C<partition> |
148 | descriptors for GPT and both C<legacypartition> and C<partition> |
181 | descriptors for GPT and both C<legacypartition> and C<partition> |
149 | descriptors for MBR partitions. |
182 | descriptors for MBR partitions. |
|
|
183 | |
|
|
184 | With C<--json> it will print similar information as C<lsblk --json>, but |
|
|
185 | with extra C<bcd_device> and C<bcd_legacy_device> attributes. |
|
|
186 | |
|
|
187 | =item C<bcd-device> F<path> |
|
|
188 | |
|
|
189 | Tries to find the BCD device element for the given device, which currently |
|
|
190 | must be a a partition of some kind. Prints the C<partition=> descriptor as |
|
|
191 | a result, or nothing. Exit status will be true on success, and false on |
|
|
192 | failure. |
|
|
193 | |
|
|
194 | Like C<lsblk>, above, this likely only works on GNU/Linux systems. |
|
|
195 | |
|
|
196 | Example: print the partition descriptor of tghe partition with label DATA. |
|
|
197 | |
|
|
198 | $ pbcdedit bcd-device /dev/disk/by-label/DATA |
|
|
199 | partition=<null>,harddisk,mbr,47cbc08a,213579202560 |
|
|
200 | |
|
|
201 | =item C<bcd-legacy-device> F<path> |
|
|
202 | |
|
|
203 | Like above, but uses a C<legacypartition> descriptor instead. |
150 | |
204 | |
151 | =item C<objects> [C<--json>] |
205 | =item C<objects> [C<--json>] |
152 | |
206 | |
153 | Outputs two tables: a table listing all type aliases with their hex BCD |
207 | Outputs two tables: a table listing all type aliases with their hex BCD |
154 | element ID, and all object name aliases with their GUID and default type |
208 | element ID, and all object name aliases with their GUID and default type |
… | |
… | |
256 | |
310 | |
257 | Note that minimal doesn't mean recommended - Windows itself will add stuff |
311 | Note that minimal doesn't mean recommended - Windows itself will add stuff |
258 | to this during or after boot, and you might or might not run into issues |
312 | to this during or after boot, and you might or might not run into issues |
259 | when installing updates as it might not be able to find the F<bootmgr>. |
313 | when installing updates as it might not be able to find the F<bootmgr>. |
260 | |
314 | |
|
|
315 | This is how you would create a minimal hive with PBCDEDIT from within |
|
|
316 | GNU/Linux, assuming F</dev/sdc3> is the windows partition, using |
|
|
317 | a random GUID for the osloader and using C<partition> instead of |
|
|
318 | C<legacypartition>: |
|
|
319 | |
|
|
320 | osldr="{$(uuidgen)}" |
|
|
321 | part=$(pbcdedit bcd-device /dev/sdc3) |
|
|
322 | pbcdedit create minimal.bcd \ |
|
|
323 | set '{bootmgr}' default "$osldr" \ |
|
|
324 | set "$osldr" type application::osloader \ |
|
|
325 | set "$osldr" description 'Windows Boot' \ |
|
|
326 | set "$osldr" device "$part" \ |
|
|
327 | set "$osldr" osdevice "$part" \ |
|
|
328 | set "$osldr" path '\Windows\system32\winload.exe' \ |
|
|
329 | set "$osldr" systemroot '\Windows' |
|
|
330 | |
261 | =head2 The C<meta> key |
331 | =head2 The C<meta> key |
262 | |
332 | |
263 | The C<meta> key is not stored in the BCD data store but is used only |
333 | The C<meta> key is not stored in the BCD data store but is used only |
264 | by PBCDEDIT. It is always generated when exporting, and importing will |
334 | by PBCDEDIT. It is always generated when exporting, and importing will |
265 | be refused when it exists and the version stored inside doesn't store |
335 | be refused when it exists and the version stored inside doesn't store |
… | |
… | |
352 | |
422 | |
353 | "displaybootmenu" : 0, |
423 | "displaybootmenu" : 0, |
354 | |
424 | |
355 | =item integer |
425 | =item integer |
356 | |
426 | |
357 | Again, very simple, this is a 64 bit integer. IT can be either specified |
427 | Again, very simple, this is a 64 bit integer. It can be either specified |
358 | as a decimal number, as a hex number (by prefixing it with C<0x>) or as a |
428 | as a decimal number, as a hex number (by prefixing it with C<0x>) or as a |
359 | binary number (prefix C<0b>). |
429 | binary number (prefix C<0b>). |
360 | |
430 | |
361 | For example, the boot C<timeout> is an integer, specifying the automatic |
431 | For example, the boot C<timeout> is an integer, specifying the automatic |
362 | boot delay in seconds: |
432 | boot delay in seconds: |
… | |
… | |
364 | "timeout" : 30, |
434 | "timeout" : 30, |
365 | |
435 | |
366 | =item integer list |
436 | =item integer list |
367 | |
437 | |
368 | This is a list of 64 bit integers separated by whitespace. It is not used |
438 | This is a list of 64 bit integers separated by whitespace. It is not used |
369 | much, so here is a somewhat artificial an untested example of using |
439 | much, so here is a somewhat artificial and untested example of using |
370 | C<customactions> to specify a certain custom, eh, action to be executed |
440 | C<customactions> to specify a certain custom, eh, action to be executed |
371 | when pressing C<F10> at boot: |
441 | when pressing C<F10> at boot: |
372 | |
442 | |
373 | "customactions" : "0x1000044000001 0x54000001", |
443 | "customactions" : "0x1000044000001 0x54000001", |
374 | |
444 | |
… | |
… | |
402 | This type is why I write I<most> are easy to explain earlier: This type |
472 | This type is why I write I<most> are easy to explain earlier: This type |
403 | is the pinnacle of Microsoft-typical hacks layered on top of other |
473 | is the pinnacle of Microsoft-typical hacks layered on top of other |
404 | hacks. Understanding this type took more time than writing all the rest of |
474 | hacks. Understanding this type took more time than writing all the rest of |
405 | PBCDEDIT, and because it is so complex, this type has its own subsection |
475 | PBCDEDIT, and because it is so complex, this type has its own subsection |
406 | below. |
476 | below. |
|
|
477 | |
407 | =back |
478 | =back |
408 | |
479 | |
409 | =head4 The BCD "device" element type |
480 | =head3 The BCD "device" element type |
410 | |
481 | |
411 | Device elements specify, well, devices. They are used for such diverse |
482 | Device elements specify, well, devices. They are used for such diverse |
412 | purposes such as finding a TFTP network boot image, serial ports or VMBUS |
483 | purposes such as finding a TFTP network boot image, serial ports or VMBUS |
413 | devices, but most commonly they are used to specify the disk (harddisk, |
484 | devices, but most commonly they are used to specify the disk (harddisk, |
414 | cdrom, ramdisk, vhd...) to boot from. |
485 | cdrom, ramdisk, vhd...) to boot from. |
… | |
… | |
422 | element, so almost everything known about it had to be researched first |
493 | element, so almost everything known about it had to be researched first |
423 | in the process of writing this script, and consequently, support for BCD |
494 | in the process of writing this script, and consequently, support for BCD |
424 | device elements is partial only. |
495 | device elements is partial only. |
425 | |
496 | |
426 | On the other hand, the expressive power of PBCDEDIT in specifying devices |
497 | On the other hand, the expressive power of PBCDEDIT in specifying devices |
427 | is much bigger than BCDEDIT and therefore more can be done with it. The |
498 | is much greater than BCDEDIT and therefore more can be done with it. The |
428 | downside is that BCD device elements are much more complicated than what |
499 | downside is that BCD device elements are much more complicated than what |
429 | you might think from reading the BCDEDIT documentation. |
500 | you might think from reading the BCDEDIT documentation. |
430 | |
501 | |
431 | In other words, simple things are complicated, and complicated things are |
502 | In other words, simple things are complicated, and complicated things are |
432 | possible. |
503 | possible. |
… | |
… | |
439 | [{GUID}]type[<flags>][=arg,arg...] |
510 | [{GUID}]type[<flags>][=arg,arg...] |
440 | |
511 | |
441 | Here are some examples: |
512 | Here are some examples: |
442 | |
513 | |
443 | boot |
514 | boot |
444 | {b097d29f-bc00-11e9-8a9a-525400123456}block=file,<boot>,\\EFI" |
515 | {b097d29f-bc00-11e9-8a9a-525400123456}block=file,<boot>,\EFI |
445 | locate=<null>,element,systemroot |
516 | locate=<null>,element,systemroot |
446 | partition=<null>,harddisk,mbr,47cbc08a,1048576 |
517 | partition=<null>,harddisk,mbr,47cbc08a,1048576 |
447 | partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,76d39e5f-ad1b-407e-9c05-c81eb83b57dd |
518 | partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,76d39e5f-ad1b-407e-9c05-c81eb83b57dd |
448 | block<1>=ramdisk,<partition=<null>,harddisk,mbr,47cbc08a,68720525312>,0,0,0,\Recovery\b097d29e-bc00-11e9-8a9a-525400123456\Winre.wim |
519 | block<1>=ramdisk,<partition=<null>,harddisk,mbr,47cbc08a,68720525312>,0,0,0,\Recovery\b097d29e-bc00-11e9-8a9a-525400123456\Winre.wim |
449 | block=file,<partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,ee3a393a-f0de-4057-9946-88584245ed48>,\ |
520 | block=file,<partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,ee3a393a-f0de-4057-9946-88584245ed48>,\ |
… | |
… | |
475 | the leading GUID, which it can always decode). In such cases, it will |
546 | the leading GUID, which it can always decode). In such cases, it will |
476 | convert the device into this type with a hexdump of the element data. |
547 | convert the device into this type with a hexdump of the element data. |
477 | |
548 | |
478 | =item C<null> |
549 | =item C<null> |
479 | |
550 | |
480 | This is another special type - sometimes, a device all zero-filled, which |
551 | This is another special type - sometimes, a device is all zero-filled, |
481 | is not valid. This can mark the absence of a device or something PBCDEDIT |
552 | which is not valid. This can mark the absence of a device or something |
482 | does not understand, so it decodes it into this special "all zero" type |
553 | PBCDEDIT does not understand, so it decodes it into this special "all |
483 | called C<null>. |
554 | zero" type called C<null>. |
484 | |
555 | |
485 | It's most commonly found in devices that can use an optional parent |
556 | It's most commonly found in devices that can use an optional parent |
486 | device, when no parent device is used. |
557 | device, when no parent device is used. |
487 | |
558 | |
488 | =item C<boot> |
559 | =item C<boot> |
… | |
… | |
599 | |
670 | |
600 | Last not least, the most complex type, C<block>, which... specifies block |
671 | Last not least, the most complex type, C<block>, which... specifies block |
601 | devices (which could be inside a F<vhdx> file for example). |
672 | devices (which could be inside a F<vhdx> file for example). |
602 | |
673 | |
603 | I<devicetypes> is one of C<harddisk>, C<floppy>, C<cdrom>, C<ramdisk>, |
674 | I<devicetypes> is one of C<harddisk>, C<floppy>, C<cdrom>, C<ramdisk>, |
604 | C<file> or C<vhd> - the same as for C<partiion=>. |
675 | C<file> or C<vhd> - the same as for C<partition=>. |
605 | |
676 | |
606 | The remaining arguments change depending on the I<devicetype>: |
677 | The remaining arguments change depending on the I<devicetype>: |
607 | |
678 | |
608 | =over |
679 | =over |
609 | |
680 | |
… | |
… | |
639 | |
710 | |
640 | Probably not yet implemented. Tell me of your needs... |
711 | Probably not yet implemented. Tell me of your needs... |
641 | |
712 | |
642 | =back |
713 | =back |
643 | |
714 | |
644 | =back5 Examples |
715 | =head4 Examples |
645 | |
716 | |
646 | This concludes the syntax overview for device elements, but probably |
717 | This concludes the syntax overview for device elements, but probably |
647 | leaves many questions open. I can't help with most of them, as I also ave |
718 | leaves many questions open. I can't help with most of them, as I also have |
648 | many questions, but I can walk you through some actual examples using more |
719 | many questions, but I can walk you through some actual examples using more |
649 | complex aspects. |
720 | complex aspects. |
650 | |
721 | |
651 | =item C<< locate=<block=vhd,<block=file,<locate=<null>,path,\disk.vhdx>,\disk.vhdx>>,element,path >> |
722 | =item C<< locate=<block=vhd,<block=file,<locate=<null>,path,\disk.vhdx>,\disk.vhdx>>,element,path >> |
652 | |
723 | |
… | |
… | |
866 | sub xxd($$) { |
937 | sub xxd($$) { |
867 | open my $xxd, "| xxd | sed -e 's/^/\Q$_[0]\E: /'"; |
938 | open my $xxd, "| xxd | sed -e 's/^/\Q$_[0]\E: /'"; |
868 | syswrite $xxd, $_[1]; |
939 | syswrite $xxd, $_[1]; |
869 | } |
940 | } |
870 | |
941 | |
|
|
942 | # get some meta info on a file (uid, gid, perms) |
|
|
943 | sub stat_get($) { |
|
|
944 | [(stat shift)[4, 5, 2]] |
|
|
945 | } |
|
|
946 | |
|
|
947 | # set stat info on a file |
|
|
948 | sub stat_set($$) { |
|
|
949 | my ($fh_or_path, $stat) = @_; |
|
|
950 | |
|
|
951 | return unless $stat; |
|
|
952 | chown $stat->[0], $stat->[1], $fh_or_path; |
|
|
953 | chmod +($stat->[2] & 07777), $fh_or_path; |
|
|
954 | } |
|
|
955 | |
871 | sub file_load($) { |
956 | sub file_load($) { |
872 | my ($path) = @_; |
957 | my ($path) = @_; |
873 | |
958 | |
874 | open my $fh, "<:raw", $path |
959 | open my $fh, "<:raw", $path |
875 | or die "$path: $!\n"; |
960 | or die "$path: $!\n"; |
876 | my $size = -s $fh; |
961 | my $size = -s $fh; |
877 | $size = read $fh, my $buf, $size |
962 | $size = read $fh, my $buf, $size |
878 | or die "$path: short read\n"; |
963 | or die "$path: short read\n"; |
879 | |
964 | |
880 | $buf |
965 | $buf |
|
|
966 | } |
|
|
967 | |
|
|
968 | sub file_save($$;$) { |
|
|
969 | my ($path, $data, $stat) = @_; |
|
|
970 | |
|
|
971 | open my $fh, ">:raw", "$path~" |
|
|
972 | or die "$path~: $!\n"; |
|
|
973 | print $fh $data |
|
|
974 | or die "$path~: short write\n"; |
|
|
975 | stat_set $fh, $stat; |
|
|
976 | $fh->sync; |
|
|
977 | close $fh; |
|
|
978 | |
|
|
979 | rename "$path~", $path; |
881 | } |
980 | } |
882 | |
981 | |
883 | # sources and resources used for writing pbcdedit |
982 | # sources and resources used for writing pbcdedit |
884 | # |
983 | # |
885 | # registry: |
984 | # registry: |
… | |
… | |
1071 | my ($rname, $root) = $decode_key->($rootcell); |
1170 | my ($rname, $root) = $decode_key->($rootcell); |
1072 | |
1171 | |
1073 | [$rname, $root] |
1172 | [$rname, $root] |
1074 | } |
1173 | } |
1075 | |
1174 | |
1076 | # return a binary windows fILETIME struct |
1175 | # return a binary windows FILETIME struct |
1077 | sub filetime_now { |
1176 | sub filetime_now { |
1078 | my ($s, $ms) = Time::HiRes::gettimeofday; |
1177 | my ($s, $ms) = Time::HiRes::gettimeofday; |
1079 | |
1178 | |
1080 | pack "Q<", $s = ($s * 1_000_000 + $ms) * 10 + 116_444_736_000_000_000 |
1179 | pack "Q<", ($s * 1_000_000 + $ms) * 10 |
|
|
1180 | + 116_444_736_000_000_000 # 1970-01-01 00:00:00 |
1081 | } |
1181 | } |
1082 | |
1182 | |
1083 | # encode a registry hive |
1183 | # encode a registry hive |
1084 | sub regf_encode($) { |
1184 | sub regf_encode($) { |
1085 | my ($hive) = @_; |
1185 | my ($hive) = @_; |
… | |
… | |
1088 | |
1188 | |
1089 | # the filetime is apparently used to verify log file validity, |
1189 | # the filetime is apparently used to verify log file validity, |
1090 | # so by generating a new timestamp the log files *should* automatically |
1190 | # so by generating a new timestamp the log files *should* automatically |
1091 | # become invalidated and windows would "self-heal" them. |
1191 | # become invalidated and windows would "self-heal" them. |
1092 | # (update: has been verified by reverse engineering) |
1192 | # (update: has been verified by reverse engineering) |
1093 | # possibly the fact that the two sequence numbes match might also |
1193 | # possibly the fact that the two sequence numbers match might also |
1094 | # make windows think that the hive is not dirty and ignore logs. |
1194 | # make windows think that the hive is not dirty and ignore logs. |
1095 | # (update: has been verified by reverse engineering) |
1195 | # (update: has been verified by reverse engineering) |
1096 | |
1196 | |
1097 | my $now = filetime_now; |
1197 | my $now = filetime_now; |
1098 | |
1198 | |
… | |
… | |
1242 | |
1342 | |
1243 | regf_decode file_load $path |
1343 | regf_decode file_load $path |
1244 | } |
1344 | } |
1245 | |
1345 | |
1246 | # encode and save registry to file |
1346 | # encode and save registry to file |
1247 | sub regf_save { |
1347 | sub regf_save($$;$) { |
1248 | my ($path, $hive) = @_; |
1348 | my ($path, $hive, $stat) = @_; |
1249 | |
1349 | |
1250 | $hive = regf_encode $hive; |
1350 | $hive = regf_encode $hive; |
1251 | |
1351 | |
1252 | open my $regf, ">:raw", "$path~" |
1352 | file_save $path, $hive, $stat; |
1253 | or die "$path~: $!\n"; |
|
|
1254 | print $regf $hive |
|
|
1255 | or die "$path~: short write\n"; |
|
|
1256 | $regf->sync; |
|
|
1257 | close $regf; |
|
|
1258 | |
|
|
1259 | rename "$path~", $path; |
|
|
1260 | } |
1353 | } |
1261 | |
1354 | |
1262 | ############################################################################# |
1355 | ############################################################################# |
1263 | # bcd stuff |
1356 | # bcd stuff |
1264 | |
1357 | |
1265 | # human-readable alises for GUID object identifiers |
1358 | # human-readable aliases for GUID object identifiers |
1266 | our %bcd_objects = ( |
1359 | our %bcd_objects = ( |
1267 | '{0ce4991b-e6b3-4b16-b23c-5e0d9250e5d9}' => '{emssettings}', |
1360 | '{0ce4991b-e6b3-4b16-b23c-5e0d9250e5d9}' => '{emssettings}', |
1268 | '{1afa9c49-16ab-4a5c-4a90-212802da9460}' => '{resumeloadersettings}', |
1361 | '{1afa9c49-16ab-4a5c-4a90-212802da9460}' => '{resumeloadersettings}', |
1269 | '{1cae1eb7-a0df-4d4d-9851-4860e34ef535}' => '{default}', |
1362 | '{1cae1eb7-a0df-4d4d-9851-4860e34ef535}' => '{default}', |
1270 | '{313e8eed-7098-4586-a9bf-309c61f8d449}' => '{kerneldbgsettings}', |
1363 | '{313e8eed-7098-4586-a9bf-309c61f8d449}' => '{kerneldbgsettings}', |
… | |
… | |
1400 | BCDE_FORMAT_STRING , sub { shift }, |
1493 | BCDE_FORMAT_STRING , sub { shift }, |
1401 | BCDE_FORMAT_GUID , sub { dec_wguid enc_wguid shift }, |
1494 | BCDE_FORMAT_GUID , sub { dec_wguid enc_wguid shift }, |
1402 | BCDE_FORMAT_GUID_LIST , sub { join " ", map dec_wguid enc_wguid $_, @{+shift} }, |
1495 | BCDE_FORMAT_GUID_LIST , sub { join " ", map dec_wguid enc_wguid $_, @{+shift} }, |
1403 | BCDE_FORMAT_INTEGER , sub { unpack "Q", pack "a8", pack "H*", shift }, # integer might be 4 or 8 bytes - caused by ms coding bugs |
1496 | BCDE_FORMAT_INTEGER , sub { unpack "Q", pack "a8", pack "H*", shift }, # integer might be 4 or 8 bytes - caused by ms coding bugs |
1404 | BCDE_FORMAT_BOOLEAN , sub { shift eq "00" ? 0 : 1 }, |
1497 | BCDE_FORMAT_BOOLEAN , sub { shift eq "00" ? 0 : 1 }, |
1405 | BCDE_FORMAT_INTEGER_LIST, sub { join " ", unpack "Q*", pack "H*", shift }, # not sure if this cna be 4 bytes |
1498 | BCDE_FORMAT_INTEGER_LIST, sub { join " ", unpack "Q*", pack "H*", shift }, # not sure if this can be 4 bytes |
1406 | ); |
1499 | ); |
1407 | |
1500 | |
1408 | our %bcde_enc = ( |
1501 | our %bcde_enc = ( |
1409 | BCDE_FORMAT_DEVICE , sub { binary => enc_device $_[0], $_[1] }, |
1502 | BCDE_FORMAT_DEVICE , sub { binary => enc_device $_[0], $_[1] }, |
1410 | BCDE_FORMAT_STRING , sub { sz => shift }, |
1503 | BCDE_FORMAT_STRING , sub { sz => shift }, |
… | |
… | |
1416 | ); |
1509 | ); |
1417 | |
1510 | |
1418 | # BCD Elements |
1511 | # BCD Elements |
1419 | our %bcde_byclass = ( |
1512 | our %bcde_byclass = ( |
1420 | any => { |
1513 | any => { |
1421 | 0x11000001 => 'device', |
1514 | 0x11000001 => 'device', |
1422 | 0x12000002 => 'path', |
1515 | 0x12000002 => 'path', |
1423 | 0x12000004 => 'description', |
1516 | 0x12000004 => 'description', |
1424 | 0x12000005 => 'locale', |
1517 | 0x12000005 => 'locale', |
1425 | 0x14000006 => 'inherit', |
1518 | 0x14000006 => 'inherit', |
1426 | 0x15000007 => 'truncatememory', |
1519 | 0x15000007 => 'truncatememory', |
1427 | 0x14000008 => 'recoverysequence', |
1520 | 0x14000008 => 'recoverysequence', |
1428 | 0x16000009 => 'recoveryenabled', |
1521 | 0x16000009 => 'recoveryenabled', |
1429 | 0x1700000a => 'badmemorylist', |
1522 | 0x1700000a => 'badmemorylist', |
1430 | 0x1600000b => 'badmemoryaccess', |
1523 | 0x1600000b => 'badmemoryaccess', |
1431 | 0x1500000c => 'firstmegabytepolicy', |
1524 | 0x1500000c => 'firstmegabytepolicy', |
1432 | 0x1500000d => 'relocatephysical', |
1525 | 0x1500000d => 'relocatephysical', |
1433 | 0x1500000e => 'avoidlowmemory', |
1526 | 0x1500000e => 'avoidlowmemory', |
1434 | 0x1600000f => 'traditionalkseg', |
1527 | 0x1600000f => 'traditionalkseg', |
1435 | 0x16000010 => 'bootdebug', |
1528 | 0x16000010 => 'bootdebug', |
1436 | 0x15000011 => 'debugtype', |
1529 | 0x15000011 => 'debugtype', |
1437 | 0x15000012 => 'debugaddress', |
1530 | 0x15000012 => 'debugaddress', |
1438 | 0x15000013 => 'debugport', |
1531 | 0x15000013 => 'debugport', |
1439 | 0x15000014 => 'baudrate', |
1532 | 0x15000014 => 'baudrate', |
1440 | 0x15000015 => 'channel', |
1533 | 0x15000015 => 'channel', |
1441 | 0x12000016 => 'targetname', |
1534 | 0x12000016 => 'targetname', |
1442 | 0x16000017 => 'noumex', |
1535 | 0x16000017 => 'noumex', |
1443 | 0x15000018 => 'debugstart', |
1536 | 0x15000018 => 'debugstart', |
1444 | 0x12000019 => 'busparams', |
1537 | 0x12000019 => 'busparams', |
1445 | 0x1500001a => 'hostip', |
1538 | 0x1500001a => 'hostip', |
1446 | 0x1500001b => 'port', |
1539 | 0x1500001b => 'port', |
1447 | 0x1600001c => 'dhcp', |
1540 | 0x1600001c => 'dhcp', |
1448 | 0x1200001d => 'key', |
1541 | 0x1200001d => 'key', |
1449 | 0x1600001e => 'vm', |
1542 | 0x1600001e => 'vm', |
1450 | 0x16000020 => 'bootems', |
1543 | 0x16000020 => 'bootems', |
1451 | 0x15000022 => 'emsport', |
1544 | 0x15000022 => 'emsport', |
1452 | 0x15000023 => 'emsbaudrate', |
1545 | 0x15000023 => 'emsbaudrate', |
1453 | 0x12000030 => 'loadoptions', |
1546 | 0x12000030 => 'loadoptions', |
1454 | 0x16000040 => 'advancedoptions', |
1547 | 0x16000040 => 'advancedoptions', |
1455 | 0x16000041 => 'optionsedit', |
1548 | 0x16000041 => 'optionsedit', |
1456 | 0x15000042 => 'keyringaddress', |
1549 | 0x15000042 => 'keyringaddress', |
1457 | 0x11000043 => 'bootstatdevice', |
1550 | 0x11000043 => 'bootstatdevice', |
1458 | 0x12000044 => 'bootstatfilepath', |
1551 | 0x12000044 => 'bootstatfilepath', |
1459 | 0x16000045 => 'preservebootstat', |
1552 | 0x16000045 => 'preservebootstat', |
1460 | 0x16000046 => 'graphicsmodedisabled', |
1553 | 0x16000046 => 'graphicsmodedisabled', |
1461 | 0x15000047 => 'configaccesspolicy', |
1554 | 0x15000047 => 'configaccesspolicy', |
1462 | 0x16000048 => 'nointegritychecks', |
1555 | 0x16000048 => 'nointegritychecks', |
1463 | 0x16000049 => 'testsigning', |
1556 | 0x16000049 => 'testsigning', |
1464 | 0x1200004a => 'fontpath', |
1557 | 0x1200004a => 'fontpath', |
1465 | 0x1500004b => 'integrityservices', |
1558 | 0x1500004b => 'integrityservices', |
1466 | 0x1500004c => 'volumebandid', |
1559 | 0x1500004c => 'volumebandid', |
1467 | 0x16000050 => 'extendedinput', |
1560 | 0x16000050 => 'extendedinput', |
1468 | 0x15000051 => 'initialconsoleinput', |
1561 | 0x15000051 => 'initialconsoleinput', |
1469 | 0x15000052 => 'graphicsresolution', |
1562 | 0x15000052 => 'graphicsresolution', |
1470 | 0x16000053 => 'restartonfailure', |
1563 | 0x16000053 => 'restartonfailure', |
1471 | 0x16000054 => 'highestmode', |
1564 | 0x16000054 => 'highestmode', |
1472 | 0x16000060 => 'isolatedcontext', |
1565 | 0x16000060 => 'isolatedcontext', |
1473 | 0x15000065 => 'displaymessage', |
1566 | 0x15000065 => 'displaymessage', |
1474 | 0x15000066 => 'displaymessageoverride', |
1567 | 0x15000066 => 'displaymessageoverride', |
1475 | 0x16000068 => 'nobootuxtext', |
1568 | 0x16000068 => 'nobootuxtext', |
1476 | 0x16000069 => 'nobootuxprogress', |
1569 | 0x16000069 => 'nobootuxprogress', |
1477 | 0x1600006a => 'nobootuxfade', |
1570 | 0x1600006a => 'nobootuxfade', |
1478 | 0x1600006b => 'bootuxreservepooldebug', |
1571 | 0x1600006b => 'bootuxreservepooldebug', |
1479 | 0x1600006c => 'bootuxdisabled', |
1572 | 0x1600006c => 'bootuxdisabled', |
1480 | 0x1500006d => 'bootuxfadeframes', |
1573 | 0x1500006d => 'bootuxfadeframes', |
1481 | 0x1600006e => 'bootuxdumpstats', |
1574 | 0x1600006e => 'bootuxdumpstats', |
1482 | 0x1600006f => 'bootuxshowstats', |
1575 | 0x1600006f => 'bootuxshowstats', |
1483 | 0x16000071 => 'multibootsystem', |
1576 | 0x16000071 => 'multibootsystem', |
1484 | 0x16000072 => 'nokeyboard', |
1577 | 0x16000072 => 'nokeyboard', |
1485 | 0x15000073 => 'aliaswindowskey', |
1578 | 0x15000073 => 'aliaswindowskey', |
1486 | 0x16000074 => 'bootshutdowndisabled', |
1579 | 0x16000074 => 'bootshutdowndisabled', |
1487 | 0x15000075 => 'performancefrequency', |
1580 | 0x15000075 => 'performancefrequency', |
1488 | 0x15000076 => 'securebootrawpolicy', |
1581 | 0x15000076 => 'securebootrawpolicy', |
1489 | 0x17000077 => 'allowedinmemorysettings', |
1582 | 0x17000077 => 'allowedinmemorysettings', |
1490 | 0x15000079 => 'bootuxtransitiontime', |
1583 | 0x15000079 => 'bootuxtransitiontime', |
1491 | 0x1600007a => 'mobilegraphics', |
1584 | 0x1600007a => 'mobilegraphics', |
1492 | 0x1600007b => 'forcefipscrypto', |
1585 | 0x1600007b => 'forcefipscrypto', |
1493 | 0x1500007d => 'booterrorux', |
1586 | 0x1500007d => 'booterrorux', |
1494 | 0x1600007e => 'flightsigning', |
1587 | 0x1600007e => 'flightsigning', |
1495 | 0x1500007f => 'measuredbootlogformat', |
1588 | 0x1500007f => 'measuredbootlogformat', |
1496 | 0x15000080 => 'displayrotation', |
1589 | 0x15000080 => 'displayrotation', |
1497 | 0x15000081 => 'logcontrol', |
1590 | 0x15000081 => 'logcontrol', |
1498 | 0x16000082 => 'nofirmwaresync', |
1591 | 0x16000082 => 'nofirmwaresync', |
1499 | 0x11000084 => 'windowssyspart', |
1592 | 0x11000084 => 'windowssyspart', |
1500 | 0x16000087 => 'numlock', |
1593 | 0x16000087 => 'numlock', |
1501 | 0x26000202 => 'skipffumode', |
1594 | 0x26000202 => 'skipffumode', |
1502 | 0x26000203 => 'forceffumode', |
1595 | 0x26000203 => 'forceffumode', |
1503 | 0x25000510 => 'chargethreshold', |
1596 | 0x25000510 => 'chargethreshold', |
1504 | 0x26000512 => 'offmodecharging', |
1597 | 0x26000512 => 'offmodecharging', |
1505 | 0x25000aaa => 'bootflow', |
1598 | 0x25000aaa => 'bootflow', |
1506 | 0x45000001 => 'devicetype', |
1599 | 0x45000001 => 'devicetype', |
1507 | 0x42000002 => 'applicationrelativepath', |
1600 | 0x42000002 => 'applicationrelativepath', |
1508 | 0x42000003 => 'ramdiskdevicerelativepath', |
1601 | 0x42000003 => 'ramdiskdevicerelativepath', |
1509 | 0x46000004 => 'omitosloaderelements', |
1602 | 0x46000004 => 'omitosloaderelements', |
1510 | 0x47000006 => 'elementstomigrate', |
1603 | 0x47000006 => 'elementstomigrate', |
1511 | 0x46000010 => 'recoveryos', |
1604 | 0x46000010 => 'recoveryos', |
1512 | }, |
1605 | }, |
1513 | bootapp => { |
1606 | bootapp => { |
1514 | 0x26000145 => 'enablebootdebugpolicy', |
1607 | 0x26000145 => 'enablebootdebugpolicy', |
1515 | 0x26000146 => 'enablebootorderclean', |
1608 | 0x26000146 => 'enablebootorderclean', |
1516 | 0x26000147 => 'enabledeviceid', |
1609 | 0x26000147 => 'enabledeviceid', |
1517 | 0x26000148 => 'enableffuloader', |
1610 | 0x26000148 => 'enableffuloader', |
1518 | 0x26000149 => 'enableiuloader', |
1611 | 0x26000149 => 'enableiuloader', |
1519 | 0x2600014a => 'enablemassstorage', |
1612 | 0x2600014a => 'enablemassstorage', |
1520 | 0x2600014b => 'enablerpmbprovisioning', |
1613 | 0x2600014b => 'enablerpmbprovisioning', |
1521 | 0x2600014c => 'enablesecurebootpolicy', |
1614 | 0x2600014c => 'enablesecurebootpolicy', |
1522 | 0x2600014d => 'enablestartcharge', |
1615 | 0x2600014d => 'enablestartcharge', |
1523 | 0x2600014e => 'enableresettpm', |
1616 | 0x2600014e => 'enableresettpm', |
1524 | }, |
1617 | }, |
1525 | bootmgr => { |
1618 | bootmgr => { |
1526 | 0x24000001 => 'displayorder', |
1619 | 0x24000001 => 'displayorder', |
1527 | 0x24000002 => 'bootsequence', |
1620 | 0x24000002 => 'bootsequence', |
1528 | 0x23000003 => 'default', |
1621 | 0x23000003 => 'default', |
1529 | 0x25000004 => 'timeout', |
1622 | 0x25000004 => 'timeout', |
1530 | 0x26000005 => 'resume', |
1623 | 0x26000005 => 'resume', |
1531 | 0x23000006 => 'resumeobject', |
1624 | 0x23000006 => 'resumeobject', |
1532 | 0x24000007 => 'startupsequence', |
1625 | 0x24000007 => 'startupsequence', |
1533 | 0x24000010 => 'toolsdisplayorder', |
1626 | 0x24000010 => 'toolsdisplayorder', |
1534 | 0x26000020 => 'displaybootmenu', |
1627 | 0x26000020 => 'displaybootmenu', |
1535 | 0x26000021 => 'noerrordisplay', |
1628 | 0x26000021 => 'noerrordisplay', |
1536 | 0x21000022 => 'bcddevice', |
1629 | 0x21000022 => 'bcddevice', |
1537 | 0x22000023 => 'bcdfilepath', |
1630 | 0x22000023 => 'bcdfilepath', |
1538 | 0x26000024 => 'hormenabled', |
1631 | 0x26000024 => 'hormenabled', |
1539 | 0x26000025 => 'hiberboot', |
1632 | 0x26000025 => 'hiberboot', |
1540 | 0x22000026 => 'passwordoverride', |
1633 | 0x22000026 => 'passwordoverride', |
1541 | 0x22000027 => 'pinpassphraseoverride', |
1634 | 0x22000027 => 'pinpassphraseoverride', |
1542 | 0x26000028 => 'processcustomactionsfirst', |
1635 | 0x26000028 => 'processcustomactionsfirst', |
1543 | 0x27000030 => 'customactions', |
1636 | 0x27000030 => 'customactions', |
1544 | 0x26000031 => 'persistbootsequence', |
1637 | 0x26000031 => 'persistbootsequence', |
1545 | 0x26000032 => 'skipstartupsequence', |
1638 | 0x26000032 => 'skipstartupsequence', |
1546 | 0x22000040 => 'fverecoveryurl', |
1639 | 0x22000040 => 'fverecoveryurl', |
1547 | 0x22000041 => 'fverecoverymessage', |
1640 | 0x22000041 => 'fverecoverymessage', |
1548 | }, |
1641 | }, |
1549 | device => { |
1642 | device => { |
1550 | 0x35000001 => 'ramdiskimageoffset', |
1643 | 0x35000001 => 'ramdiskimageoffset', |
1551 | 0x35000002 => 'ramdisktftpclientport', |
1644 | 0x35000002 => 'ramdisktftpclientport', |
1552 | 0x31000003 => 'ramdisksdidevice', |
1645 | 0x31000003 => 'ramdisksdidevice', |
1553 | 0x32000004 => 'ramdisksdipath', |
1646 | 0x32000004 => 'ramdisksdipath', |
1554 | 0x35000005 => 'ramdiskimagelength', |
1647 | 0x35000005 => 'ramdiskimagelength', |
1555 | 0x36000006 => 'exportascd', |
1648 | 0x36000006 => 'exportascd', |
1556 | 0x35000007 => 'ramdisktftpblocksize', |
1649 | 0x35000007 => 'ramdisktftpblocksize', |
1557 | 0x35000008 => 'ramdisktftpwindowsize', |
1650 | 0x35000008 => 'ramdisktftpwindowsize', |
1558 | 0x36000009 => 'ramdiskmcenabled', |
1651 | 0x36000009 => 'ramdiskmcenabled', |
1559 | 0x3600000a => 'ramdiskmctftpfallback', |
1652 | 0x3600000a => 'ramdiskmctftpfallback', |
1560 | 0x3600000b => 'ramdisktftpvarwindow', |
1653 | 0x3600000b => 'ramdisktftpvarwindow', |
1561 | }, |
1654 | }, |
1562 | memdiag => { |
1655 | memdiag => { |
1563 | 0x25000001 => 'passcount', |
1656 | 0x25000001 => 'passcount', |
1564 | 0x25000002 => 'testmix', |
1657 | 0x25000002 => 'testmix', |
1565 | 0x25000003 => 'failurecount', |
1658 | 0x25000003 => 'failurecount', |
1566 | 0x26000003 => 'cacheenable', |
1659 | 0x26000003 => 'cacheenable', |
1567 | 0x25000004 => 'testtofail', |
1660 | 0x25000004 => 'testtofail', |
1568 | 0x26000004 => 'failuresenabled', |
1661 | 0x26000004 => 'failuresenabled', |
1569 | 0x25000005 => 'stridefailcount', |
1662 | 0x25000005 => 'stridefailcount', |
1570 | 0x26000005 => 'cacheenable', |
1663 | 0x26000005 => 'cacheenable', |
1571 | 0x25000006 => 'invcfailcount', |
1664 | 0x25000006 => 'invcfailcount', |
1572 | 0x25000007 => 'matsfailcount', |
1665 | 0x25000007 => 'matsfailcount', |
1573 | 0x25000008 => 'randfailcount', |
1666 | 0x25000008 => 'randfailcount', |
1574 | 0x25000009 => 'chckrfailcount', |
1667 | 0x25000009 => 'chckrfailcount', |
1575 | }, |
1668 | }, |
1576 | ntldr => { |
1669 | ntldr => { |
1577 | 0x22000001 => 'bpbstring', |
1670 | 0x22000001 => 'bpbstring', |
1578 | }, |
1671 | }, |
1579 | osloader => { |
1672 | osloader => { |
1580 | 0x21000001 => 'osdevice', |
1673 | 0x21000001 => 'osdevice', |
1581 | 0x22000002 => 'systemroot', |
1674 | 0x22000002 => 'systemroot', |
1582 | 0x23000003 => 'resumeobject', |
1675 | 0x23000003 => 'resumeobject', |
1583 | 0x26000004 => 'stampdisks', |
1676 | 0x26000004 => 'stampdisks', |
1584 | 0x26000010 => 'detecthal', |
1677 | 0x26000010 => 'detecthal', |
1585 | 0x22000011 => 'kernel', |
1678 | 0x22000011 => 'kernel', |
1586 | 0x22000012 => 'hal', |
1679 | 0x22000012 => 'hal', |
1587 | 0x22000013 => 'dbgtransport', |
1680 | 0x22000013 => 'dbgtransport', |
1588 | 0x25000020 => 'nx', |
1681 | 0x25000020 => 'nx', |
1589 | 0x25000021 => 'pae', |
1682 | 0x25000021 => 'pae', |
1590 | 0x26000022 => 'winpe', |
1683 | 0x26000022 => 'winpe', |
1591 | 0x26000024 => 'nocrashautoreboot', |
1684 | 0x26000024 => 'nocrashautoreboot', |
1592 | 0x26000025 => 'lastknowngood', |
1685 | 0x26000025 => 'lastknowngood', |
1593 | 0x26000026 => 'oslnointegritychecks', |
1686 | 0x26000026 => 'oslnointegritychecks', |
1594 | 0x26000027 => 'osltestsigning', |
1687 | 0x26000027 => 'osltestsigning', |
1595 | 0x26000030 => 'nolowmem', |
1688 | 0x26000030 => 'nolowmem', |
1596 | 0x25000031 => 'removememory', |
1689 | 0x25000031 => 'removememory', |
1597 | 0x25000032 => 'increaseuserva', |
1690 | 0x25000032 => 'increaseuserva', |
1598 | 0x25000033 => 'perfmem', |
1691 | 0x25000033 => 'perfmem', |
1599 | 0x26000040 => 'vga', |
1692 | 0x26000040 => 'vga', |
1600 | 0x26000041 => 'quietboot', |
1693 | 0x26000041 => 'quietboot', |
1601 | 0x26000042 => 'novesa', |
1694 | 0x26000042 => 'novesa', |
1602 | 0x26000043 => 'novga', |
1695 | 0x26000043 => 'novga', |
1603 | 0x25000050 => 'clustermodeaddressing', |
1696 | 0x25000050 => 'clustermodeaddressing', |
1604 | 0x26000051 => 'usephysicaldestination', |
1697 | 0x26000051 => 'usephysicaldestination', |
1605 | 0x25000052 => 'restrictapiccluster', |
1698 | 0x25000052 => 'restrictapiccluster', |
1606 | 0x22000053 => 'evstore', |
1699 | 0x22000053 => 'evstore', |
1607 | 0x26000054 => 'uselegacyapicmode', |
1700 | 0x26000054 => 'uselegacyapicmode', |
1608 | 0x26000060 => 'onecpu', |
1701 | 0x26000060 => 'onecpu', |
1609 | 0x25000061 => 'numproc', |
1702 | 0x25000061 => 'numproc', |
1610 | 0x26000062 => 'maxproc', |
1703 | 0x26000062 => 'maxproc', |
1611 | 0x25000063 => 'configflags', |
1704 | 0x25000063 => 'configflags', |
1612 | 0x26000064 => 'maxgroup', |
1705 | 0x26000064 => 'maxgroup', |
1613 | 0x26000065 => 'groupaware', |
1706 | 0x26000065 => 'groupaware', |
1614 | 0x25000066 => 'groupsize', |
1707 | 0x25000066 => 'groupsize', |
1615 | 0x26000070 => 'usefirmwarepcisettings', |
1708 | 0x26000070 => 'usefirmwarepcisettings', |
1616 | 0x25000071 => 'msi', |
1709 | 0x25000071 => 'msi', |
1617 | 0x25000072 => 'pciexpress', |
1710 | 0x25000072 => 'pciexpress', |
1618 | 0x25000080 => 'safeboot', |
1711 | 0x25000080 => 'safeboot', |
1619 | 0x26000081 => 'safebootalternateshell', |
1712 | 0x26000081 => 'safebootalternateshell', |
1620 | 0x26000090 => 'bootlog', |
1713 | 0x26000090 => 'bootlog', |
1621 | 0x26000091 => 'sos', |
1714 | 0x26000091 => 'sos', |
1622 | 0x260000a0 => 'debug', |
1715 | 0x260000a0 => 'debug', |
1623 | 0x260000a1 => 'halbreakpoint', |
1716 | 0x260000a1 => 'halbreakpoint', |
1624 | 0x260000a2 => 'useplatformclock', |
1717 | 0x260000a2 => 'useplatformclock', |
1625 | 0x260000a3 => 'forcelegacyplatform', |
1718 | 0x260000a3 => 'forcelegacyplatform', |
1626 | 0x260000a4 => 'useplatformtick', |
1719 | 0x260000a4 => 'useplatformtick', |
1627 | 0x260000a5 => 'disabledynamictick', |
1720 | 0x260000a5 => 'disabledynamictick', |
1628 | 0x250000a6 => 'tscsyncpolicy', |
1721 | 0x250000a6 => 'tscsyncpolicy', |
1629 | 0x260000b0 => 'ems', |
1722 | 0x260000b0 => 'ems', |
1630 | 0x250000c0 => 'forcefailure', |
1723 | 0x250000c0 => 'forcefailure', |
1631 | 0x250000c1 => 'driverloadfailurepolicy', |
1724 | 0x250000c1 => 'driverloadfailurepolicy', |
1632 | 0x250000c2 => 'bootmenupolicy', |
1725 | 0x250000c2 => 'bootmenupolicy', |
1633 | 0x260000c3 => 'onetimeadvancedoptions', |
1726 | 0x260000c3 => 'onetimeadvancedoptions', |
1634 | 0x260000c4 => 'onetimeoptionsedit', |
1727 | 0x260000c4 => 'onetimeoptionsedit', |
1635 | 0x250000e0 => 'bootstatuspolicy', |
1728 | 0x250000e0 => 'bootstatuspolicy', |
1636 | 0x260000e1 => 'disableelamdrivers', |
1729 | 0x260000e1 => 'disableelamdrivers', |
1637 | 0x250000f0 => 'hypervisorlaunchtype', |
1730 | 0x250000f0 => 'hypervisorlaunchtype', |
1638 | 0x220000f1 => 'hypervisorpath', |
1731 | 0x220000f1 => 'hypervisorpath', |
1639 | 0x260000f2 => 'hypervisordebug', |
1732 | 0x260000f2 => 'hypervisordebug', |
1640 | 0x250000f3 => 'hypervisordebugtype', |
1733 | 0x250000f3 => 'hypervisordebugtype', |
1641 | 0x250000f4 => 'hypervisordebugport', |
1734 | 0x250000f4 => 'hypervisordebugport', |
1642 | 0x250000f5 => 'hypervisorbaudrate', |
1735 | 0x250000f5 => 'hypervisorbaudrate', |
1643 | 0x250000f6 => 'hypervisorchannel', |
1736 | 0x250000f6 => 'hypervisorchannel', |
1644 | 0x250000f7 => 'bootux', |
1737 | 0x250000f7 => 'bootux', |
1645 | 0x260000f8 => 'hypervisordisableslat', |
1738 | 0x260000f8 => 'hypervisordisableslat', |
1646 | 0x220000f9 => 'hypervisorbusparams', |
1739 | 0x220000f9 => 'hypervisorbusparams', |
1647 | 0x250000fa => 'hypervisornumproc', |
1740 | 0x250000fa => 'hypervisornumproc', |
1648 | 0x250000fb => 'hypervisorrootprocpernode', |
1741 | 0x250000fb => 'hypervisorrootprocpernode', |
1649 | 0x260000fc => 'hypervisoruselargevtlb', |
1742 | 0x260000fc => 'hypervisoruselargevtlb', |
1650 | 0x250000fd => 'hypervisorhostip', |
1743 | 0x250000fd => 'hypervisorhostip', |
1651 | 0x250000fe => 'hypervisorhostport', |
1744 | 0x250000fe => 'hypervisorhostport', |
1652 | 0x250000ff => 'hypervisordebugpages', |
1745 | 0x250000ff => 'hypervisordebugpages', |
1653 | 0x25000100 => 'tpmbootentropy', |
1746 | 0x25000100 => 'tpmbootentropy', |
1654 | 0x22000110 => 'hypervisorusekey', |
1747 | 0x22000110 => 'hypervisorusekey', |
1655 | 0x22000112 => 'hypervisorproductskutype', |
1748 | 0x22000112 => 'hypervisorproductskutype', |
1656 | 0x25000113 => 'hypervisorrootproc', |
1749 | 0x25000113 => 'hypervisorrootproc', |
1657 | 0x26000114 => 'hypervisordhcp', |
1750 | 0x26000114 => 'hypervisordhcp', |
1658 | 0x25000115 => 'hypervisoriommupolicy', |
1751 | 0x25000115 => 'hypervisoriommupolicy', |
1659 | 0x26000116 => 'hypervisorusevapic', |
1752 | 0x26000116 => 'hypervisorusevapic', |
1660 | 0x22000117 => 'hypervisorloadoptions', |
1753 | 0x22000117 => 'hypervisorloadoptions', |
1661 | 0x25000118 => 'hypervisormsrfilterpolicy', |
1754 | 0x25000118 => 'hypervisormsrfilterpolicy', |
1662 | 0x25000119 => 'hypervisormmionxpolicy', |
1755 | 0x25000119 => 'hypervisormmionxpolicy', |
1663 | 0x2500011a => 'hypervisorschedulertype', |
1756 | 0x2500011a => 'hypervisorschedulertype', |
1664 | 0x25000120 => 'xsavepolicy', |
1757 | 0x25000120 => 'xsavepolicy', |
1665 | 0x25000121 => 'xsaveaddfeature0', |
1758 | 0x25000121 => 'xsaveaddfeature0', |
1666 | 0x25000122 => 'xsaveaddfeature1', |
1759 | 0x25000122 => 'xsaveaddfeature1', |
1667 | 0x25000123 => 'xsaveaddfeature2', |
1760 | 0x25000123 => 'xsaveaddfeature2', |
1668 | 0x25000124 => 'xsaveaddfeature3', |
1761 | 0x25000124 => 'xsaveaddfeature3', |
1669 | 0x25000125 => 'xsaveaddfeature4', |
1762 | 0x25000125 => 'xsaveaddfeature4', |
1670 | 0x25000126 => 'xsaveaddfeature5', |
1763 | 0x25000126 => 'xsaveaddfeature5', |
1671 | 0x25000127 => 'xsaveaddfeature6', |
1764 | 0x25000127 => 'xsaveaddfeature6', |
1672 | 0x25000128 => 'xsaveaddfeature7', |
1765 | 0x25000128 => 'xsaveaddfeature7', |
1673 | 0x25000129 => 'xsaveremovefeature', |
1766 | 0x25000129 => 'xsaveremovefeature', |
1674 | 0x2500012a => 'xsaveprocessorsmask', |
1767 | 0x2500012a => 'xsaveprocessorsmask', |
1675 | 0x2500012b => 'xsavedisable', |
1768 | 0x2500012b => 'xsavedisable', |
1676 | 0x2500012c => 'kerneldebugtype', |
1769 | 0x2500012c => 'kerneldebugtype', |
1677 | 0x2200012d => 'kernelbusparams', |
1770 | 0x2200012d => 'kernelbusparams', |
1678 | 0x2500012e => 'kerneldebugaddress', |
1771 | 0x2500012e => 'kerneldebugaddress', |
1679 | 0x2500012f => 'kerneldebugport', |
1772 | 0x2500012f => 'kerneldebugport', |
1680 | 0x25000130 => 'claimedtpmcounter', |
1773 | 0x25000130 => 'claimedtpmcounter', |
1681 | 0x25000131 => 'kernelchannel', |
1774 | 0x25000131 => 'kernelchannel', |
1682 | 0x22000132 => 'kerneltargetname', |
1775 | 0x22000132 => 'kerneltargetname', |
1683 | 0x25000133 => 'kernelhostip', |
1776 | 0x25000133 => 'kernelhostip', |
1684 | 0x25000134 => 'kernelport', |
1777 | 0x25000134 => 'kernelport', |
1685 | 0x26000135 => 'kerneldhcp', |
1778 | 0x26000135 => 'kerneldhcp', |
1686 | 0x22000136 => 'kernelkey', |
1779 | 0x22000136 => 'kernelkey', |
1687 | 0x22000137 => 'imchivename', |
1780 | 0x22000137 => 'imchivename', |
1688 | 0x21000138 => 'imcdevice', |
1781 | 0x21000138 => 'imcdevice', |
1689 | 0x25000139 => 'kernelbaudrate', |
1782 | 0x25000139 => 'kernelbaudrate', |
1690 | 0x22000140 => 'mfgmode', |
1783 | 0x22000140 => 'mfgmode', |
1691 | 0x26000141 => 'event', |
1784 | 0x26000141 => 'event', |
1692 | 0x25000142 => 'vsmlaunchtype', |
1785 | 0x25000142 => 'vsmlaunchtype', |
1693 | 0x25000144 => 'hypervisorenforcedcodeintegrity', |
1786 | 0x25000144 => 'hypervisorenforcedcodeintegrity', |
1694 | 0x21000150 => 'systemdatadevice', |
1787 | 0x21000150 => 'systemdatadevice', |
1695 | 0x21000151 => 'osarcdevice', |
1788 | 0x21000151 => 'osarcdevice', |
1696 | 0x21000153 => 'osdatadevice', |
1789 | 0x21000153 => 'osdatadevice', |
1697 | 0x21000154 => 'bspdevice', |
1790 | 0x21000154 => 'bspdevice', |
1698 | 0x21000155 => 'bspfilepath', |
1791 | 0x21000155 => 'bspfilepath', |
1699 | }, |
1792 | }, |
1700 | resume => { |
1793 | resume => { |
1701 | 0x21000001 => 'filedevice', |
1794 | 0x21000001 => 'filedevice', |
1702 | 0x22000002 => 'filepath', |
1795 | 0x22000002 => 'filepath', |
1703 | 0x26000003 => 'customsettings', |
1796 | 0x26000003 => 'customsettings', |
1704 | 0x26000004 => 'pae', |
1797 | 0x26000004 => 'pae', |
1705 | 0x21000005 => 'associatedosdevice', |
1798 | 0x21000005 => 'associatedosdevice', |
1706 | 0x26000006 => 'debugoptionenabled', |
1799 | 0x26000006 => 'debugoptionenabled', |
1707 | 0x25000007 => 'bootux', |
1800 | 0x25000007 => 'bootux', |
1708 | 0x25000008 => 'bootmenupolicy', |
1801 | 0x25000008 => 'bootmenupolicy', |
1709 | 0x26000024 => 'hormenabled', |
1802 | 0x26000024 => 'hormenabled', |
1710 | }, |
1803 | }, |
1711 | startup => { |
1804 | startup => { |
1712 | 0x26000001 => 'pxesoftreboot', |
1805 | 0x26000001 => 'pxesoftreboot', |
1713 | 0x22000002 => 'applicationname', |
1806 | 0x22000002 => 'applicationname', |
1714 | }, |
1807 | }, |
1715 | ); |
1808 | ); |
1716 | |
1809 | |
1717 | # mask, value => class |
1810 | # mask, value => class |
1718 | our @bcde_typeclass = ( |
1811 | our @bcde_typeclass = ( |
… | |
… | |
1782 | our @part_type = qw(gpt mbr raw); |
1875 | our @part_type = qw(gpt mbr raw); |
1783 | |
1876 | |
1784 | our $NULL_DEVICE = "\x00" x 16; |
1877 | our $NULL_DEVICE = "\x00" x 16; |
1785 | |
1878 | |
1786 | # biggest bitch to decode, ever |
1879 | # biggest bitch to decode, ever |
1787 | # this decoded a device portion after the GUID |
1880 | # this decodes a device portion after the GUID |
1788 | sub dec_device_($$); |
1881 | sub dec_device_($$); |
1789 | sub dec_device_($$) { |
1882 | sub dec_device_($$) { |
1790 | my ($device, $type) = @_; |
1883 | my ($device, $type) = @_; |
1791 | |
1884 | |
1792 | my $res; |
1885 | my $res; |
… | |
… | |
2199 | or die "$_: malformed or missing vmbus interface instance guid\n"; |
2292 | or die "$_: malformed or missing vmbus interface instance guid\n"; |
2200 | my $instance = enc_guid $1; |
2293 | my $instance = enc_guid $1; |
2201 | |
2294 | |
2202 | $payload = pack "a16a16x24", $type, $instance; |
2295 | $payload = pack "a16a16x24", $type, $instance; |
2203 | |
2296 | |
|
|
2297 | # } elsif ($type eq "udp") { |
|
|
2298 | # $payload = pack "Va16", 1, "12345678"; |
|
|
2299 | |
2204 | } else { |
2300 | } else { |
2205 | die "$type: not a supported device type (binary, null, boot, legacypartition, partition, block, locate)\n"; |
2301 | die "$type: not a supported device type (binary, null, boot, legacypartition, partition, block, locate)\n"; |
2206 | } |
2302 | } |
2207 | |
2303 | |
2208 | return ( |
2304 | return ( |
… | |
… | |
2390 | } |
2486 | } |
2391 | |
2487 | |
2392 | } |
2488 | } |
2393 | |
2489 | |
2394 | ############################################################################# |
2490 | ############################################################################# |
2395 | # command line parser |
2491 | # other utilities |
2396 | |
2492 | |
2397 | # json to stdout |
2493 | # json to stdout |
2398 | sub prjson($) { |
2494 | sub prjson($) { |
2399 | print $json_coder->encode ($_[0]); |
2495 | print $json_coder->encode ($_[0]); |
2400 | } |
2496 | } |
… | |
… | |
2404 | my $json; |
2500 | my $json; |
2405 | 1 while read STDIN, $json, 65536, length $json; |
2501 | 1 while read STDIN, $json, 65536, length $json; |
2406 | $json_coder->decode ($json) |
2502 | $json_coder->decode ($json) |
2407 | } |
2503 | } |
2408 | |
2504 | |
2409 | # all subcommands |
2505 | sub lsblk() { |
|
|
2506 | my $lsblk = $json_coder->decode (scalar qx<lsblk --json -o PATH,KNAME,MAJ:MIN,TYPE,PTTYPE,PTUUID,PARTUUID,LABEL,FSTYPE>); |
|
|
2507 | |
|
|
2508 | for my $dev (@{ $lsblk->{blockdevices} }) { |
|
|
2509 | if ($dev->{type} eq "part") { |
|
|
2510 | |
|
|
2511 | # lsblk sometimes gives a bogus pttype, so we recreate it here |
|
|
2512 | $dev->{pttype} = $dev->{ptuuid} =~ /^$RE_GUID\z/ |
|
|
2513 | ? "gpt" : "dos"; |
|
|
2514 | |
|
|
2515 | if ($dev->{pttype} eq "gpt") { |
|
|
2516 | $dev->{bcd_device} = "partition=<null>,harddisk,gpt,$dev->{ptuuid},$dev->{partuuid}"; |
|
|
2517 | } elsif ($dev->{pttype} eq "dos") { # why not "mbr" :( |
|
|
2518 | if ($dev->{partuuid} =~ /^([0-9a-f]{8})-([0-9a-f]{2})\z/i) { |
|
|
2519 | my ($diskid, $partno) = ($1, hex $2); |
|
|
2520 | $dev->{bcd_legacy_device} = "legacypartition=<null>,harddisk,mbr,$diskid,$partno"; |
|
|
2521 | if (open my $fh, "/sys/class/block/$dev->{kname}/start") { |
|
|
2522 | my $start = 512 * readline $fh; |
|
|
2523 | $dev->{bcd_device} = "partition=<null>,harddisk,mbr,$diskid,$start"; |
|
|
2524 | } |
|
|
2525 | } |
|
|
2526 | } |
|
|
2527 | } |
|
|
2528 | } |
|
|
2529 | |
|
|
2530 | $lsblk->{blockdevices} |
|
|
2531 | } |
|
|
2532 | |
|
|
2533 | sub prdev($$) { |
|
|
2534 | my ($path, $attribute) = @_; |
|
|
2535 | |
|
|
2536 | # rather than stat'ing and guessing how devices are encoded, we use lsblk for this |
|
|
2537 | my $mm = $json_coder->decode (scalar qx<lsblk -d -o MAJ:MIN -J \Q$path\E>)->{blockdevices}[0]{"maj:min"}; |
|
|
2538 | |
|
|
2539 | my $lsblk = lsblk; |
|
|
2540 | |
|
|
2541 | for my $dev (@$lsblk) { |
|
|
2542 | if ($dev->{"maj:min"} eq $mm && $dev->{$attribute}) { |
|
|
2543 | say $dev->{$attribute}; |
|
|
2544 | exit 0; |
|
|
2545 | } |
|
|
2546 | } |
|
|
2547 | |
|
|
2548 | exit 1; |
|
|
2549 | } |
|
|
2550 | |
|
|
2551 | ############################################################################# |
|
|
2552 | # command line parser |
|
|
2553 | |
2410 | our %CMD = ( |
2554 | our %CMD = ( |
2411 | help => sub { |
2555 | help => sub { |
2412 | require Pod::Usage; |
2556 | require Pod::Usage; |
2413 | Pod::Usage::pod2usage (-verbose => 2); |
2557 | Pod::Usage::pod2usage (-verbose => 2); |
2414 | }, |
2558 | }, |
… | |
… | |
2465 | BCDE_FORMAT_INTEGER , "integer", |
2609 | BCDE_FORMAT_INTEGER , "integer", |
2466 | BCDE_FORMAT_BOOLEAN , "boolean", |
2610 | BCDE_FORMAT_BOOLEAN , "boolean", |
2467 | BCDE_FORMAT_INTEGER_LIST, "integer list", |
2611 | BCDE_FORMAT_INTEGER_LIST, "integer list", |
2468 | ); |
2612 | ); |
2469 | |
2613 | |
2470 | my %element; |
2614 | my @element; |
2471 | |
2615 | |
2472 | for my $class (sort keys %rbcde_byclass) { |
2616 | for my $class (sort keys %rbcde_byclass) { |
2473 | my $rbcde = $rbcde_byclass{$class}; |
2617 | my $rbcde = $rbcde_byclass{$class}; |
2474 | |
2618 | |
2475 | unless ($json) { |
2619 | unless ($json) { |
… | |
… | |
2478 | printf "%-9s %-12s %s\n", "Element", "Format", "Name Alias"; |
2622 | printf "%-9s %-12s %s\n", "Element", "Format", "Name Alias"; |
2479 | } |
2623 | } |
2480 | for my $name (sort keys %$rbcde) { |
2624 | for my $name (sort keys %$rbcde) { |
2481 | my $id = $rbcde->{$name}; |
2625 | my $id = $rbcde->{$name}; |
2482 | my $format = $format_name{$id & BCDE_FORMAT}; |
2626 | my $format = $format_name{$id & BCDE_FORMAT}; |
2483 | $id = sprintf "%08x", $id; |
|
|
2484 | |
2627 | |
2485 | if ($json) { |
2628 | if ($json) { |
2486 | $element{$id} = [$class, $format, $name]; |
2629 | push @element, [$class, $id * 1, $format, $name]; |
2487 | } else { |
2630 | } else { |
|
|
2631 | $id = sprintf "%08x", $id; |
2488 | printf "%-9s %-12s %s\n", $id, $format, $name; |
2632 | printf "%-9s %-12s %s\n", $id, $format, $name; |
2489 | } |
2633 | } |
2490 | } |
2634 | } |
2491 | } |
2635 | } |
2492 | print "\n" unless $json; |
2636 | print "\n" unless $json; |
2493 | |
2637 | |
2494 | prjson { |
2638 | prjson { |
2495 | version => $JSON_VERSION, |
2639 | version => $JSON_VERSION, |
2496 | element => \%element, |
2640 | element => \@element, |
2497 | class => \@bcde_typeclass, |
2641 | class => \@bcde_typeclass, |
2498 | } if $json; |
2642 | } if $json; |
2499 | |
2643 | |
2500 | }, |
2644 | }, |
2501 | |
2645 | |
… | |
… | |
2505 | |
2649 | |
2506 | import => sub { |
2650 | import => sub { |
2507 | regf_save shift, bcd_encode rdjson; |
2651 | regf_save shift, bcd_encode rdjson; |
2508 | }, |
2652 | }, |
2509 | |
2653 | |
|
|
2654 | create => sub { |
|
|
2655 | my $path = shift; |
|
|
2656 | my $stat = stat_get $path; # should actually be done at file load time |
|
|
2657 | my $bcd = { }; |
|
|
2658 | bcd_edit $path, $bcd, @_; |
|
|
2659 | regf_save $path, bcd_encode $bcd; |
|
|
2660 | stat_set $path, $stat; |
|
|
2661 | }, |
|
|
2662 | |
2510 | edit => sub { |
2663 | edit => sub { |
2511 | my $path = shift; |
2664 | my $path = shift; |
|
|
2665 | my $stat = stat_get $path; # should actually be done at file load time |
2512 | my $bcd = bcd_decode regf_load $path; |
2666 | my $bcd = bcd_decode regf_load $path; |
2513 | bcd_edit $path, $bcd, @_; |
2667 | bcd_edit $path, $bcd, @_; |
2514 | regf_save $path, bcd_encode $bcd; |
2668 | regf_save $path, bcd_encode $bcd; |
|
|
2669 | stat_set $path, $stat; |
2515 | }, |
2670 | }, |
2516 | |
2671 | |
2517 | parse => sub { |
2672 | parse => sub { |
2518 | my $path = shift; |
2673 | my $path = shift; |
2519 | my $bcd = bcd_decode regf_load $path; |
2674 | my $bcd = bcd_decode regf_load $path; |
… | |
… | |
2528 | "import-regf" => sub { |
2683 | "import-regf" => sub { |
2529 | regf_save shift, rdjson; |
2684 | regf_save shift, rdjson; |
2530 | }, |
2685 | }, |
2531 | |
2686 | |
2532 | lsblk => sub { |
2687 | lsblk => sub { |
|
|
2688 | my $json = $_[0] eq "--json"; |
|
|
2689 | |
|
|
2690 | my $lsblk = lsblk; |
|
|
2691 | |
|
|
2692 | if ($json) { |
|
|
2693 | prjson $lsblk; |
|
|
2694 | } else { |
2533 | printf "%-10s %-8.8s %-6.6s %-3s %s\n", "DEVICE", "LABEL", "FSTYPE", "PT", "DEVICE DESCRIPTOR"; |
2695 | printf "%-10s %-8.8s %-6.6s %-3s %s\n", "DEVICE", "LABEL", "FSTYPE", "PT", "DEVICE DESCRIPTOR"; |
2534 | |
2696 | for my $dev (@$lsblk) { |
2535 | my $lsblk = $json_coder->decode (scalar qx<lsblk --json -o PATH,KNAME,TYPE,PTTYPE,PTUUID,PARTUUID,LABEL,FSTYPE>); |
2697 | for my $bcd ($dev->{bcd_device}, $dev->{bcd_legacy_device}) { |
2536 | |
|
|
2537 | for my $dev (@{ $lsblk->{blockdevices} }) { |
|
|
2538 | my $pr = sub { |
|
|
2539 | printf "%-10s %-8.8s %-6.6s %-3s %s\n", |
2698 | printf "%-10s %-8.8s %-6.6s %-3s %s\n", |
2540 | $dev->{path}, $dev->{label}, $dev->{fstype}, $dev->{pttype}, $_[0]; |
2699 | $dev->{path}, $dev->{label}, $dev->{fstype}, $dev->{pttype}, $bcd |
2541 | }; |
|
|
2542 | |
|
|
2543 | if ($dev->{type} eq "part") { |
|
|
2544 | if ($dev->{pttype} eq "gpt") { |
|
|
2545 | $pr->("partition=<null>,harddisk,gpt,$dev->{ptuuid},$dev->{partuuid}"); |
|
|
2546 | } elsif ($dev->{pttype} eq "dos") { # why not "mbr" :( |
|
|
2547 | if ($dev->{partuuid} =~ /^([0-9a-f]{8})-([0-9a-f]{2})\z/i) { |
|
|
2548 | my ($diskid, $partno) = ($1, hex $2); |
|
|
2549 | $pr->("legacypartition=<null>,harddisk,mbr,$diskid,$partno"); |
|
|
2550 | if (open my $fh, "/sys/class/block/$dev->{kname}/start") { |
|
|
2551 | my $start = 512 * readline $fh; |
|
|
2552 | $pr->("partition=<null>,harddisk,mbr,$diskid,$start"); |
|
|
2553 | } |
2700 | if $bcd; |
2554 | } |
|
|
2555 | } |
2701 | } |
2556 | } |
2702 | } |
2557 | } |
2703 | } |
|
|
2704 | }, |
|
|
2705 | |
|
|
2706 | "bcd-device" => sub { |
|
|
2707 | prdev shift, "bcd_device"; |
|
|
2708 | }, |
|
|
2709 | |
|
|
2710 | "bcd-legacy-device" => sub { |
|
|
2711 | prdev shift, "bcd_legacy_device"; |
2558 | }, |
2712 | }, |
2559 | |
2713 | |
2560 | version => sub { |
2714 | version => sub { |
2561 | print "\n", |
2715 | print "\n", |
2562 | "PBCDEDIT version $VERSION, copyright 2019 Marc A. Lehmann <pbcdedit\@schmorp.de>.\n", |
2716 | "PBCDEDIT version $VERSION, copyright 2019 Marc A. Lehmann <pbcdedit\@schmorp.de>.\n", |